/* ============ TURKUAZ TASARIM SISTEMI ============ */
:root {
  --turkuaz: #06b6d4;
  --turkuaz-bright: #22d3ee;
  --turkuaz-deep: #0891b2;
  --navy: #0a1f3a;
  --navy-2: #0e2a4d;
  --ink: #e8f4f8;
  --ink-dim: #9db8c8;
  --card-bg: rgba(14, 42, 77, 0.55);
  --card-border: rgba(34, 211, 238, 0.18);
  --glass-blur: 14px;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --gold: #fbbf24;
  --shadow: 0 10px 40px rgba(2, 12, 27, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --navy: #eef7fa;
  --navy-2: #dcedf4;
  --ink: #0b2536;
  --ink-dim: #4a6b7d;
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(6, 182, 212, 0.25);
  --shadow: 0 10px 32px rgba(9, 60, 84, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* KRITIK: hidden attribute'u her zaman kazanmali — display atayan class'lar
   (.overlay, .row, .jokers vb.) UA stylesheet'ini ezip flicker'a yol aciyordu */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--navy);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: 1rem; color: inherit; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; }

/* ============ ARKA PLAN KATMANI ============ */
.bg-layer {
  position: fixed; inset: 0; z-index: -1;
  transition: opacity .8s ease;
}

/* ============ UST BAR ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { font-weight: 900; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.brand-name {
  background: linear-gradient(90deg, var(--turkuaz-bright), var(--turkuaz));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  cursor: pointer; font-size: 1.15rem;
  transition: transform .15s ease, border-color .15s ease;
}
.icon-btn:hover { transform: translateY(-2px); border-color: var(--turkuaz); }
.icon-btn.small { width: 34px; height: 34px; font-size: .9rem; }

/* ============ POPOVER ============ */
.popover {
  position: fixed; top: 64px; right: 16px; z-index: 60;
  padding: 14px; border-radius: var(--radius);
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow);
}
.popover-title { font-weight: 700; margin-bottom: 10px; font-size: .9rem; color: var(--ink-dim); }
.bg-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bg-options button {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--card-border);
  background: transparent; cursor: pointer; text-align: left;
  transition: background .15s, border-color .15s;
}
.bg-options button:hover { background: rgba(6, 182, 212, .15); border-color: var(--turkuaz); }
.bg-options button.selected { background: rgba(6, 182, 212, .25); border-color: var(--turkuaz); }

/* ============ EKRANLAR ============ */
.screen { min-height: calc(100vh - 70px); padding: 16px; }
#app { max-width: 1200px; margin: 0 auto; }

/* ============ KARTLAR / CAM EFEKTI ============ */
.card {
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.glass {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* ============ BUTONLAR ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  background: rgba(6, 182, 212, 0.1); color: var(--ink);
  font-weight: 600; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--turkuaz), var(--turkuaz-deep));
  border: none; color: #fff;
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}
.btn.primary:hover { box-shadow: 0 8px 26px rgba(6, 182, 212, 0.5); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; font-size: 1.05rem; min-height: 52px; }
.btn.small-btn { min-height: 38px; padding: 6px 14px; font-size: .88rem; }
.btn.danger { background: rgba(248, 113, 113, .15); border-color: rgba(248, 113, 113, .4); }

/* ============ FORM ============ */
label { display: block; font-size: .9rem; font-weight: 600; margin: 12px 0 6px; color: var(--ink-dim); }
input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%; min-height: 44px; padding: 10px 14px; margin-top: 4px;
  border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  background: rgba(10, 31, 58, 0.4); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] input[type="text"], [data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"], [data-theme="light"] select {
  background: rgba(255, 255, 255, 0.75);
}
input:focus, select:focus { border-color: var(--turkuaz); box-shadow: 0 0 0 3px rgba(6, 182, 212, .2); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--turkuaz); }
.row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.row.center { justify-content: center; }
.row > input, .row > select { flex: 1; margin-top: 0; }
.muted { color: var(--ink-dim); font-size: .9rem; }
.error-msg { color: var(--danger); font-weight: 600; margin-top: 10px; }
.pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(6, 182, 212, .18); border: 1px solid var(--card-border);
  font-size: .82rem; font-weight: 700;
}
.pill-green { background: rgba(52, 211, 153, .16); border-color: rgba(52, 211, 153, .4); color: var(--success); }
.pill-gray { background: rgba(157, 184, 200, .14); border-color: rgba(157, 184, 200, .3); color: var(--ink-dim); }
.pill-gold { background: rgba(251, 191, 36, .16); border-color: rgba(251, 191, 36, .45); color: var(--gold); }

/* ============ GIRIS EKRANI ============ */
.auth-wrap { max-width: 460px; margin: 0 auto; padding-top: 4vh; }
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { font-size: 2.6rem; }
.tagline { color: var(--ink-dim); margin-top: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs.small { margin-top: 4px; }
.tab {
  flex: 1; min-height: 42px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-dim);
  font-weight: 700; cursor: pointer; transition: all .15s;
}
.tab.active { background: rgba(6, 182, 212, .16); color: var(--ink); border-color: var(--card-border); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 6px 0; }
.emoji-grid button {
  aspect-ratio: 1; min-width: 0; font-size: 1.3rem; border-radius: 10px;
  border: 1px solid transparent; background: rgba(6, 182, 212, .07); cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.emoji-grid button:hover { transform: scale(1.12); }
.emoji-grid button.selected { border-color: var(--turkuaz); background: rgba(6, 182, 212, .28); }

/* ============ LOBI ============ */
.lobby-wrap { padding-top: 8px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.rooms-card h3 { margin-bottom: 10px; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, .08); border: 1px solid var(--card-border);
}
.room-item .names { color: var(--ink-dim); font-size: .85rem; }

/* ============ OYUN MASASI ============ */
.game-wrap { display: flex; flex-direction: column; gap: 12px; }
.game-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-code {
  font-weight: 900; font-size: 1.2rem; letter-spacing: .2em;
  padding: 6px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(6, 182, 212, .15); border: 1px dashed var(--turkuaz);
}
.game-status { flex: 1; text-align: center; color: var(--ink-dim); font-weight: 600; min-width: 160px; }
.table-area {
  position: relative; height: min(62vh, 620px); min-height: 380px;
  border-radius: var(--radius); overflow: hidden;
}
.scene-container, .scene-container canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lite-wheel-container {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.lite-wheel-container canvas {
  width: min(64vw, 46vh, 380px); height: min(64vw, 46vh, 380px);
  filter: drop-shadow(0 12px 30px rgba(2, 12, 27, .5));
}
.lite-pointer {
  position: absolute; top: calc(50% - min(32vw, 23vh, 190px) - 30px); left: 50%;
  transform: translateX(-50%); font-size: 1.8rem; color: var(--gold); z-index: 5;
  text-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.wheel-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 999px; font-weight: 800; font-size: 1.05rem;
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(var(--glass-blur)); z-index: 6; white-space: nowrap;
  animation: bannerIn .3s ease;
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Oyuncu kartlari — masa etrafinda */
.players-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.player-card {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 8px 12px; border-radius: 14px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  transition: box-shadow .3s, border-color .3s, opacity .3s;
}
.player-card .pc-avatar { font-size: 1.7rem; line-height: 1; }
.player-card .pc-name { font-weight: 700; font-size: .82rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card .pc-score { font-weight: 800; font-size: .9rem; color: var(--turkuaz-bright); }
.player-card .pc-tag { font-size: .66rem; color: var(--ink-dim); }
.player-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .35), 0 0 30px 6px rgba(251, 191, 36, .45);
  animation: glowPulse 1.1s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(251,191,36,.35), 0 0 26px 4px rgba(251,191,36,.4); }
  50% { box-shadow: 0 0 0 5px rgba(251,191,36,.5), 0 0 44px 12px rgba(251,191,36,.6); }
}
.player-card.eliminated { opacity: .38; filter: grayscale(.9); }
.player-card.disconnected { border-style: dashed; opacity: .7; }
.player-card .pc-float {
  position: absolute; top: -14px; font-weight: 900; font-size: 1.05rem;
  color: var(--success); animation: floatUp 1.6s ease forwards; pointer-events: none;
}
.player-card .pc-float.neg { color: var(--danger); }
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-42px); } }

/* Oda kontrolleri */
.room-controls { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.bot-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; }

/* ============ OVERLAY / MODAL ============ */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 14, 28, .55); backdrop-filter: blur(4px);
  padding: 14px;
}
.modal { max-width: 480px; width: 100%; text-align: center; animation: modalIn .25s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.diff-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.diff-btn { flex-direction: column; padding: 16px 8px; font-size: 1rem; }
.diff-btn small { color: var(--ink-dim); font-weight: 500; font-size: .72rem; margin-top: 4px; }

/* ============ SORU KARTI ============ */
.question-card { max-width: 620px; width: 100%; animation: modalIn .25s ease; }
.q-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.q-asker { margin-bottom: 4px; }
.countdown { margin-left: auto; position: relative; width: 52px; height: 52px; }
.countdown svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.cd-bg { fill: none; stroke: rgba(157, 184, 200, .25); stroke-width: 4; }
.cd-ring {
  fill: none; stroke: var(--turkuaz-bright); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 125.6; stroke-dashoffset: 0;
}
.cd-ring.warn { stroke: var(--danger); }
#cd-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
}
.q-text { font-size: 1.3rem; margin: 10px 0 16px; line-height: 1.45; }
.q-mask {
  font-family: monospace; font-size: 1.6rem; letter-spacing: .35em;
  margin-bottom: 12px; color: var(--turkuaz-bright); font-weight: 700;
}
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.q-options .opt {
  min-height: 54px; padding: 12px; font-size: 1rem; text-align: center;
  border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  background: rgba(6, 182, 212, .09); cursor: pointer; font-weight: 600;
  transition: all .15s;
}
.q-options .opt:hover:not(:disabled) { border-color: var(--turkuaz); background: rgba(6, 182, 212, .2); }
.q-options .opt.removed { opacity: .25; text-decoration: line-through; pointer-events: none; }
.q-options .opt.correct { background: rgba(52, 211, 153, .3); border-color: var(--success); }
.q-options .opt.wrong { background: rgba(248, 113, 113, .3); border-color: var(--danger); }
.jokers { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.joker-btn { position: relative; font-size: .85rem; min-height: 40px; padding: 6px 12px; }
.joker-btn .badge {
  position: absolute; top: -7px; right: -7px;
  min-width: 20px; height: 20px; border-radius: 999px;
  background: var(--gold); color: #1a1200; font-size: .72rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.hint-msg { margin-top: 10px; font-weight: 600; color: var(--warning); }
.q-feedback {
  margin-top: 14px; padding: 12px; border-radius: var(--radius-sm);
  font-weight: 800; font-size: 1.1rem; text-align: center; animation: modalIn .2s ease;
}
.q-feedback.ok { background: rgba(52, 211, 153, .2); color: var(--success); }
.q-feedback.no { background: rgba(248, 113, 113, .2); color: var(--danger); }
.q-explain {
  margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, .1); border-left: 3px solid var(--turkuaz);
  font-size: .92rem; color: var(--ink-dim); text-align: left;
}

/* ============ SONUC EKRANI ============ */
.result-wrap { max-width: 540px; margin: 0 auto; padding-top: 6vh; display: flex; flex-direction: column; gap: 14px; }
.result-card { text-align: center; }
.consolation { font-size: 1.15rem; margin: 14px 0 20px; color: var(--ink-dim); }
.placements { list-style: none; margin: 18px 0; display: flex; flex-direction: column; gap: 8px; }
.placements li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, .08); border: 1px solid var(--card-border);
  font-weight: 600; text-align: left;
}
.placements li.first {
  background: linear-gradient(90deg, rgba(251, 191, 36, .22), rgba(6, 182, 212, .1));
  border-color: var(--gold);
}
.placements .pl-rank { font-size: 1.3rem; width: 40px; text-align: center; }
.placements .pl-score { margin-left: auto; font-weight: 800; color: var(--turkuaz-bright); }

/* ============ PROFIL ============ */
.profile-wrap { max-width: 560px; margin: 0 auto; padding-top: 3vh; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-avatar { font-size: 3rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat {
  text-align: center; padding: 14px; border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, .1); border: 1px solid var(--card-border);
}
.stat b { display: block; font-size: 1.5rem; color: var(--turkuaz-bright); }
.stat span { font-size: .8rem; color: var(--ink-dim); }
.history { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 18px; }
.history .h-item {
  display: flex; justify-content: space-between; padding: 9px 14px;
  border-radius: 10px; background: rgba(6, 182, 212, .06);
  border: 1px solid var(--card-border); font-size: .9rem;
}

/* ============ ANTRENMAN BAR ============ */
.practice-bar {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 12px 18px;
}

/* ============ BAGLANTI GOSTERGESI ============ */
.room-info { display: flex; align-items: center; gap: 8px; }
.conn-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  flex-shrink: 0; transition: background .3s;
}
.conn-dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(52, 211, 153, .7); }
.conn-dot.warn { background: var(--warning); box-shadow: 0 0 8px rgba(251, 191, 36, .7); }
.conn-dot.bad { background: var(--danger); box-shadow: 0 0 8px rgba(248, 113, 113, .7); }
.reconnect-band {
  position: fixed; top: 0; left: 0; right: 0; z-index: 120;
  background: var(--warning); color: #241a00; text-align: center;
  font-weight: 700; font-size: .88rem; padding: 5px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 12px 22px; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  backdrop-filter: blur(var(--glass-blur)); box-shadow: var(--shadow);
  font-weight: 600; animation: bannerIn .25s ease; max-width: 92vw; text-align: center;
}

/* ============ MOBIL / LITE ============ */
@media (max-width: 767px) {
  .screen { padding: 10px; }
  .hero h1 { font-size: 2rem; }
  .q-options { grid-template-columns: 1fr; }
  .diff-btns { grid-template-columns: 1fr; }
  .table-area { height: 58vh; min-height: 430px; }
  .player-card { min-width: 74px; padding: 6px 8px; }
  .player-card .pc-avatar { font-size: 1.35rem; }
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .game-status { order: 3; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
