/* Masa Oyunları — ortak tasarım sistemi */
:root {
  --bg: #0f1a14;
  --bg-2: #15241c;
  --panel: #1b2d24;
  --panel-2: #22382d;
  --felt: #1e5c3a;
  --felt-2: #17492e;
  --line: rgba(255,255,255,.09);
  --text: #eef3ee;
  --text-2: #a9b8ad;
  --muted: #7b8c80;
  --accent: #f2b33d;
  --accent-2: #d99a1f;
  --accent-ink: #1a1200;
  --good: #4fd17a;
  --bad: #ff6b6b;
  --info: #5fb3ff;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --topbar-h: 52px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
  overscroll-behavior: none;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
img, svg { display: block; max-width: 100%; }
.hidden { display: none !important; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

/* ---- butonlar ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 600;
  min-height: 42px; transition: transform .08s, background .15s, border-color .15s;
  user-select: none; -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:hover { background: #2a4538; border-color: rgba(255,255,255,.18); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-danger { background: #5a2626; border-color: #7a3030; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn-lg { padding: 14px 22px; min-height: 50px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; position: relative; }
.chat-badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: none; place-items: center; padding: 0 4px; line-height: 1; }
.chat-badge.on { display: grid; }
.mobile-only { display: none !important; }
.players-strip { display: none; }

/* ---- form ---- */
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); min-height: 42px; outline: none;
}
.input:focus { border-color: var(--accent); }
.select { appearance: none; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }

/* ---- kart/panel ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--text-2); }
.badge-accent { background: var(--accent); color: var(--accent-ink); }
.badge-good { background: rgba(79,209,122,.18); color: var(--good); }

/* ---- üst çubuk ---- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(15,26,20,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.topbar .brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; }
.topbar .spacer { flex: 1; }
.topbar .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- lobi ---- */
.container { max-width: 1180px; margin: 0 auto; padding: 16px; }
.hero { padding: 28px 0 10px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 40px); }
.hero p { margin: 0; color: var(--text-2); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 18px 0; }
.toolbar .field { flex: 1 1 180px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px; transition: transform .12s, border-color .15s;
}
.game-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.2); }
.game-card .icon { font-size: 40px; line-height: 1; }
.game-card h3 { margin: 0; font-size: 18px; }
.game-card .desc { color: var(--text-2); font-size: 14px; flex: 1; }
.game-card .meta { font-size: 12px; color: var(--muted); }
.game-card .actions { display: flex; gap: 8px; }
.game-card .actions .btn { flex: 1; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; }
.rooms-list { display: grid; gap: 8px; }
.room-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.room-row .grow { flex: 1; }
.room-row .sub { font-size: 12px; color: var(--muted); }
footer.site-footer { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }

/* ---- oyun sayfası düzeni ---- */
.game-layout {
  display: grid; grid-template-columns: 1fr; grid-template-rows: auto auto;
  min-height: calc(100vh - var(--topbar-h)); min-height: calc(100dvh - var(--topbar-h));
}
.game-stage {
  position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  padding: 10px; min-height: 60vh; min-height: 60dvh;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-2) 70%, #10331f 100%);
}
.game-stage > .game-root { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; }
.side-panel {
  background: var(--bg-2); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; padding: 12px;
}
@media (max-width: 899px) {
  .mobile-only { display: inline-flex !important; }
  .mobile-only.hidden { display: none !important; }
  .drawer-head { display: flex !important; align-items: center; justify-content: space-between; font-weight: 700; padding-bottom: 4px; }
  .players-strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: var(--topbar-h); z-index: 40; }
  .players-strip::-webkit-scrollbar { display: none; }
  .players-strip .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; flex: none; }
  .players-strip .chip.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
  .players-strip .chip.me .name { color: var(--accent); }
  .players-strip .chip .avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--panel-2); }
  .players-strip .chip .score { color: var(--text-2); font-variant-numeric: tabular-nums; }
  .players-strip .chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
  .players-strip .chip .dot.on { background: var(--good); }
  .players-strip .chip .dot.bot { background: var(--info); }
  .game-layout { grid-template-rows: 1fr; min-height: calc(100vh - var(--topbar-h) - 44px); min-height: calc(100dvh - var(--topbar-h) - 44px); }
  .game-stage { min-height: 0; }
  .side-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 75vh; max-height: 75dvh; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .25s ease; box-shadow: 0 -10px 30px rgba(0,0,0,.45); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .side-panel.open { transform: none; }
  .side-panel.local-mode { display: none; }
  .side-panel .players-list { display: none; }
  .chat { max-height: 50vh; max-height: 50dvh; }
}
@media (min-width: 900px) {
  .game-layout { grid-template-columns: 1fr 300px; grid-template-rows: 1fr; }
  .game-stage { min-height: calc(100vh - var(--topbar-h)); padding: 16px; }
  .side-panel { border-top: 0; border-left: 1px solid var(--line); height: calc(100vh - var(--topbar-h)); position: sticky; top: var(--topbar-h); overflow: hidden; }
  .side-panel .chat { flex: 1; min-height: 0; }
}
.players-list { display: flex; flex-direction: column; gap: 6px; }
.player-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid transparent; }
.player-row.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.player-row.me .name::after { content: " (sen)"; color: var(--muted); font-weight: 400; }
.player-row .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--panel-2); flex: none; }
.player-row .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .score { font-variant-numeric: tabular-nums; color: var(--text-2); }
.player-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.player-row .dot.on { background: var(--good); }
.player-row .dot.bot { background: var(--info); }
.chat { display: flex; flex-direction: column; min-height: 180px; max-height: 40vh; }
@media (min-width: 900px) { .chat { max-height: none; } }
.chat-log { flex: 1; overflow-y: auto; font-size: 14px; display: flex; flex-direction: column; gap: 4px; padding: 6px 2px; }
.chat-log .msg .from { color: var(--accent); font-weight: 600; }
.chat-log .msg.sys { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 6px; }
.chat-form .input { min-height: 38px; }

/* ---- bekleme odası ---- */
.waiting-room { max-width: 520px; width: 100%; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.waiting-room h2 { margin: 0; }
.seat-list { display: grid; gap: 8px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-2); border-radius: var(--radius-sm); border: 1px dashed var(--line); }
.seat.filled { border-style: solid; }
.seat .label { flex: 1; }
.seat .empty { color: var(--muted); }
.code-box { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-2); border-radius: var(--radius-sm); }
.code-box .code { font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: .25em; font-weight: 800; color: var(--accent); flex: 1; }

/* ---- modal / toast ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(440px, 100%); box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 8px; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal .modal-actions .btn { flex: 1; }
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast { background: #000c; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; animation: toast-in .2s ease-out; max-width: 90vw; text-align: center; }
.toast.err { background: #7a2020ee; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-scores { display: grid; gap: 6px; margin-top: 10px; }
.result-scores .row { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--bg-2); border-radius: 6px; }
.result-scores .row.winner { background: rgba(242,179,61,.15); color: var(--accent); font-weight: 700; }
.turn-banner { text-align: center; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.25); align-self: center; margin-bottom: 8px; font-size: 14px; }
.turn-banner.mine { background: var(--accent); color: var(--accent-ink); }
.rules-content { white-space: pre-wrap; color: var(--text-2); font-size: 14px; line-height: 1.55; }

/* ---- ortak oyun bileşenleri (ui-kit) ---- */
.pcard {
  --cw: 56px; width: var(--cw); height: calc(var(--cw) * 1.42); border-radius: calc(var(--cw) * .09);
  background: #fff; color: #111; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,.35); user-select: none;
  font-family: Georgia, "Times New Roman", serif; flex: none; transition: transform .12s;
}
.pcard.red { color: #c8202a; }
.pcard .c { position: absolute; left: 6%; top: 4%; font-size: calc(var(--cw) * .3); line-height: 1; font-weight: 700; text-align: center; }
.pcard .c small { display: block; font-size: calc(var(--cw) * .24); }
.pcard .c2 { left: auto; right: 6%; top: auto; bottom: 4%; transform: rotate(180deg); }
.pcard .big { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .6); }
.pcard.back { background: repeating-linear-gradient(45deg, #2c5aa0 0 6px, #244b85 6px 12px); border: 3px solid #fff; }
.pcard.selectable { cursor: pointer; }
.pcard.selectable:hover { transform: translateY(-6px); }
.pcard.selected { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--accent), 0 6px 10px rgba(0,0,0,.4); }
.pcard.disabled { filter: brightness(.6); }
.otile {
  --tw: 44px; width: var(--tw); height: calc(var(--tw) * 1.45); border-radius: calc(var(--tw) * .14);
  background: linear-gradient(180deg, #fff8e8, #f0e2c2); color: #111; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 2px 3px rgba(0,0,0,.4), inset 0 1px 0 #fff; font-weight: 800; font-size: calc(var(--tw) * .62); user-select: none; flex: none; position: relative;
}
.otile.red { color: #d12a2a; } .otile.blue { color: #1f55c4; } .otile.black { color: #222; } .otile.yellow { color: #d08a00; }
.otile .dot { width: calc(var(--tw) * .16); height: calc(var(--tw) * .16); border-radius: 50%; background: currentColor; margin-top: 2px; }
.otile.fake::after { content: "★"; position: absolute; top: 2px; right: 4px; font-size: calc(var(--tw) * .28); color: #777; }
.otile.back { background: linear-gradient(180deg, #8c2b2b, #6a1f1f); border: 2px solid #c9a06a; }
.otile.selected { outline: 3px solid var(--accent); transform: translateY(-6px); }
.otile.selectable { cursor: pointer; }
.die {
  --dw: 40px; width: var(--dw); height: var(--dw); border-radius: calc(var(--dw) * .2); background: #fff;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: calc(var(--dw) * .12); gap: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,.4); flex: none;
}
.die span { border-radius: 50%; background: #111; opacity: 0; }
.die span.on { opacity: 1; }
.die.used { opacity: .4; }
.die.rolling { animation: die-roll .5s ease-in-out; }
@keyframes die-roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } 100% { transform: rotate(360deg) scale(1); } }
.board-grid { display: grid; gap: 0; touch-action: manipulation; user-select: none; }
.board-grid .cell { position: relative; display: grid; place-items: center; }
.board-grid .cell.hint::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(0,0,0,.25); }
.board-grid .cell.sel { box-shadow: inset 0 0 0 3px var(--accent); }
.board-grid .cell.last { box-shadow: inset 0 0 0 3px rgba(95,179,255,.8); }
