:root {
  --bg: #1f3a8a;
  --bg2: #2547a8;
  --card: #ffffff;
  --ink: #1b1f2a;
  --muted: #6b7385;
  --line: #e3e7ef;
  --green: #38b24a;
  --blue: #2f7df6;
  --purple: #8a4dff;
  --orange: #ff8a1f;
  --red: #e5484d;
  --yellow: #ffd23f;
  --radius: 14px;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg) radial-gradient(circle at 20% 0%, var(--bg2), var(--bg) 60%) fixed;
  min-height: 100vh;
}
button, input, select { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- üst çubuk ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; max-width: 1400px; margin: 0 auto; }
.logo { text-decoration: none; font-weight: 900; font-size: 30px; letter-spacing: -1px; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.logo-y { color: var(--yellow); }
.logo-d { color: #fff; margin-left: 4px; }
.online { color: #cfe0ff; font-size: 14px; }

/* ---------- yerleşim + reklam ----------
   Reklam ağı tanımlı değilse (varsayılan) reklam alanları hiç görünmez ve sayfa tek sütundur.
   /api/config bir AdSense kimliği döndürürse app.js .with-ads sınıfını ekler. */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; }
.layout.with-ads { grid-template-columns: 180px minmax(0, 1fr) 180px; max-width: 1400px; }
.ad-rail { position: sticky; top: 16px; align-self: start; }
.ad-slot { display: flex; align-items: center; justify-content: center; }
.ad-skyscraper { width: 160px; min-height: 600px; }
.ad-banner-mobile { display: none; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 320px; height: 50px; z-index: 5; }
.ad-rect { width: 300px; min-height: 250px; margin: 16px auto; }

@media (max-width: 1100px) {
  .layout.with-ads { grid-template-columns: minmax(0, 1fr); padding-bottom: 70px; }
  .layout.with-ads .ad-rail { display: none; }
  body.ads .ad-banner-mobile:not(.hidden) { display: flex; }
}

.top-right { display: flex; align-items: center; gap: 10px; }
.footer { text-align: center; color: #cfe0ff; font-size: 13px; padding: 8px 16px 32px; }
.footer a { color: #fff; }
.footer p { margin: 6px 0 0; opacity: .8; }

/* ---------- kartlar ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 0 rgba(0,0,0,.18); }
.card + .card, .grid2 + .card, .card + .grid2 { margin-top: 16px; }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

.hero { text-align: center; }
.hero h1 { margin: 4px 0; font-size: 32px; }
.hero p { margin: 0 0 16px; }

/* ---------- profil ---------- */
.profile { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.profile input { padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px; font-size: 18px; width: 220px; text-align: center; font-weight: 700; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.avatar.big { width: 72px; height: 72px; font-size: 42px; }
.avatar-nav { background: none; border: 0; font-size: 22px; color: var(--muted); cursor: pointer; padding: 6px; }

/* ---------- butonlar ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 800; cursor: pointer;
  background: #eef1f6; color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.15); transition: transform .05s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-xl { font-size: 22px; padding: 14px 26px; }
.btn-small { padding: 6px 12px; font-size: 14px; }
.btn-green { background: var(--green); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; font-weight: 700; }
.actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.actions .btn-xl { min-width: 220px; }
.actions.small { align-items: center; }
.bot-pick, .join { display: flex; gap: 6px; }
.bot-pick select { border: 2px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.join input { width: 90px; text-align: center; text-transform: uppercase; letter-spacing: 3px; font-weight: 800; border: 2px solid var(--line); border-radius: 10px; padding: 8px; }
.mystats { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- listeler ---------- */
.room-list, .leaderboard { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.room-list li, .leaderboard li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.room-list li:last-child, .leaderboard li:last-child { border-bottom: 0; }
.room-list .grow, .leaderboard .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { width: 28px; font-weight: 900; color: var(--muted); text-align: right; }
.leaderboard li:nth-child(1) .rank { color: #d4a000; }
.leaderboard li:nth-child(2) .rank { color: #8a96a8; }
.leaderboard li:nth-child(3) .rank { color: #c0702c; }
.val { font-weight: 900; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: #eef1f6; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-weight: 700; font-size: 13px; }
.tab.active { background: var(--blue); color: #fff; }
.how ul { margin: 0; padding-left: 18px; line-height: 1.6; }

/* ---------- oda ---------- */
.room-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.room-title { color: #fff; font-weight: 800; text-align: center; }
.room-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr) 260px; gap: 12px; align-items: start; }
.room-grid .card + .card { margin-top: 0; }
@media (max-width: 900px) {
  .room-grid { grid-template-columns: 1fr; }
  .players { order: 2; } .stage { order: 1; } .chat { order: 3; }
}
.players ol { list-style: none; margin: 0; padding: 0; }
.players li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; position: relative; }
.players li:nth-child(odd) { background: #f5f7fb; }
.players li.me .pname { color: var(--blue); }
.players .pname { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .pscore { font-size: 13px; color: var(--muted); }
.players .pinfo { flex: 1; min-width: 0; }
.players .pplace { font-weight: 900; width: 26px; color: var(--muted); }
.players .badge { font-size: 16px; }
.players .done { color: var(--green); font-weight: 900; }
.players .kick { border: 0; background: none; cursor: pointer; color: var(--muted); }
.players .gain { position: absolute; right: 8px; top: 2px; font-size: 12px; font-weight: 900; color: var(--green); animation: rise 1.6s ease-out forwards; }
@keyframes rise { from { opacity: 1; transform: translateY(6px); } to { opacity: 0; transform: translateY(-10px); } }

.stage { min-height: 420px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.settings select { border: 2px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; color: var(--ink); font-weight: 700; }
.settings .types { display: flex; gap: 10px; flex-wrap: wrap; color: var(--ink); font-weight: 600; }
.settings .types label { flex-direction: row; align-items: center; color: var(--ink); }
.lobby-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.countdown { font-size: 120px; font-weight: 900; text-align: center; color: var(--blue); padding: 80px 0; }

.q-meta { display: flex; justify-content: space-between; color: var(--muted); font-weight: 800; font-size: 14px; }
.timer { height: 12px; background: #eef1f6; border-radius: 6px; overflow: hidden; margin: 8px 0 16px; }
.timer-fill { height: 100%; width: 100%; background: var(--green); transform-origin: left; }
.timer-fill.warn { background: var(--orange); }
.timer-fill.danger { background: var(--red); }
.q-prompt { font-size: 18px; font-weight: 800; margin: 0 0 8px; }
.q-sentence { font-size: 22px; line-height: 1.5; margin: 0 0 18px; background: #f5f7fb; padding: 14px; border-radius: 10px; }
.q-sentence:empty { display: none; }
.q-sentence .blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--blue); color: var(--blue); font-weight: 900; text-align: center; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .options { grid-template-columns: 1fr; } }
.opt {
  text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px; font-size: 18px; font-weight: 700; cursor: pointer;
  display: flex; gap: 10px; align-items: center; box-shadow: 0 4px 0 var(--line);
}
.opt .key { display: inline-flex; width: 28px; height: 28px; border-radius: 8px; background: #eef1f6; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); flex: none; }
.opt:hover:not(:disabled) { border-color: var(--blue); }
.opt.picked { border-color: var(--blue); background: #eaf2ff; }
.opt.correct { border-color: var(--green); background: #e6f7e9; }
.opt.wrong { border-color: var(--red); background: #fdeced; }
.opt:disabled { cursor: default; color: var(--ink); }
.opt .who { margin-left: auto; font-size: 16px; }
.q-feedback { min-height: 26px; font-weight: 800; text-align: center; margin: 14px 0 0; }

.chat { display: flex; flex-direction: column; height: 520px; padding: 0; overflow: hidden; }
@media (max-width: 900px) { .chat { height: 300px; } }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 14px; }
.chat-log p { margin: 0 0 6px; word-wrap: break-word; }
.chat-log .sys { color: var(--green); font-weight: 700; }
.chat-log b { color: var(--blue); }
#chat-form { border-top: 1px solid var(--line); }
#chat-input { width: 100%; border: 0; padding: 12px; outline: none; }

/* ---------- katmanlar ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 50, .6); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 92vh; overflow: auto; }
.center { text-align: center; }
.spinner { width: 54px; height: 54px; border: 6px solid #eef1f6; border-top-color: var(--blue); border-radius: 50%; margin: 6px auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 10px 0; }
.podium .step { text-align: center; width: 110px; }
.podium .block { border-radius: 10px 10px 0 0; color: #fff; font-weight: 900; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.podium .p1 .block { height: 90px; background: #e6b400; }
.podium .p2 .block { height: 64px; background: #9aa6b8; }
.podium .p3 .block { height: 46px; background: #c0702c; }
.podium .nm { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-list { padding-left: 20px; margin: 6px 0; }
.final-list li { margin: 2px 0; }
.rating { text-align: center; font-weight: 900; font-size: 18px; margin: 6px 0; }
.rating.up { color: var(--green); } .rating.down { color: var(--red); }
.go-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: #1b1f2a; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; font-weight: 700; }

/* ---------- moderasyon ve ayarlar ---------- */
.btn-red { background: var(--red); color: #fff; }
.players li.clickable { cursor: pointer; }
.players li.clickable:hover { outline: 2px solid var(--line); }
.chat-log b.who { cursor: pointer; }
.chat-log b.who:hover { text-decoration: underline; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.presets button { border: 1px solid var(--line); background: #f5f7fb; border-radius: 14px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.presets button:hover { border-color: var(--blue); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; margin: 10px 0; }
.field select { border: 2px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0 14px; }
.modal h3 { margin: 16px 0 6px; font-size: 16px; }
.blocked-list { list-style: none; padding: 0; margin: 0; }
.blocked-list li { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }

.online { white-space: nowrap; }
@media (max-width: 520px) {
  .topbar { padding: 12px 16px; }
  .logo { font-size: 24px; }
  .online { display: none; }
}

/* ---------- alışkanlık şeridi, özellik kartları ---------- */
.habits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 16px; }
.habit { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: #f5f7fb; border: 2px solid var(--line); border-radius: 12px; padding: 10px 6px; font: inherit; color: var(--ink); }
.habit-btn { cursor: pointer; }
.habit-btn:hover { border-color: var(--blue); }
.h-big { font-weight: 900; font-size: 18px; white-space: nowrap; }
.h-sub { font-size: 12px; color: var(--muted); }
.h-bar { width: 80%; height: 6px; background: #e3e7ef; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.h-bar > div { height: 100%; width: 0; background: var(--yellow); }
@media (max-width: 520px) { .h-big { font-size: 15px; } }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.grid3 + .grid2 { margin-top: 16px; }
@media (max-width: 760px) { .grid3 { grid-template-columns: 1fr; } }
.card.feature { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; border: 0; cursor: pointer; font: inherit; color: var(--ink); }
.card.feature:hover { transform: translateY(-2px); }
.card.feature:disabled { opacity: .6; cursor: default; transform: none; }
.f-emoji { font-size: 30px; }
.f-title { font-weight: 900; font-size: 18px; }
.f-sub { color: var(--muted); font-size: 14px; }
.lb-note { margin: 0 0 6px; font-size: 13px; }
.lb-note:empty { display: none; }

.q-tag { margin: 0 0 8px; display: inline-block; background: #fff4cc; color: #7a5b00; font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.go-extra { text-align: center; font-weight: 700; margin: 4px 0 10px; line-height: 1.5; }
.go-extra:empty { display: none; }
.exam-row { display: flex; gap: 8px; }
.exam-row select, .exam-row input { border: 2px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.weak-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.weak-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.weak-list .wl-w { font-weight: 800; }
.weak-list .wl-n { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- Oyun Kur / Oyuna Katıl ---------- */
.host-join { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.host-join .btn-xl { width: 100%; }
@media (max-width: 520px) { .host-join { grid-template-columns: 1fr; } }
.code-input { width: 220px; max-width: 100%; text-align: center; font-size: 44px; font-weight: 900; letter-spacing: 12px; padding: 10px; border: 3px solid var(--line); border-radius: 14px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.code-input:focus { outline: none; border-color: var(--blue); }
.join-error { color: var(--red); font-weight: 700; min-height: 22px; margin: 0 0 8px; }
.invite-panel { background: #f5f7fb; border-radius: 12px; padding: 14px; margin-bottom: 16px; text-align: center; }
.invite-panel h3 { text-align: left; margin: 14px 0 6px; font-size: 16px; }
.big-code { font-size: 56px; font-weight: 900; letter-spacing: 14px; color: var(--blue); font-variant-numeric: tabular-nums; }
.invite-row { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.invite-row .qr { background: #fff; border-radius: 10px; padding: 6px; }
.invite-actions { max-width: 260px; text-align: left; }
.opponents { list-style: none; margin: 0; padding: 0; text-align: left; }
.opponents li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.opponents .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c3c9d4; flex: none; }
.dot.on { background: var(--green); }
#invite-avatar .avatar { margin: 0 auto 6px; }
