/* ELIO – FULL ALARM!  ·  game.css  (Elios profil: navy, mint, gul, rød · Poppins) */
@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url('../assets/fonts/Poppins-400-latin.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 500 900; font-display: swap; src: url('../assets/fonts/Poppins-500-latin.woff2') format('woff2'); }

:root {
  --navy: #233849; --navy-dark: #16242f; --navy-light: #324f66;
  --mint: #b4dfdb; --yellow: #f2efa7; --green: #2e4f2a;
  --red: #c8102e; --red-glow: #ff3b57;
  --white: #fff; --muted: #8fa3b3; --line: #d9e1e6;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--navy-dark); color: var(--white); font-family: var(--font); overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
[hidden] { display: none !important; }
button { font-family: inherit; }

.game {
  height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--navy);
}

/* HUD */
.hud { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--navy-dark); }
.hud__logo { height: 26px; width: auto; }
.hud__stats { margin-left: auto; display: flex; gap: clamp(10px, 3vw, 20px); }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat__label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat__value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--yellow); }
.stat__value.pop { animation: pop .3s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.hud__pause {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(180,223,219,.35);
  background: transparent; color: var(--mint); font-size: 13px; cursor: pointer;
}
.hud__pause:hover { background: rgba(180,223,219,.12); }

.stress { display: flex; align-items: center; gap: 10px; padding: 6px 14px 8px; background: var(--navy-dark); }
.stress__label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); width: 74px; }
.stress__bar { flex: 1; height: 10px; border-radius: 6px; background: #0d1820; overflow: hidden; }
.stress__fill { height: 100%; width: 0; border-radius: 6px; background: var(--mint); transition: width .2s linear, background .3s; }
.stress__fill.warn { background: var(--yellow); }
.stress__fill.crit { background: var(--red-glow); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }

/* Scene */
.stage { position: relative; flex: 1; min-height: 0; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }

/* Overlays */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(22,36,47,.82); backdrop-filter: blur(3px); overflow-y: auto;
}
.card { width: 100%; max-width: 440px; text-align: center; margin: auto; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--mint); }
h1, h2 { margin: 0; font-weight: 800; line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
h1 { font-size: clamp(40px, 11vw, 72px); color: var(--white); text-shadow: 0 0 24px rgba(255,59,87,.55); }
h2 { font-size: clamp(26px, 7vw, 38px); color: var(--yellow); }
.lead { margin: 12px 0 18px; font-size: 16px; color: var(--line); }
.howto { list-style: none; counter-reset: s; padding: 0; margin: 0 auto 22px; display: inline-block; text-align: left; }
.howto li { counter-increment: s; position: relative; padding: 6px 0 6px 38px; font-size: 15px; }
.howto li::before {
  content: counter(s); position: absolute; left: 0; top: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--mint); color: var(--navy); font-weight: 600; font-size: 13px; display: grid; place-items: center;
}
.howto b { color: var(--yellow); font-weight: 500; }

.btn {
  display: block; width: 100%; padding: 16px 24px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--yellow); color: var(--navy); font-size: 18px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: transform .08s, box-shadow .08s;
}
.btn:hover { background: #fffcbd; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn--ghost {
  margin-top: 12px; background: transparent; color: var(--mint); font-size: 16px; font-weight: 500;
  border: 2px solid rgba(180,223,219,.4); box-shadow: none;
}
.btn--ghost:hover { background: rgba(180,223,219,.12); }
.btn--ghost:active { transform: none; box-shadow: none; }
.btn--ghost.recommended { border-color: var(--yellow); }
.badge { display: inline-block; margin-left: 8px; padding: 1px 9px; border-radius: 99px; background: var(--yellow); color: var(--navy); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: 2px; }
.badge[hidden] { display: none; }
.link { display: inline-block; margin-top: 14px; color: var(--mint); font-size: 14px; }
.best { margin: 12px 0 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.final { font-size: clamp(54px, 16vw, 88px); font-weight: 800; color: var(--white); font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 0; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
@media (max-width: 480px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.facts div { background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px 4px; }
.facts dt { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 18px; font-weight: 600; color: var(--mint); }
.fact { margin: 0 0 16px; font-size: 13px; color: var(--line); line-height: 1.45; }

/* Meldingsstripe (humor, kort) */
.ticker {
  margin: 0; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); min-height: 44px; display: flex; align-items: center; justify-content: center;
  background: var(--navy-dark); border-top: 3px solid var(--navy-light);
  font-size: 14px; line-height: 1.25; text-align: center; color: var(--mint);
}
.ticker.warn { color: var(--yellow); }
.ticker.bad { color: var(--red-glow); }
.ticker.good { color: #9be8b4; }
.ticker.show { animation: tick .35s ease-out; }
@keyframes tick { 0% { transform: translateY(6px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Tutorial: coach-stripe erstatter meldingsstripen */
.coach {
  display: flex; align-items: center; gap: 12px; min-height: 92px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--navy-dark); border-top: 3px solid var(--yellow);
}
.coach__body { flex: 1; min-width: 0; }
.coach__step { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); }
.coach__text { margin: 3px 0 0; font-size: 15px; line-height: 1.3; color: var(--white); }
.coach.good .coach__text { color: #9be8b4; }
.coach__btns { flex: none; display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 108px; }
.coach__btn {
  padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(180,223,219,.4); background: transparent;
  color: var(--mint); font-size: 12.5px; cursor: pointer;
}
.coach__next {
  padding: 13px 14px; border-radius: 10px; border: 0; background: var(--yellow); color: var(--navy);
  font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.coach__next:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.coach__next[hidden], .coach__btn[hidden] { display: none; }
.coach__btn:hover { background: rgba(180,223,219,.12); }
body.tut:not(.tut-hud) .hud__stats, body.tut .hud__pause { visibility: hidden; }

@media (min-width: 700px) {
  .coach__text { font-size: 17px; }
  .hud { padding: 10px 22px; } .hud__logo { height: 32px; }
  .ticker { font-size: 16px; min-height: 52px; }
}

/* Lyd */
.snd { display: flex; gap: 6px; flex: none; }
.snd__btn {
  width: 36px; height: 30px; padding: 0; border-radius: 8px; border: 1px solid rgba(180,223,219,.35); background: transparent;
  color: var(--mint); cursor: pointer; display: grid; place-items: center; position: relative;
}
.snd__btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.snd__btn:hover { background: rgba(180,223,219,.12); }
.snd__btn.off { color: var(--muted); border-color: rgba(90,104,117,.5); }
.snd__btn.off::after { content: ''; position: absolute; left: 7px; right: 7px; top: 50%; height: 2px; background: var(--red-glow); transform: rotate(-35deg); border-radius: 2px; }
.vol { display: grid; gap: 8px; margin: 12px 0; text-align: left; }
.vol label { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.vol input[type=range] { width: 100%; accent-color: var(--mint); height: 28px; }
.soundset { margin-top: 12px; color: var(--muted); font-size: 13px; }
.soundset summary { cursor: pointer; text-align: center; padding: 6px; list-style: none; }
.soundset summary::-webkit-details-marker { display: none; }
body.tut:not(.tut-hud) .stress__label, body.tut:not(.tut-hud) .stress__bar { visibility: hidden; }
body.tut-hud .hud__stats, body.tut-hud .stress__bar { outline: 2px solid var(--yellow); outline-offset: 4px; border-radius: 8px; animation: spotpulse 1.2s ease-in-out infinite; }
@keyframes spotpulse { 50% { outline-color: rgba(242,239,167,.35); } }

/* ELIO PID BOOST */
:root { --auto: #6fe3c1; }
.pid { position: absolute; left: 10px; bottom: 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.pid__btn {
  pointer-events: auto; position: relative; width: 68px; height: 68px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: inherit; line-height: 1.05;
  --p: 1; --ring: var(--yellow); --track: #2a3b4a; color: var(--navy);
  background: conic-gradient(var(--ring) calc(var(--p) * 1turn), var(--track) 0);
}
.pid__btn::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--fill, var(--yellow)); z-index: 0; }
.pid__btn > span { position: relative; z-index: 1; }
.pid__top { font-size: 19px; font-weight: 800; letter-spacing: .02em; }
.pid--active .pid__top { font-size: 15px; }
.pid__sub { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; }
.pid__cap { font-size: 9px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; }
.pid__btn.pid--ready { --fill: var(--yellow); --track: var(--yellow); color: var(--navy); animation: pidpulse 1.8s ease-in-out infinite; }
@keyframes pidpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,239,167,.55), 0 3px 0 rgba(0,0,0,.4); transform: scale(1); } 50% { box-shadow: 0 0 0 9px rgba(242,239,167,0), 0 3px 0 rgba(0,0,0,.4); transform: scale(1.04); } }
.pid__btn.pid--active { --fill: #0f2a2a; --ring: var(--auto); --track: #1d3b3a; color: var(--auto); box-shadow: 0 0 14px rgba(111,227,193,.55); }
.pid__btn.pid--active.late { --ring: var(--yellow); color: var(--yellow); box-shadow: 0 0 14px rgba(242,239,167,.5); }
.pid__btn.pid--charge { --fill: #16242f; --ring: #8fa3b3; --track: #2a3b4a; color: #8fa3b3; }
.pid__btn:active { transform: scale(.96); }
body.tut .pid { display: none; }
.pidlist { text-align: left; margin: 4px 0 16px; padding-left: 20px; font-size: 14.5px; line-height: 1.4; color: var(--line); }
.pidlist li { margin: 5px 0; } .pidlist b { color: var(--yellow); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .pid__btn.pid--ready { animation: none; } }

/* Game over */
.overlay--over { align-items: flex-start; }
.card--over { position: relative; z-index: 1; }
.confetti { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.card--over h2 { font-size: clamp(30px, 9vw, 44px); color: var(--white); text-shadow: 0 0 22px rgba(255,59,87,.5); }
.rank {
  display: inline-block; margin: 12px 0 2px; padding: 6px 16px; border-radius: 99px; background: var(--yellow); color: var(--navy);
  font-size: clamp(15px, 4.4vw, 19px); font-weight: 700; letter-spacing: .02em; opacity: 0; transform: scale(.6) rotate(-4deg);
}
.rank.show { animation: rankpop .6s cubic-bezier(.2,1.5,.4,1) forwards; }
@keyframes rankpop { 0% { opacity: 0; transform: scale(.5) rotate(-8deg); } 60% { opacity: 1; transform: scale(1.12) rotate(2deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.card--over .final { font-size: clamp(52px, 15vw, 82px); margin: 2px 0 0; }
.comment { margin: 0 0 14px; min-height: 2.6em; font-size: 15px; line-height: 1.35; font-style: italic; color: var(--yellow); opacity: 0; }
.comment.show { animation: fadein .5s ease-out forwards; }
@keyframes fadein { to { opacity: 1; } }
.btn--big { font-size: 22px; padding: 20px 24px; text-transform: uppercase; letter-spacing: .04em; }
.btn--small { font-size: 14px; padding: 11px 18px; margin-top: 10px; }
@media (max-height: 700px) { .card--over .fact { display: none; } .comment { margin-bottom: 10px; } .card--over .facts { margin: 8px 0; } }

.next { margin: 2px 0 0; min-height: 1.3em; font-size: 14px; font-weight: 500; color: var(--mint); }
.cause {
  margin: 10px 0 6px; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.35; text-align: left;
  background: rgba(200,16,46,.14); border-left: 3px solid var(--red-glow); color: var(--line);
}
.cause b { color: var(--red-glow); font-weight: 600; letter-spacing: .06em; font-size: 11.5px; text-transform: uppercase; }
.cause:empty { display: none; }
/* Ny personlig rekord: gullglød */
.overlay--over.record { background: radial-gradient(circle at 50% 28%, rgba(255,200,60,.28), rgba(22,36,47,.88) 62%); }
.card--over.record .final { color: #ffd54a; text-shadow: 0 0 22px rgba(255,200,60,.75); animation: goldpulse 1.6s ease-in-out infinite; }
.card--over.record .rank { background: linear-gradient(90deg, #ffc531, #fff3b0, #ffc531); }
.best.gold { color: #ffd54a; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 14px; }
@keyframes goldpulse { 0%, 100% { text-shadow: 0 0 14px rgba(255,200,60,.5); } 50% { text-shadow: 0 0 34px rgba(255,210,80,1); } }
@media (max-height: 700px) {
  .card--over h2 { font-size: 28px; } .card--over .final { font-size: clamp(44px, 12vw, 60px); } .rank { margin: 8px 0 0; padding: 4px 12px; }
  .facts div { padding: 6px 2px; } .facts dd { font-size: 16px; } .btn--big { font-size: 19px; padding: 15px 20px; } .btn--small { padding: 9px 16px; margin-top: 8px; }
  .next { font-size: 13px; } .cause { margin: 6px 0 4px; padding: 7px 10px; font-size: 12.5px; } .vol { margin: 8px 0; } }

@media (prefers-reduced-motion: reduce) { .stat__value.pop, .stress__fill.crit, .ticker.show { animation: none; }
  .rank.show { animation: none; opacity: 1; transform: none; }
  .comment.show { animation: none; opacity: 1; }
  .card--over.record .final { animation: none; } }

/* Registrering */
.reg { text-align: left; }
.reg h2, .reg .eyebrow, .reg .lead { text-align: center; }
.reg__field { display: block; margin: 0 0 12px; font-size: 14px; color: var(--mint); }
.reg__field input {
  display: block; width: 100%; margin-top: 4px; padding: 13px 14px; border-radius: 10px; font: inherit; font-size: 17px;
  border: 2px solid rgba(180,223,219,.4); background: rgba(255,255,255,.06); color: var(--white);
}
.reg__field input:focus { outline: none; border-color: var(--yellow); }
.reg__consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 8px; font-size: 13px; color: var(--line); line-height: 1.4; }
.reg__consent input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--yellow); }
.reg__err { min-height: 1.3em; margin: 0 0 10px; font-size: 14px; color: var(--red-glow); }
.who { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.who__swap { background: none; border: 0; padding: 0; color: var(--mint); font: inherit; text-decoration: underline; cursor: pointer; }

/* Månedens toppliste */
.top { margin: 18px 0 0; text-align: left; }
.top[hidden] { display: none; }
.top h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--mint); text-align: center; font-weight: 500; }
.top ol { margin: 0; padding: 0 0 0 26px; font-size: 14px; }
.top li { padding: 3px 0; }
.top li span { display: inline-block; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.top li b { float: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.top li.me { color: var(--yellow); }
.top p { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

