:root {
  --bg: #101827;
  --bg2: #16213A;
  --surface: #1D2A45;
  --surface2: #26364F;
  --line: #34476A;
  --text: #F1F0EA;
  --muted: #A9B4C8;
  --faint: #73809A;
  --gold: #E9B96E;
  --gold-ink: #2A1E08;
  --ay: #6F94D4;
  --ay-deep: #2F4C82;
  --yildiz: #E0675F;
  --yildiz-deep: #8A2F2A;
  --neutral: #C9BFA8;
  --neutral-ink: #3A3426;
  --good: #69C29A;
  --danger: #E0675F;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --chat-w: 320px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(111, 148, 212, .16), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(233, 185, 110, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(16, 24, 39, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(52, 71, 106, .6);
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; font-weight: 900; font-size: 18px; letter-spacing: .2px; }
.brand img { border-radius: 8px; }
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; max-width: 46vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.me-chip .av { font-size: 18px; }

#screen { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
body.with-chat #screen { padding-right: calc(var(--chat-w) + 24px); max-width: calc(1100px + var(--chat-w)); }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: clamp(28px, 6vw, 44px); font-weight: 900; }
h2 { font-size: 22px; font-weight: 900; }
h3 { font-size: 17px; font-weight: 800; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.spacer { flex: 1; }

.card {
  background: linear-gradient(180deg, rgba(38, 54, 79, .92), rgba(29, 42, 69, .92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); font-weight: 800;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.gold { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.btn.gold:hover:not(:disabled) { background: #F2C886; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: #F5A39D; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 56px; font-size: 18px; padding: 12px 24px; }
.btn.block { width: 100%; }
.btn.ay { background: var(--ay-deep); border-color: var(--ay); }
.btn.yildiz { background: var(--yildiz-deep); border-color: var(--yildiz); }
.btn.selected { outline: 3px solid var(--gold); outline-offset: 1px; }
.icon-btn { background: none; border: 0; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.input, input.input, select.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(16, 24, 39, .7); font-weight: 700; font-size: 17px;
}
.input:focus { border-color: var(--gold); outline: none; }
.code-input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 22px; font-weight: 900; }
label.lbl { display: block; font-weight: 800; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* Giriş */
.hero { text-align: center; padding: 26px 0 18px; }
.hero .moon { font-size: 54px; filter: drop-shadow(0 6px 20px rgba(233, 185, 110, .35)); }
.narrow { max-width: 520px; margin: 0 auto; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-opt { aspect-ratio: 1; font-size: 26px; border-radius: 12px; border: 1px solid var(--line); background: rgba(16, 24, 39, .5); display: grid; place-items: center; padding: 0; }
.avatar-opt.on { border-color: var(--gold); background: rgba(233, 185, 110, .18); box-shadow: 0 0 0 2px var(--gold) inset; }
@media (max-width: 420px) { .avatar-grid { grid-template-columns: repeat(6, 1fr); } }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-weight: 800; font-size: 13px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.game-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.game-tile { position: relative; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(16, 24, 39, .45); display: grid; gap: 4px; }
.game-tile .gt-icon { font-size: 28px; }
.game-tile .gt-name { font-weight: 900; font-size: 17px; }
.game-tile.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; background: rgba(233, 185, 110, .08); }
.game-tile.soon { opacity: .55; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 800; background: var(--surface2); color: var(--muted); border: 1px solid var(--line); }
.tag.gold { background: rgba(233, 185, 110, .16); color: var(--gold); border-color: rgba(233, 185, 110, .4); }
.tag.ay { background: rgba(111, 148, 212, .18); color: #A9C2EE; border-color: rgba(111, 148, 212, .5); }
.tag.yildiz { background: rgba(224, 103, 95, .18); color: #F3A9A3; border-color: rgba(224, 103, 95, .5); }
.game-tile .tag { position: absolute; top: 12px; right: 12px; }

/* Lobi */
.room-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.code-chip { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 14px; background: rgba(233, 185, 110, .12); border: 1px dashed rgba(233, 185, 110, .6); }
.code-chip .code { font-size: 26px; font-weight: 900; letter-spacing: 5px; color: var(--gold); }
.lobby-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .lobby-grid { grid-template-columns: 1.1fr .9fr; } }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(16, 24, 39, .45); border: 1px solid transparent; }
.player.me { border-color: rgba(233, 185, 110, .45); }
.player .av { font-size: 24px; width: 34px; text-align: center; }
.player .nm { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .off { opacity: .45; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.away { background: var(--faint); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-col { border-radius: 14px; padding: 12px; border: 1px solid var(--line); min-height: 120px; }
.team-col.ay { background: linear-gradient(180deg, rgba(111, 148, 212, .22), rgba(111, 148, 212, .06)); border-color: rgba(111, 148, 212, .55); }
.team-col.yildiz { background: linear-gradient(180deg, rgba(224, 103, 95, .22), rgba(224, 103, 95, .06)); border-color: rgba(224, 103, 95, .55); }
.team-col h3 { display: flex; align-items: center; gap: 6px; }
.team-col ul { list-style: none; padding: 0; margin: 8px 0 10px; display: grid; gap: 6px; }
.team-col li { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; min-width: 0; }
.team-col li span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { flex: 1; min-width: 80px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(16, 24, 39, .45); font-weight: 900; font-size: 20px; display: grid; gap: 4px; justify-items: center; }
.choice.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.choice .who { font-size: 16px; min-height: 20px; }
.notice { padding: 10px 12px; border-radius: 12px; background: rgba(111, 148, 212, .12); border: 1px solid rgba(111, 148, 212, .35); font-weight: 700; font-size: 14px; }
.notice.warn { background: rgba(233, 185, 110, .12); border-color: rgba(233, 185, 110, .4); }
details.rules { border-radius: 14px; border: 1px solid var(--line); padding: 12px 14px; background: rgba(16, 24, 39, .35); }
details.rules summary { cursor: pointer; font-weight: 900; }
details.rules ul { margin: 10px 0 0; padding-left: 20px; }
details.rules li { margin: 4px 0; }

/* Oyun */
.hud { display: grid; gap: 10px; margin-bottom: 12px; }
.hud-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.turn-pill { padding: 6px 12px; border-radius: 99px; font-weight: 900; font-size: 14px; background: var(--surface2); border: 1px solid var(--line); }
.turn-pill.ay { background: rgba(111, 148, 212, .25); border-color: var(--ay); }
.turn-pill.yildiz { background: rgba(224, 103, 95, .25); border-color: var(--yildiz); }
.scorebar { display: flex; gap: 8px; flex-wrap: wrap; }
.score { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(16, 24, 39, .5); border: 1px solid var(--line); font-weight: 800; }
.score b { font-size: 20px; }
.score.ay { border-color: rgba(111, 148, 212, .6); }
.score.yildiz { border-color: rgba(224, 103, 95, .6); }
.score.active { box-shadow: 0 0 0 2px var(--gold) inset; }
.timer { position: relative; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.timer i { position: absolute; inset: 0 auto 0 0; background: var(--gold); border-radius: 99px; transition: width .25s linear; }
.timer.low i { background: var(--danger); }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 800; }
.clue-box { display: inline-flex; align-items: baseline; gap: 10px; padding: 8px 14px; border-radius: 12px; background: rgba(233, 185, 110, .14); border: 1px solid rgba(233, 185, 110, .45); }
.clue-box .cw { font-size: 22px; font-weight: 900; letter-spacing: 1px; color: var(--gold); }
.clue-box .cn { font-size: 20px; font-weight: 900; }
.secs { font-variant-numeric: tabular-nums; font-weight: 900; min-width: 34px; text-align: right; }

.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(5px, 1.2vw, 10px); }
.w {
  position: relative; min-height: clamp(58px, 11vw, 84px);
  border-radius: clamp(8px, 1.4vw, 14px);
  border: 1px solid #4A5D82;
  background: linear-gradient(180deg, #F3EEDF, #E2D9C3);
  color: #2B2618; font-weight: 900;
  font-size: clamp(11px, 2.4vw, 17px);
  text-transform: uppercase; letter-spacing: .3px;
  display: grid; place-items: center; text-align: center;
  padding: 6px 4px; overflow: hidden; word-break: break-word; hyphens: auto;
  transition: transform .1s ease, box-shadow .15s ease, filter .2s ease;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.w.clickable:hover { transform: translateY(-2px); }
.w.sel { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 rgba(0, 0, 0, .25); }
.w .votes { position: absolute; top: 3px; right: 4px; display: flex; gap: 1px; font-size: 11px; }
.w .vcount { position: absolute; top: 3px; left: 5px; font-size: 12px; background: var(--gold); color: var(--gold-ink); border-radius: 99px; padding: 0 6px; }
.w .pickbtn { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); font-size: 11px; padding: 2px 10px; border-radius: 99px; border: 0; background: #1B2740; color: var(--gold); font-weight: 900; text-transform: none; }
.w.v1 { filter: grayscale(.25) brightness(.93); }
.w.v2 { filter: grayscale(.5) brightness(.86); }
.w.v3 { filter: grayscale(.75) brightness(.8); }
.w.pending { animation: pulse .5s ease-in-out infinite alternate; box-shadow: 0 0 0 3px var(--gold); }
@keyframes pulse { to { transform: scale(1.04); } }
.w .count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; background: rgba(16, 24, 39, .55); color: var(--gold); }
/* kaptan görünümü */
.w.k-t, .w.k-ay, .w.k-yildiz, .w.k-n, .w.k-x { border-width: 3px; }
.w.k-t { border-color: var(--gold); background: linear-gradient(180deg, #F7E3BC, #EBCB8F); }
.w.k-ay { border-color: var(--ay); background: linear-gradient(180deg, #DCE6F7, #B8CBEB); }
.w.k-yildiz { border-color: var(--yildiz); background: linear-gradient(180deg, #F7DCD9, #EDB5B0); }
.w.k-n { border-color: #9C927C; }
.w.k-x { border-color: #111; background: linear-gradient(180deg, #5B5F68, #3B3F47); color: #F1F0EA; }
.w .klabel { position: absolute; bottom: 2px; right: 5px; font-size: 11px; opacity: .85; text-transform: none; }
/* açılmış kartlar */
.w.r { color: #fff; box-shadow: none; border-color: transparent; }
.w.r-t { background: linear-gradient(180deg, #E9B96E, #C9934A); color: var(--gold-ink); }
.w.r-ay { background: linear-gradient(180deg, #6F94D4, #44659F); }
.w.r-yildiz { background: linear-gradient(180deg, #E0675F, #A8433D); }
.w.r-n { background: linear-gradient(180deg, #6E6A5E, #55524A); color: #E8E2D2; }
.w.r-x { background: linear-gradient(180deg, #23252B, #0C0D10); color: #F3A9A3; }
.w.r .rw { opacity: .9; }
.w.r .by { position: absolute; bottom: 2px; right: 4px; font-size: 13px; }
.w.ghost { opacity: .55; }

.action-bar { margin-top: 14px; display: grid; gap: 10px; }
.clue-form { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; }
@media (max-width: 520px) { .clue-form { grid-template-columns: 1fr 90px; } .clue-form .btn { grid-column: 1 / -1; } }
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; font-weight: 800; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; max-height: 180px; overflow: auto; }
.log li { padding: 4px 8px; border-radius: 8px; background: rgba(16, 24, 39, .4); }
.game-grid { display: grid; gap: 14px; }
@media (min-width: 980px) { .game-grid { grid-template-columns: 1fr 260px; } }

/* Sonuç */
.result { text-align: center; padding: 22px 16px; }
.result .big-emoji { font-size: 56px; }
.result h1 { margin-top: 6px; }
.table { width: 100%; border-collapse: collapse; font-weight: 700; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 13px; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 900; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Sohbet */
.chat {
  position: fixed; z-index: 30; right: 0; top: 0; bottom: 0; width: var(--chat-w);
  display: flex; flex-direction: column;
  background: rgba(22, 33, 58, .97); border-left: 1px solid var(--line);
  padding-top: calc(60px + env(safe-area-inset-top));
}
.chat.hidden { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.chat-list { list-style: none; margin: 0; padding: 10px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-list li { font-size: 15px; line-height: 1.35; word-wrap: break-word; }
.chat-list li .who { font-weight: 900; margin-right: 4px; }
.chat-list li.sys { color: var(--gold); font-weight: 700; font-size: 13px; text-align: center; background: rgba(233, 185, 110, .08); border-radius: 8px; padding: 4px 8px; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(16, 24, 39, .7); font-size: 16px; }
.chat-close { display: none; }
.chat-fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 25; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface2); font-size: 24px; box-shadow: var(--shadow); }
.chat-fab.hidden { display: none; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center; }
.badge.hidden { display: none; }
@media (max-width: 979px) {
  body.with-chat #screen { padding-right: 16px; max-width: 1100px; }
  .chat { width: 100%; max-width: 420px; box-shadow: var(--shadow); }
  .chat-close { display: inline-block; }
}

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); z-index: 60; background: #0B111D; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 800; opacity: 0; pointer-events: none; transition: all .2s ease; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); color: #F5B1AB; }

.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
