/* ============================================================
   Logical — modern flat theme (dark), mobile-first
   ============================================================ */
:root {
  --bg:        #0d1326;
  --bg-2:      #141b33;
  --surface:   #1b2440;
  --surface-2: #222c4d;
  --line:      #2c3865;
  --bg-glow:   #1a2b4d;
  /* splash spotlight gradient (re-hued together with the bg theme, see applyBgTheme) */
  --splash-1:  #3b5aa6;
  --splash-2:  #20356a;
  --splash-3:  #0c1430;
  --splash-4:  #060a1c;
  --text:      #eaf0ff;
  --muted:     #9fb0d8;
  --primary:   #4aa8ff;
  --primary-d: #2d7fe0;
  --accent:    #3ddc97;
  --danger:    #ff5d73;
  --gold:      #ffd23f;

  /* Single source of truth for the playfield ball colours is render.js (BALL,
     exported as window.LogicalColors and reused by ui.js). These CSS vars mirror
     those exact hues so any CSS dot/swatch matches the canvas. */
  --ball-red:    #ff5160;
  --ball-yellow: #ffd23f;
  --ball-green:  #3ddc84;
  --ball-blue:   #4aa3ff;
  --ball-purple: #b083ff;
  --ball-orange: #ff9f45;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
body { background: radial-gradient(120% 80% at 50% -10%, var(--bg-glow) 0%, var(--bg) 60%), var(--bg); }
#app { position: relative; height: 100%; width: 100%; max-width: 720px; margin: 0 auto; overflow: hidden; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 16px);
  opacity: 0;
  animation: fade .22s ease both;
}
.screen.is-active { display: flex; opacity: 1; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* ============================================================
   Homage to the original 1991 title screen:
   chrome "LOGICAL" wordmark, shattered light-bulb, deep royal-blue.
   ============================================================ */
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes spin { to { transform: rotate(360deg);} }

/* ---- chrome wordmark (used on splash, menu, auth, overlays) ----
   Bright silver face via background-clip:text; the 3D extrude is built from a
   stack of solid drop-shadows (these render correctly over a clipped-text fill,
   unlike a negative-z pseudo, which paints over the face in Blink). */
.wordmark {
  position: relative;
  display: inline-block;
  margin: 0;
  font-weight: 900;
  font-size: 56px;
  line-height: .95;
  letter-spacing: 3px;
  font-family: "Arial Black", "Helvetica Neue", Impact, var(--font);
  background: linear-gradient(180deg,
    #ffffff 0%, #eaf2ff 30%, #b9cef0 50%, #ffffff 58%, #cfddf6 78%, #9bafd4 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.8px rgba(14,22,44,.45);
  filter:
    drop-shadow(0 1px 0 #36436322) drop-shadow(0 1px 0 #364363)
    drop-shadow(0 2px 0 #2a3550) drop-shadow(0 3px 0 #222b43)
    drop-shadow(0 5px 7px rgba(0,0,0,.5));
}
/* ---- "RotoR" wordmark: small lowercase o's, mirrored final R ----
   The mirrored R needs display:inline-block for the flip, which breaks it out
   of the parent's background-clip:text, so it re-declares the chrome fill. */
.wordmark-rotor .wm-o { font-size: .58em; letter-spacing: 1px; }
.wordmark-rotor .wm-flip {
  display: inline-block;
  transform: scaleX(-1);
  vertical-align: baseline;
  background: linear-gradient(180deg,
    #ffffff 0%, #eaf2ff 30%, #b9cef0 50%, #ffffff 58%, #cfddf6 78%, #9bafd4 100%);
  -webkit-background-clip: text; background-clip: text;
}
.wordmark.small {
  font-size: 30px; letter-spacing: 2px;
  -webkit-text-stroke: 0.6px rgba(14,22,44,.4);
  filter:
    drop-shadow(0 1px 0 #2f3b57) drop-shadow(0 2px 0 #242d46)
    drop-shadow(0 3px 5px rgba(0,0,0,.5));
}

/* ---- splash / title screen ---- */
.splash {
  align-items: center; justify-content: center; gap: 4px;
  background:
    radial-gradient(95% 70% at 42% 38%, var(--splash-1) 0%, var(--splash-2) 38%, var(--splash-3) 78%, var(--splash-4) 100%);
}
.splash-stage {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(14px, 3vw, 38px); flex-wrap: nowrap; max-width: 680px; width: 100%;
}
.splash-bulb {
  width: clamp(118px, 30vmin, 240px); height: auto; flex: 0 0 auto;
  filter: drop-shadow(0 12px 30px rgba(255,150,40,.28));
  animation: floaty 4s ease-in-out infinite;
}
.splash-right { text-align: left; min-width: 0; }
.splash .wordmark { font-size: clamp(40px, 10.5vmin, 82px); }
.credits { margin-top: 16px; display: flex; flex-direction: column; gap: 7px; }
.credits p { margin: 0; font-size: 12.5px; display: flex; flex-direction: column; }
.credits span { color: #8fa6d8; letter-spacing: 2px; text-transform: uppercase; font-size: 10px; font-weight: 700; }
.credits b { color: #eaf0ff; font-weight: 700; }
.splash-bottom { height: 46px; display: grid; place-items: center; margin-top: 18px; }
.splash-start {
  border: 0; background: none; color: #dfe8ff; cursor: pointer;
  font-size: 16px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  text-shadow: 0 0 14px rgba(120,170,255,.7);
  animation: pulse 1.3s ease-in-out infinite;
}
.splash-foot {
  position: absolute; bottom: calc(var(--safe-b) + 12px); left: 0; right: 0;
  text-align: center; color: #6f82b3; font-size: 11px; margin: 0; padding: 0 16px;
}
.spinner { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto;
  border: 3px solid rgba(255,255,255,.18); border-top-color: #8fb6ff; animation: spin .8s linear infinite; }

/* ---------- panels / auth ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; }
.auth-panel { margin: auto; width: 100%; max-width: 380px; text-align: center; }
.auth-logo { display: block; margin: 0 auto 6px; filter: drop-shadow(0 8px 20px rgba(255,150,40,.28)); }
.tabs { display: flex; background: var(--bg-2); border-radius: var(--radius-sm); padding: 4px; margin: 6px 0 18px; }
.tab { flex: 1; padding: 10px; border: 0; background: transparent; color: var(--muted);
  font-weight: 700; border-radius: 8px; font-size: 15px; }
.tab.is-active { background: var(--surface-2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password] {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); padding: 13px 14px; font-size: 16px; outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--primary); }
.auth-msg { min-height: 20px; margin: 12px 0 4px; font-size: 14px; color: var(--danger); font-weight: 600; }
.auth-msg.ok { color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 12px 0 0; }
.hint.center { text-align: center; }

/* ---------- buttons ---------- */
.btn { border: 0; border-radius: var(--radius-sm); padding: 14px 18px; font-size: 16px; font-weight: 700;
  color: #fff; background: var(--surface-2); cursor: pointer; transition: transform .08s, filter .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-d)); box-shadow: 0 6px 16px rgba(45,127,224,.35); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-block { width: 100%; margin-top: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 20px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { transform: scale(.94); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.topbar-title { flex: 1; text-align: center; font-size: 20px; font-weight: 800; margin: 0; }
.topbar-stat { color: var(--gold); font-weight: 700; min-width: 48px; text-align: right; }
/* Level-detail header: prev/next-level arrows hug the title in a centred group.
   The title keeps a fixed width so the arrows land on the exact same pixel for
   every level (Level 1 … Level 99) — quick, muscle-memory tapping. */
.detail-nav { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.detail-nav .topbar-title { flex: 0 0 auto; width: 110px; }
.detail-nav .nav-arrow { flex: 0 0 auto; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:disabled:active { transform: none; }
.user-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- main menu ---------- */
#screen-menu { justify-content: flex-start;
  background: radial-gradient(110% 60% at 50% -8%, #233a72 0%, #14224a 42%, transparent 80%); }
.menu-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.menu-hero { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 0; margin: 2px 0 18px; }
.menu-bulb { width: clamp(64px, 18vw, 92px); height: auto; flex: 0 0 auto;
  filter: drop-shadow(0 5px 8px rgba(255,150,40,.22)); }
/* Auto side-margins centre the wordmark in the space between the bulb (left) and
   the right-aligned "Jetzt spielen" card — so the gap to the bulb and to the card
   is identical. */
.menu-hero-text { min-width: 0; flex: 0 1 auto; margin: 0 auto; }
.menu-hero .wordmark.small { font-size: clamp(46px, 9vw, 76px); }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 8px;
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.menu-card { display: flex; align-items: center; gap: 16px; text-align: left;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); position: relative; overflow: hidden;
  padding: 16px 18px; color: var(--text); cursor: pointer; transition: transform .08s, background .15s; }
/* chrome edge highlight, echoing the metallic title */
.menu-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #cfe0ff, #5a76ad 50%, #cfe0ff); opacity: .85; }
.menu-card:active { transform: scale(.985); background: var(--surface-2); }
.menu-ico { font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: linear-gradient(160deg, #2c3865, #1a2240); border: 1px solid #3a4a7e; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
/* favicon-based icon: the SVG already carries its own rounded backdrop */
.menu-ico-img { background: none; border: none; padding: 0; overflow: hidden; }
.menu-ico-img img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.menu-text { display: flex; flex-direction: column; }
.menu-text b { font-size: 17px; }
.menu-text small { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.menu-ico svg { display: block; color: var(--text); }

/* Continue / quick-start card — lives in the hero row, filling the empty space
   to the right of the logo on wide screens and wrapping to its own full-width
   row on phones. Accent-coloured so the "where was I?" action stands out. */
#menu-resume { flex: 0 0 auto; min-width: 0; }
#menu-resume:empty { display: none; }
#menu-resume .menu-card.resume { width: auto; margin: 0; }
/* Phones: row 1 = bulb + a large wordmark that fills the space beside it;
   row 2 = the continue card across the full width. */
@media (max-width: 560px) {
  .menu-hero { gap: 10px 14px; }
  .menu-hero-text { flex: 1 1 auto; margin: 0; text-align: center; }
  .menu-hero .wordmark.small { font-size: clamp(40px, 19vw, 88px); }
  #menu-resume { flex: 1 0 100%; }                 /* force its own full-width row below */
  #menu-resume .menu-card.resume { width: 100%; }  /* span the whole screen width */
}
.menu-card.resume { border-color: var(--primary); background: linear-gradient(180deg, var(--surface-2), var(--bg-2)); }
.menu-card.resume::before { background: linear-gradient(180deg, var(--accent), var(--primary)); opacity: 1; }
.menu-card.resume .menu-ico { background: linear-gradient(160deg, var(--primary), var(--primary-d)); border-color: var(--primary); }
.menu-card.resume .menu-ico svg { color: #fff; }
.menu-card .menu-sub { color: var(--accent); font-size: 12.5px; margin-top: 2px; font-weight: 700; }

/* Short screens (e.g. phone in landscape): compact the hero so more of the
   menu list is visible at once. The list still scrolls when it overflows. */
@media (max-height: 520px) {
  .menu-hero { margin: 0 0 8px; gap: 18px; }
  .menu-bulb { width: clamp(48px, 16vh, 72px); }
  .menu-top { margin-bottom: 0; }
  .menu-buttons { margin-top: 4px; gap: 10px; }
}

/* ---------- level grid ---------- */
/* Reserve a stable gutter so the scrollbar never paints over the right
   column of cells; style a thin, unobtrusive scrollbar to match. */
/* grid-auto-rows: max-content is required — aspect-ratio cells do NOT contribute
   to automatic row-track sizing, so without it the rows collapse to content
   height and the square cells overlap (the scroll container has a definite
   height). align-content:start keeps rows packed from the top. */
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: max-content;
  align-content: start; gap: 12px; overflow-y: auto;
  padding: 4px 2px 20px; scrollbar-gutter: stable; scrollbar-width: thin;
  scrollbar-color: var(--line) transparent; }
.level-grid::-webkit-scrollbar { width: 8px; }
.level-grid::-webkit-scrollbar-track { background: transparent; }
.level-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px;
  border: 2px solid transparent; background-clip: padding-box; }
.level-grid::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
.level-cell { aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text); font-weight: 800; font-size: 18px; cursor: pointer; position: relative;
  overflow: hidden; transition: transform .08s; }
.level-cell:active { transform: scale(.95); }
.level-cell.locked { color: var(--muted); background: var(--bg-2); cursor: pointer; opacity: .65; }
.level-cell.locked .mini-stars { color: var(--muted); }
.level-cell.done { border-color: var(--accent); }
.level-cell .lvl-no { font-size: 18px; font-weight: 800; line-height: 1; }
.level-cell .mini-stars { font-size: 11px; color: var(--gold); letter-spacing: 1px; height: 12px; }
/* Original level name — small, single line, ellipsised so it never breaks the square cell. */
.level-cell .level-name { max-width: 100%; padding: 0 5px; font-size: 8.5px; font-weight: 600; line-height: 1.15;
  color: var(--muted); text-align: center; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Chapter-jump arrows flanking the centred final row (‹ previous · next ›).
   Same square footprint as a level tile, but dashed and not a `.level-cell`. */
.level-navcell { aspect-ratio: 1; border-radius: 14px; border: 1px dashed var(--line);
  background: var(--bg-2); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; color: var(--accent); cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s; }
.level-navcell:not(.disabled):hover { border-color: var(--accent); background: var(--surface); }
.level-navcell:not(.disabled):active { transform: scale(.95); }
.level-navcell .nav-chev { font-size: 34px; font-weight: 800; line-height: .9; }
.level-navcell .nav-cap { font-size: 9.5px; font-weight: 700; color: var(--muted); letter-spacing: .3px; }
.level-navcell.disabled { opacity: .22; cursor: default; pointer-events: none; color: var(--muted); }

/* ---------- chapter chooser (Level 1–10, 11–20, …) ---------- */
.chapter-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start; gap: 12px; padding: 4px 2px 20px; scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.chapter-grid::-webkit-scrollbar { width: 8px; }
.chapter-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px;
  border: 2px solid transparent; background-clip: padding-box; }
.chapter-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; color: var(--text); cursor: pointer; text-align: left;
  min-height: 92px; transition: transform .08s, background .15s; }
.chapter-card:active { transform: scale(.985); background: var(--surface-2); }
.chapter-card.done { border-color: var(--accent); }
.chapter-card.locked { opacity: .72; }
.ch-range { font-size: 17px; font-weight: 800; }
.ch-prog { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.ch-stars { color: var(--gold); font-weight: 700; }
.ch-bar { width: 100%; height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-top: auto; }
.ch-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 99px; }
.ch-lock { position: absolute; top: 12px; right: 14px; font-size: 16px; opacity: .85; }

/* ---------- level detail / preview ---------- */
.level-detail { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 2px 2px 20px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; }
.detail-shot { flex: 0 0 auto; width: 180px; max-width: 44%; aspect-ratio: 8 / 5; object-fit: cover;
  border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.detail-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.detail-name { font-size: 18px; font-weight: 800; line-height: 1.25; }
.detail-name .lvl-row-no { margin-right: 2px; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.detail-fact { color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-fact b { color: var(--text); }
.detail-colors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.detail-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.35); }
.detail-section-title { margin: 2px 0 0; font-size: 15px; font-weight: 800; }
.detail-parts { display: flex; flex-direction: column; gap: 8px; }
.detail-part { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 8px 8px; }
.detail-part canvas { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line); }
.detail-part-info { flex: 1; min-width: 0; line-height: 1.4; }
.detail-part-name { font-weight: 700; color: var(--text); }
.detail-part-desc { color: var(--muted); font-size: 12.5px; }
.detail-part-count { flex: 0 0 auto; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.detail-empty { color: var(--muted); font-size: 14px; margin: 0; }
.detail-actions { margin-top: 2px; }
.detail-locked-note { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: grayscale(.35); box-shadow: none; }

/* per-level statistics on the detail screen (own vs the others' average) */
.detail-stats-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 2px 0 0; }
#detail-comm { margin-top: 8px; }
.detail-metrics { border-top: 0; margin-top: 8px; padding-top: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }

/* ---------- game screen ---------- */
/* The whole HUD (title, NÄCHSTE preview, stats, buttons, overflow gauge) is
   drawn into the canvas side panels by render.js — there is no DOM HUD. The game
   breaks out of the #app max-width so it fills the whole screen (TVs / laptops).
   100dvh (with a 100vh fallback) so the bottom board edge never hides behind the
   mobile browser toolbar. The win moment is celebrated in-canvas (confetti +
   flash + final burst), so the board no longer shakes. */
.game-screen { padding: 0; }
#screen-game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; }
.board-wrap { flex: 1; display: grid; place-items: center; min-height: 0; margin: 0; }
#board { touch-action: none; display: block; max-width: 100%; max-height: 100%; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ---------- overlays ---------- */
/* Flex column + margin:auto on the card centres it when it fits but lets the
   overlay scroll (and never clips the top/bottom button) on short landscape
   screens — unlike place-items:center, which clips both ends when too tall. */
.overlay { position: absolute; inset: 0; background: rgba(7,11,24,.72); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 30; animation: fade .2s ease both; padding: 24px; }
.overlay-card { margin: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 22px; width: 100%; max-width: 340px; text-align: center; }
.overlay-card h2 { margin: 0 0 14px; font-size: 24px; }
.overlay-bulb { display: block; width: 52px; height: auto; margin: 0 auto 8px;
  filter: drop-shadow(0 6px 14px rgba(255,150,40,.3)); }
.overlay-card.win h2 { color: var(--accent); }
.overlay-card.lose h2 { color: var(--danger); }
.stars-big { font-size: 40px; letter-spacing: 6px; color: var(--gold); margin-bottom: 12px; min-height: 44px; }
.stars-big .empty { color: var(--line); }
.win-stats { color: var(--muted); margin-bottom: 8px; font-size: 14px; line-height: 1.7; }
.confirm-text { color: var(--muted); margin: 0 0 6px; font-size: 15px; line-height: 1.5; }

/* Compact the win/lose dialog on short landscape screens so it fits without scrolling. */
@media (max-height: 640px) {
  .overlay { padding: 14px; }
  .overlay-card { padding: 18px 20px; }
  .overlay-card h2 { margin-bottom: 8px; font-size: 21px; }
  .stars-big { font-size: 30px; margin-bottom: 8px; min-height: 34px; }
  .win-stats { margin-bottom: 4px; line-height: 1.45; }
  .overlay .btn-block { margin-top: 8px; }
  .overlay .btn { padding: 11px 16px; }
}

/* ---------- leaderboard ---------- */
.lb-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 16px; }
.lb-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; }
.lb-rank { font-weight: 800; width: 28px; color: var(--muted); }
.lb-row.top .lb-rank { color: var(--gold); }
.lb-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- level overview ---------- */
.level-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; }
.level-list-intro { margin: 2px 4px 10px; }
.lvl-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; }
.lvl-shot { flex: 0 0 auto; width: 120px; height: 75px; object-fit: cover; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line); }
.lvl-info { flex: 1; min-width: 0; }
.lvl-row-name { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl-row-no { display: inline-block; min-width: 1.6em; color: var(--gold); font-weight: 800; }
.lvl-row-stats { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.lvl-stat { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* per-level metrics: your value vs the anonymous average of the others */
.lvl-row { align-items: flex-start; }
.lvl-metrics { margin-top: 8px; display: flex; flex-direction: column; gap: 3px;
  border-top: 1px solid var(--line); padding-top: 8px; }
.lvl-metric { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lvl-metric.hint { border: 0; padding: 0; }
.lm-head { flex: 0 0 auto; min-width: 7.5em; color: var(--text); font-weight: 600; }
.lm-ico { margin-right: 4px; }
.lm-you b, .lm-avg b { color: var(--text); font-weight: 700; }
.lm-you.good b { color: var(--accent); }           /* your run beats the others' average */
.lm-you.meh b  { color: var(--gold); }             /* the others are ahead of you */
.lm-avg { color: var(--muted); }
.lm-range { margin-left: auto; color: var(--muted); opacity: .8; font-size: 11.5px;
  white-space: nowrap; cursor: help; }

/* ---------- how to ---------- */
.howto { overflow-y: auto; line-height: 1.6; padding-bottom: 20px; }
.howto h3 { margin: 18px 0 6px; }
.howto p { color: var(--muted); margin: 0 0 8px; }
.howto .demo { display: block; margin: 12px auto; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.howto .parts { margin: 4px 0 8px; }
.howto .part { display: flex; align-items: center; gap: 14px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.howto .part:last-child { border-bottom: 0; }
.howto .part canvas { flex: 0 0 auto; width: 60px; height: 60px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.howto .part .pt { flex: 1; line-height: 1.4; }
.howto .part .pt b { display: block; color: var(--text); margin-bottom: 2px; }
.howto .part .pt span { color: var(--muted); font-size: 14px; }
.legal h3 { font-size: 15px; }
.legal a { color: var(--accent); }
/* inline text link rendered as a button (DSGVO / Datenschutz) */
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer; }

/* ---------- settings ---------- */
.settings { display: flex; flex-direction: column; gap: 12px;
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.switch-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.switch-row span:first-child { flex: 1; }
.switch-row input { display: none; }
.switch { width: 48px; height: 28px; border-radius: 99px; background: var(--bg-2); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s; }
.switch-row input:checked + .switch { background: var(--primary); }
.switch-row input:checked + .switch::after { transform: translateX(20px); background: #fff; }
.select-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.select-row span:first-child { flex: 1; }
.select { flex: 0 0 auto; max-width: 58%; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 30px 8px 12px; font: inherit; font-weight: 600; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239fb0d8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.select:focus { outline: none; border-color: var(--primary); }
/* menu-colour picker */
.theme-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.theme-row > span { flex: 1; }
.theme-swatches { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.theme-swatches .swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 0;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .08s; }
.theme-swatches .swatch:active { transform: scale(.9); }
.theme-swatches .swatch.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--muted); }
/* avatar picker: a full-width grid of emoji choices */
.avatar-row { background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.avatar-row > span { display: block; margin-bottom: 10px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; }
.avatar-grid .avatar-swatch { aspect-ratio: 1; display: grid; place-items: center; padding: 0;
  font-size: 23px; line-height: 1; border-radius: 12px; border: 2px solid transparent;
  background: var(--bg-2); cursor: pointer; transition: transform .08s; }
.avatar-grid .avatar-swatch:active { transform: scale(.9); }
.avatar-grid .avatar-swatch.is-active { border-color: #fff; background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
#btn-account { font-size: 24px; }
.settings-account { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ---------- toast ---------- */
.toast { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- orientation hint ---------- */
.orient-hint { position: fixed; inset: 0; background: rgba(7,11,24,.93); backdrop-filter: blur(8px);
  display: none; place-items: center; z-index: 100; padding: 28px; }
.orient-hint.show { display: grid; }
.orient-card { text-align: center; max-width: 360px; }
.orient-emoji { font-size: 54px; margin-bottom: 12px; animation: rotsway 2s ease-in-out infinite; }
@keyframes rotsway { 0%,100%{transform:rotate(-12deg)} 50%{transform:rotate(12deg)} }
.orient-card h2 { margin: 0 0 10px; font-size: 24px; }
.orient-card p { color: var(--muted); line-height: 1.6; margin: 0 0 18px; }

/* ---------- DSGVO / cookie notice ---------- */
.cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; justify-content: center; pointer-events: none;
  padding: 12px 12px calc(12px + var(--safe-b)); }
.cookie-banner[hidden] { display: none; }
.cookie-card { pointer-events: auto; width: 100%; max-width: 560px;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; animation: cookie-rise .3s ease; }
@keyframes cookie-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.cookie-ico { font-size: 28px; line-height: 1; flex: 0 0 auto; }
.cookie-text { flex: 1; min-width: 0; }
.cookie-text b { font-size: 14.5px; }
.cookie-text p { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 4px 0 0; }
.cookie-text .link-btn { font-size: inherit; }
.cookie-ok { flex: 0 0 auto; margin: 0; padding: 10px 18px; white-space: nowrap; }
@media (max-width: 560px) {
  .cookie-card { flex-direction: column; align-items: stretch; gap: 10px; }
  .cookie-ok { width: 100%; }
}

/* ---------- volume sliders (settings) ---------- */
.range-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.range-row > span { flex: 0 0 auto; }
.range { flex: 1; min-width: 0; appearance: none; -webkit-appearance: none; height: 6px; border-radius: 99px;
  background: var(--bg-2); outline: none; cursor: pointer; }
.range:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--primary);
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }
.settings-credits { margin-top: 8px; line-height: 1.6; }
.legal-url { color: var(--accent); word-break: break-all; }

/* danger / delete-account control in settings */
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:active { background: rgba(255,93,115,.12); }
.danger-confirm { background: rgba(255,93,115,.08); border: 1px solid var(--danger); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.danger-confirm p { margin: 0; color: var(--text); font-size: 13.5px; line-height: 1.5; }
.danger-confirm input { width: 100%; }

/* ---------- win celebration extras ---------- */
.overlay-card.win { animation: win-pop .42s cubic-bezier(.18,.9,.3,1.3) both; }
@keyframes win-pop { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
/* Stars pop in one after another for a little payoff rhythm. */
.stars-big span { display: inline-block; animation: star-pop .42s cubic-bezier(.2,.8,.3,1.5) both; }
.stars-big span:nth-child(1) { animation-delay: .05s; }
.stars-big span:nth-child(2) { animation-delay: .22s; }
.stars-big span:nth-child(3) { animation-delay: .39s; }
@keyframes star-pop { 0% { opacity: 0; transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.35) rotate(8deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.win-rank { color: var(--gold); font-weight: 800; font-size: 15px; margin: 0 0 10px; min-height: 1.2em; }
.win-rank .win-rank-hint { color: var(--muted); font-weight: 600; font-size: 13px; }
.lose-bulb { filter: grayscale(1) brightness(.75) drop-shadow(0 6px 14px rgba(0,0,0,.4)); opacity: .85; }

/* ---------- leaderboard: own row + "Dein Platz" ---------- */
.lb-row.me { border-color: var(--primary); background: var(--surface-2); }
.lb-row .lb-you-tag { font-size: 11px; font-weight: 800; color: var(--primary);
  background: rgba(74,168,255,.14); border-radius: 99px; padding: 2px 8px; margin-left: 6px; }
.lb-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 2px 0; }

/* ---------- level screenshots: fade in, neutral fallback ---------- */
.lvl-shot, .detail-shot { opacity: 0; transition: opacity .25s ease; }
.lvl-shot.loaded, .detail-shot.loaded { opacity: 1; }

/* ---------- utility ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
