:root {
  --bg: #1b120b;
  --bg2: #2a1a0e;
  --card: #34221399;
  --card-solid: #342213;
  --line: #ffffff1a;
  --text: #f5ead8;
  --muted: #c7b49a;
  --gold: #f0b54a;
  --gold-d: #c98a1e;
  --green: #3fbf7f;
  --red: #e0594a;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, #3b2414 0%, var(--bg) 60%) fixed, var(--bg);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2 { font-size: 1.05rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

.btn {
  font: inherit; font-weight: 700; color: var(--text);
  background: #ffffff14; border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  transition: transform .08s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #ffffff22; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-d)); color: #2a1606; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px; font-size: 1.05rem; }
.btn.icon { padding: 10px 12px; }
.pill { font-size: .75rem; font-weight: 600; background: #ffffff18; padding: 2px 8px; border-radius: 99px; color: var(--muted); }

input {
  font: inherit; color: var(--text); background: #00000040; border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; outline: none; width: 100%; min-width: 0;
}
input:focus { border-color: var(--gold); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; backdrop-filter: blur(6px); }

/* Giriş */
#login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); text-align: center; }
.login-card form { display: grid; gap: 12px; margin-top: 20px; }
.logo { font-size: 2.6rem; font-weight: 800; letter-spacing: .5px; }
.logo span { background: linear-gradient(180deg, #ffd889, var(--gold-d)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.small { font-size: 1.5rem; }

/* Salon */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; max-width: 1200px; margin: 0 auto; }
.me { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.me b { color: var(--gold); }
.lobby-grid { display: grid; gap: 16px; padding: 0 16px 24px; max-width: 1200px; margin: 0 auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.seg { display: inline-flex; background: #00000040; border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--gold); color: #2a1606; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.divider { text-align: center; color: var(--muted); font-size: .8rem; margin: 16px 0 10px; display: flex; gap: 10px; align-items: center; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.table-list { display: grid; gap: 8px; max-height: 320px; overflow: auto; }
.table-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #00000030; border-radius: 10px; }
.table-item .names { flex: 1; min-width: 0; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-item .meta { font-size: .75rem; color: var(--muted); }
.empty { color: var(--muted); font-size: .9rem; padding: 12px 0; text-align: center; }

.leaderboard { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: .9rem; }
.leaderboard li span { color: var(--muted); float: right; }

/* Sohbet */
.chat-card { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; min-height: 140px; max-height: 260px; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; padding-right: 4px; overflow-wrap: anywhere; }
.chat-log .sys { color: var(--muted); font-style: italic; font-size: .8rem; }
.chat-log b { color: var(--gold); }
.chat-log b.s1 { color: #9ad0ff; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick button { font: inherit; font-size: .78rem; color: var(--text); background: #ffffff10; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; cursor: pointer; }

/* Masa */
#table { min-height: 100%; }
.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding: 12px 16px; max-width: 1300px; margin: 0 auto; }
.play-area { display: grid; gap: 8px; min-width: 0; }
.board-wrap { position: relative; width: 100%; }
#board { width: 100%; height: auto; display: block; border-radius: 12px; box-shadow: 0 18px 40px #0009; user-select: none; touch-action: none; }
.board-overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.board-overlay > * { pointer-events: auto; }
.overlay-card { background: #1b120bee; border: 1px solid var(--gold-d); border-radius: 16px; padding: 18px 22px; text-align: center; max-width: 86%; box-shadow: 0 10px 40px #000a; }
.overlay-card h3 { margin: 0 0 6px; font-size: 1.4rem; color: var(--gold); }
.overlay-card p { margin: 4px 0 12px; }
.overlay-card .actions { justify-content: center; }

.player-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; position: relative; overflow: hidden; min-height: 52px; }
.player-bar.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.player-bar .chip { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 4px #0005, 0 1px 2px #000a; }
.chip.c0 { background: radial-gradient(circle at 35% 30%, #fff, #e8dcc3); }
.chip.c1 { background: radial-gradient(circle at 35% 30%, #6a4a3a, #1e120c); }
.player-bar .pname { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .pinfo { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.player-bar .grow { flex: 1; min-width: 0; }
.player-bar .pscore { font-size: 1.4rem; font-weight: 800; color: var(--gold); }
.player-bar .dc { color: var(--red); font-size: .75rem; }
.timer { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--green); transition: width .25s linear; }
.timer.warn { background: var(--red); }

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.score-box { text-align: center; }
.score-box .big { font-size: 2rem; font-weight: 800; }
.score-box .small { color: var(--muted); font-size: .85rem; }

/* SVG tahta */
.pt-click, .zone { cursor: pointer; }
.target { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.die.rolling { animation: roll .55s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes roll {
  0% { transform: rotate(-200deg) scale(.4); opacity: 0; }
  70% { transform: rotate(15deg) scale(1.08); opacity: 1; }
  100% { transform: rotate(0) scale(1); }
}

/* Diyalog & bildirim */
dialog { background: var(--card-solid); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: #000a; }
dialog code { word-break: break-all; font-size: .78rem; background: #0005; padding: 2px 4px; border-radius: 4px; }
dialog .row { margin: 8px 0; }
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); }
.toast { background: #2b1b10f2; border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px #0008; animation: toastIn .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 900px) {
  .table-layout { grid-template-columns: 1fr; padding: 8px; }
  .lobby-grid { grid-template-columns: 1fr; }
  .controls .btn { flex: 1 1 auto; padding: 10px 8px; font-size: .9rem; }
  .chat-log { max-height: 180px; }
}

/* Salon: oyun menüsü ve masa ayarları */
.play-menu { display: grid; gap: 10px; }
.play-tile {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  font: inherit; color: var(--text); cursor: pointer;
  background: #00000030; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  transition: transform .08s, background .15s, border-color .15s;
}
.play-tile:hover { background: #ffffff12; border-color: #f0b54a66; }
.play-tile:active { transform: scale(.98); }
.play-tile .ico { font-size: 1.8rem; width: 44px; height: 44px; display: grid; place-items: center; background: #ffffff10; border-radius: 12px; flex: none; }
.play-tile b { display: block; font-size: 1.05rem; }
.play-tile small { color: var(--muted); }
.play-tile.main { background: linear-gradient(180deg, #f0b54a33, #c98a1e22); border-color: #f0b54a88; }
.setup h3 { margin: 0 0 14px; font-size: 1.25rem; }
.setup .field { margin-bottom: 16px; }
.setup .seg { display: flex; width: 100%; }
.setup .seg button { flex: 1; padding: 12px 8px; font-size: 1rem; }
.setup .hint { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.setup .actions { margin-top: 6px; }

/* Giriş */
.login-step { display: grid; gap: 10px; margin-top: 18px; text-align: left; }
.login-step .btn { width: 100%; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #222; }
.google-btn:hover { background: #f1f1f1; }
.gift { margin-top: 14px; background: #f0b54a22; border: 1px solid #f0b54a66; color: #ffe2a6; border-radius: 12px; padding: 10px; }
.hint { font-size: .82rem; color: var(--muted); }
.row-form { display: flex; gap: 8px; }
.row-form .btn { width: auto; }
.code-input { text-align: center; font-size: 1.6rem; letter-spacing: .5em; }
.beans { display: inline-flex; align-items: center; gap: 4px; background: #f0b54a22; border: 1px solid #f0b54a55; color: #ffe2a6; padding: 3px 10px; border-radius: 99px; font-weight: 800; }
.topbar { gap: 10px; }
.topbar .me { margin-left: auto; }
.bean { width: 1.15em; height: 1.15em; vertical-align: -0.2em; }
.stake-row { display: flex; gap: 8px; align-items: stretch; }
.stake-row .btn { flex: none; }
.stake-box { flex: 1; display: flex; align-items: center; gap: 8px; background: #00000040; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.stake-box .bean { width: 1.5em; height: 1.5em; }
.stake-input { border: 0; background: none; padding: 10px 0; font-size: 1.3rem; font-weight: 800; color: var(--gold); text-align: center; }
.stake-input::-webkit-inner-spin-button { display: none; }
.big-beans { font-size: 1.05rem; padding: 6px 14px; }
.table-item .beans { flex: none; }

/* Ödüllü reklam */
.ad-btn { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(180deg, #3fbf7f, #258a57); color: #fff; border-color: transparent; padding: 8px 12px; }
.ad-btn:hover { filter: brightness(1.08); background: linear-gradient(180deg, #3fbf7f, #258a57); }
.ad-btn small { opacity: .8; font-weight: 600; }
.ad-btn:disabled { background: #ffffff14; color: var(--muted); opacity: 1; }
.ad-label { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: #f0b54a; color: #2a1606; padding: 2px 8px; border-radius: 6px; margin-bottom: 10px; }
.ad-stage { display: flex; align-items: center; gap: 14px; background: #0006; border: 1px solid var(--line); border-radius: 12px; padding: 22px 16px; min-height: 140px; }
.ad-logo { width: 96px; height: 96px; flex: none; display: grid; place-items: center; animation: adSpin 4s linear infinite; }
.ad-logo img { width: 100%; height: 100%; object-fit: contain; }
.ad-logo-text { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; text-align: center; font-weight: 800; font-size: .95rem; color: #2a1606; background: radial-gradient(circle at 35% 30%, #ffe08a, #f0b54a 60%, #c98a1e); border: 3px solid #fff3c4; box-shadow: 0 4px 14px #0008; }
@keyframes adSpin { to { transform: rotate(360deg); } }
.ad-stage > div:nth-child(2) { flex: 1; }
.ad-count { width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--gold); display: grid; place-items: center; font-size: 1.3rem; font-weight: 800; flex: none; }
.ad-track { height: 6px; background: #ffffff18; border-radius: 99px; margin: 12px 0 14px; overflow: hidden; }
.ad-bar { height: 100%; width: 0; background: var(--gold); transition: width 1s linear; }
.ad-modal .actions .btn { flex: 1; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .topbar .me { order: 3; width: 100%; margin-left: 0; }
  .ad-btn { margin-left: auto; }
}

.email-tabs { width: 100%; display: flex; }
.email-tabs button { flex: 1; padding: 10px; }
.link-btn { background: none; border: 0; color: var(--gold); font: inherit; font-size: .85rem; cursor: pointer; justify-self: end; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* Oyuncu kartları (üstte yan yana) ve dairesel süre */
.players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 4px 2px; }
.pcard { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 40px; transition: border-color .2s, box-shadow .2s; }
.pcard.right { flex-direction: row-reverse; text-align: right; }
.pcard.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 0 18px #f0b54a44; }
.avatar { position: relative; width: 56px; height: 56px; flex: none; }
.avatar .ring { position: absolute; inset: -4px; width: 64px; height: 64px; }
.ring-track { fill: none; stroke: #ffffff14; stroke-width: 4; }
.ring-bar { fill: none; stroke: var(--green); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .2s linear, stroke .3s; }
.avatar.warn .ring-bar { stroke: var(--red); }
.avatar-face { position: absolute; inset: 4px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #7a4a26, #3a1f0e); border: 2px solid #d8b878; overflow: hidden; }
.avatar.bot .avatar-face { background: radial-gradient(circle at 35% 30%, #4a5a6a, #1e2630); }
.avatar-letter { font-size: 1.35rem; font-weight: 800; color: #ffe2a6; }
.avatar-sec { position: absolute; inset: 0; display: none; place-items: center; font-size: 1.15rem; font-weight: 800; color: #fff; background: #0008; text-shadow: 0 1px 3px #000; }
.avatar.ticking .avatar-sec { display: grid; }
.avatar.warn .avatar-sec { color: #ffb4a8; animation: pulse 1s ease-in-out infinite; }
.avatar .chip { position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border: 2px solid #2a1407; }
.pmeta { min-width: 0; }
.pcard .pname { font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pinfo { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .78rem; color: var(--muted); }
.pcard.right .pinfo { justify-content: flex-end; }
.pbeans { display: inline-flex; align-items: center; gap: 3px; color: #ffe2a6; font-weight: 800; }
.pscoreboard { text-align: center; padding: 0 4px; }
.pscore-big { font-size: 1.5rem; font-weight: 800; color: var(--gold); line-height: 1; }
.pscore-sub { font-size: .72rem; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

/* Telefon (dikey): masa ekranı tam yükseklik, tahta ortada ve olabildiğince büyük */
@media (max-width: 700px) and (orientation: portrait) {
  .table-layout { display: block; padding: 0; }
  .play-area { height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .players { flex: none; gap: 4px; }
  .pcard { flex-direction: column; gap: 4px; padding: 6px 4px 8px; border-radius: 16px; text-align: center; }
  .pcard.right { flex-direction: column; text-align: center; }
  .pcard .pinfo, .pcard.right .pinfo { justify-content: center; }
  .pcard .pname { font-size: .82rem; max-width: 100%; }
  .board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
  #board { width: auto; height: 100%; max-width: 100%; border-radius: 10px; }
  .controls { flex: none; flex-wrap: nowrap; gap: 6px; }
  .controls .btn { padding: 9px 4px; font-size: .78rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .side { padding: 8px; }
  .score-box { display: none; }
}
