/* Snug Table Farkle: açık sayfa, yeşil çuha masa, büyük krem zarlar (Snug Nine zar çizimiyle aynı aile) */
:root { --bg: #f6f1e7; --card: #fffdf8; --text: #1d140c; --muted: #6b5a45; --line: rgba(29, 20, 12, .12); --green: #1f8f42; --gold: #f1c75b; --die: 64px; color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
a { color: #1f5fb3; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 12px 28px; }
.wrap > .site-bar { padding-left: 4px; padding-right: 4px; }

/* Üst çubuk */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 12px 4px 10px; }
.title h1 { margin: 0; font-size: 28px; line-height: 1.1; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.tool { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(29, 20, 12, .2); background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.tool:hover:not(:disabled) { background: #f1ebdf; }
.tool:disabled { opacity: .45; cursor: default; }

/* Oyuncular */
.players { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 4px 10px; }
.pl { flex: 1 1 140px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 8px; padding: 8px 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); transition: box-shadow .2s, background .2s; }
.pl .pl-ic { grid-row: span 2; font-size: 22px; line-height: 1; }
.pl .pl-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .pl-total { grid-row: span 2; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pl .pl-note { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.pl .bar-mini { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: rgba(0, 0, 0, .07); overflow: hidden; }
.pl .bar-mini i { display: block; height: 100%; background: linear-gradient(90deg, #5fb36f, var(--gold)); border-radius: inherit; transition: width .5s ease; }
.pl.turn { background: #fff6dc; border-color: rgba(201, 150, 40, .6); box-shadow: 0 0 0 3px rgba(241, 199, 91, .35); }
.pl.lead .pl-name::after { content: " ★"; color: #c08a1e; }
.pl.bump { animation: bump .6s; }
@keyframes bump { 30% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(31, 143, 66, .25); } }

/* Masa ve skor tablosu */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 12px; align-items: start; }
.felt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 330px; padding: 14px 12px 16px; border-radius: 18px;
  background: radial-gradient(ellipse 80% 70% at 50% 40%, #2c8a5a 0%, #1f6a44 55%, #154a30 100%); box-shadow: inset 0 0 70px rgba(0, 0, 0, .35), 0 8px 24px rgba(40, 25, 10, .18); color: #f2efe4; }
html[data-felt="blue"] .felt { background: radial-gradient(ellipse 80% 70% at 50% 40%, #2f6f9a 0%, #1f4f74 55%, #14344f 100%); }
html[data-felt="wood"] .felt { background: radial-gradient(ellipse 80% 70% at 50% 35%, rgba(255, 220, 170, .18), transparent 70%), repeating-linear-gradient(92deg, #7a4f2c 0 6px, #714828 6px 13px, #7f5530 13px 21px); }
.turn-line { margin: 0; padding: 4px 14px; border-radius: 999px; background: rgba(0, 0, 0, .28); font-weight: 800; font-size: 15px; text-align: center; }
.turn-line.mine { background: rgba(241, 199, 91, .92); color: #2a1a05; }

/* Ayrılan zarlar: grup grup, puanıyla */
.aside { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 44px; }
.grp { display: flex; align-items: center; gap: 3px; padding: 4px 8px 4px 5px; border-radius: 10px; background: rgba(0, 0, 0, .22); }
.grp .die { width: 30px; height: 30px; box-shadow: 0 2px 0 #c9b58c; }
.grp b { margin-left: 4px; font-size: 13px; color: #fff3cf; }
.grp.hot { box-shadow: 0 0 0 2px var(--gold); }

.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; min-height: calc(var(--die) + 12px); max-width: calc(var(--die) * 3 + 24px + 40px); align-content: center; }
@media (min-width: 560px) { .tray { max-width: none; } }
.tray .die { width: var(--die); height: var(--die); cursor: pointer; border: 0; transition: transform .15s, box-shadow .15s, opacity .2s; }
.tray .die:disabled { cursor: default; }
.tray .die.scorer:not(:disabled):hover { transform: translateY(-3px); }
.tray .die.dead { filter: brightness(.8) saturate(.7); }
.tray .die.sel { transform: translateY(-8px); box-shadow: 0 0 0 4px var(--gold), 0 10px 18px rgba(0, 0, 0, .35); }
.tray .die.hint { box-shadow: 0 0 0 4px #7fd3ff, 0 6px 14px rgba(0, 0, 0, .3); }
.tray .die.cpu-keep { box-shadow: 0 0 0 4px var(--gold), 0 6px 14px rgba(0, 0, 0, .3); }
.tray.rolling .die { animation: tumble .5s cubic-bezier(.2, .8, .3, 1.15) backwards; }
.tray.rolling .die:nth-child(2) { animation-delay: .04s; } .tray.rolling .die:nth-child(3) { animation-delay: .08s; }
.tray.rolling .die:nth-child(4) { animation-delay: .02s; } .tray.rolling .die:nth-child(5) { animation-delay: .06s; } .tray.rolling .die:nth-child(6) { animation-delay: .1s; }
@keyframes tumble { 0% { transform: translate(-30px, -40px) rotate(-200deg) scale(.7); opacity: 0; } 70% { transform: translate(2px, 4px) rotate(8deg) scale(1.03); opacity: 1; } 100% { transform: none; } }
.tray-empty { color: rgba(242, 239, 228, .7); font-weight: 600; font-size: 15px; align-self: center; }

.stamp { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) rotate(-8deg); padding: 6px 22px; border: 4px solid #ff8a7a; border-radius: 12px;
  color: #ffe2dc; background: rgba(120, 20, 10, .55); font: 900 40px/1.1 system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; pointer-events: none; animation: stamp .35s ease-out; }
.stamp.good { border-color: var(--gold); color: #fff6d8; background: rgba(90, 60, 0, .55); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-8deg) scale(1.8); opacity: 0; } }

.turn-total { display: flex; align-items: baseline; gap: 10px; margin-top: auto; padding: 6px 16px; border-radius: 14px; background: rgba(0, 0, 0, .28); }
.tt-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.turn-total b { font-size: 30px; font-variant-numeric: tabular-nums; }
.tt-sel { font-size: 14px; font-weight: 700; color: #fff3cf; }
.tt-sel.bad { color: #ffc2b8; }

/* Zar (pip ızgarası) */
.die { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 0; border-radius: 18%; background: linear-gradient(180deg, #fffdf6, #efe2c4);
  box-shadow: 0 3px 0 #c9b58c, 0 6px 14px rgba(0, 0, 0, .3); flex: none; }
.die i { display: block; margin: 22%; border-radius: 50%; }
.die i.p { background: radial-gradient(circle at 40% 35%, #4a3a2e, #120c08); }
.die.one i.p { background: radial-gradient(circle at 40% 35%, #d9534f, #8a1c14); }

.chart { padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.chart h2 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: #8a6224; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
.chart-table td:last-child { text-align: right; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-table tr.on td { background: #fff1c2; }
.chart-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* Eylem düğmeleri */
.actions { display: flex; justify-content: center; gap: 10px; margin: 12px 4px 0; }
.act { flex: 0 1 220px; min-height: 52px; padding: 8px 20px; border-radius: 999px; border: 0; font-weight: 800; font-size: 17px; cursor: pointer; }
.act:disabled { opacity: .4; cursor: default; }
.act-roll { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(31, 143, 66, .3); }
.act-roll:hover:not(:disabled) { background: #23a04b; }
.act-bank { background: #1d140c; color: #fff8e6; }
.act-bank:hover:not(:disabled) { background: #3a2a1c; }

.coach-line { margin: 10px auto 0; max-width: 680px; padding: 8px 12px; border-radius: 12px; background: #fff3cf; border: 1px solid rgba(138, 98, 36, .3); color: #4a3310; font-size: 14px; text-align: center; }
.coach-line.good { background: #e3f6e8; border-color: rgba(31, 143, 66, .35); color: #17532b; }
.coach-line.hint { background: #e3f1fb; border-color: rgba(31, 95, 179, .3); color: #173e6b; }
.fair-row { margin: 10px 0 0; text-align: center; }
.fair-badge { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.fair-badge.ok { color: #17532b; border-color: rgba(31, 143, 66, .4); background: #e3f6e8; }
.keys { margin: 10px 4px 0; color: var(--muted); font-size: 13px; text-align: center; }
kbd { padding: 0 5px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); background: #fff; font: 600 12px ui-monospace, Consolas, monospace; }

/* Pencereler */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(20, 12, 6, .55); }
.modal-card { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; border-radius: 18px; background: var(--card); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.modal-card.wide { width: min(560px, 100%); }
.modal-card h2 { margin: 0 0 10px; font-size: 22px; }
.modal-card h3 { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #8a6224; }
fieldset { margin: 0 0 12px; padding: 0; border: 0; }
legend { margin-bottom: 4px; font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: #8a6224; }
fieldset label { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; }
fieldset label:has(input:checked) { border-color: var(--green); background: #e3f6e8; }
fieldset small, .check small { display: block; margin-left: 24px; font-weight: 500; color: var(--muted); }
.seg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-row legend { width: 100%; }
.seg-row label { flex: 1 1 0; margin: 0; }
.names { display: grid; gap: 6px; margin-bottom: 6px; }
.names .nm { display: flex; gap: 6px; }
.names input { flex: 1; min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid rgba(29, 20, 12, .25); background: #fff; }
.names button { min-width: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.check { display: block; margin: 8px 0; font-weight: 600; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid rgba(29, 20, 12, .2); background: #fff; font-weight: 700; cursor: pointer; }
.btn-small { min-height: 36px; padding: 4px 14px; font-size: 14px; }
.btn:hover { background: #f1ebdf; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #23a04b; }
.score-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table thead th { font-size: 13px; color: var(--muted); }
.score-table tfoot td { font-weight: 800; border-top: 2px solid rgba(29, 20, 12, .3); }
.score-table .fk { color: #b0392b; font-weight: 700; }
.score-table .lead { background: #e3f6e8; }
.score-scroll { max-height: 46vh; overflow: auto; }
.big-line { font-size: 18px; margin: 4px 0 8px; }
.coach-box { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: #fff3cf; border: 1px solid rgba(138, 98, 36, .3); color: #4a3310; font-size: 15px; line-height: 1.45; }
.coach-box p { margin: 4px 0; }
.hint-text { color: var(--muted); font-size: 14px; }
.mono { font: 12px/1.4 ui-monospace, Consolas, monospace; word-break: break-all; background: #f3ede1; padding: 6px 8px; border-radius: 8px; }
.ok-text { color: #17532b; font-weight: 700; } .bad-text { color: #a0281b; font-weight: 700; }
.review { margin-top: 12px; } .review h3 { margin: 0 0 4px; } .review ol { margin: 0; padding-left: 20px; } .review li { margin: 4px 0; }
.rv-g { font-weight: 800; } .rv-g.blunder { color: #a0281b; } .rv-g.error { color: #b8661a; } .rv-g.minor { color: #8a6224; }

.about { margin-top: 32px; padding: 22px 4px 0; border-top: 1px solid var(--line); }
.about-inner { max-width: 720px; }

/* Görünüm seçenekleri */
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches legend { width: 100%; }
.swatches label { display: flex; align-items: center; gap: 8px; flex: 1 1 110px; margin: 0; }
.swatches input { position: absolute; opacity: 0; }
.swatches label:has(input:focus-visible) { outline: 3px solid var(--green); outline-offset: 2px; }
.sw { width: 26px; height: 34px; flex: none; border-radius: 5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.felt-green { background: #1f6a44; } .felt-blue { background: #1f4f74; } .felt-wood { background: repeating-linear-gradient(92deg, #7a4f2c 0 4px, #6a4424 4px 8px); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .chart { order: 2; }
  .chart-table tbody { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .chart-table tr { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
  .chart-table td { border: 0; }
}
@media (max-width: 640px) {
  :root { --die: 54px; }
  .wrap { padding: 0 6px 24px; }
  .bar { margin: 8px 2px; gap: 6px 10px; }
  .title h1 { font-size: 22px; }
  .tools { margin-left: 0; width: 100%; }
  .tool { flex: 1 1 auto; min-height: 40px; padding: 6px 8px; font-size: 13px; }
  #btnSettings { flex: 0 0 auto; } #btnSettings .tl { display: none; }
  .players { gap: 6px; margin: 0 2px 8px; }
  .pl { flex-basis: 120px; padding: 6px 9px; gap: 0 6px; }
  .pl .pl-total { font-size: 18px; } .pl .pl-ic { font-size: 18px; }
  .felt { min-height: 280px; padding: 10px 6px 12px; border-radius: 14px; gap: 10px; }
  .tray { gap: 10px; }
  .stamp { font-size: 30px; }
  .actions { position: sticky; bottom: 0; z-index: 5; margin: 0 -6px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
  .act { flex: 1 1 0; min-height: 50px; font-size: 16px; padding: 8px 10px; }
  .keys { display: none; }
  /* Koç satırı düğmelerin hemen üstüne yapışır: uzun sayfada da ekranda kalır */
  .coach-line { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 5; margin: 6px 0 0; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
}
@media (prefers-reduced-motion: reduce) { .tray.rolling .die, .stamp, .pl.bump, .tray .die { animation: none !important; transition: none !important; } }
@media (prefers-contrast: more) { .die { box-shadow: 0 0 0 2px #000; } .tray .die.sel { box-shadow: 0 0 0 5px #000; } }
