/* Täta pipelinen: gränssnittets stil. Färger och rubrikstil enligt docs/04-spec-tillagg.md 3.3 och 3.8.
   Varumärket (CONFIG.brand) sätter --accent, --accent-text, --head och --text-font från js/ui.js. */
/* Varumärkets typsnitt (öppen licens, variabla filer). De hämtas först när något på sidan använder dem, alltså bara
   när CONFIG.brand.fontDisplay eller fontText pekar hit, och texten visas direkt i reservtypsnittet (font-display: swap). */
@font-face {
  font-family: "Familjen Grotesk"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../assets/fonts/familjen-grotesk-latin-1.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url("../assets/fonts/schibsted-grotesk-latin-5.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --bg: #12163A; --ink: #1B1440; --panel: rgba(18, 22, 58, 0.92); --text: #FFFFFF; --text2: #C4CCEA;
  --gold: #FFD23F; --seal: #5CF2FF; --danger: #FF2E55; --orange: #FF7A1A; --green: #12D6A0; --blue: #2F7BFF;
  --right: #12D6A0; --wrong: #FF8FA3; --line: #343B78;
  --accent: var(--gold); --accent-text: #12163A;
  --head: "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --m: 24px; --body: 18px; --val: 22px; --h: 36px; --skew: -9deg;
  --st: env(safe-area-inset-top, 0px); --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body {
  color: var(--text); font-family: var(--text-font);
  font-size: var(--body); line-height: 1.4; -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
/* Rubrikstil: tung, lutad, versal. Bara systemtypsnitt. */
.head, #st-name, #banner h2, .btn, #end-title b, .dialog h2, #end-h, #combo-n, .ins-head, #sp-lbl { font-family: var(--head); font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: 0.02em; }

/* overflow: clip (inte hidden): spelytan ska inte vara en scrollbehållare, annars stannar tangentscroll (mellanslag, PageDown)
   i den när den har fokus i stället för att gå vidare till värdsidan */
#game { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; background: var(--bg); overflow: hidden; overflow: clip; touch-action: auto; outline: none; }
#game.playing { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game.aiming { cursor: crosshair; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 0.6s, filter 1s; pointer-events: none; touch-action: auto; }
#c.ready { opacity: 1; }
#c.grey { filter: grayscale(1) brightness(0.8); }
#game.playing #c { touch-action: none; }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 1; }
#fade.on { opacity: 1; }
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(255, 46, 85, 0.75); transition: opacity 0.15s; }
#vignette.hit { opacity: 1; }
#vignette.low { animation: vig 1s ease-in-out infinite; }
#vignette.hit.low { animation: none; opacity: 1; }
@keyframes vig { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.8; } }

/* Raka paneler (allt som ska läsas) */
.panel { background: var(--panel); border-radius: 8px; padding: 8px 12px; }
.lbl { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); white-space: nowrap; }
.val { font-family: var(--head); font-size: var(--val); font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { position: relative; height: 16px; background: #0B0E26; border-radius: 4px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--gold); transform-origin: left center; }
.bar > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bg); }

/* HUD-paneler: sned kortsida, ram och hård skugga. Skuggan och ramen ligger på ett snedställt underlag. */
#h-arr, #h-wave, #h-score, #h-blocks, #msg, #boss, #h-energy, #h-special, #banner { background: none; position: relative; isolation: isolate; border-radius: 0; padding: 8px 18px; }
#h-arr::before, #h-wave::before, #h-score::before, #h-blocks::before, #msg::before, #boss::before, #h-energy::before, #h-special::before, #banner::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--panel); border: 3px solid var(--ink); transform: skewX(var(--skew)); box-shadow: 5px 5px 0 var(--ink); }

/* Knappar */
.btn {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; min-width: 48px; padding: 10px 26px;
  font-size: 17px; line-height: 1.15; cursor: pointer; text-decoration: none; border: 0; background: none; color: var(--text);
  text-align: center; touch-action: manipulation;
}
.btn::before { content: ""; position: absolute; inset: 0; z-index: -1; transform: skewX(var(--skew)); border-radius: 3px; }
.btn.primary { color: var(--accent-text); min-height: 56px; font-size: 20px; }
.btn.primary::before { background: var(--accent); box-shadow: 4px 4px 0 var(--ink); }
.btn.secondary::before, .btn.ghost::before { border: 2px solid var(--text); background: rgba(18, 22, 58, 0.55); }
.btn.small { padding: 8px 18px; font-size: 15px; min-height: 44px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn:hover:not([disabled])::before { filter: brightness(1.12); }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn kbd, #sp-key { font: 700 14px/1 var(--text-font); font-style: normal; border: 2px solid currentColor; border-radius: 4px; padding: 4px 7px; text-transform: none; letter-spacing: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 8px; border: 2px solid var(--text2); background: var(--panel); color: var(--text);
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; pointer-events: auto; touch-action: manipulation;
}
.icon-btn svg { width: 22px; height: 22px; }
:focus-visible { outline: 3px solid var(--seal); outline-offset: 2px; }
h2[tabindex]:focus { outline: none; }
a { color: var(--text); text-underline-offset: 3px; }

/* HUD */
#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--m) + var(--st)) calc(var(--m) + var(--sr)) calc(var(--m) + var(--sb)) calc(var(--m) + var(--sl)); }
#hud-top { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "arr wave score"; gap: 10px 12px; align-items: start; }
#h-right { grid-area: score; justify-self: end; display: flex; gap: 12px; align-items: stretch; }
#hud.only-arr #h-wave, #hud.only-arr #h-score, #hud.only-arr #h-blocks { visibility: hidden; }
#h-arr { grid-area: arr; justify-self: start; display: grid; grid-template-columns: auto auto auto; grid-template-areas: "l l l" "b v p"; column-gap: 12px; align-items: center; }
#h-arr .lbl { grid-area: l; }
#arr-bar { grid-area: b; width: 240px; height: 20px; border: 3px solid var(--ink); border-radius: 0; transform: skewX(var(--skew)); }
#arr-val { grid-area: v; min-width: 4.6em; }
#arr-pct { grid-area: p; color: var(--gold); }
#arr-fill.mid { background: var(--orange); }
#arr-fill.low { background: var(--danger); }
#arr-over { left: 62.5%; width: 37.5%; background: #FFF3B0; animation: glit 0.9s ease-in-out infinite; }
#arr-bar > #arr-mark { left: 62.5%; width: 3px; background: var(--ink); }
@keyframes glit { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
#h-wave { grid-area: wave; justify-self: center; display: flex; flex-direction: column; align-items: center; min-width: 180px; }
#hud.boss-mode #h-wave { visibility: hidden; }
#h-score { display: flex; gap: 12px; align-items: center; }
#h-score .col { display: flex; flex-direction: column; align-items: flex-end; }
#score-val { display: inline-block; transform-origin: right center; }
#score-val.bump { animation: bump 0.12s ease-out 1; }
@keyframes bump { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
#h-blocks { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; }
#h-mid { grid-column: 1 / -1; grid-row: 2; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: clamp(200px, calc(100vw - 770px), 620px); }
#msg { font-weight: 600; text-align: center; max-width: 100%; }
#msg.p3 { color: #FFD0D5; }
#msg.p3::before { border-color: var(--danger); }
#msg.p2 { color: #FFD0D5; }
/* Kombo: under poängen. Tar ingen höjd i rutnätet, så inget flyttar sig när den visas. */
#combo { grid-column: 3; grid-row: 2; justify-self: end; height: 0; display: flex; flex-direction: column; align-items: flex-end; margin-right: 8px; opacity: 1; transition: opacity 0.3s; }
#combo.off { opacity: 0; }
#combo-n { font-size: 28px; line-height: 1; color: #fff; text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 3px 3px 0 var(--ink); }
#combo.c5 #combo-n { color: var(--seal); }
#combo.c10 #combo-n, #combo.c20 #combo-n { color: var(--gold); }
#combo.c20 #combo-n { animation: glit 0.5s ease-in-out infinite; }
#combo-line { display: block; width: 64px; height: 3px; margin-top: 4px; background: rgba(27, 20, 64, 0.6); }
#combo-fill { display: block; width: 100%; height: 100%; background: currentColor; transform-origin: right center; }
#combo.c5 #combo-line { color: var(--seal); }
#combo.c10 #combo-line, #combo.c20 #combo-line { color: var(--gold); }
/* Silons livmätare: nere i mitten, så att bossen syns fri. Tre tredjedelar som töms från höger. */
#boss { position: absolute; left: 50%; bottom: calc(var(--m) + var(--sb)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 7px 18px; }
#boss-bar { position: relative; width: clamp(180px, 30vw, 420px); height: 14px; border: 2px solid var(--ink); overflow: hidden; transform: skewX(var(--skew));
  background: linear-gradient(90deg, var(--green) 0 33.33%, var(--blue) 33.33% 66.67%, var(--orange) 66.67% 100%); }
#boss-cover { position: absolute; inset: 0; background: #0B0E26; transform-origin: right center; transform: scaleX(0); }
#boss-bar > b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.blocks { display: flex; gap: 6px; flex-wrap: wrap; }
#blocks { flex-wrap: nowrap; }
.chip { font-size: 14px; line-height: 1; padding: 6px 8px; border-radius: 4px; border: 2px solid var(--text2); color: var(--text2); white-space: nowrap; }
.chip.on { background: var(--seal); border-color: var(--seal); color: var(--bg); font-weight: 700; }
.chip.on::before { content: "\2713\00a0"; }
.chip .short { display: none; }
.chip.pulse { animation: chip 0.6s ease-out 1; }
@keyframes chip { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

#banner { margin-top: 16px; text-align: center; max-width: min(680px, 100%); padding: 12px 28px; animation: slide 0.3s ease-out; }
#banner h2 { font-size: 28px; line-height: 1.15; color: var(--gold); }
#banner-sub { color: var(--seal); font-size: 16px; text-transform: uppercase; letter-spacing: 0.06em; }
#banner-extra { color: var(--seal); font-weight: 600; margin-top: 4px; }
@keyframes slide { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
/* Insiktskortet: sned etikettflik på en rak textpanel */
#insight { position: absolute; bottom: calc(var(--m) + var(--sb)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 560px)); min-width: 320px;
  border: 3px solid var(--ink); background: rgba(18, 22, 58, 0.96); animation: rise 0.3s ease-out; padding: 12px 16px 10px; }
#insight .ins-head { position: absolute; left: 10px; bottom: calc(100% - 2px); display: flex; gap: 10px; align-items: baseline; font-size: 16px; line-height: 1; padding: 6px 20px 5px; background: var(--seal); color: #12163A;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); white-space: nowrap; }
#insight .lbl { color: #12163A; font-size: inherit; letter-spacing: 0.02em; opacity: 0.75; }
#ins-text { font-size: 20px; }
@keyframes rise { from { transform: translateX(-50%) translateY(16px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* Siktet: fyra hörnvinklar och en punkt. Vid lås roterar vinklarna 45 grader och blir turkosa. */
#cross { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --c: #fff; filter: drop-shadow(0 0 1px rgba(27, 20, 64, 0.9)) drop-shadow(0 0 1px rgba(27, 20, 64, 0.9)); }
#cross .dot { position: absolute; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--c); }
#cross .ring { position: absolute; width: 30px; height: 30px; margin: -15px; transition: transform 0.08s;
  background:
    linear-gradient(var(--c), var(--c)) left top / 9px 3px no-repeat, linear-gradient(var(--c), var(--c)) left top / 3px 9px no-repeat,
    linear-gradient(var(--c), var(--c)) right top / 9px 3px no-repeat, linear-gradient(var(--c), var(--c)) right top / 3px 9px no-repeat,
    linear-gradient(var(--c), var(--c)) left bottom / 9px 3px no-repeat, linear-gradient(var(--c), var(--c)) left bottom / 3px 9px no-repeat,
    linear-gradient(var(--c), var(--c)) right bottom / 9px 3px no-repeat, linear-gradient(var(--c), var(--c)) right bottom / 3px 9px no-repeat; }
#cross.lock { --c: var(--seal); }
#cross.lock .ring { transform: rotate(45deg) scale(0.8); }
#game.golden #cross.lock { --c: var(--gold); }
/* Hotpilen: röd sned bricka med utropstecken */
.arrow { position: absolute; top: 50%; margin-top: -20px; width: 34px; height: 40px; background: var(--danger); border: 3px solid var(--ink); transform: skewX(var(--skew)); box-shadow: 3px 3px 0 var(--ink);
  display: flex; align-items: center; justify-content: center; animation: arrow 0.8s ease-in-out infinite; }
.arrow b { font: 900 24px/1 var(--head); color: #fff; transform: skewX(9deg); }
.arrow.left { left: calc(12px + var(--sl)); }
.arrow.right { right: calc(12px + var(--sr)); }
@keyframes arrow { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
#hint { position: absolute; left: 50%; top: 67%; transform: translateX(-50%); font-weight: 600; text-align: center; max-width: calc(100% - 32px); font-size: 16px; padding: 6px 14px; }
#h-energy { position: absolute; right: calc(var(--m) + var(--sr)); bottom: calc(var(--m) + var(--sb)); min-width: 204px; display: flex; flex-direction: column; gap: 6px; }
#h-energy .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#ticks { display: flex; gap: 3px; }
#ticks i { flex: 1; height: 14px; min-width: 6px; background: #0B0E26; transform: skewX(var(--skew)); }
#ticks i.on { background: var(--seal); }
#game.golden #ticks i.on { background: var(--gold); }
#game.coffee #ticks i.on { background: #C98A5A; }
#reload-bar { height: 14px; }
#reload-fill { background: var(--seal); }
#energy-msg { font-size: 16px; font-weight: 600; }
#floats span { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 22px; color: var(--seal); text-shadow: 0 0 4px #000, 0 1px 2px #000; opacity: 0; will-change: transform, opacity; white-space: nowrap; }
#floats span.gold { color: var(--gold); }
/* Specialmätaren: tre zonfärgade tredjedelar som blir en turkos stapel när den är full */
#h-special { position: absolute; left: calc(var(--m) + var(--sl)); bottom: calc(var(--m) + var(--sb)); display: flex; flex-direction: column; gap: 5px; }
#sp-lbl { font-size: 14px; color: var(--text2); }
.sp-row { display: flex; align-items: center; gap: 10px; }
#sp-bar { position: relative; width: 200px; height: 14px; background: #0B0E26; border: 2px solid var(--ink); overflow: hidden; transform: skewX(var(--skew)); }
#sp-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--orange) 0 33.33%, var(--blue) 33.33% 66.67%, var(--green) 66.67% 100%); background-size: 200px 100%; }
#sp-bar > b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
#sp-key { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--text2); border-color: var(--text2); }
#h-special.full #sp-fill { background: var(--seal); }
#h-special.full #sp-bar > b { display: none; }
#h-special.full #sp-key { color: #12163A; background: var(--seal); border-color: var(--seal); animation: keyp 1.2s ease-in-out infinite; }
#h-special.full #sp-lbl { color: var(--seal); }
#h-special.teach #sp-key { animation: keyp 0.5s ease-in-out infinite; transform-origin: center; }
#h-special.teach { z-index: 2; }
@keyframes keyp { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
#btn-special { position: absolute; right: calc(24px + var(--sr)); bottom: calc(136px + var(--sb)); width: 64px; height: 64px; border-radius: 50%; padding: 0; border: 0; pointer-events: auto; touch-action: manipulation;
  background: rgba(18, 22, 58, 0.7); color: #fff; opacity: 0.4; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
#btn-special i { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--seal) calc(var(--p, 0) * 1turn), rgba(255, 255, 255, 0.35) 0);
  -webkit-mask: radial-gradient(circle, transparent 0 26px, #000 27px); mask: radial-gradient(circle, transparent 0 26px, #000 27px); }
#btn-special svg { width: 34px; height: 34px; position: relative; }
#btn-special.full { opacity: 1; background: var(--seal); color: #12163A; animation: keyp 1.2s ease-in-out infinite; }
#btn-special.full.teach { animation-duration: 0.5s; }
/* Hoppa över bonusbanan */
#btn-skip { position: absolute; left: 50%; bottom: calc(var(--m) + var(--sb)); transform: translateX(-50%); pointer-events: auto; }
#btn-skip-touch { pointer-events: auto; }
#btn-skip-touch { padding: 6px 10px; font-size: 14px; min-height: 44px; }
/* Bonusbanans avslut på dator: insiktsraden ligger ovanför hoppa över-knappen */
@media (min-width: 761px) and (min-height: 501px) {
  #hud.bonus #insight { bottom: calc(var(--m) + var(--sb) + 68px); }
}

#prompt { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; font-size: 22px; font-weight: 700; padding: 16px 24px; border: 2px solid var(--seal); pointer-events: none; text-align: center; }
#count { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 5; width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--seal); border-top-color: transparent; animation: spin 1s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Pekskärm */
#touch { position: absolute; inset: 0; z-index: 3; touch-action: none; }
#joy { position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.5); background: rgba(18, 22, 58, 0.35); pointer-events: none; }
#joy-knob { position: absolute; left: 32px; top: 32px; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, 0.75); }
#btn-fire { position: absolute; right: calc(24px + var(--sr)); bottom: calc(24px + var(--sb)); width: 96px; height: 96px; border-radius: 50%; background: rgba(92, 242, 255, 0.28); border: 3px solid var(--seal); display: flex; align-items: center; justify-content: center; }
#btn-fire i { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--seal); position: relative; }
#btn-fire i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--seal); }
#btn-fire.down { background: rgba(92, 242, 255, 0.6); }

/* Skärmar */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); }
.screen.overlay { background: rgba(18, 22, 58, 0.74); }
/* Ingen scrollbehållare här: fingerdrag över startskärmen ska scrolla värdsidan */
#scr-start { background: rgba(18, 22, 58, 0.42); overflow: visible; }
.col-start { max-width: 640px; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; margin: auto;
  padding: 26px 32px 18px; border-radius: 16px; background: rgba(18, 22, 58, 0.93); border: 3px solid var(--ink); box-shadow: 8px 8px 0 rgba(27, 20, 64, 0.85); }
.st-intro, .st-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.st-actions { gap: 12px; }
#st-heading, #st-sub { text-wrap: balance; }
#st-name { font-size: 50px; line-height: 1.05; color: #fff; display: inline-flex; align-items: center; gap: 10px; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  text-shadow: 4px 4px 0 var(--ink); }
#st-name.gold { color: var(--gold); }
#st-name.sheen { animation: sheen 0.8s ease-out 1; }
@keyframes sheen { 0% { transform: scale(1); filter: brightness(1); } 35% { transform: scale(1.06); filter: brightness(1.7); } 100% { transform: scale(1); filter: brightness(1); } }
#st-star { width: 0.5em; height: 0.5em; color: var(--gold); flex: none; filter: drop-shadow(2px 2px 0 var(--ink)); }
.tagline { color: var(--text2); }
.tagline.code { color: var(--gold); font-weight: 600; }
#st-brand { color: var(--text2); font-size: 15px; margin-top: -4px; }
#st-brand b { color: var(--text); font-weight: 700; letter-spacing: 0.02em; }
#st-heading { font-size: 28px; line-height: 1.2; margin-top: 8px; }
#st-sub { max-width: 30em; }
.start-btns { display: flex; gap: 14px; width: 100%; margin-top: 4px; padding: 0 6px; }
#btn-start { flex: 3 1 0; min-height: 60px; padding: 8px 18px; }
#btn-start svg { width: 28px; height: 28px; }
#btn-start-muted { flex: 2 1 0; min-height: 60px; padding: 8px 14px; font-size: 16px; }
.b-col { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.b-main { display: block; }
.b-sub { display: block; font: 600 14px/1.1 var(--text-font); font-style: normal; text-transform: none; letter-spacing: 0; opacity: 0.85; }
.lb-line { font-size: 16px; color: var(--text2); display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; }
.lb-open { color: var(--text); font-size: 16px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
.lb-open svg { width: 18px; height: 18px; color: var(--gold); flex: none; }
.controls { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ctl-h { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); font-weight: 600; }
.ctl-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 15px; color: var(--text2); }
.ctl-list kbd { font: inherit; font-weight: 700; border: 1px solid var(--text2); border-radius: 4px; padding: 1px 7px; margin-right: 6px; color: var(--text); background: rgba(255, 255, 255, 0.06); }
#lnk-skip { font-size: 16px; padding: 6px 4px; color: var(--text2); }
.showcase { position: absolute; left: calc(var(--m) + var(--sl)); top: calc(var(--m) + var(--st)); display: flex; flex-direction: column; border: 3px solid var(--ink); }
.showcase .val { font-size: 32px; color: var(--gold); }

#scr-brief { align-items: flex-end; pointer-events: auto; }
.brief { width: 720px; max-width: 100%; padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; border: 3px solid var(--ink); background: rgba(18, 22, 58, 0.95); }
#brief-lines p { animation: fadein 0.3s ease-out; color: var(--text2); max-width: 60ch; }
#brief-lines p.cur { color: var(--text); }
#brief-lines p.big { font-size: 24px; line-height: 1.3; }
#brief-controls { align-items: flex-start; }
#brief-controls .ctl-list { justify-content: flex-start; }
#btn-ready { align-self: flex-start; margin-top: 6px; animation: fadein 0.3s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.dialog { width: 760px; max-width: 100%; padding: 24px 28px; margin: auto; display: flex; flex-direction: column; gap: 14px; background: rgba(18, 22, 58, 0.97); border: 3px solid var(--ink); }
.dialog h2 { font-size: 32px; line-height: 1.15; }
#ch-h.right { color: var(--right); }
#ch-h.wrong { color: var(--wrong); }
#ch-situation { font-size: 22px; line-height: 1.35; max-width: 60ch; }
#ch-options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; text-align: left; font: inherit; color: var(--text);
  background: rgba(255, 255, 255, 0.05); border: 2px solid var(--text2); border-radius: 8px; cursor: pointer; touch-action: manipulation; }
.opt:hover:not([disabled]) { background: rgba(255, 255, 255, 0.12); border-color: #fff; }
.opt .num { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.opt[disabled] { cursor: default; opacity: 0.6; }
.opt.chosen { opacity: 1; border-width: 4px; padding: 8px 14px; }
.opt.right { opacity: 1; border-color: var(--right); color: var(--right); }
.opt.wrong { border-color: var(--wrong); color: var(--wrong); }
.opt .mark { margin-left: auto; font-weight: 800; font-size: 22px; flex: none; }
#ch-result { display: flex; flex-direction: column; gap: 10px; animation: fadein 0.3s; }
#ch-explain { max-width: 60ch; }
#ch-upgrade { border-left: 4px solid var(--gold); padding: 6px 12px; background: rgba(255, 210, 63, 0.08); border-radius: 0 6px 6px 0; }
#ch-upgrade.none { border-color: var(--text2); background: rgba(255, 255, 255, 0.04); }
#ch-upgrade strong { color: var(--gold); margin-right: 10px; }
#ch-upgrade .chip { display: inline-block; vertical-align: middle; }
.ch-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; border-top: 1px solid var(--line); padding-top: 12px; }
#ch-blockline { flex: 1 1 260px; font-size: 16px; color: var(--seal); min-height: 1.4em; }
.ch-notes { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#ch-all { font-weight: 700; color: var(--seal); font-size: 16px; }
#ch-special { font-size: 16px; color: var(--gold); font-weight: 600; }
#btn-next { margin-left: auto; min-width: 160px; }
#btn-next:not([disabled]) { color: var(--bg); }
#btn-next:not([disabled])::before { background: var(--text); }

.pause { width: 520px; align-items: center; text-align: center; }
.pause h2 { font-size: 26px; }
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.btn-close { position: absolute; left: calc(12px + var(--sl)); top: calc(12px + var(--st)); width: 44px; height: 44px; z-index: 12; }

/* Slutskärm */
#scr-end { background: rgba(18, 22, 58, 0.96); align-items: stretch; padding: 0; }
/* Kolumnerna centreras var för sig i höjdled, så att högerkolumnen (lärdomar och CTA) aldrig flyttas av det som händer i den vänstra */
.end-grid { width: 100%; max-width: 1100px; margin: 0 auto; min-height: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding: 20px 28px; align-items: center; }
.end-left, .end-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#end-h { font-size: 32px; line-height: 1.1; }
#end-title { font-size: 20px; margin-top: 4px; }
#end-title b { color: var(--gold); font-size: 22px; }
#end-titleline { color: var(--text2); }
#end-stats { margin: 4px 0 2px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; }
#end-stats li { min-width: 0; }
#end-stats b { font-weight: 700; }
#end-stats .award { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; line-height: 1; padding: 4px 8px; margin: 1px 6px 1px 0; border-radius: 4px; background: rgba(255, 210, 63, 0.14); border: 1px solid rgba(255, 210, 63, 0.6); color: var(--gold); white-space: nowrap; }
#end-stats .award svg { width: 13px; height: 13px; }
#end-buttons { justify-content: flex-start; margin-top: 2px; padding-left: 6px; }
#end-copied { color: var(--seal); font-size: 16px; }
#end-sumh { font-size: 22px; line-height: 1.2; }
#end-summary { counter-reset: s; display: flex; flex-direction: column; gap: 4px; }
#end-summary li { counter-increment: s; position: relative; padding-left: 1.6em; line-height: 1.3; opacity: 0; animation: fadein 0.3s forwards; }
#end-summary li::before { content: counter(s) "."; position: absolute; left: 0; color: var(--seal); font-weight: 700; }
.cta { margin: 0 0 12px; padding: 14px 18px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); border: 2px solid var(--accent); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.cta h3 { font-size: 22px; line-height: 1.2; }
.cta .btn { margin-top: 6px; margin-left: 5px; }
.brand-mark { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; margin-bottom: 4px; }
/* Ordbilden: tecknet i accentfärgen följt av namnet i versaler. Rak stil, vikt 700, tät spärrning. */
.wordmark { font-family: var(--head); font-weight: 700; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: -0.01em; text-transform: uppercase; color: #fff; white-space: nowrap; }
.wm-mark { color: var(--accent); }
a.brand-mark[href]:hover { color: var(--text); }
.brand-mark img { height: 26px; width: auto; max-width: 180px; display: block; }
.anim { opacity: 0; animation: fadein 0.4s forwards; }
.a1 { animation-delay: 0.4s; } .a2 { animation-delay: 0.8s; }
.a4 { animation: ctain 0.5s 1.2s forwards; }
.a4 .btn { animation: pulse 0.6s 1.7s 1; }
@keyframes ctain { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.07); } 100% { transform: scale(1); } }
#scr-end.instant .anim, #scr-end.instant #end-summary li { animation: none !important; opacity: 1; }
#scr-end.instant .a4 .btn { animation: none; }

/* Topplisteremsan i slutskärmens vänsterkolumn */
#lb-strip { margin-top: 4px; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
#lb-form, #lb-saved { display: flex; flex-direction: column; gap: 6px; }
#nick-prompt { font-size: 15px; font-weight: 600; }
.nick-row { display: flex; gap: 14px; align-items: stretch; padding-right: 6px; }
#nick-input { flex: 1 1 0; min-width: 0; height: 48px; padding: 0 12px; font: inherit; font-size: 18px; color: var(--text); background: #0B0E26; border: 2px solid var(--text2); border-radius: 6px; }
#nick-input::placeholder { color: #8891BD; }
#nick-input:focus { border-color: var(--seal); outline: none; }
#nick-save { flex: none; min-height: 48px; padding: 8px 18px; font-size: 15px; }
#nick-help { font-size: 14px; color: var(--text2); display: none; }
#lb-form:focus-within #nick-help { display: block; }
#nick-error { font-size: 15px; color: var(--wrong); font-weight: 600; }
#nick-privacy { font-size: 14px; color: var(--text2); }
#lb-status { font-weight: 700; color: var(--gold); font-size: 17px; }
#lb-note { font-size: 14px; color: var(--text2); }
#lb-saved .lb-open { align-self: flex-start; font-size: 15px; padding: 0; }
#lb-gap { font-weight: 700; color: var(--seal); font-size: 17px; }
#lb-open-summary { align-self: flex-start; }
/* Listrader (remsa och panel). Namn sätts alltid med textContent. */
.lb-rows { display: flex; flex-direction: column; }
.lb-rows li, .lb-cols { display: grid; grid-template-columns: 54px minmax(0, 1fr) minmax(0, 150px) 84px; gap: 10px; align-items: center; height: 36px; padding: 0 10px; font-size: 16px; }
.lb-rows li { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.lb-rows li > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-rows .r { color: var(--text2); font-weight: 700; }
.lb-rows .n { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.lb-rows .n i { overflow: hidden; text-overflow: ellipsis; font-style: normal; }
.lb-rows .t { color: var(--text2); font-size: 14px; }
.lb-rows .s { text-align: right; font-weight: 700; }
.lb-rows li.you { background: rgba(92, 242, 255, 0.16); border-radius: 4px; border-top-color: transparent; }
.lb-rows li.sep { margin-top: 6px; border-top: 2px solid var(--text2); border-radius: 0 0 4px 4px; }
.lb-rows .tag { flex: none; font-size: 14px; font-weight: 800; line-height: 1; padding: 3px 6px; border-radius: 3px; background: var(--seal); color: #12163A; text-transform: uppercase; letter-spacing: 0.04em; }
#lb-around li { height: 30px; font-size: 15px; grid-template-columns: 34px minmax(0, 1fr) 84px; }
#lb-around .t { display: none; }
.lb-cols { height: 26px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); }
.lb-cols span:last-child { text-align: right; }
/* Topplistepanelen */
#lb-panel { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; overflow-y: auto; background: rgba(18, 22, 58, 0.8);
  padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); }
.lb-dialog { width: 520px; padding: 18px 20px; gap: 6px; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.lb-dialog h2 { font-size: 22px; }
#lb-close { flex: none; width: 44px; height: 44px; }
#lb-offline { font-size: 15px; color: var(--gold); padding: 6px 10px; border-radius: 6px; background: rgba(255, 210, 63, 0.1); }
#lb-empty { padding: 28px 10px; text-align: center; color: var(--text2); }
#lb-start { align-self: center; margin-top: 12px; }
/* Från slutskärmen på dator: panelen ligger över vänsterkolumnen, högerkolumnen med CTA:n syns hela tiden */
@media (min-width: 900px) {
  #lb-panel.over-left { right: 50%; background: #12163A; padding-right: 14px; justify-content: flex-end; }
  #lb-panel.over-left .lb-dialog { width: min(520px, 100%); margin: auto 0 auto auto; border: 0; background: none; padding: 12px 0 12px 12px; }
}
@media (max-width: 899px) {
  #lb-panel.with-cta { bottom: var(--cta-h, 0px); background: #12163A; align-items: flex-start; }
}
@media (max-width: 599px) {
  .lb-rows li, .lb-cols { grid-template-columns: 50px minmax(0, 1fr) 80px; }
  .lb-rows .t, .lb-cols .c-title { display: none; }
  .lb-dialog { padding: 14px 12px; }
}
@media (max-height: 560px) {
  .lb-rows li { height: 30px; font-size: 15px; }
  .lb-dialog { padding-top: 10px; padding-bottom: 10px; }
  .lb-dialog h2 { font-size: 22px; }
  #lb-start { margin-top: 6px; min-height: 44px; }
  #lb-empty { padding: 12px 10px; }
}

#debug { position: absolute; left: 4px; bottom: 4px; z-index: 30; margin: 0; padding: 4px 6px; font: 12px/1.3 monospace; color: #9f9; background: rgba(0, 0, 0, 0.7); pointer-events: none; white-space: pre; }

/* Under 1500 px visas byggstenarna med två bokstäver så att de ryms bredvid mittraden */
@media (max-width: 1499px) {
  #h-blocks .chip .full { display: none; }
  #h-blocks .chip .short { display: inline; }
}
/* Smalare än 1200 px: byggstenarna på egen rad under poängen, kombon under dem */
@media (max-width: 1199px) {
  #hud-top { grid-template-areas: "arr wave score" ". . blocks"; }
  #h-right { display: contents; }
  #h-score { grid-area: score; justify-self: end; }
  #h-blocks { grid-area: blocks; justify-self: end; flex-direction: row; align-items: center; gap: 10px; }
  #combo { grid-row: 3; }
  /* Meddelanderaden delar rad med byggstenarna: den får de två vänstra kolumnerna */
  #h-mid { grid-column: 1 / 3; max-width: 100%; }
  #arr-bar { width: 150px; }
  #sp-bar { width: 150px; }
  #sp-fill { background-size: 150px 100%; }
  #insight { width: min(520px, calc(100% - 520px)); }
}

/* Slutskärm i en kolumn, CTA fast i nederkant */
@media (max-width: 899px) {
  #scr-end { display: block; padding: 0; }
  .end-grid { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: calc(16px + var(--st)) calc(16px + var(--sr)) 190px calc(16px + var(--sl)); }
  .end-left, .end-right { display: contents; }
  #end-h { order: 1; } #end-text { order: 2; } #end-result { order: 3; } #lb-strip { order: 4; } #end-sumh { order: 5; } #end-summary { order: 6; } #lb-gap { order: 7; } #lb-open-summary { order: 7; } #end-buttons { order: 8; } #end-copied { order: 9; }
  #scr-end.has-close #end-h { margin-top: 48px; }
  .cta { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; border: 0; border-top: 3px solid var(--accent); background: #171B47; z-index: 11;
    padding: 10px calc(16px + var(--sr)) calc(10px + var(--sb)) calc(16px + var(--sl)); align-items: stretch; text-align: center; }
  .cta h3 { font-size: 20px; }
  .cta p { font-size: 16px; }
  .cta .btn { margin-left: 6px; margin-right: 6px; }
  .brand-mark { justify-content: center; font-size: 14px; }
  .brand-mark img { height: 20px; }
}
@media (max-width: 899px) and (max-height: 400px) {
  #cta-support, .cta .brand-mark { display: none; }
  .end-grid { padding-bottom: 130px; }
}

/* Kompakt HUD: mobil */
@media (max-width: 760px), (max-height: 500px) {
  :root { --m: 8px; --body: 16px; --val: 18px; --h: 26px; }
  .panel { padding: 6px 8px; }
  #h-arr, #h-wave, #h-score, #h-blocks, #msg, #boss, #h-energy, #banner { padding: 6px 12px; }
  #h-arr::before, #h-wave::before, #h-score::before, #h-blocks::before, #msg::before, #boss::before, #h-energy::before, #banner::before { border-width: 2px; box-shadow: 3px 3px 0 var(--ink); }
  #hud-top { gap: 8px 10px; padding: 0 2px; }
  #h-arr { column-gap: 8px; }
  #arr-bar { width: 96px; height: 16px; border-width: 2px; }
  #h-wave { min-width: 0; }
  #h-score { gap: 8px; }
  .icon-btn { width: 44px; height: 44px; }
  #btn-sound-hud { display: none; }
  #h-mid { max-width: 100%; }
  .chip .full { display: none; }
  .chip .short { display: inline; }
  .chip { padding: 5px 6px; }
  #h-blocks { gap: 6px; }
  #banner { margin-top: 8px; padding: 8px 16px; }
  #banner h2 { font-size: 21px; }
  #banner-sub { font-size: 14px; }
  #insight { position: static; transform: none; width: auto; min-width: 0; max-width: min(440px, 62%); margin-top: 30px; animation: fadein 0.3s; padding: 8px 10px 6px; position: relative; left: auto; bottom: auto; }
  #insight .ins-head { font-size: 14px; padding: 5px 16px 4px; }
  #ins-text { font-size: 17px; line-height: 1.3; }
  #h-special { display: none; }
  #h-energy { right: calc(132px + var(--sr)); bottom: calc(24px + var(--sb)); min-width: 0; width: 96px; padding: 4px 8px; gap: 3px; }
  #h-energy .row { flex-direction: column; align-items: center; gap: 0; }
  #ticks { display: none; }
  #energy-msg { font-size: 14px; text-align: center; line-height: 1.2; }
  #boss { bottom: calc(12px + var(--sb)); }
  #boss-bar { width: clamp(120px, 26vw, 260px); }
  #combo-n { font-size: 24px; }
  #st-name { font-size: 30px; text-shadow: 3px 3px 0 var(--ink); }
  .col-start { gap: 8px; padding: 14px 16px 10px; }
  .st-intro { gap: 4px; }
  .st-actions { gap: 8px; }
  #st-heading { margin-top: 4px; font-size: 22px; }
  #st-brand { margin-top: 0; font-size: 14px; }
  .ctl-list { font-size: 14px; gap: 4px 12px; }
  .showcase .val { font-size: 22px; }
  .brief { padding: 14px 16px; min-height: 0; }
  #brief-lines p.big { font-size: 19px; }
  .dialog { padding: 16px; gap: 10px; }
  .dialog h2 { font-size: 24px; }
  #ch-situation { font-size: 18px; }
  #ch-blockline, #ch-special { font-size: 14px; }
  #prompt { font-size: 18px; }
  #msg { font-size: 15px; }
  #end-h { font-size: 26px; }
}
/* Pekläge: specialknappen ersätter mätaren, hoppa över-knappen tar pausknappens plats */
#game:not(.touch) #btn-special, #game:not(.touch) #btn-skip-touch { display: none !important; }
#game.touch #h-special, #game.touch #btn-skip { display: none !important; }
#game.touch #h-energy { right: calc(132px + var(--sr)); bottom: calc(24px + var(--sb)); }

/* Smala skärmar: startknapparna under varandra */
@media (max-width: 599px) {
  .start-btns { flex-direction: column; gap: 8px; }
  #btn-start { min-height: 56px; flex: none; justify-content: center; }
  #btn-start-muted { min-height: 44px; flex: none; }
  .lb-line, .lb-open { font-size: 15px; }
}
/* Stående mobil: ARR och poäng på första raden, våg och kombo på andra, byggstenar på tredje */
@media (max-width: 600px) and (orientation: portrait) {
  #hud-top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "arr score" "wave wave" "blocks blocks"; }
  #h-right { display: contents; }
  #h-score { grid-area: score; justify-self: end; }
  #h-blocks { grid-area: blocks; justify-self: start; flex-direction: column; align-items: flex-start; gap: 4px; }
  #h-arr { justify-self: stretch; grid-template-columns: minmax(40px, 1fr) auto auto; }
  #arr-bar { width: auto; }
  #arr-val { min-width: 0; }
  #h-wave { justify-self: start; align-items: baseline; flex-direction: row; gap: 8px; max-width: calc(100% - 84px); }
  #wave-name { font-size: 17px; white-space: normal; line-height: 1.1; }
  #combo { grid-column: 2; grid-row: 2; height: auto; align-self: center; }
  #blocks { gap: 4px; }
  #h-mid { grid-row: 4; }
  #insight { max-width: 100%; margin-top: calc(4vh + 24px); }
  #scr-start { align-items: flex-start; }
  .col-start { padding: 56px 10px 10px; border: 0; box-shadow: 0 0 24px 16px rgba(18, 22, 58, 0.93); border-radius: 0; background: rgba(18, 22, 58, 0.9); }
  /* Silons mätare ovanför specialknappen */
  #boss { left: calc(12px + var(--sl)); transform: none; bottom: calc(214px + var(--sb)); }
  #boss-bar { width: 44vw; }
  /* Bonusbanan: ARR får hela första raden (värde och procentsats ska rymmas), byggstenarna behövs inte här */
  #hud.bonus #hud-top { grid-template-areas: "arr arr" "wave score"; }
  #hud.bonus #h-blocks { display: none; }
  #hud.bonus #combo { grid-row: 3; }
  #hud.bonus #h-wave { max-width: 100%; align-self: center; }
}
/* Liggande mobil */
@media (max-height: 500px) and (orientation: landscape) {
  #hud-top { grid-template-areas: "arr wave score" ". . blocks"; }
  #h-mid { grid-column: 1 / 3; justify-self: start; max-width: calc(100vw - 470px); }
  #insight { position: absolute; left: calc(10px + var(--sl)); top: calc(124px + var(--st)); width: 41%; max-width: 41%; margin: 0; bottom: auto; }
  /* Silons mätare nere till vänster, så att den inte krockar med energin bredvid skjutknappen */
  #boss { left: calc(14px + var(--sl)); transform: none; }
  #ins-text { font-size: 16px; }
  #banner { align-self: flex-end; margin-right: 116px; max-width: 50%; }
  #h-wave { flex-direction: row; gap: 8px; align-items: baseline; }
  #h-blocks { flex-direction: row; align-items: center; gap: 8px; }
  /* Startskärmen i två kolumner: text till vänster, val till höger */
  .col-start { max-width: 820px; flex-direction: row; align-items: center; gap: 20px; text-align: left; padding: 12px 18px; }
  .st-intro { flex: 58 1 0; align-items: flex-start; }
  .st-actions { flex: 42 1 0; align-items: stretch; }
  .st-actions .controls { display: none; }
  .start-btns { flex-direction: column; gap: 8px; padding: 0 6px; margin-top: 0; }
  #btn-start { min-height: 52px; flex: none; }
  #btn-start-muted { min-height: 44px; flex: none; }
  .lb-line { justify-content: flex-start; font-size: 14px; }
  #lnk-skip { padding: 2px 0; font-size: 14px; }
  #st-name { font-size: 26px; }
  #st-heading { font-size: 20px; text-wrap: wrap; }
  #st-sub { max-width: none; font-size: 15px; text-wrap: wrap; }
  .showcase { display: none; }
  .pause { gap: 8px; }
  .pause h2 { font-size: 20px; }
}

/* Smal stående skärm (360 x 640): kontrollraden flyttas till briefingen så att allt ryms */
@media (max-width: 380px) and (max-height: 680px) and (orientation: portrait) {
  .st-actions .controls { display: none; }
}
/* Liten liggande skärm (640 x 360): vågens namn utan etikett och kortare ARR-stapel, så att toppraden ryms */
@media (max-height: 500px) and (max-width: 700px) and (orientation: landscape) {
  #hud:not(.bonus) #wave-n { display: none; }
  #arr-bar { width: 60px; }
  #blocks-lbl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #vignette { box-shadow: none; border: 4px solid var(--danger); }
  #vignette.low { animation: none; opacity: 1; }
  #banner, #insight { animation: fadein 0.3s; }
  .arrow, .chip.pulse, #count, #score-val.bump, #arr-over, #h-special.full #sp-key, #h-special.teach #sp-key, #btn-special.full, #combo.c20 #combo-n, #st-name.sheen { animation: none; }
  .anim, #end-summary li { animation: none !important; opacity: 1 !important; }
  .a4 .btn { animation: none; }
  #cross .ring { transition: none; }
  #cross.lock .ring { transform: none; }
}
/* CONFIG.calmEffects ger samma lugna läge */
#game.calm #vignette.low { animation: none; opacity: 1; }
#game.calm .arrow, #game.calm .chip.pulse, #game.calm #score-val.bump, #game.calm #arr-over, #game.calm #h-special.full #sp-key, #game.calm #h-special.teach #sp-key,
#game.calm #btn-special.full, #game.calm #combo.c20 #combo-n, #game.calm #st-name.sheen { animation: none; }
#game.calm #banner, #game.calm #insight { animation: fadein 0.3s; }
#game.calm #cross .ring { transition: none; }
#game.calm #cross.lock .ring { transform: none; }
#game.calm .a4 .btn { animation: none; }

/* Skyltfönstrets ARR-ruta får inte krocka med startkolumnen */
@media (min-width: 761px) and (max-width: 1039px) { .showcase { display: none; } }
/* Låg startskärm på bred yta (till exempel inbäddad 960 x 540): tätare, så att allt ryms */
@media (max-height: 620px) and (min-width: 761px) and (min-height: 501px) {
  .col-start { gap: 8px; padding: 14px 28px 10px; }
  .st-intro { gap: 5px; }
  .st-actions { gap: 7px; }
  #st-name { font-size: 40px; }
  #st-heading { font-size: 24px; margin-top: 4px; }
  #st-sub { font-size: 16px; }
  #btn-start, #btn-start-muted { min-height: 54px; }
  .ctl-list { font-size: 14px; gap: 4px 14px; }
  .lb-line, .lb-open, #lnk-skip { font-size: 15px; }
  #lnk-skip { padding: 2px 4px; }
  .controls { gap: 4px; }
}

/* Låga skärmar: vägvalet och slutskärmen ska rymmas utan scroll */
@media (max-height: 620px) and (min-width: 761px) {
  .dialog { padding: 12px 22px; gap: 7px; }
  .dialog h2 { font-size: 24px; }
  #ch-situation { font-size: 19px; line-height: 1.25; }
  #ch-options { gap: 6px; }
  .opt { min-height: 46px; padding: 6px 14px; font-size: 17px; line-height: 1.25; }
  .opt.chosen { padding: 4px 12px; }
  #ch-result { gap: 5px; }
  #ch-explain { font-size: 16px; line-height: 1.3; }
  #ch-upgrade { padding: 3px 12px; font-size: 16px; }
  .ch-foot { padding-top: 6px; gap: 4px 12px; }
  #ch-blockline, #ch-special, #ch-all { font-size: 15px; }
  #btn-next { min-height: 44px; }
}
@media (min-width: 900px) and (max-height: 620px) {
  .end-grid { padding: 10px 24px; gap: 24px; }
  .end-left, .end-right { gap: 5px; }
  #end-h { font-size: 26px; }
  #end-text, #end-titleline { font-size: 16px; line-height: 1.3; }
  #end-title { margin-top: 0; }
  #end-stats { font-size: 16px; margin: 2px 0; }
  #lb-strip { padding: 7px 10px; margin-top: 2px; }
  #lb-form, #lb-saved { gap: 4px; }
  #nick-input, #nick-save { height: 44px; min-height: 44px; }
  #lb-gap { font-size: 16px; }
  #end-buttons .btn { min-height: 44px; }
  #end-summary { font-size: 16px; }
}

/* Liten stående yta (mobil i iframe före helskärm): allt på startskärmen ska rymmas */
@media (max-height: 560px) and (orientation: portrait) {
  #scr-start { padding: 6px 12px; }
  .col-start { padding: 44px 4px 4px; gap: 5px; }
  .st-actions { gap: 5px; }
  .showcase { display: none; }
  #st-name { font-size: 26px; }
  #st-heading { font-size: 20px; margin-top: 2px; }
  #st-sub { font-size: 15px; line-height: 1.3; }
  .st-actions .controls { display: none; }
  #btn-start { min-height: 52px; }
  #lnk-skip { padding: 2px; }
  /* HUD på samma lilla yta: byggstenarna utan etikett, insiktskortet högre upp */
  #blocks-lbl { display: none; }
  #insight { margin-top: 26px; }
  #hint { top: 50%; }
}

/* Språkväljare (specens 1.1): uppe till höger på startskärmen, slutskärmen och i läsläget */
.lang-switch { position: absolute; right: calc(var(--m) + var(--sr)); top: calc(var(--m) + var(--st)); z-index: 12; display: flex; }
.lang-switch button {
  position: relative; height: 36px; min-width: 44px; padding: 0 14px; font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  color: #FFFFFF; background: rgba(18, 22, 58, 0.7); border: 2px solid #FFFFFF; cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.lang-switch button::before { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; }   /* träffyta 44 px */
.lang-switch button:first-child { border-radius: 8px 0 0 8px; }
.lang-switch button:last-child { border-radius: 0 8px 8px 0; }
.lang-switch button + button { border-left-width: 0; }
.lang-switch button[aria-checked="true"] { background: #FFFFFF; color: #12163A; cursor: default; }
.lang-switch button:focus-visible { z-index: 1; }
/* Slutskärmen: väljaren ligger uppe till höger i vänsterkolumnen, inte över CTA:n */
#scr-end .lang-switch { top: calc(12px + var(--st)); right: calc(16px + var(--sr)); }
@media (min-width: 900px) {
  #scr-end .lang-switch { position: static; align-self: flex-end; margin-bottom: -4px; }
}
@media (max-width: 899px) {
  /* Slutskärm i en kolumn: rubriken får inte hamna under väljaren */
  #scr-end.has-lang #end-h { margin-top: 44px; }
}
@media (max-width: 760px), (max-height: 500px) {
  .lang-switch button { padding: 0 10px; font-size: 14px; }
}

/* ================= Revidering 3 (efter granskningarna) ================= */

/* Startskärmen: en diskret styrrad i stället för hela kontrollistan (den finns i briefingen och i pausen) */
#st-ctl { font-size: 14px; color: var(--text2); opacity: 0.9; }
#lnk-skip { white-space: normal; }

/* Byggstenar i HUD:en: egen rad under poängen, med hela namnen. Förtjänad = fylld, lånad = streckad och räknas inte. */
#hud-top { grid-template-areas: "arr wave score" ". . blocks"; }
#h-right { display: contents; }
#h-score { grid-area: score; justify-self: end; }
#h-blocks { grid-area: blocks; justify-self: end; flex-direction: row; align-items: center; gap: 10px; }
#h-blocks .chip .full { display: inline; }
#h-blocks .chip .short { display: none; }
#combo { grid-row: 3; }
/* Meddelanderaden ligger under byggstenarna, mitt i bild, så att de aldrig krockar */
#h-mid { grid-column: 1 / -1; grid-row: 3; max-width: min(620px, 100%); }
/* Insiktskortet lite till vänster om mitten, så att vapnet (nere till höger) aldrig ligger över det */
@media (min-width: 761px) and (min-height: 501px) { #game:not(.touch) #insight { left: 45%; } }
.chip.lent { border-style: dashed; border-color: var(--gold); color: var(--gold); background: none; font-weight: 600; }
.chip.lent::before { content: none; }
.pa-blocks { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pa-blocks .blocks { justify-content: center; }
#end-stats li.lent { color: var(--gold); font-size: 15px; }

/* Vägval */
#ch-options .opt { transition: opacity 0.15s; }
#ch-options.arming .opt { opacity: 0.45; pointer-events: none; }
#ch-blockline { display: flex; flex-direction: column; gap: 2px; }
#ch-blockline.lent { color: var(--gold); }
.ch-next { display: flex; justify-content: flex-end; margin-top: -4px; }
#btn-next { margin-left: 0; }
/* Pekskärm: vägvalet ligger aldrig under skjutknappens yta (nere till höger). Ett sent tryck där träffar ingenting. */
@media (orientation: portrait) {
  #game.touch #scr-choice { bottom: calc(132px + var(--sb)); box-shadow: 0 200px 0 rgba(18, 22, 58, 0.74); }
}
@media (orientation: landscape) {
  #game.touch #scr-choice { right: calc(136px + var(--sr)); box-shadow: 200px 0 0 rgba(18, 22, 58, 0.74); }
}

/* Slutskärmen: språkväljaren uppe till höger, CTA-kortet överst i högerkolumnen */
#scr-end .lang-switch { position: absolute; top: calc(12px + var(--st)); right: calc(16px + var(--sr)); margin: 0; }
@media (min-width: 900px) {
  #scr-end .lang-switch { position: absolute; align-self: auto; margin: 0; }
  #scr-end.has-lang .end-grid { padding-top: 56px; }
  .cta .btn { align-self: flex-start; }
  /* Läsläget: en samlad kolumn i mitten i stället för en ensam rubrik till vänster */
  #scr-end.summary-only .end-grid { grid-template-columns: minmax(0, 1fr); max-width: 760px; align-content: center; gap: 16px; }
  #scr-end.summary-only .end-left, #scr-end.summary-only .end-right { display: contents; }
  #scr-end.summary-only #end-h { order: 1; font-size: 38px; }
  #scr-end.summary-only #end-summary { order: 2; font-size: 20px; gap: 8px; }
  #scr-end.summary-only .cta { order: 3; margin: 6px 0 0; }
  #scr-end.summary-only #lb-open-summary { order: 4; }
  #scr-end.summary-only #end-buttons { order: 5; }
}
.cta-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (max-width: 899px) {
  .cta { margin: 0; }
  .wordmark { font-size: 18px; }
}
/* Liggande mobil: CTA-remsan är en enda rad (högst en femtedel av höjden), så att resultatet syns */
@media (max-width: 899px) and (max-height: 500px) {
  .cta { flex-direction: row; align-items: center; gap: 12px; text-align: left; border-top-width: 2px;
    padding: 6px calc(16px + var(--sr)) calc(6px + var(--sb)) calc(16px + var(--sl)); }
  .cta-text { flex: 1 1 auto; }
  .cta h3 { font-size: 16px; line-height: 1.15; }
  #cta-support, .cta .brand-mark { display: none; }
  .cta .btn { flex: none; margin: 0 6px; min-height: 44px; font-size: 15px; padding: 6px 16px; }
  .end-grid { padding-bottom: 76px; }
}
/* Smal skärm: namnfältet på egen rad, så att platshållaren ryms */
@media (max-width: 420px) {
  .nick-row { flex-direction: column; gap: 8px; padding-right: 0; }
  #nick-input { flex: none; width: 100%; }
  #nick-save { align-self: stretch; margin: 0 6px; }
}

/* Hoppa över bonusbanan: tätare bakgrund, så att texten syns också mot ljus himmel */
#btn-skip::before, #btn-skip-touch::before { background: rgba(18, 22, 58, 0.9); }

/* Pekskärm oavsett storlek: 44 px knappar, Silons mätare nere till vänster (energin ligger bredvid skjutknappen),
   insiktskortet i nederkant mellan mätaren och energin */
#game.touch .icon-btn { width: 44px; height: 44px; }
#game.touch #boss { left: calc(var(--m) + var(--sl)); transform: none; }
#game.touch #insight { left: calc(var(--m) + var(--sl)); right: calc(250px + var(--sr)); bottom: calc(var(--m) + var(--sb) + 52px); top: auto; width: auto; min-width: 0; max-width: none; margin: 0; transform: none; animation: fadein 0.3s; }

/* Kompakt HUD (mobil): byggstensraden dold under strid (den visas i pausen och vid vägvalen),
   insiktskortet i nederkant som på dator, ovanför pekkontrollerna och aldrig över siktet eller skarven */
@media (max-width: 760px), (max-height: 500px) {
  #h-blocks { display: none !important; }
  #h-mid { grid-column: 1 / -1; max-width: 100%; }
  #boss { left: calc(14px + var(--sl)); transform: none; bottom: calc(12px + var(--sb)); }
  #insight, #game.touch #insight { position: absolute; left: calc(10px + var(--sl)); right: calc(244px + var(--sr)); bottom: calc(58px + var(--sb)); top: auto;
    width: auto; min-width: 0; max-width: none; margin: 0; transform: none; animation: fadein 0.3s; }
  #hint { top: 62%; }
}
@media (max-width: 600px) and (orientation: portrait) {
  #hud-top { grid-template-areas: "arr score" "wave wave"; }
  #h-mid { grid-row: 3; }
  #insight, #game.touch #insight { left: calc(8px + var(--sl)); right: calc(100px + var(--sr)); bottom: calc(134px + var(--sb)); margin: 0; max-width: none; }
  #boss, #game.touch #boss { left: calc(10px + var(--sl)); bottom: calc(86px + var(--sb)); }
  #boss-bar { width: 32vw; }
  #hint { top: 60%; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #hud-top { grid-template-areas: "arr wave score"; }
  #h-mid { grid-column: 1 / 3; justify-self: start; }
  #insight, #game.touch #insight { left: calc(14px + var(--sl)); right: calc(250px + var(--sr)); bottom: calc(54px + var(--sb)); top: auto; width: auto; max-width: none; }
  /* Banderollen är en enda rad i liggande läge, mitt under toppraden */
  #banner { align-self: center; margin: 6px 0 0; max-width: 72%; padding: 5px 16px; }
  #banner h2 { font-size: 19px; white-space: nowrap; }
  #banner-sub, #banner-line, #banner-extra { display: none !important; }
  #banner-title[hidden] ~ #banner-line { display: block !important; font-size: 15px; font-weight: 600; }
  /* Briefingen: bara aktuell rad, så att panelen inte täcker världen */
  .brief { width: 560px; padding: 10px 14px; gap: 6px; }
  #brief-lines p:not(.cur):not(.big) { display: none; }
  #brief-lines p.big:not(.cur) { font-size: 15px; line-height: 1.25; }
  #brief-lines p.big { font-size: 17px; }
  #brief-controls .ctl-list { font-size: 13px; gap: 2px 10px; }
  #btn-ready { min-height: 44px; margin-top: 2px; }
  #st-ctl { display: none; }
}
/* Små skärmar: efter svaret visas bara det valda alternativet och det rätta, och Vidare ligger fast i nederkant */
@media (max-width: 760px), (max-height: 500px) {
  #ch-options.answered .opt:not(.chosen):not(.right) { display: none; }
  #ch-options.answered .opt { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  .ch-next { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 8px 22px 12px; background: #12163A; border-top: 1px solid var(--line); z-index: 2; }
  .ch-next:has(#btn-next[hidden]) { display: none; }
  #btn-next { flex: 1 1 auto; min-height: 48px; }
  .ch-foot { padding-top: 8px; }
  #ch-explain { font-size: 15px; line-height: 1.35; }
  #ch-upgrade { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { #ch-options.arming .opt { animation: none; } }
#game.calm #ch-options.arming .opt { animation: none; }
#btn-ready.busy { opacity: 0.7; cursor: progress; }
/* Låg skärm: när svaret är givet behövs inte frågan längre, så att förklaringen och Vidare ryms */
@media (max-height: 500px) { #scr-choice.answered #ch-situation { display: none; } }
/* Pekskärm som inte är kompakt (surfplatta): energipanelen är bred, så insiktskortet slutar till vänster om den */
@media (min-width: 761px) and (min-height: 501px) { #game.touch #insight { right: calc(352px + var(--sr)); } }
/* Små skärmar: vägvalet ryms utan rullning. Byggstensraden visas först när svaret är givet. */
@media (max-width: 760px), (max-height: 500px) {
  #scr-choice:not(.answered) .ch-foot { display: none; }
}
@media (max-width: 400px) {
  .choice { padding: 12px; gap: 8px; }
  #ch-situation { font-size: 16px; line-height: 1.3; }
  .opt { min-height: 48px; padding: 6px 10px; gap: 10px; font-size: 15px; line-height: 1.3; }
  .opt.chosen { padding: 4px 8px; }
  .opt .num { width: 26px; height: 26px; font-size: 14px; }
}
@media (max-height: 500px) {
  #scr-choice { padding-top: calc(8px + var(--st)); padding-bottom: calc(8px + var(--sb)); }
  .choice { padding: 10px 14px; gap: 6px; }
  .choice h2 { font-size: 18px; }
  #ch-situation { font-size: 15px; line-height: 1.3; }
  #ch-options { gap: 6px; }
  .opt { min-height: 44px; padding: 4px 12px; font-size: 15px; line-height: 1.25; }
  .opt.chosen { padding: 2px 10px; }
  .opt .num { width: 24px; height: 24px; font-size: 13px; }
  .ch-next { bottom: -10px; margin: 0 -14px -10px; padding: 6px 20px 8px; }
  #btn-next { min-height: 44px; }
}
/* Låg stående skärm (360 x 640): CTA-remsan utan stödrad, så att resultatet får plats */
@media (max-width: 899px) and (max-height: 700px) { #cta-support { display: none; } }
/* Smal men inte kompakt bredd (surfplatta stående): kortare ARR-stapel, så att ARR och vågrutan inte går i varandra */
@media (min-width: 761px) and (max-width: 899px) { #arr-bar { width: 96px; } #arr-val { min-width: 0; } #h-wave { min-width: 0; } }

/* ================= Revidering 4 (efter granskning 2) ================= */
/* Byggstenarna: i översta HUD-raden mellan vågrutan och poängen från 1100 px (hela namn och rubriken Byggstenar n/4, se revidering 6 längre ner).
   Smalare än så är de dolda under strid, som på telefon (de visas i pausen och vid vägvalen).
   Andra raden är därmed fri, så att varumärkets banderoll i världen aldrig täcks. */
@media (min-width: 1100px) and (min-height: 501px) {
  #hud-top { grid-template-areas: "arr wave score"; }
  #h-right { display: flex; grid-area: score; justify-self: end; gap: 12px; align-items: stretch; }
  #h-score, #h-blocks { grid-area: auto; justify-self: auto; }
  #blocks-lbl { display: none; }
  #h-blocks { padding-left: 12px; padding-right: 12px; }
}
/* Ingen bock i HUD:en: fylld bricka = förtjänad, streckad = lånad, tom kontur = inte tagen. */
#h-blocks .chip { font-size: 12px; padding: 5px 6px; }
#h-blocks .chip.on::before { content: none; }
@media (min-width: 1100px) { #h-wave { min-width: 150px; } }
@media (max-width: 1099px) { #h-blocks { display: none !important; } }
/* Meddelanderaden: till vänster under ARR-rutan, så att mitten av andra raden (där banderollen syns) är fri */
#h-mid { grid-column: 1; grid-row: 2; justify-self: start; align-items: flex-start; max-width: min(340px, 25vw); }
#msg { text-align: left; }
#combo { grid-row: 2; }
@media (max-width: 760px), (max-height: 500px) {
  #h-mid { grid-column: 1 / -1; max-width: 100%; }
}
@media (max-width: 600px) and (orientation: portrait) { #h-mid { grid-row: 3; justify-self: start; } #combo { grid-row: 2; } }
@media (max-height: 500px) and (orientation: landscape) { #h-mid { grid-column: 1 / 3; } }

/* Smal skärm (360 px): CTA-knappen på en rad, statistiken i en kolumn */
@media (max-width: 380px) {
  #cta-btn { font-size: 15px; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
  #end-stats { grid-template-columns: 1fr; }
}
/* Låg skärm: när svaret är givet behövs inte frågan längre, så att dom, förklaring, brickor och Vidare ryms utan rullning */
@media (max-height: 700px) { #scr-choice.answered #ch-situation { display: none; } }
/* Startskärmens ARR-ruta ryms inte bredvid språkväljaren på smala skärmar */
@media (max-width: 480px) { .showcase { display: none; } }
/* Surfplatta stående: startkortet mitt i höjdled och större brödtext */
@media (min-width: 700px) and (max-width: 1100px) and (min-height: 800px) {
  #scr-start { align-items: center; }
  .col-start { margin: auto; }
  #st-sub, #end-text, #end-titleline, #end-stats, #end-summary, .cta p, #ch-explain, #ch-upgrade { font-size: 18px; }
  #end-summary { gap: 8px; }
  .end-grid { gap: 20px; }
}
/* Läsläget i liggande mobil: knappen före punkterna, så att den inte hamnar under CTA-remsan */
@media (max-width: 899px) and (max-height: 500px) {
  #scr-end.summary-only #end-buttons { order: 2; }
  #scr-end.summary-only #lb-open-summary { order: 3; }
  #scr-end.summary-only #end-summary { order: 6; }
}
/* Specialknappen på mobil: tydligare också innan den är laddad */
#btn-special { opacity: 0.62; background: rgba(18, 22, 58, 0.82); }
/* Stödraden i CTA:n (vem man bokar och att det är kostnadsfritt) visas alltid, också i de kompakta remsorna */
#cta-support { text-wrap: balance; }
@media (max-width: 899px) and (max-height: 700px) { #cta-support { display: block; font-size: 14px; line-height: 1.25; } }
@media (max-width: 899px) and (max-height: 500px) {
  #cta-support { display: block; font-size: 13px; line-height: 1.2; }
  .cta h3 { font-size: 15px; }
  .cta-text { gap: 1px; }
}
/* 404-sidan (fristående sajt) */
.notfound { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px;
  --accent: #F28C00; --accent-text: #14233A; --head: "Familjen Grotesk", "Avenir Next", "Segoe UI", Roboto, Arial, sans-serif; font-family: "Schibsted Grotesk", system-ui, sans-serif; }
.notfound h1 { font: 700 30px/1.2 var(--head); }
.notfound p { color: var(--text2); }
/* Låg och smal skärm (360 x 640): resultatläget tätare, så att domen, förklaringen och Vidare ryms utan rullning */
@media (max-height: 700px) and (max-width: 480px) {
  #scr-choice.answered .choice { gap: 6px; padding: 10px 12px; }
  #scr-choice.answered .choice h2 { font-size: 20px; }
  #scr-choice.answered .opt { min-height: 40px; font-size: 14px; line-height: 1.25; padding: 4px 8px; }
  #scr-choice.answered #ch-explain, #scr-choice.answered #ch-upgrade { font-size: 14px; line-height: 1.3; }
  #scr-choice.answered #ch-upgrade { padding: 4px 10px; }
  #scr-choice.answered #ch-blocks { display: none; }
  #scr-choice.answered .ch-foot { padding-top: 6px; gap: 4px; }
  #scr-choice.answered #ch-blockline, #scr-choice.answered #ch-special { font-size: 13px; line-height: 1.3; }
  #scr-choice.answered .ch-next { padding: 6px 18px 8px; }
  #scr-choice.answered #btn-next { min-height: 44px; }
}

/* ================= Revidering 5 (efter granskning 3) ================= */
/* CTA-remsan (fast i nederkant under 900 px bredd): högst en femtedel av höjden i alla storlekar.
   Slutskärmens nedre luft följer remsans verkliga höjd (--cta-h sätts av js/ui.js med ResizeObserver),
   så att knappar, namnfält och lärdomar alltid går att rulla fram. */
@media (max-width: 899px) {
  #scr-end #cta { flex-direction: column; align-items: stretch; text-align: center; gap: 6px; border-top-width: 2px;
    padding: 8px calc(16px + var(--sr)) calc(8px + var(--sb)) calc(16px + var(--sl)); }
  #scr-end #cta .brand-mark { display: none; }
  #scr-end #cta .cta-text { gap: 3px; }
  #scr-end #cta h3 { font-size: 18px; line-height: 1.15; }
  #scr-end #cta-support { display: block; font-size: 14px; line-height: 1.25; text-wrap: balance; }
  #scr-end #cta .btn { flex: none; margin: 0 6px; min-height: 48px; font-size: 17px; padding: 6px 14px; white-space: nowrap; }
  #scr-end .end-grid { padding-bottom: calc(var(--cta-h, 150px) + 16px); }
  /* Skärmtangentbordet uppe (namnfältet har fokus): remsan viker undan, så att fältet och Spara syns.
     Klassen kb sätts av js/ui.js och ligger kvar en kort stund efter att fältet tappat fokus: ett tryck på Spara flyttar
     fokus innan klicket landar, och remsan får inte hinna tillbaka under fingret (klicket skulle då missa knappen). */
  #scr-end.kb #cta { visibility: hidden; pointer-events: none; }
}
/* Låg och smal yta (telefon med låg höjd, inbäddad ram): bara rubrik och knapp */
@media (max-width: 599px) and (max-height: 700px) {
  #scr-end #cta-support { display: none; }
  #scr-end #cta h3 { font-size: 16px; }
  #scr-end #cta .btn { min-height: 44px; font-size: 15px; }
}
/* Liggande mobil (bred och låg): en rad med text till vänster och knappen till höger */
@media (min-width: 480px) and (max-width: 899px) and (max-height: 500px) {
  #scr-end #cta { flex-direction: row; align-items: center; text-align: left; gap: 12px; padding-top: 6px; padding-bottom: calc(6px + var(--sb)); }
  #scr-end #cta .cta-text { flex: 1 1 auto; gap: 1px; }
  #scr-end #cta h3 { font-size: 15px; }
  #scr-end #cta-support { font-size: 13px; line-height: 1.2; text-wrap: wrap; }
  #scr-end #cta .btn { min-height: 44px; font-size: 15px; padding: 6px 16px; }
}
/* Säkerhetsnät, mätt av js/ui.js: blir remsan ändå högre än en femtedel av ytan (mycket låg ram, skärmtangentbord som
   krymper ytan) visas bara knappen, och ryms inte heller den döljs remsan. */
#scr-end.cta-min #cta-support, #scr-end.cta-min #cta .cta-text { display: none !important; }
#scr-end.cta-min #cta { padding-top: 5px; padding-bottom: calc(5px + var(--sb)); }
#scr-end.cta-min #cta .btn { min-height: 40px; font-size: 15px; padding: 4px 14px; }
#scr-end.cta-off #cta { display: none; }
@media (min-width: 900px) { #cta-support { max-width: none; text-wrap: balance; } }

/* Insiktskortet står fritt från Samsyn-rutan på dator */
@media (min-width: 761px) and (min-height: 501px) { #game:not(.touch) #insight { left: 46.5%; } }
/* Stora skärmar: HUD:en skalas upp måttligt, så att text och brickor inte blir små i 1920 */
@media (min-width: 1600px) and (min-height: 850px) {
  #hud-top, #h-energy, #h-special, #boss, #insight { zoom: 1.2; }
}
/* Stående surfplatta: meddelanderaden får bredd (banderollen står långt under HUD:en där) */
@media (min-width: 761px) and (max-width: 1099px) and (orientation: portrait) { #h-mid { grid-column: 1 / 3; max-width: 58vw; } }
/* Briefingen: diskret rad om att ett tryck går vidare */
#brief-next { font-size: 14px; color: var(--text2); opacity: 0.85; }
/* 1100 till 1279 px: högerkolumnen (byggstenar och poäng) får alltid sin fulla bredd. Är vågens namn långt (Överlämningen,
   The Customer Base) flyttar vågrutan sig hellre några pixlar åt vänster än går in under byggstenarna. */
@media (min-width: 1100px) and (max-width: 1279px) {
  #hud-top { grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr); }
}
/* Liten liggande skärm (640 x 360, 568 x 320): resultatläget i vägvalet tätare, så att domen, förklaringen och Vidare ryms */
@media (max-height: 380px) and (max-width: 760px) {
  #scr-choice.answered .choice { gap: 4px; padding: 8px 14px; }
  #scr-choice.answered .choice h2 { font-size: 18px; }
  #scr-choice.answered #ch-options { gap: 4px; }
  #scr-choice.answered .opt { min-height: 34px; font-size: 14px; line-height: 1.2; padding: 3px 8px; }
  #scr-choice.answered #ch-result { gap: 3px; }
  #scr-choice.answered #ch-explain, #scr-choice.answered #ch-upgrade { font-size: 13.5px; line-height: 1.25; }
  #scr-choice.answered #ch-upgrade { padding: 2px 10px; }
  #scr-choice.answered #ch-blocks { display: none; }
  #scr-choice.answered .ch-foot { padding-top: 4px; gap: 2px; }
  #scr-choice.answered #ch-blockline, #scr-choice.answered #ch-special, #scr-choice.answered #ch-all { font-size: 13px; line-height: 1.25; }
  #scr-choice.answered #btn-next { min-height: 40px; }
}

/* ================= Revidering 6 (efter granskning 4) ================= */
/* Taglinen bryts bara mellan meningarna */
.tg-part { display: inline-block; }
/* Ordbilden på startskärmen, i radens storlek */
#st-brand .wordmark { font-size: 17px; vertical-align: -1px; margin-left: 2px; }
/* Slutskärmen: raden om vad som saknas för högsta titeln */
#end-titleneed { color: var(--gold); font-size: 16px; margin-top: 2px; }
/* Namnfältet: tydlig fokusring, inte bara ändrad ramfärg */
#nick-input:focus-visible { outline: 3px solid var(--seal); outline-offset: 2px; }
/* Språkväljaren på pekskärm: knapparna är själva 44 px höga */
#game.touch .lang-switch button { min-height: 44px; }
@media (pointer: coarse) { .lang-switch button { min-height: 44px; } }

/* CTA-knappens underrad ("Kostnadsfritt, med Nils på Purasu"): visas där stödraden inte ryms, så att avsändaren och priset alltid står vid knappen */
#cta-btn .b-col { align-items: center; text-align: center; gap: 1px; }
#cta-btn .b-sub { display: none; font-size: 12.5px; opacity: 0.9; white-space: nowrap; }
@media (max-width: 599px) and (max-height: 700px) {
  #scr-end #cta-btn .b-sub:not([hidden]) { display: block; }
  #scr-end #cta .btn { min-height: 48px; padding-top: 5px; padding-bottom: 5px; }
}
/* Steg 1 när remsan är för hög (mätt av js/ui.js): stödraden bort, underraden fram, mindre rubrik */
#scr-end.cta-s1 #cta-support { display: none !important; }
#scr-end.cta-s1 #cta-btn .b-sub:not([hidden]) { display: block; }
#scr-end.cta-s1 #cta h3 { font-size: 15px; line-height: 1.1; }
#scr-end.cta-s1 #cta { gap: 4px; padding-top: 5px; padding-bottom: calc(5px + var(--sb)); }
#scr-end.cta-s1 #cta .btn { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
/* Steg 2: bara knappen med underrad. Steg 3 (cta-off, se ovan): ingen remsa */
#scr-end.cta-min #cta .btn { min-height: 44px; }

/* Byggstenarna på dator: rubriken "Byggstenar n/4" över brickorna, som poängrutan har sin rubrik */
@media (min-width: 1100px) and (min-height: 501px) {
  #h-blocks { flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; }
  #blocks-lbl { display: block; }
}
/* 1100 till 1279 px: hela namn i 11 px, aldrig förkortningar */
@media (min-width: 1100px) and (max-width: 1279px) {
  #h-blocks .chip .full { display: inline; }
  #h-blocks .chip .short { display: none; }
  #h-blocks .chip { font-size: 11px; padding: 5px 4px; }
  #blocks { gap: 3px; }
  #h-blocks { padding-left: 10px; padding-right: 10px; }
}
/* Uppgraderingsraden och andra meddelanden på dator: bredare ruta, så att raden inte bryts på tre rader */
@media (min-width: 1100px) and (min-height: 501px) { #game:not(.touch) #h-mid { max-width: min(470px, 36vw); } }
/* Briefingens tangentrad på dator: tätare, så att sista tangenten (Esc) inte hamnar ensam på egen rad */
/* 5 px mellan tangent och etikett, 14 px mellan paren. Rutan är något bredare på dator, så att raden ryms på engelska. */
@media (min-width: 900px) and (min-height: 501px) { .brief { width: 780px; } }
@media (min-width: 900px) { #brief-controls .ctl-list { gap: 6px 14px; font-size: 13.5px; } #brief-controls .ctl-list kbd { padding: 1px 4px; margin-right: 5px; } }
/* Läsläget i liggande telefon: lärdomarna före knappen, så att de syns först */
@media (max-width: 899px) and (max-height: 500px) {
  #scr-end.summary-only .lang-switch { order: -4; }
  #scr-end.summary-only #end-h { order: -3; }
  #scr-end.summary-only #end-summary { order: -2; }
}
/* Vägvalskortet efter fel svar: raden under brickorna är tom (texten står i rutan ovanför) och ska inte ta plats */
#ch-blockline:empty { display: none; min-height: 0; }

/* ================= Revidering 7 (efter granskning 5) ================= */
/* Stora skärmar (från 1600 x 880): korten skalas upp som HUD:en, så att spelets viktigaste läsning inte står i minst storlek.
   Slutskärmens rutnät fyller höjden före skalningen (100 % / 1,2), så att sidan inte börjar rulla. */
@media (min-width: 1600px) and (min-height: 880px) {
  .col-start, .brief, #scr-choice .dialog, #scr-pause .dialog, #showcase-arr, .lb-dialog { zoom: 1.2; }
  #scr-end .end-grid { zoom: 1.2; min-height: calc(100% / 1.2); }
}
/* Felsvarskortet på telefon: brickraden är dold och raden under är tom. Då ritas inte heller avdelarlinjen. */
@media (max-height: 700px) and (max-width: 480px), (max-height: 380px) and (max-width: 760px) {
  #scr-choice.answered .ch-foot:not(:has(#ch-blockline > p)):not(:has(.ch-notes p:not([hidden]))) { display: none; }
}
/* Briefingens definitionsrad: jämna rader, inget ensamt sista ord */
#brief-lines p { text-wrap: balance; }
/* Mycket låg och smal yta (358 x 480, inbäddad ram på telefon): vägvalskortet ännu tätare, så att det ryms utan rullning */
@media (max-height: 520px) and (max-width: 480px) {
  #scr-choice .choice { gap: 5px; padding: 8px 12px; }
  #ch-situation { font-size: 16px; line-height: 1.2; }
  #scr-choice.answered .choice { gap: 4px; padding: 8px 12px; }
  #scr-choice.answered .choice h2 { font-size: 17px; }
  #scr-choice.answered #ch-options { gap: 4px; }
  #scr-choice.answered .opt { min-height: 34px; font-size: 13px; line-height: 1.2; padding: 3px 8px; }
  #scr-choice.answered #ch-result { gap: 3px; }
  #scr-choice.answered #ch-explain, #scr-choice.answered #ch-upgrade { font-size: 13px; line-height: 1.25; }
  #scr-choice.answered #ch-upgrade { padding: 2px 8px; }
  #scr-choice.answered .ch-foot { padding-top: 3px; gap: 2px; }
  #scr-choice.answered #ch-blockline, #scr-choice.answered #ch-special, #scr-choice.answered #ch-all { font-size: 12.5px; line-height: 1.2; }
  #scr-choice.answered #btn-next { min-height: 40px; }
}
