/* Basis (fra den oprindelige artifact-ramme) */
:root{color-scheme:light;box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
body{margin:0;padding:0;font:14px -apple-system,BlinkMacSystemFont,sans-serif;background:#faf9f5;color:#141413}
img{max-width:100%}
[hidden]:not([hidden=until-found i]){display:none!important}

/* Layout: fuldskærms-spil i landskab. Banen skaleres ind i feltet mellem toplinje og værktøjskasse. */
:root {
  --ink: #3B2A5C; --ink-soft: #6B5A8C; --cream: #FFF6E9; --sun: #FFC93C; --sun-deep: #F2A516;
  --grass: #37C16B; --grass-deep: #23994F; --tomato: #FF5A5F; --tomato-deep: #D63A48; --sky: #7FD3FF; --lilac: #C9B6F2;
  --panel: #FFFFFF; --wall: #FFE7C9;
  --f-display: 'Baloo 2', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --f-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --top: 68px; --tool: 132px;
  color-scheme: light;
}
html, body { height: 100%; }
body { margin: 0; background: var(--wall); color: var(--ink); font-family: var(--f-body); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: var(--f-display); color: var(--ink); border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
svg { display: block; }

/* runde "slik"-knapper */
.rb { width: 56px; height: 56px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  box-shadow: 0 5px 0 rgba(59,42,92,.18), 0 8px 18px rgba(59,42,92,.18); transition: transform .12s; }
.rb:active { transform: translateY(3px) scale(.96); box-shadow: 0 2px 0 rgba(59,42,92,.18); }
.rb svg { width: 30px; height: 30px; }
.rb.soft { width: 46px; height: 46px; opacity: .75; }
.rb.soft svg { width: 24px; height: 24px; }
.rb.sun { background: linear-gradient(#FFE07A, var(--sun)); }
.rb.big { width: 96px; height: 96px; }
.rb.big svg { width: 50px; height: 50px; }
.rb.go { background: linear-gradient(#6BE08F, var(--grass)); box-shadow: 0 6px 0 var(--grass-deep), 0 10px 22px rgba(35,153,79,.35); }
.rb.stop { background: linear-gradient(#FF8A8E, var(--tomato)); box-shadow: 0 6px 0 var(--tomato-deep), 0 10px 22px rgba(214,58,72,.35); }
.rb.go svg, .rb.stop svg { fill: #fff; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.pop-in { animation: popin .35s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes popin { from { transform: scale(.4); opacity: 0; } }

/* ---------- spil-HUD ---------- */
#hud { position: absolute; left: 0; right: var(--tool); top: 0; height: var(--top); padding: 6px 12px 0 max(12px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 12px; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud .lvl { font-family: var(--f-display); font-weight: 800; font-size: 30px; min-width: 64px; height: 50px; padding: 0 16px; border-radius: 25px; background: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(59,42,92,.15); }
#hud .stars { display: flex; gap: 2px; background: rgba(255,255,255,.75); padding: 6px 10px; border-radius: 26px; }
#hud .stars svg { width: 34px; height: 34px; transition: transform .25s, opacity .25s; }
#hud .stars svg.off { opacity: .28; transform: scale(.8); filter: grayscale(1); }
#hud .goalchip { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.75); padding: 6px 12px; border-radius: 26px; font-family: var(--f-display); font-weight: 800; font-size: 26px; }
#hud .goalchip .dot { width: 20px; height: 20px; border-radius: 50%; background: #E3DBEF; box-shadow: inset 0 2px 0 rgba(59,42,92,.15); }
#hud .goalchip .dot.on { background: radial-gradient(circle at 35% 35%, #D8FFA8, #3FA535); }
#hud .spacer { flex: 1; }
#hintBtn[hidden] { display: none; }

#toolbox { position: absolute; right: 0; top: 0; bottom: 0; width: var(--tool); padding: 10px 12px calc(12px + env(safe-area-inset-bottom)) 10px; box-sizing: border-box;
  background: linear-gradient(90deg, rgba(255,255,255,.0), rgba(255,255,255,.55) 18%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
#tools { display: flex; flex-direction: column; gap: 10px; align-items: center; flex: 1; overflow: auto; padding-top: 4px; width: 100%; }
.tool { position: relative; width: 100px; height: 88px; border-radius: 22px; background: #fff; box-shadow: 0 5px 0 rgba(59,42,92,.14), 0 8px 18px rgba(59,42,92,.14); display: grid; place-items: center; touch-action: none; flex: none; }
.tool canvas { width: 84px; height: 84px; pointer-events: none; }
.tool .n { position: absolute; right: -6px; top: -6px; min-width: 32px; height: 32px; border-radius: 16px; background: var(--ink); color: #fff; font: 800 20px/32px var(--f-display); text-align: center; }
.tool.empty { opacity: .35; }
.tool .q { position: absolute; left: -6px; bottom: -6px; width: 30px; height: 30px; border-radius: 50%; background: var(--sun); font: 800 19px/30px var(--f-display); text-align: center; box-shadow: 0 3px 0 var(--sun-deep); }
#playBtn { flex: none; }

#partMenu { position: absolute; display: flex; gap: 10px; transform: translate(-50%, -100%); pointer-events: auto; }
#partMenu[hidden] { display: none; }
#partMenu .rb { width: 52px; height: 52px; }

#hand { position: absolute; width: 64px; height: 64px; pointer-events: none; z-index: 5; filter: drop-shadow(0 6px 6px rgba(59,42,92,.3)); }
#hand[hidden] { display: none; }

/* ---------- skærme ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.screen[hidden] { display: none !important; }
#scrTitle { background: radial-gradient(ellipse at 50% 30%, #FFF6D8, #FFD9A8 60%, #FFC08A); gap: 28px; }
.logo { font-family: var(--f-display); font-weight: 800; font-size: clamp(64px, 12vw, 132px); line-height: .9; letter-spacing: -1px; color: #fff;
  text-shadow: 0 6px 0 #E0703A, 0 12px 0 rgba(59,42,92,.25); transform: rotate(-3deg); }
.logo span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.tag { font-family: var(--f-display); font-weight: 700; font-size: 22px; color: var(--ink-soft); }
#titleCanvas { width: min(520px, 80vw); height: 150px; }

#scrProfiles, #scrMap { background: linear-gradient(#FFF1DC, #FFE0BD); }
.profiles { display: grid; grid-template-columns: repeat(4, minmax(120px, 170px)); gap: 22px; padding-inline: 16px; }
.pcard { aspect-ratio: 3/4; border-radius: 30px; background: #fff; box-shadow: 0 8px 0 rgba(59,42,92,.14), 0 14px 30px rgba(59,42,92,.14); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.pcard .av { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 60px; }
.pcard .pst { display: flex; align-items: center; gap: 4px; font: 800 24px var(--f-display); }
.pcard .pst svg { width: 26px; height: 26px; }
.pcard.add { background: rgba(255,255,255,.55); border: 4px dashed rgba(59,42,92,.25); box-shadow: none; }
.pcard.add svg { width: 64px; height: 64px; opacity: .5; }
.avpick { display: grid; grid-template-columns: repeat(4, 84px); gap: 14px; }
.avpick button { width: 84px; height: 84px; border-radius: 50%; font-size: 50px; background: #fff; box-shadow: 0 5px 0 rgba(59,42,92,.14); }

#scrMap { justify-content: flex-start; }
.maptop { width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 14px; padding: 14px max(18px, env(safe-area-inset-left)) 0; }
.maptop .who { width: 60px; height: 60px; border-radius: 50%; font-size: 38px; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(59,42,92,.15); }
.maptop .world { font: 800 34px var(--f-display); display: flex; align-items: center; gap: 12px; }
.maptop .world .wi { width: 54px; height: 54px; }
.chip { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 26px; padding: 6px 14px; font: 800 24px var(--f-display); box-shadow: 0 4px 0 rgba(59,42,92,.12); }
.chip svg { width: 28px; height: 28px; }
.chip .duckico { font-size: 26px; line-height: 1; }
#mapWrap { position: relative; width: min(1100px, 96vw); flex: 1; min-height: 0; }
#mapSvg { position: absolute; inset: 0; width: 100%; height: 100%; }
.node { position: absolute; width: 84px; height: 84px; transform: translate(-50%, -50%); border-radius: 50%; background: linear-gradient(#fff, #F3EAFB);
  box-shadow: 0 6px 0 rgba(59,42,92,.2), 0 10px 20px rgba(59,42,92,.15); font: 800 36px var(--f-display); display: grid; place-items: center; }
.node.done { background: linear-gradient(#FFE58A, var(--sun)); box-shadow: 0 6px 0 var(--sun-deep), 0 10px 20px rgba(242,165,22,.35); }
.node.next { background: linear-gradient(#6BE08F, var(--grass)); color: #fff; box-shadow: 0 6px 0 var(--grass-deep), 0 10px 20px rgba(35,153,79,.35); animation: pulse 1.4s infinite; }
.node.locked { background: #E6DFF0; color: rgba(59,42,92,.35); }
.node .ns { position: absolute; bottom: -24px; display: flex; gap: 0; }
.node .ns svg { width: 22px; height: 22px; }
.node .lk { position: absolute; width: 34px; height: 34px; right: -8px; top: -8px; }
.node .dk { position: absolute; left: -10px; top: -12px; font-size: 24px; }
.worlds { display: flex; gap: 12px; padding: 8px 16px 16px; overflow-x: auto; max-width: 100%; box-sizing: border-box; flex: none; }
.wcard { flex: none; width: 104px; height: 84px; border-radius: 20px; background: rgba(255,255,255,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 38px; position: relative; }
.wcard.on { background: #fff; box-shadow: 0 5px 0 rgba(59,42,92,.14); }
.wcard small { font: 700 13px var(--f-body); color: var(--ink-soft); margin-top: 2px; }
.wcard .lk { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; opacity: .5; }
.badges { display: flex; gap: 6px; }
.badge { width: 44px; height: 44px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(59,42,92,.12); }
.badge canvas { width: 36px; height: 36px; }
.badge.off { opacity: .3; filter: grayscale(1); }

#corner { position: absolute; left: 0; top: 0; width: 70px; height: 70px; z-index: 30; }
#corner i { position: absolute; left: 10px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: rgba(59,42,92,.12); }
#corner.hold i { background: var(--sun); box-shadow: 0 0 0 10px rgba(255,201,60,.3); }

/* ---------- overlays ---------- */
.ov { position: absolute; inset: 0; background: rgba(59,42,92,.45); display: grid; place-items: center; z-index: 20; padding: 16px; box-sizing: border-box; }
.ov[hidden] { display: none; }
.card { background: #fff; border-radius: 36px; padding: 26px 30px; box-shadow: 0 14px 0 rgba(59,42,92,.18), 0 30px 60px rgba(59,42,92,.3); display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: min(640px, 92vw); max-height: 92vh; box-sizing: border-box; }
.row { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }
.winstars { display: flex; gap: 8px; align-items: flex-end; }
.winstars svg { width: 90px; height: 90px; opacity: .2; filter: grayscale(1); transform: scale(.7); transition: all .35s cubic-bezier(.3,1.7,.5,1); }
.winstars svg:nth-child(2) { width: 116px; height: 116px; }
.winstars svg.on { opacity: 1; filter: none; transform: scale(1); }
.wintitle { font: 800 44px var(--f-display); }
.partcount { display: flex; align-items: center; gap: 10px; font: 800 26px var(--f-display); color: var(--ink-soft); }
.partcount .pc { display: flex; gap: 4px; }
.partcount .pc i { width: 16px; height: 16px; border-radius: 5px; background: #E89A4B; display: block; }
#introCv { width: min(460px, 80vw); aspect-ratio: 460/280; border-radius: 24px; background: linear-gradient(#FFF1DC, #FFE0BD); }
.gateq { font: 800 56px var(--f-display); }
.gatea { display: grid; grid-template-columns: repeat(4, 84px); gap: 12px; }
.gatea button { height: 72px; border-radius: 20px; background: #F3EAFB; font: 800 32px var(--f-display); box-shadow: 0 4px 0 rgba(59,42,92,.14); }
.gatelabel { font: 700 18px var(--f-body); color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }

/* forældrepanel (må gerne have tekst) */
#ovParent .card { align-items: stretch; width: min(760px, 94vw); overflow: auto; font-size: 16px; line-height: 1.45; gap: 14px; }
#ovParent .card > * { flex-shrink: 0; }
#ovParent h2 { font: 800 30px var(--f-display); margin: 0; }
#ovParent h3 { font: 800 20px var(--f-display); margin: 6px 0 0; }
#ovParent p { margin: 0; color: var(--ink-soft); max-width: 65ch; }
.ptable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ptable td, .ptable th { padding: 8px 6px; border-bottom: 1px solid #EEE6F6; text-align: left; }
.ptable th { font: 800 14px var(--f-body); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.goals { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.goals div { display: flex; gap: 8px; align-items: flex-start; background: #FAF6FF; border-radius: 12px; padding: 8px 10px; min-width: 0; }
.goals b { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #E6DFF0; color: #fff; font-size: 14px; display: grid; place-items: center; }
.goals b.ok { background: var(--grass); }
.tog { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #EEE6F6; }
.tog input { width: 52px; height: 30px; appearance: none; -webkit-appearance: none; background: #E6DFF0; border-radius: 15px; position: relative; transition: background .2s; flex: none; }
.tog input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.tog input:checked { background: var(--grass); }
.tog input:checked::after { left: 25px; }
.pbtn { font: 800 18px var(--f-display); padding: 10px 18px; border-radius: 16px; background: #F3EAFB; box-shadow: 0 3px 0 rgba(59,42,92,.14); }
.pbtn.go { background: var(--grass); color: #fff; box-shadow: 0 3px 0 var(--grass-deep); }
.pbtn.warn { background: #FFE3E4; color: var(--tomato-deep); }
.pbtn[disabled] { opacity: .5; }
.note { font-size: 14px; color: var(--ink-soft); }

#ovRotate { background: var(--cream); z-index: 50; }
#ovRotate svg { width: 120px; height: 120px; animation: rot 2s ease-in-out infinite; }
@keyframes rot { 50% { transform: rotate(-90deg); } }
@media (orientation: landscape) { #ovRotate { display: none !important; } }
@media (max-height: 560px) { :root { --top: 58px; --tool: 112px; } .tool { width: 84px; height: 72px; } .tool canvas { width: 68px; height: 68px; } .rb.big { width: 76px; height: 76px; } .node { width: 64px; height: 64px; font-size: 28px; } .profiles { grid-template-columns: repeat(4, minmax(100px, 130px)); } }
@media (prefers-reduced-motion: reduce) { .pulse, .logo span, .node.next { animation: none; } }

/* figur-bygger */
.chcard { flex-direction: row; align-items: center; gap: 24px; max-width: min(900px, 96vw); }
#chPreview { width: 260px; height: 340px; background: radial-gradient(ellipse at 50% 85%, #FFE9C7, #FFF6E9 70%); border-radius: 28px; flex: none; }
.chrows { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.chrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chico { width: 40px; height: 40px; flex: none; opacity: .8; }
.swrow { display: flex; gap: 10px; flex-wrap: wrap; }
.chopt { width: 76px; height: 76px; border-radius: 22px; background: #F6F0FC; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(59,42,92,.12); }
.chopt.on, .sw.on { box-shadow: 0 0 0 5px var(--grass), 0 4px 0 rgba(59,42,92,.12); transform: scale(1.06); }
.sw { width: 58px; height: 58px; border-radius: 50%; box-shadow: inset 0 -5px 0 rgba(0,0,0,.15), 0 4px 0 rgba(59,42,92,.12); transition: transform .15s; }
.pcard { position: relative; aspect-ratio: auto; padding: 10px 0 14px; }
.pcard canvas { display: block; }
.pcard .edit { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border-radius: 50%; background: #F6F0FC; display: grid; place-items: center; }
.pcard .edit svg { width: 24px; height: 24px; }
.maptop .who { background: #fff; overflow: hidden; }
.maptop .who img { width: 56px; height: 56px; }
@media (max-width: 760px) { .chcard { flex-direction: column; } #chPreview { width: 180px; height: 235px; } }

/* bane-oversigt med billeder */
#scrMap { background-size: cover; background-position: center; }
#mapWrap { display: grid; place-items: center; padding: 8px 16px; box-sizing: border-box; }
.lgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 22px; width: 100%; max-width: 980px; }
.lcard { position: relative; padding: 0; border-radius: 20px; background: #fff; box-shadow: 0 6px 0 rgba(59,42,92,.16), 0 12px 22px rgba(59,42,92,.14); aspect-ratio: 3/2; }
.lcard img { width: 100%; height: 100%; object-fit: cover; border-radius: 20px; display: block; border: 4px solid #fff; box-sizing: border-box; }
.lcard .no { position: absolute; left: -10px; top: -12px; min-width: 42px; height: 42px; border-radius: 21px; background: #fff; font: 800 26px/42px var(--f-display); text-align: center; box-shadow: 0 3px 0 rgba(59,42,92,.15); }
.lcard.done .no { background: linear-gradient(#FFE58A, var(--sun)); }
.lcard.next { box-shadow: 0 0 0 6px var(--grass), 0 10px 22px rgba(35,153,79,.35); animation: pulse 1.6s infinite; }
.lcard.next .no { background: var(--grass); color: #fff; }
.lcard.locked img { filter: grayscale(.35); opacity: .85; }
.lcard .ns { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); display: flex; background: #fff; border-radius: 14px; padding: 2px 6px; box-shadow: 0 3px 0 rgba(59,42,92,.12); }
.lcard .ns svg { width: 22px; height: 22px; }
.lcard .lk { position: absolute; right: -8px; top: -10px; width: 36px; height: 36px; background: #fff; border-radius: 50%; display: grid; place-items: center; }
.lcard .lk svg { width: 24px; height: 24px; }
.lcard .dk { position: absolute; right: 6px; bottom: 4px; font-size: 22px; }
@media (max-width: 900px) { .lgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.lgrid.many { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px 18px; max-width: 900px; }

/* verdens-kort med temabilleder */
.wcard { width: 128px; padding: 0; overflow: visible; }
.worlds { padding-top: 14px; }
.wcard img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 20px; border: 3px solid #fff; box-sizing: border-box; }
.wcard .wic { position: absolute; left: 6px; bottom: 2px; font-size: 26px; filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 -1px 0 #fff); }
.wcard.on { box-shadow: 0 0 0 4px var(--grass), 0 5px 0 rgba(59,42,92,.14); }
.wcard .lk { right: -6px; top: -6px; width: 30px; height: 30px; opacity: 1; background: #fff; border-radius: 50%; padding: 4px; box-sizing: border-box; box-shadow: 0 2px 0 rgba(59,42,92,.15); }
#ovWorld .card { padding: 18px 18px 22px; gap: 14px; max-width: 96vw; }
#worldView { width: min(840px, 88vw, calc((88vh - 150px) * 1.5)); aspect-ratio: 3/2; border-radius: 24px; overflow: hidden; background: #fff; }
#worldView svg, #worldView img { width: 100%; height: 100%; display: block; object-fit: cover; }
.wtitle { font: 800 32px var(--f-display); display: flex; align-items: center; gap: 10px; }
.wtitle svg { width: 30px; height: 30px; }

[hidden]{display:none!important}

/* Rulletekster */
.card.credits { width: min(560px, 92vw); padding: 18px 20px; gap: 10px; }
.crwin { height: min(70vh, 560px); width: 100%; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent); }
.crroll { text-align: center; padding: 70vh 8px 30vh; animation: crRoll 70s linear forwards; color: var(--ink, #3B2A5C); }
.crwin:active .crroll { animation-play-state: paused; }
@keyframes crRoll { to { transform: translateY(-100%); } }
.crlogo { font: 800 40px var(--f-display); margin-bottom: 16px; }
.crroll h3 { font: 800 24px var(--f-display); margin: 26px 0 10px; }
.crrow { display: flex; flex-direction: column; margin: 0 0 14px; }
.crrow .crw { font-size: 14px; opacity: .7; }
.crrow b { font: 700 19px var(--f-display); }
.crend { font-size: 48px; margin-top: 40px; }
