:root {
  --ink: #ffffff;
  --muted: #cfc8ff;
  --panel: rgba(22, 16, 56, 0.72);
  --panel-solid: #1d1548;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ffcf3a;
  --accent-ink: #2a1a00;
  --go: #3fe07a;
  --pink: #ff7ad9;
  --cyan: #5ee6ff;
  --radius: 18px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120c30; color: var(--ink); -webkit-tap-highlight-color: transparent; user-select: none; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); text-shadow: 0 2px 8px rgba(0,0,0,.4); }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: .3rem 0; }
.small { font-size: .9rem; color: var(--muted); }
.muted { color: var(--muted); font-size: .7em; }
.lead { font-size: 1.15rem; max-width: 36rem; text-align: center; }
.logo {
  font-size: clamp(2.6rem, 8vw, 5rem); letter-spacing: .02em;
  background: linear-gradient(90deg, #ffd84a, #ff7ad9, #5ee6ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.45));
}

.screen { position: fixed; inset: 0; padding: max(16px, env(safe-area-inset-top)) 16px 16px; z-index: 5; }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; background: radial-gradient(ellipse at center, rgba(18,12,48,.55), rgba(18,12,48,.9)); }
.screen.scroll { overflow-y: auto; background: linear-gradient(180deg, rgba(18,12,48,.82), rgba(18,12,48,.94)); padding-bottom: 32px; }
.screen.scroll > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.screen.home { display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.screen.home > * { pointer-events: auto; }

.bar { width: min(420px, 80vw); height: 14px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .3s; }

.btn {
  font: inherit; font-weight: 800; font-size: 1.05rem; color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 999px; padding: .8rem 1.3rem; cursor: pointer; box-shadow: 0 4px 0 #c28d00, 0 8px 18px rgba(0,0,0,.3);
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c28d00; }
.btn:disabled { opacity: .45; }
.btn.big { font-size: 1.5rem; padding: 1rem 2.4rem; }
.btn.small { font-size: .9rem; padding: .5rem .9rem; box-shadow: 0 3px 0 #c28d00; }
.btn.ghost { background: rgba(255,255,255,.14); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 1rem; }

.chip { display: inline-flex; align-items: center; gap: .35rem; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .75rem; font-weight: 800; color: var(--ink); font: inherit; font-weight: 800; }
.chip.ghost-btn { cursor: pointer; font-size: 1.1rem; }
.ico-gem { width: 14px; height: 14px; background: linear-gradient(135deg, var(--cyan), var(--pink)); transform: rotate(45deg); border-radius: 3px; display: inline-block; }

.field { display: flex; flex-direction: column; gap: .4rem; font-weight: 700; }
.input, .field input { font: inherit; font-size: 1.2rem; padding: .7rem 1rem; border-radius: 14px; border: 2px solid var(--line); background: rgba(255,255,255,.1); color: var(--ink); min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; backdrop-filter: blur(6px); margin-bottom: .8rem; }

/* Forside */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.level { display: flex; align-items: center; gap: .6rem; background: rgba(0,0,0,.4); border-radius: 999px; padding: .3rem .9rem .3rem .3rem; }
.level b { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #ff9f1c); color: var(--accent-ink); font-size: 1.3rem; }
.level .xp { width: 110px; height: 10px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.level .xp i { display: block; height: 100%; background: var(--go); width: 0; }
.level span { font-weight: 800; }
.chips { display: flex; gap: .5rem; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; max-width: 1100px; width: 100%; margin: .8rem auto 0; align-self: flex-start; }
.home-grid .panel { margin: 0; }
.home-actions { display: flex; flex-direction: column; align-items: center; gap: .7rem; padding-bottom: env(safe-area-inset-bottom); }
.bike-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.bike-status { background: rgba(0,0,0,.45); padding: .4rem .8rem; border-radius: 999px; font-weight: 700; }
.bike-status.on { background: rgba(63,224,122,.3); }
.km-total b { font-size: 1.8rem; }
.week-bar { position: relative; height: 16px; border-radius: 99px; background: rgba(255,255,255,.15); margin: .6rem 0 .3rem; }
.week-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: linear-gradient(90deg, #cd7f32, #c0c0c0, var(--accent)); width: 0; }
.week-bar .tick { position: absolute; top: -4px; bottom: -4px; width: 3px; background: #fff; border-radius: 2px; }
.stamps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: .4rem 0; }
.stamps span { aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(255,255,255,.3); display: grid; place-items: center; font-size: .9rem; }
.stamps span.on { border: 0; background: radial-gradient(circle, #ffe27a, #ff9f1c); box-shadow: 0 0 10px rgba(255,200,60,.6); }
.eggs { display: flex; gap: .6rem; }
.egg { flex: 1; text-align: center; }
.egg .shape { width: 46px; height: 58px; margin: 0 auto .3rem; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; background: radial-gradient(circle at 35% 30%, #fff, #ffd6f0 40%, #b38cff); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.egg.stort .shape { background: radial-gradient(circle at 35% 30%, #fff, #ffe27a 40%, #ff9f1c); }
.egg.tom .shape { background: rgba(255,255,255,.08); box-shadow: none; border: 2px dashed rgba(255,255,255,.25); }
.egg .mini { height: 6px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.egg .mini i { display: block; height: 100%; background: var(--pink); }

/* Kort */
.cards { display: grid; gap: .8rem; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 220px)); }
.cards.worlds { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card { background: var(--panel); border: 3px solid transparent; border-radius: var(--radius); padding: .8rem; text-align: center; cursor: pointer; color: var(--ink); font: inherit; }
.card img { width: 100%; max-width: 160px; aspect-ratio: 1; object-fit: contain; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,207,58,.25); }
.card.locked { opacity: .55; cursor: default; }
.card b { display: block; font-size: 1.1rem; }
.world-card { min-height: 120px; display: flex; flex-direction: column; justify-content: flex-end; background-size: cover; }
.world-card .swatch { height: 60px; border-radius: 12px; margin-bottom: .5rem; }

.seg { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.seg button { font: inherit; font-weight: 800; font-size: 1.1rem; color: var(--ink); background: var(--panel); border: 3px solid var(--line); border-radius: 16px; padding: .8rem 1.2rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 96px; }
.seg button.sel { border-color: var(--accent); background: rgba(255,207,58,.18); }
.seg .face { font-size: 2rem; }
.omni button { min-width: 0; flex: 1; font-size: .9rem; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left { position: absolute; left: 16px; top: max(14px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: .4rem; }
.speed { background: rgba(0,0,0,.42); border-radius: 18px; padding: .3rem .9rem; display: flex; align-items: baseline; gap: .3rem; }
.speed b { font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1; }
.rpm { background: rgba(0,0,0,.42); border-radius: 14px; padding: .5rem .8rem; width: 200px; }
.rpm-bar { position: relative; height: 14px; border-radius: 99px; background: rgba(255,255,255,.18); margin-bottom: .3rem; overflow: visible; }
.rpm-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--cyan); width: 0; transition: background .2s; }
.rpm-bar i.ok { background: var(--go); }
.rpm-bar .target { position: absolute; top: -5px; bottom: -5px; width: 4px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px #fff; }
.hud-mid { position: absolute; left: 50%; transform: translateX(-50%); top: max(14px, env(safe-area-inset-top)); text-align: center; width: min(46vw, 420px); }
.phase { font-weight: 800; background: rgba(0,0,0,.42); border-radius: 999px; padding: .3rem .9rem; display: inline-block; margin-bottom: .4rem; }
.chapter { height: 8px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.chapter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--pink)); }
.time { font-weight: 800; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
.hud-right { position: absolute; right: 16px; top: max(14px, env(safe-area-inset-top)); display: flex; gap: .5rem; align-items: center; }
.enc { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(560px, 92vw); background: rgba(20,14,50,.85); border: 2px solid var(--line); border-radius: 22px; padding: .9rem 1.1rem; text-align: center; }
.enc-title { font-size: 1.35rem; font-weight: 900; }
.enc-goal { font-size: 1.1rem; margin: .2rem 0 .5rem; }
.enc-goal b.ok { color: var(--go); }
.meter { height: 24px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--go)); transition: width .1s linear; }
.enc-time { height: 6px; border-radius: 99px; background: rgba(255,255,255,.12); margin-top: .5rem; overflow: hidden; }
.enc-time i { display: block; height: 100%; background: var(--pink); width: 100%; }
.seg-panel { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); background: rgba(20,14,50,.85); border-radius: 16px; padding: .5rem 1rem; display: flex; gap: .8rem; align-items: center; font-weight: 700; }
.turbo { position: absolute; right: 24px; top: 70px; font-size: 2.2rem; font-weight: 900; color: #fff; text-shadow: 0 0 12px var(--pink), 0 0 24px var(--cyan); animation: pulse .5s infinite alternate; }
.paused { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: rgba(20,14,50,.85); padding: 1rem 1.4rem; border-radius: 18px; font-size: 1.3rem; font-weight: 800; }
.demo-pedal { position: absolute; right: 22px; bottom: 22px; width: 140px; height: 140px; border-radius: 50%; border: 0; font: inherit; font-weight: 900; font-size: 1.05rem; color: #fff; background: radial-gradient(circle at 35% 30%, #7ff, #36c); box-shadow: 0 8px 20px rgba(0,0,0,.4); touch-action: none; }
.demo-pedal:active { transform: scale(.95); }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

/* Efter turen */
.sum-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: .8rem 0; }
.stat { background: var(--panel); border-radius: 16px; padding: .8rem; text-align: center; }
.stat b { display: block; font-size: 2rem; }
.events { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.event { background: var(--panel); border-left: 0; border-radius: 14px; padding: .7rem 1rem; display: flex; gap: .8rem; align-items: center; font-weight: 700; }
.event img { width: 56px; height: 56px; }
.event .big { font-size: 1.6rem; }

/* Bog */
.book { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.book h3 { grid-column: 1 / -1; margin-top: .8rem; }
.bcard { background: var(--panel); border: 3px solid transparent; border-radius: 16px; padding: .5rem; text-align: center; cursor: pointer; color: var(--ink); font: inherit; }
.bcard.buddy { border-color: var(--go); }
.bcard img { width: 100%; aspect-ratio: 1; }
.bcard b { display: block; }
.bcard .mini { height: 6px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: .3rem; }
.bcard .mini i { display: block; height: 100%; background: var(--go); }
.bcard .tag { font-size: .75rem; color: var(--muted); }

/* Udvikling */
.journey { position: relative; padding: .4rem 0; }
.journey .track { height: 14px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.journey .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--go), var(--cyan), var(--pink)); }
.journey ul { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; }
.journey li { color: var(--muted); }
.journey li.done { color: var(--ink); }
.journey li.done::before { content: "★ "; color: var(--accent); }
.weeks { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 1.2rem; }
.weeks .w { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.weeks .w i { width: 100%; max-width: 42px; border-radius: 8px 8px 2px 2px; background: linear-gradient(180deg, var(--cyan), #3d6bd6); min-height: 3px; position: relative; }
.weeks .w i.now { background: linear-gradient(180deg, var(--accent), #ff9f1c); }
.weeks .w span { font-size: .75rem; color: var(--muted); }
.weeks .w em { font-style: normal; font-size: .8rem; font-weight: 800; }
.month, .records { display: grid; gap: .4rem; }
.mrow { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.mrow .up { color: var(--go); font-weight: 900; }

/* Butik */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.item { background: var(--panel); border: 3px solid transparent; border-radius: 16px; padding: .8rem; text-align: center; color: var(--ink); font: inherit; cursor: pointer; }
.item.on { border-color: var(--go); }
.item .sw { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto .4rem; border: 3px solid rgba(255,255,255,.4); }
.item .price { color: var(--accent); font-weight: 800; }
.item.locked { opacity: .5; }

.debug { font-size: .75rem; white-space: pre-wrap; background: rgba(0,0,0,.4); padding: .6rem; border-radius: 10px; max-height: 260px; overflow: auto; user-select: text; }

.toasts { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: rgba(20,14,50,.92); border: 2px solid var(--accent); padding: .7rem 1.2rem; border-radius: 18px; font-weight: 800; font-size: 1.2rem; text-align: center; animation: toastIn .35s ease-out; max-width: 86vw; }
@keyframes toastIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .cards.three { grid-template-columns: repeat(3, 1fr); }
  .rpm { width: 150px; }
  .hud-mid { top: 120px; width: 70vw; }
  .btn.big { font-size: 1.25rem; }
  .home-grid { grid-template-columns: 1fr 1fr; }
}
