/* Vinterljuset – ett rödmålat allmogeskåp i en vinternatt */
:root {
  --natt: #0e1b24;
  --natt-2: #16293a;
  --falu: #8a2f24;
  --falu-dark: #5e1f18;
  --gron: #2f5d5a;
  --gron-dark: #1f423f;
  --massing: #d2a84a;
  --massing-ljus: #f0d58a;
  --ben: #efe6d0;
  --black: #1c1712;
  --lingon: #b3312b;
  --display: 'Gloock', 'Iowan Old Style', Georgia, serif;
  --letter: 'Special Elite', 'Courier New', monospace;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--natt); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--natt); color: var(--ben);
  font: 16px/1.5 var(--ui); overscroll-behavior: none;
}
#app { position: relative; min-height: 100dvh; margin: 0 auto; overflow-x: hidden; }
@media (min-width: 700px) and (min-height: 600px) {
  #app { max-width: 460px; box-shadow: 0 0 0 1px #ffffff14, 0 0 80px #0008; }
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, .thread-hit:focus-visible { outline: 3px solid var(--massing-ljus); outline-offset: 2px; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }

/* Knappar */
.btn {
  display: block; width: 100%; max-width: 340px; margin: 14px auto 0; padding: 13px 18px;
  border: 0; border-radius: 10px; background: var(--massing); color: var(--black);
  font-weight: 650; font-size: 1rem; box-shadow: 0 3px 0 #8a6a22, 0 8px 18px #0005;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6a22; }
.btn:disabled { background: #6f6548; color: #2a251b; box-shadow: none; cursor: default; }
.btn-big { padding: 16px 18px; font-size: 1.08rem; }
.btn-small { width: auto; margin: 0; padding: 10px 12px; font-size: .9rem; flex: 1; }
.btn-quiet { background: transparent; color: var(--massing-ljus); box-shadow: inset 0 0 0 1.5px #d2a84a88; }
.btn-quiet:active { box-shadow: inset 0 0 0 1.5px #d2a84a88; }
.btn-danger { background: transparent; color: #f0a9a2; box-shadow: inset 0 0 0 1.5px #b3312b; margin-top: 28px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: #ffffff12; color: var(--ben);
}
.icon-btn.ghost { background: none; }
.icon-btn svg, .tab-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn span { display: grid; }
.hint-btn { background: var(--massing); color: var(--black); }

/* Rubriker */
.title { font-family: var(--display); font-weight: 400; font-size: clamp(2.6rem, 13vw, 3.6rem); line-height: 1; margin: 0; color: var(--massing-ljus); letter-spacing: .01em; }
.title-small { font-size: 2rem; }
.subtitle { color: #b9c7c9; margin: 6px 0 22px; }
.top { padding: calc(18px + var(--safe-t)) 20px 8px; text-align: center; }
.progress { margin: 4px 0 0; color: #b9c7c9; font-size: .95rem; }

/* Intro */
.intro { position: relative; min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end; }
.intro .scene { position: absolute; inset: 0 0 auto 0; width: 100%; height: 52dvh; }
.intro-text { position: relative; padding: 46dvh 24px calc(28px + var(--safe-b)); background: linear-gradient(#0e1b2400 30dvh, var(--natt) 50dvh); }
.prologue { font-family: var(--letter); color: #dcd3bd; font-size: .98rem; line-height: 1.6; }

/* Scenen */
.scene { display: block; background: linear-gradient(#0a141c, #16293a 70%, #24424a); }
.scene-star { fill: #fff; opacity: .7; animation: twinkle 4s infinite ease-in-out; }
@keyframes twinkle { 50% { opacity: .2; } }
.scene-hill { fill: #12232e; }
.scene-house, .scene-tower { fill: #0a141c; }
.scene-window { fill: #f0d58a; opacity: .85; }
.scene-snow { fill: #dfeaf0; }
.scene-dial { fill: #c9c2ad; }
.scene-hands { stroke: #1c1712; stroke-width: 1.6; stroke-linecap: round; fill: none; }
.scene-vinterljus { fill: #3a4a52; }
.scene-glow { fill: #f0d58a; opacity: 0; }
.scene-lit .scene-vinterljus { fill: #fff3c4; filter: drop-shadow(0 0 6px #f0d58a); animation: starOn 2.4s ease-out both; }
.scene-lit .scene-glow { animation: glowOn 3s ease-out forwards; filter: blur(22px); }
@keyframes starOn { from { fill: #3a4a52; transform: scale(.6); } 60% { transform: scale(1.25); } }
.scene-vinterljus { transform-origin: 200px 62px; }
@keyframes glowOn { to { opacity: .45; } }

/* Bokstavsraden */
.phrase { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; padding: 8px 14px 4px; }
.phrase-word { display: flex; gap: 3px; }
.phrase-slot {
  width: 17px; height: 24px; display: grid; place-items: center; border-bottom: 2px solid #ffffff30;
  font-family: var(--display); font-size: 1rem; color: var(--massing-ljus);
}
.phrase-slot.got { border-color: var(--massing); }
.ribbon { margin: 10px 20px 0; padding: 8px 12px; border-radius: 8px; background: #d2a84a1f; color: var(--massing-ljus); font-size: .82rem; text-align: center; }

/* Skåpet */
.cabinet-view { padding-bottom: calc(96px + var(--safe-b)); }
.cabinet {
  margin: 16px 12px 0; padding: 0 10px; border-radius: 120px 120px 10px 10px / 54px 54px 10px 10px;
  background: linear-gradient(90deg, #6f251c, var(--falu) 12%, var(--falu) 88%, #6f251c);
  box-shadow: inset 0 0 0 2px #00000030, 0 20px 40px #000a;
}
.cabinet-crown { height: 58px; display: grid; place-items: center; padding-top: 14px; }
.cabinet-crown span { font-family: var(--display); font-size: .86rem; color: #f0d58acc; letter-spacing: .08em; }
.drawers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 8px; background: var(--falu-dark); border-radius: 6px; box-shadow: inset 0 2px 8px #0008; }
.cabinet-foot { height: 22px; }
.drawer {
  position: relative; aspect-ratio: 1 / 1.08; border: 0; border-radius: 5px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8%;
  background: linear-gradient(#37706c, var(--gron) 30%, var(--gron-dark));
  box-shadow: inset 0 0 0 1px #00000040, inset 0 0 0 5px var(--gron), inset 0 0 0 6px #ffffff24, 0 2px 0 #0006;
  transition: transform .1s;
}
.drawer:active { transform: translateY(2px); }
.plate {
  min-width: 52%; padding: 1px 8px 2px; border-radius: 40px; text-align: center;
  background: linear-gradient(var(--massing-ljus), var(--massing)); color: var(--black);
  font-family: var(--display); font-size: clamp(1.05rem, 5vw, 1.4rem); line-height: 1.3; box-shadow: 0 1px 0 #0007;
}
.knob { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c4, var(--massing) 55%, #7a5c1c); box-shadow: 0 2px 2px #0008; }
.drawer.locked { filter: saturate(.55) brightness(.62); }
.drawer.locked .knob { background: #4a4433; }
.drawer.today { box-shadow: inset 0 0 0 1px #00000040, inset 0 0 0 5px var(--gron), inset 0 0 0 6px #ffffff24, 0 0 0 2px var(--massing-ljus), 0 0 18px #f0d58a99; }
.drawer.solved { background: #17302e; box-shadow: inset 0 3px 10px #000b, inset 0 0 0 1px #0006; }
.drawer.solved .knob { display: none; }

/* Kugghjul */
.cog { display: block; }
.cog-body { fill: var(--massing); }
.cog-ring { fill: #b88f38; stroke: #8a6a22; stroke-width: 1.5; }
.cog-hole { fill: var(--natt); }
.cog-letter { font-family: var(--display); font-size: 34px; fill: var(--black); }
.cog-drawer { width: 76%; }
.cog-medium { width: 84px; margin: 0 auto; }
.cog-tiny { width: 34px; }
.cog-big { width: 150px; margin: 8px auto 18px; animation: cogIn 1.2s cubic-bezier(.2, .9, .3, 1) both; filter: drop-shadow(0 8px 14px #0008); }
@keyframes cogIn { from { transform: rotate(-200deg) scale(.3); opacity: 0; } }

/* Flikar */
.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: inherit; z-index: 5;
  display: flex; padding: 6px 8px calc(6px + var(--safe-b)); background: #0a141cf2; border-top: 1px solid #ffffff1a; backdrop-filter: blur(8px);
}
@media (min-width: 700px) and (min-height: 600px) { .tabs { max-width: 460px; } }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: #93a4a8; font-size: .78rem; border-radius: 8px; }
.tab.active { color: var(--massing-ljus); }
.tab-icon { display: grid; }

/* Brev och papper */
.paper {
  margin: 16px 18px; padding: 20px 20px 12px; background: var(--ben); color: var(--black); border-radius: 3px;
  font-family: var(--letter); font-size: 1rem; line-height: 1.62; box-shadow: 0 10px 24px #0007; transform: rotate(-.4deg);
  background-image: linear-gradient(#0000 0, #0000 calc(100% - 1px), #1c171210 100%); background-size: 100% 1.62em;
}
.paper:nth-of-type(even) { transform: rotate(.5deg); }
.paper-head { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 1.15rem; color: var(--falu); }
.letters-view, .settings-view { padding-bottom: calc(100px + var(--safe-b)); }
.empty { margin: 30px 28px; text-align: center; color: #b9c7c9; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 20px; padding: 16px 0; border-bottom: 1px solid #ffffff1a; }
.setting strong { display: block; }
.setting small { color: #b9c7c9; font-size: .86rem; }
.setting input { width: 26px; height: 26px; accent-color: var(--massing); flex: none; }
.about { margin: 22px 20px 0; color: #d5dcdc; font-size: .95rem; }
.about h2 { font-family: var(--display); font-weight: 400; color: var(--massing-ljus); margin: 0 0 8px; font-size: 1.3rem; }
.settings-view .btn { width: calc(100% - 40px); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 30; width: max-content; max-width: 86vw;
  padding: 11px 16px; border-radius: 10px; background: var(--ben); color: var(--black); font-weight: 600; box-shadow: 0 8px 24px #000a; animation: toastIn .25s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Lådvyn */
.drawer-view { position: fixed; inset: 0; z-index: 10; overflow-y: auto; overflow-x: hidden; background: var(--natt); animation: drawerIn .28s ease-out; }
@media (min-width: 700px) and (min-height: 600px) { .drawer-view { left: 50%; right: auto; width: 460px; transform: translateX(-50%); animation: none; } }
@keyframes drawerIn { from { opacity: 0; transform: translateY(24px); } }
.drawer-bar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 12px 10px; background: #0e1b24f2; backdrop-filter: blur(8px); }
.drawer-title { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--display); font-size: 1.2rem; color: var(--massing-ljus); min-width: 0; }
.drawer-num { flex: none; min-width: 34px; padding: 0 9px; border-radius: 30px; background: linear-gradient(var(--massing-ljus), var(--massing)); color: var(--black); text-align: center; }
.drawer-body { padding: 4px 0 calc(40px + var(--safe-b)); }
.drawer-body > .btn { width: calc(100% - 36px); }
.paper-letter { margin-top: 10px; }
.solved-box { text-align: center; margin: 22px 20px; color: #d5dcdc; }
.stars { display: block; text-align: center; font-size: 1.7rem; letter-spacing: .2em; margin: 6px 0; }
.star { color: #ffffff26; }
.star.on { color: var(--massing-ljus); text-shadow: 0 0 12px #f0d58a88; }
.task { margin: 8px 22px 14px; font-size: 1.02rem; color: #e6ecea; text-align: center; text-wrap: balance; }
.puzzle { padding: 0 18px; }
.alt-link { display: block; margin: 34px auto 0; padding: 10px 14px; max-width: 320px; border: 0; background: none; color: #93a4a8; font-size: .86rem; text-decoration: underline; text-underline-offset: 3px; }
.alt-link.on { color: var(--massing-ljus); text-decoration: none; cursor: default; }
.answer-msg { min-height: 1.5em; margin: 10px 0 0; text-align: center; color: #f0c9a0; font-size: .95rem; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* Ledtrådar */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: #000a; }
.sheet { width: 100%; max-width: 460px; max-height: 86dvh; overflow-y: auto; padding: 20px 20px calc(22px + var(--safe-b)); background: var(--natt-2); border-radius: 18px 18px 0 0; animation: drawerIn .22s ease-out; }
.sheet h2 { margin: 0 0 10px; font-family: var(--display); font-weight: 400; color: var(--massing-ljus); }
.sheet-note { color: #b9c7c9; }
.hint { padding: 12px 14px; border-radius: 10px; background: #ffffff10; }
.hint strong { display: block; color: var(--massing-ljus); font-size: .85rem; }

/* Belöning och final */
.reward { text-align: center; padding: 12px 22px; }
.reward-after { font-family: var(--letter); font-size: 1.05rem; color: #e6dcc3; }
.reward-letter { color: #b9c7c9; }
.reward-letter strong { font-family: var(--display); font-size: 1.4rem; color: var(--massing-ljus); font-weight: 400; }
.reward .phrase { margin: 10px 0 6px; }
.finale .scene { width: 100%; height: 44dvh; }
.finale-text { padding: 18px 24px; text-align: center; }
.finale-text p { font-family: var(--letter); color: #e6dcc3; }
.finale-text .finale-phrase { font-family: var(--display); font-size: 2rem; line-height: 1.15; color: var(--massing-ljus); margin: 14px 0; text-wrap: balance; }
.finale-text .finale-score { font-family: var(--ui); color: #b9c7c9; }

/* Sifferlås och ordsvar */
.lock { margin-top: 20px; }
.wheels { display: flex; justify-content: center; gap: 10px; }
.wheel { display: flex; flex-direction: column; align-items: center; background: linear-gradient(90deg, #8a6a22, var(--massing) 30%, var(--massing-ljus) 50%, var(--massing) 70%, #8a6a22); border-radius: 10px; padding: 2px; box-shadow: 0 4px 10px #0007; }
.wheel-btn { width: 58px; height: 40px; border: 0; background: none; color: #5a4310; font-size: .9rem; }
.wheel-digit { width: 52px; height: 54px; display: grid; place-items: center; background: var(--ben); color: var(--black); border-radius: 4px; font-family: var(--display); font-size: 2rem; box-shadow: inset 0 3px 6px #0005; }
.word { margin-top: 20px; }
.word-row { display: flex; gap: 8px; max-width: 380px; margin: 0 auto; }
.word-row .btn { width: auto; margin: 0; flex: none; }
.word-input { flex: 1; min-width: 0; padding: 12px 14px; border: 2px solid var(--massing); border-radius: 10px; background: var(--ben); color: var(--black); font: 1.1rem var(--letter); text-transform: uppercase; letter-spacing: .08em; }
.word-input::placeholder { text-transform: none; letter-spacing: 0; color: #7a715e; }

/* Urtavla */
.clock-wrap { text-align: center; }
.clock { width: min(64vw, 250px); display: block; margin: 0 auto; }
.clock-mirror { transform: scaleX(-1); }
.clock-rim { fill: var(--massing); }
.clock-face { fill: var(--ben); }
.clock-tick { stroke: var(--black); stroke-width: 2.5; }
.clock-num { font-family: var(--display); font-size: 17px; fill: var(--black); }
.hand { stroke: var(--black); stroke-linecap: round; transition: transform .25s; transform-box: view-box; }
.hand-h { stroke-width: 6; }
.hand-m { stroke-width: 3.5; }
.clock-hub { fill: var(--falu); }
.clock-controls { display: flex; gap: 6px; max-width: 380px; margin: 14px auto 0; }

/* 1 Frost */
.frost-pane { position: relative; aspect-ratio: 4 / 3; border: 10px solid #5a3a22; border-radius: 6px; background: linear-gradient(#0a141c, #24424a); overflow: hidden; box-shadow: 0 10px 24px #0007; }
.frost-bars { position: absolute; inset: 0; background: linear-gradient(90deg, #0000 calc(50% - 4px), #5a3a22 0 calc(50% + 4px), #0000 0), linear-gradient(#0000 calc(50% - 4px), #5a3a22 0 calc(50% + 4px), #0000 0); }
.frost-n { position: absolute; font-family: var(--display); font-size: 3.2rem; line-height: 1; color: var(--massing-ljus); text-align: center; }
.frost-n i { display: block; font-style: normal; font-size: .9rem; letter-spacing: .15em; }
.frost-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }

/* 2 Spegel */
.mirror-note { margin: 10px 4px; padding: 26px 20px 18px; }
.mirrored { transform: scaleX(-1); font-size: 1.15rem; }

/* 3 Glob */
.globe-canvas { display: block; width: min(100%, 330px); margin: 0 auto; }

/* 4 Ljusslinga */
.pipes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-width: 340px; margin: 0 auto; padding: 8px; background: #5a3a22; border-radius: 10px; box-shadow: 0 10px 24px #0007; }
.pipe { aspect-ratio: 1; padding: 0; border: 0; border-radius: 5px; background: #12232e; overflow: hidden; }
.pipe svg { display: block; transition: transform .2s; }
.wire { stroke: #4b5c63; stroke-width: 12; stroke-linecap: round; }
.joint { fill: #4b5c63; }
.bulb { fill: #2a3a42; stroke: #4b5c63; stroke-width: 5; }
.battery { fill: var(--massing); stroke: #8a6a22; stroke-width: 4; }
.pipe.lit .wire { stroke: var(--massing-ljus); }
.pipe.lit .joint { fill: var(--massing-ljus); }
.pipe.lit .bulb { fill: #fff3c4; stroke: var(--massing-ljus); filter: drop-shadow(0 0 8px #f0d58a); }

/* 5 Räknesnurra */
.calc { max-width: 320px; margin: 0 auto; padding: 16px; border-radius: 16px; background: linear-gradient(#3b4d4a, #24332f); box-shadow: 0 10px 24px #0007, inset 0 1px 0 #ffffff26; }
.calc-display { display: flex; justify-content: flex-end; gap: 4px; padding: 12px; background: #0b130f; border-radius: 8px; box-shadow: inset 0 3px 8px #000; }
.seg-digit { width: 11%; }
.seg { fill: #17251d; }
.seg.on { fill: #7dffb0; filter: drop-shadow(0 0 3px #7dffb0aa); }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.calc-key { padding: 13px 0; border: 0; border-radius: 9px; background: var(--ben); color: var(--black); font-size: 1.2rem; font-weight: 650; box-shadow: 0 3px 0 #8f8771; }
.calc-key:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f8771; }
.calc-key.op { background: var(--falu); color: var(--ben); box-shadow: 0 3px 0 #4a1812; }
.calc-key.wide { grid-column: span 4; }

/* 6 Glöd */
.hearth { --g: 0; position: relative; height: 250px; max-width: 340px; margin: 0 auto; border-radius: 120px 120px 8px 8px; background: #0a0a0a; border: 12px solid #3a3a3a; overflow: hidden; box-shadow: 0 10px 24px #0007; }
.hearth-coals { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 4px; }
.hearth-coals span { width: 44px; height: 30px; border-radius: 50% 50% 40% 40%; background: radial-gradient(circle at 50% 40%, rgb(255 180 80 / calc(.15 + var(--g) * .85)), rgb(200 50 20 / calc(.25 + var(--g) * .75)) 55%, #1a0d08); box-shadow: 0 0 calc(var(--g) * 30px) rgb(255 120 40 / calc(var(--g) * .8)); }
.hearth-coals span:nth-child(odd) { height: 24px; margin-top: 8px; }
.hearth-flame { position: absolute; left: 50%; bottom: 30px; width: 120px; height: 170px; transform: translateX(-50%) scale(0); transform-origin: 50% 100%; border-radius: 50% 50% 20% 20% / 70% 70% 30% 30%; background: radial-gradient(ellipse at 50% 85%, #fff3c4, #f0a030 40%, #c8321400 72%); opacity: 0; transition: transform 1s, opacity 1s; }
.hearth.burning .hearth-flame { opacity: 1; transform: translateX(-50%) scale(1); animation: flicker .5s infinite alternate; }
@keyframes flicker { to { transform: translateX(-50%) scale(1.06, .94); } }

/* 7 Chifferhjul */
.cipher-text { text-align: center; font-family: var(--letter); color: #e6dcc3; }
.cipher-text strong { display: block; margin-top: 4px; font-size: 1.7rem; letter-spacing: .1em; color: var(--massing-ljus); }
.cipher-wheel { display: block; width: min(100%, 350px); margin: 0 auto; }
.cw-outer { fill: var(--massing); }
.cw-inner { fill: var(--ben); }
.cw-core { fill: var(--falu); }
.cw-letter { font: 700 15px var(--ui); fill: var(--black); }
.cw-tick { stroke: #1c171240; stroke-width: 1; }
.cw-count { font: 34px var(--display); fill: var(--massing-ljus); }
.cw-count-label { font: 13px var(--ui); fill: #f0d58acc; }
.wheel-inner { transform-origin: 150px 150px; transition: transform .25s; }

/* 8 Bläck */
.ink-sheet { min-height: 240px; margin: 0 4px; padding: 22px 20px; border-radius: 3px; background: #f7f1e1; color: #6d675b; font-family: var(--letter); box-shadow: 0 10px 24px #0007; transition: background 1.6s, color 1.6s; }
.ink-pencil { font-size: .95rem; }
.ink-secret { margin-top: 34px; font-size: 1.25rem; line-height: 1.5; color: transparent; transition: color 1.8s .6s, text-shadow 1.8s .6s; }
.ink-sheet.ink-night { background: #101820; color: #5d6b74; }
.ink-revealed.ink-night .ink-secret { color: #b7ffd8; text-shadow: 0 0 12px #6affb4; }
.ink-revealed:not(.ink-night) .ink-secret { color: #5e1f18; }

/* 9 Klockspel */
.bells { display: flex; justify-content: center; align-items: flex-start; gap: 6px; padding-top: 6px; }
.bell { flex: 1; max-width: 68px; padding: 0 0 6px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; transform-origin: 50% 0; }
.bell-body { display: block; width: 100%; aspect-ratio: 1 / 1.15; border-radius: 50% 50% 14% 14% / 62% 62% 12% 12%; background: linear-gradient(100deg, #8a6a22, var(--massing) 35%, var(--massing-ljus) 55%, var(--massing) 75%, #8a6a22); box-shadow: 0 6px 10px #0007; }
.bell-0 .bell-body { width: 100%; } .bell-1 .bell-body { width: 92%; } .bell-2 .bell-body { width: 84%; } .bell-3 .bell-body { width: 76%; } .bell-4 .bell-body { width: 68%; }
.bell-num { color: #b9c7c9; font-family: var(--display); }
.bell.ringing { animation: ring .38s ease-out; }
.bell.ringing .bell-body { filter: brightness(1.5) drop-shadow(0 0 14px #f0d58a); }
@keyframes ring { 25% { transform: rotate(9deg); } 60% { transform: rotate(-7deg); } }
.round-dots { display: flex; justify-content: center; gap: 10px; margin: 18px 0 4px; }
.round-dots span { width: 12px; height: 12px; border-radius: 50%; background: #ffffff22; }
.round-dots span.on { background: var(--massing-ljus); box-shadow: 0 0 10px #f0d58a; }

/* 10 Labyrint */
.maze-canvas { display: block; width: min(100%, 330px); margin: 0 auto; border: 8px solid #3b2416; border-radius: 8px; box-shadow: 0 10px 24px #0007; }

/* 11 Fönster */
.house { max-width: 280px; margin: 0 auto; }
.house-roof { height: 80px; background: var(--falu-dark); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.house-wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 20px; background: var(--falu); box-shadow: 0 10px 24px #0007; }
.window { aspect-ratio: 1 / 1.15; border: 5px solid var(--ben); border-radius: 3px; padding: 0; background: #0a141c; transition: background .2s, box-shadow .2s; background-image: linear-gradient(90deg, #0000 calc(50% - 2px), var(--ben) 0 calc(50% + 2px), #0000 0), linear-gradient(#0000 calc(50% - 2px), var(--ben) 0 calc(50% + 2px), #0000 0); }
.window.on { background-color: #ffd97a; box-shadow: 0 0 22px #ffd97a99; }

/* 12 Tystnad */
.noise-sky { position: relative; height: 330px; border-radius: 10px; overflow: hidden; background: linear-gradient(#0a141c, #16293a); box-shadow: inset 0 0 0 1px #ffffff14; }
.noise-sky::before { content: ''; position: absolute; inset: -20px; background: repeating-linear-gradient(0deg, #ffffff12 0 1px, #0000 1px 4px); animation: static .25s steps(3) infinite; transition: opacity 1.5s; }
@keyframes static { to { transform: translateY(6px); } }
.noise-word { position: absolute; padding: 3px 9px; border-radius: 20px; background: #ffffff1c; color: #dfe7e8; font-size: .86rem; animation: jitter 1.3s infinite ease-in-out alternate; transition: opacity 1.2s; }
@keyframes jitter { from { transform: translate(-8px, 3px) rotate(-3deg); } to { transform: translate(9px, -4px) rotate(3deg); } }
.quiet-star { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff; opacity: 0; transition: opacity 1.4s; box-shadow: 0 0 8px #fff; }
.quiet-text { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; font-family: var(--display); font-size: 1.5rem; color: var(--massing-ljus); opacity: 0; transition: opacity 1.4s 1s; }
.noise-sky.quiet::before, .noise-sky.quiet .noise-word { opacity: 0; }
.noise-sky.quiet .quiet-star, .noise-sky.quiet .quiet-text { opacity: 1; }

/* 13 Luciatåg */
.clues { margin: 0 4px 16px; padding: 14px 16px 14px 34px; background: var(--ben); color: var(--black); border-radius: 3px; font-family: var(--letter); font-size: .95rem; }
.clues li { margin: 4px 0; }
.train { display: flex; gap: 5px; }
.kid { flex: 1; min-width: 0; padding: 10px 2px 6px; border: 2px solid #0000; border-radius: 10px; background: #ffffff12; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kid.picked { border-color: var(--massing-ljus); background: #d2a84a33; transform: translateY(-6px); }
.kid-icon { font-size: 1.7rem; line-height: 1.1; }
.kid-name { font-size: .66rem; text-align: center; hyphens: manual; line-height: 1.2; min-height: 2.4em; }
.kid-pos { font-family: var(--display); color: var(--massing-ljus); }

/* 14 Lykta */
.lantern { width: 110px; height: 150px; margin: 0 auto; padding: 22px 16px 16px; border-radius: 30px 30px 10px 10px; background: #1c1712; border: 4px solid #5a4310; box-shadow: 0 10px 24px #0007; }
.lantern-glass { height: 100%; border-radius: 16px 16px 6px 6px; background: #2a2a22; transition: background .05s, box-shadow .05s; }
.lantern.on .lantern-glass { background: #fff3c4; box-shadow: 0 0 50px 16px #f0d58a; }
.morse-table { margin: 18px 0 0; padding: 10px 12px; border-radius: 10px; background: #ffffff0f; }
.morse-table summary { color: var(--massing-ljus); cursor: pointer; }
.morse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px 10px; margin-top: 10px; font-size: .78rem; letter-spacing: .08em; white-space: nowrap; }
.morse-grid b { display: inline-block; width: 1.4em; font-size: .95rem; color: var(--massing-ljus); }

/* 15 Räkning */
.bill { margin: 6px 4px; padding: 18px 14px 8px; background-image: none; }
.bill-row { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 1.7rem; margin: 0 0 10px; }
.bill-num { font-family: var(--display); min-width: 1.4em; text-align: center; }

/* 16 Deg */
.dough { --rise: 0; position: relative; width: 220px; height: 170px; margin: 10px auto 0; }
.dough-bowl { position: absolute; left: 0; right: 0; bottom: 0; height: 90px; border-radius: 12px 12px 110px 110px / 12px 12px 90px 90px; background: linear-gradient(#f1ede2, #cfc8b6); box-shadow: 0 10px 20px #0007; }
.dough-bun { position: absolute; left: 22px; right: 22px; bottom: 70px; height: 70px; border-radius: 50% 50% 10% 10% / 90% 90% 10% 10%; background: radial-gradient(ellipse at 40% 30%, #ffe9a8, #e9c46a); transform-origin: 50% 100%; transform: scaleY(calc(.35 + var(--rise) * .95)); }

/* 17 Rutmönster */
.nono { display: grid; grid-template-columns: 54px repeat(5, 1fr); gap: 4px; max-width: 330px; margin: 0 auto; }
.nono-clue { display: flex; gap: 10px; align-items: center; justify-content: flex-end; font-family: var(--display); font-size: 1.15rem; color: var(--massing-ljus); padding-right: 8px; }
.nono-col { flex-direction: column; gap: 0; justify-content: flex-end; padding: 0 0 6px; min-height: 54px; }
.nono-clue b { font-weight: 400; }
.nono-cell { aspect-ratio: 1; border: 0; border-radius: 4px; background: var(--ben); padding: 0; position: relative; }
.nono-cell.fill { background: var(--lingon); box-shadow: inset 0 0 0 3px #7d201b; }
.nono-cell.cross::after { content: '×'; position: absolute; inset: 0; display: grid; place-items: center; color: #8f8771; font-size: 1.6rem; }

/* 18 Gårdstomten */
.porch { position: relative; height: 300px; border-radius: 10px; overflow: hidden; background: linear-gradient(#0a141c, #1b3340 70%, #dfeaf0 70%); }
.porch-moon { position: absolute; right: 36px; top: 30px; width: 44px; height: 44px; border-radius: 50%; background: #f4f0dc; box-shadow: 0 0 30px #f4f0dc88; }
.porch-step { position: absolute; left: 22%; right: 22%; top: 62%; height: 22px; background: #5a3a22; border-radius: 3px; }
.porch-bowl { position: absolute; left: 50%; top: 44%; font-size: 3.2rem; transform: translateX(-50%); transition: filter 1s, opacity 1s; z-index: 1; }
.porch-prints { position: absolute; left: 8%; bottom: 26px; color: #8aa0ab; font-size: 1.6rem; letter-spacing: .1em; opacity: 0; transition: opacity 1.2s .4s; white-space: pre; }
.porch-thanks { position: absolute; left: 66%; top: 51%; opacity: 0; transition: opacity 1s .8s; z-index: 1; }
.porch.visited .porch-bowl { filter: grayscale(1) brightness(.6); opacity: .75; }
.porch.visited .porch-prints, .porch.visited .porch-thanks { opacity: 1; }
.blindfold { position: fixed; inset: 0; z-index: 40; background: #000; display: grid; place-items: center; color: #555; }

/* 19 Spegel */
.mirror-frame { width: fit-content; margin: 0 auto 22px; padding: 14px; border-radius: 50% / 46%; background: linear-gradient(135deg, #cfe0e6, #7f9aa6 50%, #cfe0e6); border: 8px solid var(--massing); box-shadow: 0 10px 24px #0007; }
.mirror-frame .clock { width: min(40vw, 150px); }

/* 20 Sigill */
.seals { --p: 0; position: relative; aspect-ratio: 1 / 1.25; max-width: 340px; margin: 0 auto; border-radius: 12px; background: #5a3a22; box-shadow: inset 0 0 0 6px #3b2416, 0 10px 24px #0007; touch-action: none; user-select: none; -webkit-user-select: none; }
.seal { position: absolute; width: 84px; height: 84px; border: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d6564d, var(--lingon) 50%, #6f1b16); color: #f3c9c4; font: 1.9rem var(--display); box-shadow: 0 5px 0 #4a1210, 0 10px 14px #0008; touch-action: none; -webkit-touch-callout: none; }
.seal-0 { left: 16px; top: 16px; } .seal-1 { right: 16px; top: 16px; } .seal-2 { left: 16px; bottom: 16px; } .seal-3 { right: 16px; bottom: 16px; }
.seal.down { transform: translateY(4px); box-shadow: 0 1px 0 #4a1210, 0 0 26px #f0d58a; background: radial-gradient(circle at 35% 30%, #fff3c4, var(--massing) 55%, #8a6a22); color: var(--black); }
.seal-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(calc(var(--p) * 360deg)); opacity: calc(.25 + var(--p) * .75); pointer-events: none; }

/* 21 Remsa */
.strip-window { display: flex; justify-content: center; overflow: hidden; margin: 30px -18px 10px; padding: 12px 0; }
.strip-window.scrollable { justify-content: flex-start; overflow-x: auto; }
.strip { display: flex; justify-content: space-between; align-items: center; gap: 1.2vmax; flex: none; width: 86vmax; padding: 14px 1.6vmax; background: var(--ben); color: var(--black); font-family: var(--letter); font-size: 1.8vmax; white-space: nowrap; box-shadow: 0 6px 14px #0007; }
.strip-code { font-weight: 700; color: var(--falu); letter-spacing: .12em; }

/* 22 Tråd */
.thread { display: block; width: min(100%, 310px); margin: 0 auto; }
.thread-edge { stroke: #ffffff2e; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 9; }
.thread-edge.drawn { stroke: var(--massing-ljus); stroke-dasharray: none; filter: drop-shadow(0 0 4px #f0d58a); }
.thread-node { fill: var(--ben); stroke: var(--massing); stroke-width: 4; }
.thread-node.current { fill: var(--lingon); }
.thread-hit { fill: #0000; cursor: pointer; }

/* 23 Tornlås */
.guesses { margin: 6px 4px; padding: 16px 16px 6px; font-size: .92rem; background-image: none; }
.guesses b { display: block; font: 1.7rem var(--display); font-weight: 400; color: var(--falu); letter-spacing: .1em; }

/* 24 Final */
.wind { --p: 0; position: relative; width: min(84vw, 330px); aspect-ratio: 1; margin: 16px auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.wind-cog { position: absolute; left: 44%; top: 0; width: 12%; height: 100%; pointer-events: none; }
.wind-cog .cog { opacity: .22; transition: opacity .3s; }
.wind-cog.on .cog { opacity: 1; animation: spin 2.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wind-star { position: absolute; inset: 22%; border: 0; border-radius: 50%; padding: 0; background: radial-gradient(circle, rgb(240 213 138 / calc(var(--p) * .7)), #0000 70%); touch-action: none; -webkit-touch-callout: none; }
.wind-star svg { display: block; width: 100%; transform: rotate(calc(var(--p) * 180deg)); }
.wind-star path { fill: color-mix(in srgb, #fff3c4 calc(var(--p) * 100%), #3a4a52); stroke: var(--massing); stroke-width: 2; }
.wind.lit .wind-star svg { filter: drop-shadow(0 0 26px #f0d58a); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .intro .scene { height: 100dvh; opacity: .5; }
  .intro-text { padding-top: 24px; background: none; }
}
