:root {
  --bg: #0f1226;
  --bg-2: #161a3a;
  --panel: #1d2247;
  --panel-2: #242a58;
  --line: #33397a;
  --text: #eef0ff;
  --muted: #a6abdc;
  --primary: #6c7bff;
  --primary-2: #8a97ff;
  --gold: #ffcb47;
  --green: #38d39f;
  --green-bg: rgba(56, 211, 159, 0.15);
  --red: #ff6b7d;
  --red-bg: rgba(255, 107, 125, 0.15);
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.5px) 0 0 / 22px 22px,
    radial-gradient(1200px 820px at 12% -12%, #2f356f 0%, transparent 55%),
    radial-gradient(1000px 720px at 112% 8%, #402766 0%, transparent 52%),
    radial-gradient(900px 700px at 50% 118%, #21306b 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  padding-block: calc(20px + env(safe-area-inset-top)) calc(48px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .flag {
  width: 10px; height: 34px; border-radius: 3px;
  background: linear-gradient(180deg, #111 0 33%, #d7141a 33% 66%, var(--gold) 66% 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.2px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 0.72rem; }
.icon-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.icon-btn:hover { background: var(--panel-2); transform: translateY(-1px); }
.top-actions { display: flex; gap: 8px; }

/* ---------- Cards / screens ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2 { margin: 0 0 6px; font-size: 1.5rem; }
.lead { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }

.rules {
  list-style: none; padding: 0; margin: 0 0 20px;
  display: grid; gap: 10px;
}
.rules li {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.rules .em { font-size: 1.3rem; line-height: 1.2; }
.rules b { color: var(--primary-2); }

.mode-badge { color: var(--muted); font-weight: 600; }
.mode-badge.cloud { color: var(--green); }

/* greeting on the start screen */
.greeting {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.greeting .ava { font-size: 2rem; line-height: 1; }
.greeting .hello { font-size: 1.05rem; }
.greeting .hello b { color: var(--primary-2); }

/* avatar picker on the registration screen */
.avatar-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.ava-opt {
  width: 46px; height: 46px; font-size: 1.4rem; line-height: 1; cursor: pointer;
  background: var(--panel-2); border: 2px solid var(--line); border-radius: 12px;
  transition: transform .08s ease, border-color .15s;
}
.ava-opt:hover { transform: translateY(-2px); }
.ava-opt.sel { border-color: var(--primary); background: rgba(108,123,255,0.18); }

.reg-notice { color: var(--muted); font-size: 0.78rem; margin: 8px 2px 0; line-height: 1.4; }
.legal-links { text-align: center; margin-top: 10px; font-size: 0.75rem; color: var(--muted); }
.legal-links a { color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: var(--primary-2); text-decoration: underline; }
.form-error { color: var(--red); font-size: 0.88rem; margin: -6px 0 14px; font-weight: 600; }
.lb-loading { color: var(--muted); text-align: center; padding: 22px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 14px 16px; font-size: 1.05rem;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,123,255,0.25); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; font-size: 1.05rem; font-weight: 700;
  color: #fff; background: linear-gradient(180deg, var(--primary-2), var(--primary));
  border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(108,123,255,0.35);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  box-shadow: none;
}

/* ---------- HUD ---------- */
.hud {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.stat .k { display: block; font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .v { display: block; font-size: 1.25rem; font-weight: 800; margin-top: 2px; }
.stat .v.gold { color: var(--gold); }
.stat .v.green { color: var(--green); }
.hearts { letter-spacing: 2px; font-size: 1.15rem; }
.hearts .lost { filter: grayscale(1); opacity: 0.35; }

/* ---------- Timer ---------- */
.timer { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
.timer > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .1s linear; }
.timer.warn > i { background: linear-gradient(90deg, var(--gold), var(--red)); }

/* ---------- Question ---------- */
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 0.72rem; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.chip.case { color: var(--gold); border-color: rgba(255,203,71,0.4); }

.sentence {
  font-size: 1.5rem; line-height: 1.55; text-align: center;
  padding: 8px 4px 4px; margin-bottom: 6px; font-weight: 500;
}
.sentence .art { color: var(--muted); }
.sentence .noun { color: var(--text); }
.sentence .blank {
  display: inline-block; min-width: 84px; padding: 0 8px; margin: 0 2px;
  border-bottom: 3px dashed var(--primary); color: var(--primary-2); font-weight: 800;
}
.sentence .blank.filled { border-bottom-style: solid; }
.hint-line { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.2em; margin-bottom: 16px; }

/* ---------- Options ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  padding: 16px; font-size: 1.15rem; font-weight: 700; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: transform .08s ease, border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--green-bg); border-color: var(--green); color: #d6fff0; }
.opt.wrong { background: var(--red-bg); border-color: var(--red); color: #ffdde2; }
.opt.dim { opacity: 0.45; }

/* ---------- Feedback ---------- */
.feedback {
  margin-top: 16px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.feedback.good { border-color: var(--green); background: var(--green-bg); }
.feedback.bad { border-color: var(--red); background: var(--red-bg); }
.feedback .fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.feedback .fb-title { font-weight: 800; font-size: 1.05rem; }
.feedback .fb-points { font-weight: 800; color: var(--gold); white-space: nowrap; }
.feedback .fb-expl { color: var(--text); font-size: 0.92rem; line-height: 1.5; }
.feedback .fb-expl .full { color: var(--green); font-weight: 700; }
.feedback .fb-sub { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
.pointsflash { color: var(--green); font-weight: 700; }
.mult { color: var(--primary-2); }

/* ---------- Game over ---------- */
.go-hero { text-align: center; margin-bottom: 18px; }
.go-hero .score { font-size: 3rem; font-weight: 900; color: var(--gold); line-height: 1; }
.go-hero .score small { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.go-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }

/* ---------- Leaderboard ---------- */
.lb { width: 100%; border-collapse: collapse; }
.lb th, .lb td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.lb th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; }
.lb td.num, .lb th.num { text-align: right; }
.lb .rank { width: 34px; color: var(--muted); font-weight: 800; }
.lb tr.me td { background: rgba(108,123,255,0.16); }
.lb tr.me .rank { color: var(--primary-2); }
.lb .medal { font-size: 1rem; }
.lb-empty { color: var(--muted); text-align: center; padding: 18px; }
.me-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(108,123,255,0.28), rgba(108,123,255,0.14));
  border: 1px solid var(--primary); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
}
.me-banner .mb-place { font-weight: 800; color: var(--gold); margin-right: 8px; }
.me-banner .mb-name { font-weight: 700; }
.me-banner .mb-right { color: var(--text); font-size: 0.88rem; }
.me-banner .mb-right b { color: var(--gold); font-size: 1rem; }
.you-tag {
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  color: #fff; background: var(--primary); padding: 2px 6px; border-radius: 999px; margin-left: 6px;
}
.lb .lb-sep td { text-align: center; color: var(--muted); padding: 4px; letter-spacing: 4px; }
.lb-actions { display: flex; gap: 10px; margin-top: 16px; }
.lb-actions .btn { flex: 1; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.82rem; text-decoration: underline; padding: 6px; }
.link-btn:hover { color: var(--red); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(6,8,20,0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40;
}
.modal { max-width: 640px; width: 100%; max-height: 88vh; overflow: auto; }
.modal h2 { margin-bottom: 12px; }
.tbl-wrap { overflow-x: auto; margin: 12px 0; }
/* fixed layout: the 5 columns split the width evenly so it fits a phone
 * without sideways scrolling (endings are short: -er/-en/-es/-em/-e). */
table.decl { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.decl caption { text-align: left; font-weight: 700; color: var(--primary-2); padding: 6px 0; }
table.decl th, table.decl td { border: 1px solid var(--line); padding: 8px 3px; text-align: center; font-size: 0.95rem; }
table.decl th:first-child, table.decl td:first-child { width: 22%; } /* NOM/AKK/DAT label column */
table.decl th { background: var(--panel-2); color: var(--muted); }
table.decl td b { color: var(--gold); }
@media (max-width: 420px) {
  table.decl th, table.decl td { padding: 7px 1px; font-size: 0.82rem; }
}
.modal .close-row { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ---------- Konnektoren reference chart ---------- */
/* connector = amber pill; conjugated verb = red double underline. */
.k-c {
  background: rgba(255, 203, 71, 0.16); color: var(--gold);
  border: 1px solid rgba(255, 203, 71, 0.35);
  border-radius: 6px; padding: 0 5px; font-weight: 600; white-space: nowrap;
}
.k-v {
  text-decoration: underline double var(--red);
  text-underline-offset: 3px; font-weight: 600; color: var(--text);
}
.k-legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  font-size: 0.78rem; color: var(--muted);
  padding: 10px 0 4px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.k-legend b { color: var(--text); }
.k-group { margin-top: 16px; }
.k-group-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.k-group-head h3 { margin: 0; font-size: 0.98rem; color: var(--primary-2); }
.k-group-head .k-pattern { font-size: 0.74rem; color: var(--muted); }
.k-group .k-note { font-size: 0.76rem; color: var(--muted); margin: 3px 0 8px; line-height: 1.4; }
.k-subhead {
  font-size: 0.76rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px; margin: 10px 0 4px;
}
.k-row {
  display: grid; grid-template-columns: 84px 1fr; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--line); align-items: start;
}
.k-word { font-weight: 700; color: var(--gold); font-size: 0.9rem; line-height: 1.3; }
.k-word .k-mean { display: block; color: var(--muted); font-weight: 400; font-size: 0.72rem; }
.k-ex { font-size: 0.82rem; line-height: 1.55; }
.k-ex + .k-ex { margin-top: 3px; }
.k-label {
  display: inline-block; min-width: 30px; margin-right: 6px;
  font-size: 0.66rem; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px;
}
@media (max-width: 420px) {
  .k-row { grid-template-columns: 66px 1fr; gap: 8px; }
  .k-ex { font-size: 0.78rem; }
  .k-word { font-size: 0.84rem; }
}

/* ---------- Adverbien extras (tip box, dort/da table, frequency scale) ---------- */
.tip-box {
  margin-top: 14px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); border-radius: 10px;
  font-size: 0.86rem; line-height: 1.5; color: var(--text);
}
.tip-box i { color: var(--muted); }
.k-subcard {
  margin-top: 14px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
}
.k-subcard h3 { margin: 0 0 6px; font-size: 0.98rem; color: var(--primary-2); }
.da-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 6px 0; }
.da-table th, .da-table td {
  border: 1px solid var(--line); padding: 6px 6px; font-size: 0.78rem;
  text-align: left; vertical-align: top;
}
.da-table th { background: var(--panel); color: var(--muted); }
.da-table th:last-child, .da-table td:last-child { text-align: center; width: 22%; }
.da-table .yes { color: var(--green); font-weight: 700; }
.da-table .no { color: var(--red); font-weight: 700; }
.freq-scale {
  display: flex; align-items: stretch; gap: 2px; margin: 8px 0 4px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
}
.freq-scale span {
  flex: 1; text-align: center; font-size: 0.72rem; font-weight: 600;
  padding: 6px 2px; color: #1b1e3a;
  background: linear-gradient(180deg, var(--green), var(--gold));
}
.freq-scale span:nth-child(1) { background: var(--green); }
.freq-scale span:nth-child(2) { background: #7fd98a; }
.freq-scale span:nth-child(3) { background: var(--gold); }
.freq-scale span:nth-child(4) { background: #ff9e6b; }
.freq-scale span:nth-child(5) { background: var(--red); color: #fff; }
.k-badge {
  display: inline-block; font-size: 0.64rem; font-weight: 700;
  background: rgba(138,151,255,0.18); color: var(--primary-2);
  border: 1px solid rgba(138,151,255,0.4); border-radius: 6px;
  padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}

/* ---------- Satzbau (word-order) tiles ---------- */
.order-area { margin-top: 4px; }
.order-build {
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  min-height: 62px; padding: 12px; margin-bottom: 14px;
  background: var(--bg-2); border: 2px dashed var(--line); border-radius: 12px;
}
.order-build:empty::before {
  content: "Tippe die Wörter unten in der richtigen Reihenfolge an …";
  color: var(--muted); font-size: 0.88rem; align-self: center;
}
.order-bank {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px;
  padding-bottom: 4px;
}
.tile {
  font-family: var(--font); font-size: 1rem; font-weight: 600;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 13px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.tile:hover { background: var(--panel); transform: translateY(-1px); }
.tile:active { transform: translateY(0); }
.tile.placed { background: var(--panel); border-style: dashed; }
.tile.correct { background: var(--green-bg); border-color: var(--green); color: #d6fff0; }
.tile.wrong { background: var(--red-bg); border-color: var(--red); color: #ffdde2; }
.tile:disabled { cursor: default; }
.tile.ghost { opacity: 0.35; }
.order-actions { display: flex; gap: 10px; align-items: stretch; }
.order-actions .btn { margin-top: 8px; }
#orderCheck { flex: 1; }
#orderReset { width: auto; padding-left: 18px; padding-right: 18px; font-size: 1.2rem; }
#orderCheck:disabled { opacity: 0.5; cursor: default; }
@media (max-width: 480px) {
  .tile { font-size: 0.95rem; padding: 9px 11px; }
}

.footnote { text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 22px; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .sentence { font-size: 1.25rem; }
  .options { grid-template-columns: 1fr 1fr; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .go-grid { grid-template-columns: repeat(3, 1fr); }
  .brand h1 { font-size: 1rem; }
}

/* ---------- Greeting tier chip ---------- */
.greeting { position: relative; }
.greeting .greet-main { flex: 1; }
.tier-chip {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 0.8rem; cursor: pointer;
  white-space: nowrap; transition: transform .08s ease, border-color .15s;
}
.tier-chip:hover { transform: translateY(-1px); }
.tier-chip.paid { color: var(--gold); border-color: rgba(255,203,71,0.5); background: rgba(255,203,71,0.08); }

/* ---------- Topics ---------- */
.topics { display: grid; gap: 10px; margin-bottom: 16px; }
.topic {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; color: var(--text); cursor: pointer; transition: transform .08s ease, border-color .15s;
}
.topic:hover:not(.soon) { transform: translateY(-2px); border-color: var(--primary); }
.topic.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.topic .t-emoji { font-size: 1.7rem; line-height: 1; }
.topic .t-main { flex: 1; display: flex; flex-direction: column; }
.topic .t-main b { font-size: 1.05rem; }
.topic .t-main small { color: var(--muted); font-size: 0.82rem; }
.topic .t-go { font-size: 1.1rem; color: var(--primary-2); }
.topic.soon { opacity: 0.55; cursor: default; }
.topic.soon .t-go { color: var(--muted); }

.howto { margin-top: 6px; }
.howto summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 0; }
.howto[open] summary { color: var(--text); }

/* ---------- Store / tiers ---------- */
.tiers { display: grid; gap: 12px; margin-bottom: 12px; }
.tier {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.tier.hl { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,203,71,0.4); }
.tier.current { border-color: var(--primary); }
.tier-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tier-emoji { font-size: 2rem; line-height: 1; }
.tier-id b { font-size: 1.15rem; }
.tier-badge { font-size: 0.62rem; font-weight: 800; text-transform: uppercase; color: #2a1e00;
  background: var(--gold); border-radius: 999px; padding: 2px 7px; margin-left: 4px; vertical-align: middle; }
.tier-price { color: var(--gold); font-weight: 800; font-size: 1.1rem; margin-top: 2px; }
.tier-price small { color: var(--muted); font-weight: 600; font-size: 0.75rem; }
.tier-perks { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.tier-perks li { color: var(--text); font-size: 0.9rem; padding-left: 20px; position: relative; }
.tier-perks li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 800; }
.fineprint { color: var(--muted); font-size: 0.72rem; text-align: center; margin-top: 12px; line-height: 1.5; }

/* ---------- Ad slot (banner) ---------- */
.ad-slot { margin: 4px 0 12px; }
.ad-banner {
  display: flex; align-items: center; justify-content: center; height: 56px;
  border: 1px dashed var(--line); border-radius: 10px; color: var(--muted);
  font-size: 0.78rem; letter-spacing: 0.5px; background: rgba(255,255,255,0.02);
}

/* ---------- Ad / pay overlays ---------- */
.ad-back {
  position: fixed; inset: 0; background: rgba(6,8,20,0.8); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60;
  animation: fade .2s ease;
}
.ad-box {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 22px; width: 100%; max-width: 360px; text-align: center;
}
.ad-box h3 { margin: 6px 0 4px; font-size: 1.3rem; }
.ad-tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 12px; }
.ad-fake {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px;
  height: 150px; border-radius: 12px; margin-bottom: 14px; font-size: 2.2rem;
  background: linear-gradient(135deg, #2a3170, #3a2560); color: #cfd4ff;
}
.ad-count { color: var(--muted); margin-bottom: 12px; font-size: 0.9rem; }
.ad-skip, .ad-reward { width: 100%; }
.ad-reward:disabled { opacity: 0.5; }
.ad-x {
  position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; line-height: 1;
}
.pay-box .pay-emoji, .revive-box .pay-emoji { font-size: 2.6rem; }
.pay-price { color: var(--gold); font-weight: 800; font-size: 1.4rem; margin: 4px 0 4px; }
.pay-price small { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.pay-box .btn, .revive-box .btn { width: 100%; margin-top: 8px; }

/* ---------- Accessibility ---------- */
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* answer correctness is not colour-only */
.opt.correct::after { content: " ✓"; font-weight: 800; }
.opt.wrong::after { content: " ✗"; font-weight: 800; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
  .screen { animation: none !important; }
}

/* ---------- Settings ---------- */
.settings-group { display: grid; gap: 12px; margin-bottom: 18px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.settings-row .sr-main b { display: block; }
.settings-row .sr-main small { color: var(--muted); font-size: 0.82rem; }
.toggle {
  position: relative; width: 52px; height: 30px; flex: 0 0 auto; border-radius: 999px;
  background: var(--line); border: none; cursor: pointer; transition: background .15s;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.toggle[aria-checked="true"] { background: var(--primary); }
.toggle[aria-checked="true"]::after { transform: translateX(22px); }
.danger-btn { color: var(--red); border-color: rgba(255,107,125,0.4); }
.settings-note { color: var(--muted); font-size: 0.82rem; }
.sync-pill {
  display: inline-block; margin-top: 8px; font-size: 0.78rem; color: var(--muted);
}

.hidden { display: none !important; }
/* the hidden attribute must win over element display rules (e.g. .btn) */
[hidden] { display: none !important; }
