/* Hep Yek — kahvehane tahtası, İznik turkuazı çerçeve.
   Düzen: lobide oyun kartları + masa listesi; masada tahta solda, yan panel sağda (dar ekranda alt alta). */
:root {
  --ground: #e6eceb;
  --panel: #f6f9f8;
  --panel-2: #edf2f1;
  --ink: #15272a;
  --muted: #55696c;
  --line: #ccd8d7;
  --accent: #0a6c76;
  --accent-ink: #ffffff;
  --accent-soft: #d3e9ea;
  --alert: #ad3626;
  --alert-soft: #f6dcd6;
  --gold: #9a6f17;
  --ok: #2d7a48;
  --shadow: 0 1px 2px rgba(8, 28, 30, .08), 0 8px 28px rgba(8, 28, 30, .10);
  /* Eczar'da olmayan harfler (Kiril vb.) Alegreya Sans'tan, ikisinde de olmayanlar (Arapça, Ermenice, Çince…) sistemden gelir */
  --font-display: 'Eczar', 'Alegreya Sans', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Alegreya Sans', 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --radius: 10px;

  /* tahta: iki temada da aynı — açık çerçeve, ceviz zemin, krem haneler, pirinç menteşe */
  --wood-frame: #a46c3b;
  --wood-frame-hi: rgba(255, 226, 182, .28);
  --hinge-strip: #b37b46;
  --tray-wood: #7b4b25;
  --pt-cream: #e8d48f;
  --pt-inlay: #16241b;
  --pt-wal: rgba(28, 6, 2, .34);
  --frame-label: rgba(58, 28, 8, .62);
  --hl: #2fe0e8;
  --hl-dest: rgba(47, 224, 232, .38);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c1618; --panel: #132225; --panel-2: #182b2f; --ink: #e2ebea; --muted: #95a9a8;
    --line: #253a3e; --accent: #4ac0c8; --accent-ink: #04211f; --accent-soft: #143a3e;
    --alert: #e7745f; --alert-soft: #3d201b; --gold: #d8ab4a; --ok: #6cc38c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0c1618; --panel: #132225; --panel-2: #182b2f; --ink: #e2ebea; --muted: #95a9a8;
  --line: #253a3e; --accent: #4ac0c8; --accent-ink: #04211f; --accent-soft: #143a3e;
  --alert: #e7745f; --alert-soft: #3d201b; --gold: #d8ab4a; --ok: #6cc38c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- üst şerit */
.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-inline-end: auto; min-width: 0; }
.brand h1 { font-size: 26px; letter-spacing: .01em; }
.brand h1 .dot { color: var(--accent); }
.brand .tag { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-size: 14px; white-space: nowrap;
}
.conn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.on::before { background: var(--ok); }
.conn.off::before { background: var(--alert); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); font-weight: 500;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--alert); border-color: color-mix(in srgb, var(--alert) 45%, var(--line)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }

/* ---------- lobi */
.lobby { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 28px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.lobby > * { min-width: 0; }
@media (max-width: 880px) { .lobby { grid-template-columns: minmax(0, 1fr); } .lobby > section:last-child { order: -1; } .lobby > .play-hero { order: -2; } }
/* Lobinin başı: Rakip bul, seçili oyun, öbür yollar, canlı sayılar */
.play-hero { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.hero-top { flex: 1 1 340px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.play-hero .lobby-act { flex: 0 1 auto; }
.hero-stats { flex: 1 1 100%; }
.btn.hero-find { font-size: 20px; font-weight: 700; padding: 14px 36px; min-height: 56px; border-radius: 14px; }
.hero-fmt { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); }
.hero-fmt strong { color: var(--ink); font-weight: 600; }
.play-hero .lobby-act { margin-top: 0; }
.hero-stats { margin: 0; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.hero-stats::before { content: ''; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.sub-h { margin: 6px 0 0; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-family: var(--font-body); }
.sub-h:first-child { margin-top: 0; }
.prow .fact { align-items: center; flex-wrap: nowrap; gap: 8px; }
.prow .lrate { font-size: 15px; }
.trow .who .lrate { font-weight: 400; color: var(--muted); font-size: 14px; }
@media (max-width: 560px) { .btn.hero-find { flex: 1 1 100%; } .play-hero { padding: 14px; } }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title h2 { font-size: 22px; }

/* oyun düzeni seçici */
.fmt { display: grid; gap: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 14px; font-weight: 500; }
.chipbtn:hover { border-color: var(--accent); }
.chipbtn.on { background: var(--accent-soft); border-color: var(--accent); }
.glist { display: grid; gap: 8px; }
.grow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
}
.grow:not(.on) .g-main { opacity: .55; }
.grow.on { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.grow > input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.g-main { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: center; cursor: pointer; min-width: 0; }
.g-thumb { display: block; border-radius: 7px; overflow: hidden; line-height: 0; }
.g-thumb svg { width: 100%; height: auto; display: block; }
.g-text { display: grid; gap: 2px; min-width: 0; }
.g-name { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.1; display: flex; gap: 6px; align-items: baseline; }
.g-no { color: var(--accent); font-size: 18px; }
.g-desc { color: var(--muted); font-size: 15px; }
.g-act { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg-b { border: 0; background: transparent; padding: 8px 16px; min-height: 42px; font-weight: 500; }
.seg-b + .seg-b { border-inline-start: 1px solid var(--line); }
.seg-b.on { background: var(--accent); color: var(--accent-ink); }
.fmt-len { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.fmt-sum { margin: 0; }
.lbl-s { font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lobby-act { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 560px) {
  .grow { grid-template-columns: auto minmax(0, 1fr); padding: 10px; }
  .g-main { grid-template-columns: 88px minmax(0, 1fr); gap: 10px; }
  .g-act { grid-column: 2; justify-content: flex-start; }
  .g-name { font-size: 19px; }
  .g-desc { font-size: 14px; }
  .brand .tag { display: none; }
}

/* masa listesi */
.tables { display: grid; gap: 8px; }
.trow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.trow .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .meta { grid-column: 1; font-size: 14px; color: var(--muted); }
.trow .btn { grid-row: 1 / span 2; grid-column: 2; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge.wait { background: var(--accent-soft); color: var(--accent); }
.badge.live { background: var(--alert-soft); color: var(--alert); }
.badge.done { background: var(--panel-2); color: var(--muted); }
.empty { padding: 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.joinbox { display: flex; gap: 8px; margin-top: 14px; }
.joinbox input, .field input {
  flex: 1; min-width: 0; min-height: 42px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); text-transform: uppercase; letter-spacing: .12em;
}
.field { display: grid; gap: 6px; }
.field input { text-transform: none; letter-spacing: normal; }
.note { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.note:empty { display: none; }
.srvrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 14px; flex-wrap: wrap; }
.srv-host { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.srvbox { text-align: start; }
.srvbox .joinbox { margin-top: 0; }
.srvform input { text-transform: none; letter-spacing: normal; }

/* ---------- masa: başlık + tahta ve panel; ekran yüksekliğini doldurur */
#app.tablescreen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
#app.tablescreen > .top { flex: none; }
#app.tablescreen > .table-wrap { flex: 1 1 auto; width: 100%; }
.table-wrap {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto 1fr;
  grid-template-areas: "board opp" "board side"; gap: 12px 16px;
  padding: 12px 16px 24px; max-width: 1400px; margin: 0 auto; align-items: start; align-content: start;
}
.table-wrap .opp { grid-area: opp; min-width: 0; }
.table-wrap .board-box { grid-area: board; }
.table-wrap .side { grid-area: side; }
@media (max-width: 920px), (max-aspect-ratio: 1/1) {
  .table-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "opp" "board" "side"; gap: 10px; }
}
.board-box { position: relative; min-width: 0; direction: ltr; }   /* tahta her dilde aynı yönde */
.board-box .waitcard, .board-box .fx { direction: inherit; }
[dir="rtl"] .board-box .waitcard, [dir="rtl"] .board-box .fx { direction: rtl; }
.board-box svg.board { width: 100%; height: auto; max-height: calc(100vh - 96px); display: block; margin: 0 auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
@media (max-width: 920px), (max-aspect-ratio: 1/1) { .board-box svg.board { max-height: none; } }
.side { display: grid; gap: 12px; min-width: 0; }
.pcard {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.pcard.turn { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.pcard .sw { width: 26px; height: 26px; border-radius: 50%; grid-row: span 2; border: 1.5px solid #9b6f42; background: radial-gradient(circle at 40% 35%, #f8e6c8, #e3bf8e 70%, #c99a63); box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0), inset 0 0 0 6.5px rgba(122, 78, 36, .35); }
.pcard .sw.b { border-color: #050506; background: radial-gradient(circle at 40% 35%, #4a4b52, #232328 65%, #121215); box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0), inset 0 0 0 6.5px rgba(255, 255, 255, .13); }
.pcard .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .nm .you { font-weight: 400; color: var(--muted); }
.pcard .sub { font-size: 13px; color: var(--muted); grid-column: 2; }
.pcard .sc { grid-row: span 2; font-family: var(--font-display); font-size: 32px; font-weight: 600; line-height: 1; }
.dotline::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dotline.on::before { background: var(--ok); }
.status { padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 6px; }
.status .big { font-family: var(--font-display); font-size: 24px; line-height: 1.15; }
.status .small { font-size: 15px; color: var(--muted); }
.fmtbox .btn { justify-self: start; }
.status.alert { border-color: var(--alert); }
.status.good { border-color: var(--accent); }
.stages { display: flex; flex-wrap: wrap; gap: 4px; }
.stage { display: inline-flex; gap: 2px; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.stage.cur { background: var(--accent); color: var(--accent-ink); }
.stage.used { opacity: .45; text-decoration: line-through; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions .btn { width: 100%; }
.actions .wide { grid-column: 1 / -1; }
.compact-top { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.compact-top > .btn, .compact-top > .chip { flex: none; white-space: nowrap; }   /* başlık daralır, düğmeler kırılmaz */
.compact-top .title { font-family: var(--font-display); font-size: 20px; margin-inline-end: auto; min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* simgeli düğmeler: dar ekranda yalnız simge */
.btn .ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn.ico { gap: 6px; }
@media (max-width: 900px) { .compact-top .btn.ico .txt { display: none; } .compact-top .btn.ico { padding-inline: 8px; min-width: 38px; } }
@media (max-width: 640px) { .top > .btn.ico .txt { display: none; } .top > .btn.ico { padding-inline: 8px; min-width: 38px; } }
.lang .lcode { display: none; font-weight: 700; letter-spacing: .04em; }
.lang .lcode::after { content: attr(data-code); }
@media (max-width: 560px) {
  .top { gap: 6px; }
  .compact-top { gap: 6px; }
  .compact-top .title { display: none; }
  .compact-top .back { margin-inline-end: auto; }
  .top .chip.conn { font-size: 0; gap: 0; padding: 8px; }
  .lang .lname { display: none; }
  .lang .lcode { display: inline; }
}
.waitcard {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: color-mix(in srgb, var(--ground) 55%, transparent); backdrop-filter: blur(2px);
}
.waitcard .inner { max-width: 420px; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 10px; text-align: center; }
.code { font-family: var(--font-display); font-size: 40px; letter-spacing: .14em; color: var(--accent); }
.linkbox { display: flex; gap: 6px; }
.linkbox input { flex: 1; min-width: 0; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); font-size: 14px; }

/* ---------- tahta (SVG) — renkler seçilen tahtadan gelir (app.js: TAHTA, svg'nin style'ında değişkenler) */
.board .frame { fill: var(--wood-frame); }
.board .frame-hi { fill: none; stroke: var(--wood-frame-hi); stroke-width: 2; }
.board .field-edge { fill: none; stroke: var(--field-edge, rgba(40, 14, 4, .55)); stroke-width: 3; }
.board .hinge-strip { fill: var(--hinge-strip); }
.board .hinge-im path { fill: none; stroke-width: .15; stroke-linejoin: round; }
.board .hinge-im .hi { stroke: rgba(255, 244, 205, .55); }
.board .hinge-im .lo { stroke: #6a4a14; }
.board .tray { fill: var(--tray-wood); }
.board .tray-line { stroke: rgba(255, 226, 182, .25); stroke-width: 2; }
.board .pt-cream { fill: var(--pt-cream); }
.board .pt-inlay { fill: var(--pt-inlay); }
.board .pt-wal { fill: var(--pt-wal); }
.board .lbl { fill: var(--frame-label); font: 700 13px var(--font-body); text-anchor: middle; dominant-baseline: central; }
.board .tray-lbl { fill: #f6e4c6; font: 700 15px var(--font-body); text-anchor: middle; }
/* pul: gölge, gövde (seçilen takımın degradesi), dış çizgi, kabartma, desen ya da im, parlama */
.chk .shd { fill: rgba(0, 0, 0, .36); }
.chk .body { stroke-width: 1.6; }
.chk .rim { fill: none; stroke-width: 1.1; }
.chk.w .rim { stroke: rgba(40, 20, 4, .42); }
.chk.b .rim { stroke: rgba(255, 244, 228, .3); }
.chk .bev { stroke-width: 2.4; }
.chk .ring { stroke-width: 2; }
.chk .ring.thin { stroke-width: 1.4; }
.chk .sedef { opacity: .95; }
.chk .glow { fill: none; stroke: var(--hl); stroke-width: 4; }
.board .chk .cnt { font: 700 19px var(--font-body); text-anchor: middle; dominant-baseline: central; }
.board .chk.src .glow { animation: breathe 1.9s ease-in-out infinite; }
.board .chk.sel .glow { stroke-width: 6; }
.board .chk.drag .glow { stroke-width: 5; opacity: .85; }
@keyframes breathe { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .42; } }
.board .chk.pinned .body { stroke-dasharray: 5 4; }
.board .slab .slab-hi { fill: rgba(255, 255, 255, .32); }
.board .lock circle { fill: var(--alert); stroke: #fff; stroke-width: 1.5; }
.board .dest { fill: var(--hl-dest); transition: fill .12s; }
.board .dest.hover { fill: rgba(47, 224, 232, .62); }
.board .dest-dot { fill: var(--hl); stroke: #0b3d40; stroke-width: 2; }
.board .dest-dot.hover { stroke: #fff; stroke-width: 3; }
.board .tray-dest { fill: var(--hl-dest); stroke: var(--hl); stroke-width: 3; }
.board .tray-dest.hover { fill: rgba(47, 224, 232, .6); }
.board .hit { fill: transparent; cursor: pointer; }
.board .hit.src { cursor: grab; }
.board .hit:focus-visible { fill: rgba(47, 224, 232, .18); stroke: var(--hl); stroke-width: 3; outline: none; }
/* canlı tahtada tarayıcı kaydırma/yakınlaştırma yapmasın: parmakla sürükleme pula gitsin (üstteki manipulation kuralını ezmeli) */
.board-box svg.board.live, .board.live { touch-action: none; -webkit-touch-callout: none; }
.board .die-shd { fill: rgba(0, 0, 0, .32); }
.board .die-face { fill: #fbf7ee; stroke: #6d5636; stroke-width: 2; }
.board .die.b .die-face { fill: #26232a; stroke: #8b8590; }
.board .die circle { fill: #241a12; }
.board .die.b circle { fill: #f3e8d2; }
.board .die circle.yek { fill: #c8281e; }
.board .die.used { opacity: .38; }
/* bir dokunuşta oynanacak zar (önce büyük; zarlara dokununca öbürü) */
.board .die.act .die-face { stroke: var(--hl); stroke-width: 4; }
.board .dice-note { fill: #f6e4c6; font: 700 20px var(--font-body); dominant-baseline: central; }
.board .dice-tag { fill: #ffd27a; font: 700 15px var(--font-body); text-anchor: middle; letter-spacing: .08em; }
/* rakibin son elde oynadığı hamlelerin izi */
.board .trail { fill: none; stroke: var(--hl); stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: .5 8; opacity: .9; }
.board .arrow-head { fill: var(--hl); }
.board .trail-from { fill: none; stroke: var(--hl); stroke-width: 2.5; stroke-dasharray: 5 5; opacity: .85; }
.board .trail-to { fill: none; stroke: var(--hl); stroke-width: 2.5; opacity: .9; }
.board.mini { pointer-events: none; }
/* sıra sende: zarların geleceği yerde silik zarlar; tahtaya dokununca atılır */
.board.rollable { cursor: pointer; }
.board .roll-hint rect { fill: rgba(255, 250, 235, .1); stroke: rgba(255, 244, 220, .75); stroke-width: 2; stroke-dasharray: 6 5; }
.board .roll-hint { animation: breatheHint 1.8s ease-in-out infinite; }
.board .roll-txt { fill: rgba(255, 244, 220, .85); font: 700 15px var(--font-body); text-anchor: middle; dominant-baseline: central; letter-spacing: .02em; }
@keyframes breatheHint { 0%, 100% { opacity: .95; } 50% { opacity: .5; } }
/* çift gelince zarlar bir kez parlar */
.board .die.shine { animation: shine 1.3s ease-out 1; }
@keyframes shine { 0% { filter: drop-shadow(0 0 0 rgba(255, 214, 102, 0)); } 35% { filter: drop-shadow(0 0 9px rgba(255, 214, 102, .95)); } 100% { filter: drop-shadow(0 0 0 rgba(255, 214, 102, 0)); } }
@media (prefers-reduced-motion: reduce) { .board .chk.src .glow, .board .roll-hint, .board .die.shine { animation: none; } }

/* ---------- açılır pencere + bildirim */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 14, 16, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(720px, 100%); max-height: min(86vh, 900px); overflow: auto; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; display: grid; gap: 12px; }
.modal h2 { font-size: 26px; }
.modal .tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.modal .tabs .btn[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rules { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; max-width: 65ch; }
.modal.guide { width: min(860px, 100%); max-height: min(92vh, 1000px); }
.modal.guide .tabs { position: sticky; top: -18px; z-index: 1; background: var(--panel); padding: 8px 0; margin-top: -8px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
.modal.guide .tabs .btn { flex: none; }
.guide-body { display: grid; gap: 10px; max-width: 70ch; }
.guide-body h3 { font-size: 21px; margin-top: 8px; }
.guide-body p { margin: 0; }
.guide-body .steps, .guide-body .tips { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.guide-body .steps li::marker { color: var(--accent); font-weight: 700; }
.guide-body .tips li::marker { color: var(--gold); }
.guide-board { max-width: 560px; border-radius: 10px; overflow: hidden; line-height: 0; }
.guide-board svg { width: 100%; height: auto; display: block; }
.dicegrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 560px) { .dicegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dicecell { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.dicecell.cift { background: var(--accent-soft); }
.dicepair { font-weight: 700; min-width: 2.6em; }
.rules li::marker { color: var(--accent); }
.src-note { font-size: 13px; color: var(--muted); }
.toasts { position: fixed; left: 50%; bottom: calc(16px + var(--sa-b)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 30; width: min(460px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--ground); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 15px; animation: tin .2s ease-out; }
.toast.alert { background: var(--alert); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
footer.foot { padding: 0 16px 24px; text-align: center; font-size: 13px; color: var(--muted); }
footer.foot .motto { margin: 0 0 8px; font-family: var(--font-display); font-size: 17px; font-style: italic; color: var(--ink); opacity: .75; }

/* ---------- çentikli ve kenardan kenara ekranlar
   Telefon uygulamasında (Android) güvenli alan payları --safe-area-inset-* değişkenleriyle gelir;
   tarayıcı ve iPhone env(safe-area-inset-*) verir. İkisinin büyüğü alınır, hiçbiri yoksa 0. */
:root {
  --sa-t: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --sa-r: max(env(safe-area-inset-right, 0px), var(--safe-area-inset-right, 0px));
  --sa-b: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --sa-l: max(env(safe-area-inset-left, 0px), var(--safe-area-inset-left, 0px));
}
.top { padding: calc(10px + var(--sa-t)) calc(16px + var(--sa-r)) 10px calc(16px + var(--sa-l)); }
.lobby { padding-left: calc(16px + var(--sa-l)); padding-right: calc(16px + var(--sa-r)); }
.table-wrap { padding: 12px calc(16px + var(--sa-r)) calc(24px + var(--sa-b)) calc(16px + var(--sa-l)); }
footer.foot { padding: 0 calc(16px + var(--sa-r)) calc(24px + var(--sa-b)) calc(16px + var(--sa-l)); }
.modal-bg { padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l)); }
.modal, .modal.guide { max-height: calc(100vh - 32px - var(--sa-t) - var(--sa-b)); }
@supports (height: 100dvh) {
  .modal, .modal.guide { max-height: calc(100dvh - 32px - var(--sa-t) - var(--sa-b)); }
}
@media (min-height: 1100px) { .modal, .modal.guide { max-height: 1000px; } }

/* ---------- pul seçimi */
.pulgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pulbtn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: start; font-weight: 500; min-height: 56px; }
.pulbtn:hover { border-color: var(--accent); }
.pulbtn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.pulsample { width: 64px; height: 32px; flex: none; }

/* ---------- el ve maç sonu efektleri (tahtanın üstünde, dokunmayı engellemez) */
.fx { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; display: grid; place-items: center; padding: 12px; }
.fx-card {
  position: relative; max-width: min(92%, 440px); text-align: center; padding: 14px 22px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; gap: 4px; justify-items: center;
  animation: fxIn .42s cubic-bezier(.2, 1.35, .45, 1) both, fxOut .45s ease-in forwards; animation-delay: 0s, var(--life, 2400ms);
}
.fx-card .t { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3.6vw, 32px); line-height: 1.12; }
.fx-card.win .t { color: var(--accent); }
.fx-card .s { color: var(--muted); font-size: 15px; }
.fx-card.big { padding: 18px 26px 20px; border-color: var(--accent); }
.fx-card.big.lose { border-color: var(--line); }
.fx-card.big .t { font-size: clamp(26px, 4.6vw, 40px); }
.fx-stamp {
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .16em; color: #c8281e;
  border: 3px solid #c8281e; border-radius: 8px; padding: 0 10px 0 13px; transform: rotate(-7deg);
  animation: stamp .5s cubic-bezier(.2, 1.7, .4, 1) both .12s;
}
.fx-dice { width: 92px; height: 50px; animation: diceIn .9s cubic-bezier(.2, 1.4, .4, 1) both .1s; }
.fx-p {
  position: absolute; left: 50%; top: 50%; width: var(--sz); height: var(--sz); margin: calc(var(--sz) / -2) 0 0 calc(var(--sz) / -2);
  border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .2), inset 0 0 0 5px rgba(255, 255, 255, .12);
  animation: burst var(--d) cubic-bezier(.12, .75, .3, 1) forwards;
}
.fx-c {
  position: absolute; top: -28px; left: var(--x); width: var(--sz); height: var(--sz); border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .2); opacity: 0;
  animation: fall var(--d) cubic-bezier(.3, .1, .7, 1) var(--dl) forwards;
}
.fx-c.die { border-radius: 24%; background: #fbf7ee; box-shadow: inset 0 0 0 1.5px #6d5636; }
.fx-c.die::after { content: ''; position: absolute; inset: 33%; border-radius: 50%; background: #c8281e; }
@keyframes fxIn { from { opacity: 0; transform: scale(.86) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fxOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes fxFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes stamp { from { opacity: 0; transform: rotate(-7deg) scale(2.2); } to { opacity: 1; transform: rotate(-7deg) scale(1); } }
@keyframes diceIn { from { opacity: 0; transform: translateY(-30px) rotate(-25deg); } to { opacity: 1; transform: none; } }
@keyframes burst { 0% { opacity: 0; transform: translate(0, 0) scale(.3); } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); } }
@keyframes fall { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--fall)) rotate(var(--rot)); } }
@media (prefers-reduced-motion: reduce) {
  .fx-card { animation: fxFade .2s both, fxOut .3s forwards; animation-delay: 0s, var(--life, 2400ms); }
  .fx-stamp, .fx-dice { animation: none; }
  .fx-p, .fx-c { display: none; }
}

/* ---------- profil ve arkadaşlar */
.side-col { display: grid; gap: 10px; align-content: start; }
.side-col > .section-title { margin: 14px 0 0; }
.side-col > .section-title:first-of-type { margin-top: 0; }
.profile { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.mecode { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-s { font-family: var(--font-display); font-size: 24px; letter-spacing: .12em; color: var(--accent); }
.profile .note { margin: 0; }
.row-links { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 -6px -4px; }
.friends { display: grid; gap: 8px; }
.frow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.frow:not(.on):not(.req):not(.out) .fname { color: var(--muted); }
.frow.req { border-color: var(--accent); background: var(--accent-soft); }
.fdot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.fdot.lobide { background: var(--ok); }
.fdot.bekliyor { background: var(--gold); }
.fdot.oynuyor { background: var(--alert); }
.fdot.req { background: var(--accent); }
.fdot.out { background: transparent; border: 2px dashed var(--muted); box-shadow: none; }
.fmain { min-width: 0; }
.fname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsub { font-size: 13px; color: var(--muted); }
.fact { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.friends .joinbox { margin-top: 4px; }
.invlist { display: grid; gap: 6px; text-align: start; }

/* ---------- gelen davet şeridi */
.invite {
  position: fixed; left: 50%; top: calc(10px + var(--sa-t)); transform: translateX(-50%); z-index: 40;
  width: min(520px, calc(100% - 24px)); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 2px solid var(--accent); box-shadow: var(--shadow);
  animation: invIn .3s cubic-bezier(.2, 1.3, .4, 1) both;
}
.inv-text { min-width: 0; }
.inv-act { display: flex; gap: 6px; }
@keyframes invIn { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .invite { animation: none; } }

/* ---------- gizlilik ve hesap silme sayfaları */
.doc { max-width: 760px; margin: 0 auto; padding: calc(20px + var(--sa-t)) calc(16px + var(--sa-r)) calc(48px + var(--sa-b)) calc(16px + var(--sa-l)); }
.doc h1 { font-size: 32px; margin: 8px 0 14px; }
.doc h2 { font-size: 21px; margin: 22px 0 8px; }
.doc p, .doc li { max-width: 68ch; }
.doc ul, .doc ol { padding-inline-start: 22px; display: grid; gap: 4px; }
.doc a, .foot a { color: var(--accent); }
.doc mark { background: var(--alert-soft); color: var(--alert); padding: 0 4px; border-radius: 4px; }

/* ---------- dil seçimi */
.lang { white-space: nowrap; }
.langgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.langbtn { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 17px; font-weight: 500; text-align: start; }
.langbtn:hover { border-color: var(--accent); }
.langbtn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.langbtn .beta { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; }

/* bilgisayara karşı: seviye seçimi */
.botlevels { display: grid; gap: 10px; }
.botlevel { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); text-align: start; cursor: pointer; }
.botlevel:hover { border-color: var(--accent); }
.botlevel.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.botlevel .bl-name { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.botlevel .bl-desc { color: var(--muted); font-size: 15px; }

/* canlı masada sıra süresi (son 30 saniye) */
.status .clock { margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--muted); }
.status .clock.late { color: var(--alert); font-weight: 700; }
.btn.snd { min-width: 40px; padding-inline: 8px; }

/* hazır sohbet */
.pcard { position: relative; }
.pcard .bubble { position: absolute; inset-inline-start: 52px; bottom: calc(100% - 6px); z-index: 5; max-width: 70%; padding: 6px 12px; border-radius: 14px; background: var(--ink); color: var(--panel); font-size: 16px; font-weight: 500; box-shadow: 0 6px 18px rgba(0,0,0,.18); animation: bubble-in .18s ease-out; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .bubble::after { content: ''; position: absolute; inset-inline-start: 16px; top: 100%; border: 7px solid transparent; border-top-color: var(--ink); }
@keyframes bubble-in { from { transform: translateY(6px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pcard .bubble { animation: none; } }
.saygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.saybtn { min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 17px; text-align: start; cursor: pointer; }
.saybtn:hover { border-color: var(--accent); }
.saybtn.emo { font-size: 26px; text-align: center; }

/* sıralama, profil */
.linklike { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: start; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 30%, transparent); text-underline-offset: 3px; }
.linklike:hover { text-decoration-color: currentColor; }
.leaders { display: grid; gap: 4px; margin-bottom: 14px; }
.lrow { display: grid; grid-template-columns: 2.2em 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.lrow.me { border-color: var(--accent); background: var(--accent-soft); }
.lrank { color: var(--muted); font-weight: 700; text-align: center; }
.lname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrate { font-weight: 700; font-size: 18px; }
.lsub { font-size: 14px; }
.myrating { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-top: 8px; }
.myrating strong { font-size: 20px; }
.pstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.pstats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.pstats strong { font-size: 20px; }
.pstats strong.big { font-size: 26px; }
.pvs { display: grid; gap: 4px; margin-bottom: 10px; }
.pv { display: flex; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--line); }

/* ---------- telefon yan çevrilince: tahta solda yüksekliğe sığar, panel sağda kayar */
@media (orientation: landscape) and (max-height: 560px) {
  .top { padding: calc(3px + var(--sa-t)) calc(10px + var(--sa-r)) 3px calc(10px + var(--sa-l)); gap: 8px; }
  .top .btn.small { min-height: 32px; }
  .compact-top .btn.ico .txt { display: none; }
  .compact-top .btn.ico { padding-inline: 7px; min-width: 36px; }
  .compact-top .title { font-size: 17px; }
  #app.tablescreen { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  #app.tablescreen > .table-wrap { min-height: 0; }
  .table-wrap {
    --bh: calc(100vh - var(--top-h, 40px) - var(--sa-b) - 14px);
    grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "board opp" "board side";
    gap: 6px 10px; max-width: none; align-items: start;
    padding: 6px calc(10px + var(--sa-r)) calc(8px + var(--sa-b)) calc(10px + var(--sa-l));
  }
  .table-wrap .board-box { width: min(calc(var(--bh) * 906 / 680), calc(100vw - var(--sa-l) - var(--sa-r) - 260px)); }
  .board-box svg.board { max-height: none; }
  .table-wrap .side { align-self: stretch; overflow-y: auto; min-height: 0; gap: 8px; padding-bottom: 4px; }
  .pcard { padding: 6px 10px; }
  .pcard .sc { font-size: 26px; }
  .pcard .sw { width: 22px; height: 22px; }
  .status { padding: 8px 10px; gap: 4px; }
  .status .big { font-size: 19px; }
  .status .small { font-size: 14px; }
  .actions { gap: 6px; }
  .actions .btn { min-height: 38px; }
}
@supports (height: 100dvh) {
  @media (orientation: landscape) and (max-height: 560px) {
    .table-wrap { --bh: calc(100dvh - var(--top-h, 40px) - var(--sa-b) - 14px); }
  }
}

/* masa adabı: selam, tebrik, çay */
.actions .gest { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.actions .gest .btn { width: auto; flex: 1 1 0; min-width: max-content; }
.gest-b { border-radius: 999px; }
/* zarları otomatik at: küçük, tıklanabilen anahtar */
.autoroll { display: inline-flex; align-items: center; gap: 10px; justify-self: start; padding: 6px 4px; font-size: 15px; color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; }
.autoroll input { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
.autoroll input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.autoroll input:checked { background: var(--accent); }
.autoroll input:checked::after { transform: translateX(16px); }
.autoroll input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.autoroll:has(input:checked) { color: var(--ink); }
/* üstteki rakip kartında balon kartın altına açılır (başlığın üstüne taşmasın) */
.opp .pcard .bubble { bottom: auto; top: calc(100% - 6px); }
.opp .pcard .bubble::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }
.gest-b.done { opacity: .5; }

/* pul ve tahta seçimi: imin anlamı, tahta önizlemesi */
.pulbtn .pb-t { display: grid; gap: 1px; min-width: 0; }
.pulbtn .pb-m { font-size: 13px; color: var(--muted); font-weight: 400; }
.tahtasample { width: 92px; height: 50px; flex: none; border-radius: 6px; }
.pulgrid.imler { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* Google ile giriş (isteğe bağlı) */
.gbind { display: grid; gap: 8px; justify-items: start; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.gstate { color: var(--ok); }
.gwelcome { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gslot { min-height: 48px; display: flex; align-items: center; }
.authform { display: grid; gap: 10px; }
.authform input { width: 100%; min-height: 46px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: inherit; font: inherit; }
.authform input[autocomplete=one-time-code] { letter-spacing: .3em; font-size: 20px; text-align: center; }
.authform .note { margin: 0; }
.modal .seg { flex-wrap: wrap; }
