:root {
  --night: #0a1322;
  --night-2: #111d31;
  --glass: rgba(14, 24, 40, 0.72);
  --glass-line: rgba(232, 222, 200, 0.16);
  --ink: #f3ecdf;
  --ink-dim: rgba(243, 236, 223, 0.72);
  --gold: #e0b866;
  --gold-deep: #b98a35;
  --red: #b8322c;
  --green: #2f8f52;
  --green-hi: #49b56d;
  --frost: #cfe3f2;
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font: 16px/1.5 var(--sans); overscroll-behavior: none; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
img { display: block; }

#app { position: fixed; inset: 0; overflow: hidden; max-width: 560px; margin: 0 auto; background: var(--night); }

/* ── Karta ─────────────────────────────────────────────── */
.view { position: absolute; inset: 0; }
.map-scroll { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 40%, #13213a, #070d18); overflow: hidden; touch-action: none; cursor: grab; }
.map-scroll:active { cursor: grabbing; }
.map-scroll::-webkit-scrollbar { display: none; }
.map { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; --inv: 1; opacity: 0; transition: opacity .8s ease; }
.is-ready .map { opacity: 1; }
.map-img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.fog { position: absolute; inset: -2%; width: 104%; height: 104%; pointer-events: none; animation: drift 16s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate3d(-4px, 0, 0) scale(1); } to { transform: translate3d(6px, -5px, 0) scale(1.012); } }

/* vinjett så att UI går att läsa */
.view-map::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(6,12,22,.72) 0, rgba(6,12,22,0) 150px), linear-gradient(to top, rgba(6,12,22,.45) 0, rgba(6,12,22,0) 160px); }

.markers { position: absolute; inset: 0; }
.marker { position: absolute; transform: translate(-50%, -50%) scale(var(--inv)); border: 0; background: none; padding: 0; min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.marker .dot { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, #fff6d8 0 30%, var(--gold) 31% 60%, rgba(224,184,102,0) 61%); box-shadow: 0 0 0 3px rgba(224,184,102,.35), 0 0 18px rgba(255,214,140,.8); }
.marker-label { position: absolute; top: 34px; white-space: nowrap; font: 600 12px/1 var(--sans); letter-spacing: .02em; padding: 6px 10px; border-radius: 999px; background: rgba(10,19,34,.78); border: 1px solid var(--glass-line); backdrop-filter: blur(6px); }
.marker-current { transform: translate(-50%, -100%) scale(var(--inv)); transform-origin: 50% 100%; z-index: 3; }
.pin-label { position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 12px/1 var(--sans); padding: 6px 10px; border-radius: 999px; background: rgba(10,19,34,.82); border: 1px solid rgba(224,184,102,.5); color: var(--ink); }
.route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.route path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.route-glow { stroke: rgba(255,200,110,.35); stroke-width: 9; filter: blur(3px); }
.route-line { stroke: #ffe3a3; stroke-width: 3.5; stroke-dasharray: 1 9; }
.stop { position: absolute; transform: translate(-50%, -50%) scale(var(--inv)); width: 44px; height: 44px; border: 0; padding: 0; background: none; display: grid; place-items: center; z-index: 1; }
/* Dagpunkterna: små guldmynt med präglad kant och serifsiffra */
.stop span { position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 650 13px/1 var(--serif); font-variant-numeric: lining-nums; color: #4a3208; text-shadow: 0 1px 0 rgba(255,244,214,.7);
  background: radial-gradient(circle at 34% 28%, #fff6d8 0 12%, #f3d48a 38%, #d9a84c 70%, #a87a2c 100%);
  box-shadow: inset 0 0 0 2px rgba(255,240,200,.55), inset 0 0 0 3.5px rgba(122,82,20,.55), inset 0 -3px 5px rgba(90,56,10,.35), 0 0 0 1.5px rgba(10,19,34,.75), 0 3px 6px rgba(0,0,0,.45), 0 0 14px rgba(255,210,130,.45); transition: transform .2s ease; }
.stop span::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(125deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 58%); background-size: 260% 100%; background-position: 120% 0; animation: coin-glint 7s ease-in-out infinite; animation-delay: var(--glint, 0s); mix-blend-mode: soft-light; pointer-events: none; }
.stop:active span { transform: scale(.92); }
/* Klarat uppdrag: liten grön bock i hörnet */
.stop.is-done span::after { content: ''; position: absolute; right: -5px; top: -5px; width: 14px; height: 14px; border-radius: 50%; background: #2f8f52 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.4l2.6 2.5L12 5.4' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; box-shadow: 0 0 0 1.5px #0a1322, 0 1px 3px rgba(0,0,0,.5); }
/* Oläst brev på en tidigare dag: rött lackmynt med guldkant som pulserar */
.stop.is-new span { color: #ffe3a3; text-shadow: 0 1px 0 rgba(60,8,4,.6); background: radial-gradient(circle at 34% 28%, #ff9d8c 0 10%, #d9493d 40%, #9e2520 100%); box-shadow: inset 0 0 0 2px rgba(255,200,150,.35), inset 0 0 0 3.5px rgba(224,184,102,.9), 0 0 0 1.5px rgba(10,19,34,.75), 0 3px 6px rgba(0,0,0,.45), 0 0 16px rgba(255,110,80,.75); animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes coin-glint { 0%, 80% { background-position: 120% 0; } 100% { background-position: -40% 0; } }
/* Ett mynt dyker upp när Nissen just passerat platsen */
.stop.is-pop span { animation: coin-pop .5s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes coin-pop { from { transform: scale(0) rotate(-90deg); } }
.place { position: absolute; transform: translate(-50%, -150%) scale(var(--inv)); transform-origin: 50% 100%; border: 0; background: none; padding: 0; z-index: 2; }
.place span { display: block; white-space: nowrap; font: 600 11px/1 var(--sans); letter-spacing: .04em; padding: 5px 9px; border-radius: 999px; background: rgba(10,19,34,.72); border: 1px solid var(--glass-line); color: var(--ink-dim); }
.pin { position: relative; width: 66px; height: 66px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); background: linear-gradient(140deg, #f4d58d, var(--gold-deep)); padding: 4px; box-shadow: 0 10px 26px rgba(0,0,0,.55), 0 0 30px rgba(255,210,130,.35); animation: bob 3.2s ease-in-out infinite; }
.pin img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; transform: rotate(45deg); }
.pin-base { position: absolute; bottom: -10px; left: 50%; width: 34px; height: 12px; margin-left: -17px; border-radius: 50%; border: 2px solid rgba(255,214,140,.9); box-shadow: 0 0 16px rgba(255,214,140,.9); animation: pulse 2.4s ease-out infinite; }
@keyframes bob { 50% { translate: 0 -5px; } }
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }

.snow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.snow i { position: absolute; top: -10px; border-radius: 50%; background: #fff; filter: blur(.4px); animation: fall linear infinite; }
@keyframes fall { to { transform: translate3d(30px, 110vh, 0); } }

/* ── Topp ──────────────────────────────────────────────── */
.topbar { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-t) + 14px) 16px 0; display: flex; justify-content: center; align-items: flex-start; pointer-events: none; z-index: 5; }
.brand { margin: 0; line-height: 0; }
.brand-logo { display: block; width: min(64vw, 280px); height: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,.55)); }
body[data-view="log"] .brand-logo { width: min(44vw, 190px); }

/* ── Dagens kort ───────────────────────────────────────── */
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

.tag { align-self: flex-start; display: inline-block; font: 700 13px/1 var(--sans); color: #2a1d08; padding: 6px 10px 5px; border-radius: 6px; background: linear-gradient(180deg, #f3dca5, #d9b46a); transform: rotate(-3deg); box-shadow: 0 2px 6px rgba(0,0,0,.35); }

/* ── Knappar ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; font: 650 16px/1 var(--sans); transition: transform .12s ease, filter .2s ease; }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { position: relative; overflow: hidden; isolation: isolate; color: #ffe3a3; font-weight: 700; letter-spacing: .01em;
  background: linear-gradient(180deg, #d8473c 0%, #b8322c 45%, #8e221e 100%);
  border: 2px solid #e0b866;
  box-shadow: 0 6px 20px rgba(150,30,24,.45), 0 0 0 1px rgba(90,20,10,.6), inset 0 1px 0 rgba(255,220,180,.35), inset 0 -3px 8px rgba(60,8,4,.35);
  text-shadow: 0 1px 0 rgba(70,10,4,.9), 0 0 10px rgba(255,200,110,.35);
  animation: btn-glow 3.2s ease-in-out infinite; }
/* Glimmer som sveper över knappen då och då */
.btn-primary::after { content: ''; position: absolute; inset: -2px; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,236,190,.55) 48%, rgba(255,255,255,.75) 50%, rgba(255,236,190,.55) 52%, transparent 65%);
  transform: translateX(-130%); animation: btn-shine 4.2s ease-in-out infinite; mix-blend-mode: soft-light; }
.btn-primary::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background: radial-gradient(120% 90% at 50% -20%, rgba(255,210,150,.35), transparent 60%); }
@keyframes btn-shine { 0%, 55% { transform: translateX(-130%); } 85%, 100% { transform: translateX(130%); } }
@keyframes btn-glow { 50% { box-shadow: 0 6px 26px rgba(200,60,40,.55), 0 0 18px rgba(255,200,110,.35), 0 0 0 1px rgba(90,20,10,.6), inset 0 1px 0 rgba(255,220,180,.35), inset 0 -3px 8px rgba(60,8,4,.35); } }
@media (prefers-reduced-motion: reduce) { .btn-primary, .btn-primary::after { animation: none; } }
.btn-primary:disabled { filter: grayscale(.8) brightness(.7); box-shadow: none; animation: none; }
.btn-primary:disabled::after { display: none; }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid rgba(224,184,102,.55); color: #f3dca5; }
.btn-ghost.danger { color: #ffb4a8; }
.btn-big { min-height: 58px; font-size: 18px; width: 100%; }
.btn-small { min-height: 40px; font-size: 14px; }

/* ── Flikar ────────────────────────────────────────────── */
.maphint { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 100px); transform: translateX(-50%); z-index: 4; margin: 0; width: max-content; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font: 600 14px/1.3 var(--sans); text-align: center; }
body[data-view="log"] .maphint { display: none; }
.pin-new { position: absolute; left: 50%; bottom: calc(100% + 30px); transform: translateX(-50%); white-space: nowrap; font: 800 13px/1 var(--sans); padding: 7px 11px; border-radius: 12px; background: #b8322c; color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.45); animation: nudge 1.6s ease-in-out infinite; pointer-events: none; }
.pin-new::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: #b8322c; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }
.tabs { position: absolute; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 10px); z-index: 4; height: 64px; display: grid; grid-template-columns: 1fr 1fr; border-radius: 22px; background: rgba(12,20,34,.5); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); }
.tab { position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 600 13px/1 var(--sans); color: var(--ink-dim); }
.tab svg { width: 26px; height: 26px; }
.tab.is-active { color: #7fd99a; }
.tab.is-active::after { content: ''; position: absolute; bottom: 6px; width: 40px; height: 3px; border-radius: 2px; background: var(--green-hi); box-shadow: 0 0 10px var(--green-hi); }
.tab-dot { position: absolute; top: 10px; left: calc(50% + 10px); width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--night); }

/* ── Meddelanden ───────────────────────────────────────── */
.view-log { overflow-y: auto; padding: calc(var(--safe-t) + 110px) 14px calc(var(--safe-b) + 100px);
  background: radial-gradient(120% 60% at 50% 0%, #1b2d4a 0%, var(--night) 60%); }
.log-head h2 { margin: 0; font: 650 28px/1.1 var(--serif); }
.log-head p { margin: 4px 0 16px; color: var(--ink-dim); font-size: 14px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.log-item { width: 100%; display: grid; grid-template-columns: 86px 1fr; gap: 14px; text-align: left; padding: 10px; border-radius: 18px; border: 1px solid var(--glass-line); background: rgba(255,255,255,.04); }
.log-item.is-new { border-color: rgba(224,184,102,.55); background: rgba(224,184,102,.07); }
.log-thumb { width: 86px; height: 110px; border-radius: 12px; overflow: hidden; position: relative; }
.log-thumb img, .log-thumb .art-fallback { width: 100%; height: 100%; object-fit: cover; }
.log-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 2px; }
.log-date { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); }
.log-date b { color: #ff9c8f; }
.log-text strong { font: 650 18px/1.2 var(--serif); }
.log-excerpt { font-size: 14px; color: var(--ink-dim); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.log-empty { color: var(--ink-dim); padding: 30px 0; text-align: center; }
body[data-view="log"] .topbar { background: linear-gradient(var(--night) 72%, transparent); padding-bottom: 26px; }

/* ── Sheet (brev/uppdrag) ──────────────────────────────── */
.sheet { position: absolute; inset: 0; z-index: 10; overflow-y: auto; background: var(--night); transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); overscroll-behavior: contain; }
.sheet.is-open { transform: none; }
.sheet-inner { min-height: 100%; padding-bottom: calc(var(--safe-b) + 28px); }
.close { position: fixed; z-index: 3; top: calc(var(--safe-t) + 12px); right: max(12px, calc(50vw - 268px)); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--glass-line); background: rgba(10,19,34,.7); backdrop-filter: blur(8px); display: grid; place-items: center; }
.close svg { width: 20px; height: 20px; }
.hero { margin: 0; position: relative; height: min(62vh, 560px); overflow: hidden; }
.hero .art, .hero .art-fallback { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
.hero::after { content: ''; position: absolute; inset: auto 0 0; height: 45%; background: linear-gradient(transparent, var(--night)); pointer-events: none; }
.hero figcaption { position: absolute; z-index: 1; left: 20px; bottom: 26px; font: 600 12px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-dim); }
.art-fallback { background: url(assets/map/world-map.webp) var(--fx) var(--fy) / 320% auto no-repeat; filter: saturate(1.05); }
.letter { position: relative; padding: 0 22px; margin-top: -8px; }
.letter h2 { margin: 12px 0 14px; font: 650 30px/1.1 var(--serif); }
.letter-body p { margin: 0 0 14px; font-size: 18px; line-height: 1.6; color: #efe7d8; }
.sign { margin: 4px 0 24px; color: var(--ink-dim); font-style: italic; }
.sign span { font: italic 650 22px/1 var(--serif); color: var(--gold); margin-left: 4px; }
.letter.center { text-align: center; display: flex; flex-direction: column; align-items: center; padding-top: calc(var(--safe-t) + 70px); }
.letter.center .tag { align-self: center; }
.avatar-big { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); margin: 10px auto 18px; box-shadow: 0 0 40px rgba(224,184,102,.35); }

.mission { padding: 18px; border-radius: 20px; background: linear-gradient(160deg, rgba(36,52,78,.7), rgba(18,28,46,.7)); border: 1px solid var(--glass-line); display: grid; gap: 12px; }
.mission.soft { background: rgba(255,255,255,.04); }
.mission h4 { margin: 0; font: 650 19px/1.2 var(--serif); color: var(--gold); }
.mission p { margin: 0; color: var(--ink-dim); }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.items label { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid transparent; font-size: 17px; cursor: pointer; }
.items input { appearance: none; width: 26px; height: 26px; flex: none; border-radius: 8px; border: 2px solid var(--gold); display: grid; place-items: center; margin: 0; }
.items input:checked { background: var(--gold); }
.items input:checked::after { content: '✓'; color: #2a1d08; font-weight: 800; font-size: 16px; }
.items label:has(input:checked) { border-color: rgba(224,184,102,.5); }
.items label:has(input:checked) span { color: var(--ink-dim); text-decoration: line-through; text-decoration-color: rgba(224,184,102,.7); }
.done-note { color: #8fe0a8; font-weight: 600; margin: 12px 0 0; }
.hint { font-size: 14px; }
.name-form { display: grid; gap: 10px; }
.name-form input, .modal input, .modal select { width: 100%; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--glass-line); background: rgba(255,255,255,.07); color: var(--ink); font: 500 18px var(--sans); }
.reply { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 16px; border-radius: 20px; background: rgba(47,143,82,.12); border: 1px solid rgba(73,181,109,.35); margin-bottom: 14px; }
.reply img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.reply-from { font: 650 15px var(--serif); color: #8fe0a8; }
.reply p { margin: 4px 0 0; font-size: 17px; }

.welcome .letter-body { text-align: left; max-width: 420px; }
.welcome .btn { width: 100%; max-width: 420px; margin-top: 6px; }
.signal { display: flex; gap: 6px; align-items: flex-end; height: 26px; margin-bottom: 12px; }
.signal i { width: 7px; border-radius: 2px; background: var(--green-hi); box-shadow: 0 0 10px var(--green-hi); animation: sig 1.4s ease-in-out infinite; }
.signal i:nth-child(1) { height: 10px; } .signal i:nth-child(2) { height: 17px; animation-delay: .2s; } .signal i:nth-child(3) { height: 26px; animation-delay: .4s; }
@keyframes sig { 50% { opacity: .35; } }

/* spel tar hela ytan */
.sheet.is-game { background: #070e1a; }
.game { min-height: 100dvh; }

/* ── Bildvisare & modal ────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(3,7,14,.7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.modal-box { width: 100%; max-width: 380px; padding: 22px; border-radius: 22px; background: var(--night-2); border: 1px solid var(--glass-line); display: grid; gap: 12px; }
.modal-box h3 { margin: 0; font: 650 22px var(--serif); }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-dim); }
.small { margin: 0; font-size: 14px; color: var(--ink-dim); }

/* ── Firande ───────────────────────────────────────────── */
.spark { position: fixed; z-index: 40; bottom: 30%; width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle, #fff, var(--gold)); box-shadow: 0 0 12px var(--gold); pointer-events: none; animation: spark 1.4s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Kortet krymper när man utforskar kartan; tryck för att fälla ut igen */
/* Utzoomat: mindre markörer, inga etiketter */
.map.is-far .place, .map.is-far .pin-label, .map.is-far .stop span { font-size: 0; }
.map.is-far .place { display: none; }
.map.is-far .stop span { width: 13px; height: 13px; }
.map.is-far .stop.is-done span::after { display: none; }
.map.is-far .marker-current { transform: translate(-50%, -100%) scale(calc(var(--inv) * .7)); }
.map.is-far .pin-label { display: none; }

/* ── Paket från Nissen ─────────────────────────────────── */
.gift { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: start; margin: 18px 0 6px; padding: 16px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(184,50,44,.28), rgba(36,52,78,.6)); border: 1px solid rgba(255,214,140,.45); box-shadow: 0 0 28px rgba(255,200,120,.15); }
.gift h4 { margin: 2px 0 4px; font: 650 19px/1.2 var(--serif); color: var(--gold); }
.gift p { margin: 0 0 12px; color: var(--ink-dim); }
.gift .btn { width: 100%; }
.gift-box { font-size: 44px; line-height: 1; animation: giftwiggle 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
.gift.is-found { background: rgba(47,143,82,.16); border-color: rgba(127,217,154,.4); box-shadow: none; }
.gift.is-found p { margin: 0; }
.gift.is-found .gift-box { animation: none; }
@keyframes giftwiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-12deg) scale(1.08); } 82% { transform: rotate(10deg) scale(1.08); } 88% { transform: rotate(-6deg); } 94% { transform: rotate(3deg); } }

/* ── Firande när ett uppdrag är klart ──────────────────── */
.reward { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, rgba(255,210,130,.42) 0, rgba(40,30,20,.35) 30%, rgba(5,10,20,.82) 70%);
  animation: rw-in .35s ease-out both; }
.reward.is-out { opacity: 0; transition: opacity .45s ease; }
.reward-rays { position: absolute; left: 50%; top: 40%; width: 180vmax; height: 180vmax; translate: -50% -50%; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255,226,160,.26) 0deg 7deg, transparent 7deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 18%, transparent 45%); mask: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 18%, transparent 45%);
  animation: rw-spin 18s linear infinite, rw-rays .9s ease-out both; }
.reward-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.reward-body { position: relative; display: grid; justify-items: center; text-align: center; padding: 0 24px; margin-top: -8vh; }
.reward-medal { position: relative; width: 150px; height: 150px; border-radius: 50%; padding: 6px;
  background: conic-gradient(from 200deg, #fff1c9, #e0b866, #a87a2c, #f4d58d, #fff1c9);
  box-shadow: 0 0 0 6px rgba(255,226,160,.25), 0 0 70px rgba(255,210,130,.85), 0 20px 40px rgba(0,0,0,.5);
  animation: rw-pop .8s cubic-bezier(.2,1.6,.4,1) .1s both; }
.reward-medal img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; animation: rw-hop 1.1s ease-in-out .9s 2; }
.reward-check { position: absolute; right: -4px; bottom: 4px; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  font: 800 28px/1 var(--sans); color: #fff; background: linear-gradient(180deg, var(--green-hi), var(--green)); border: 3px solid #fff6dc;
  box-shadow: 0 6px 16px rgba(0,0,0,.4); animation: rw-pop .5s cubic-bezier(.2,1.8,.4,1) .75s both; }
.reward-title { margin: 26px 0 6px; font: 700 clamp(40px, 12vw, 56px)/1 var(--serif); letter-spacing: -.01em;
  background: linear-gradient(180deg, #fff8e6 10%, #f4d58d 55%, #d9a443); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(90,50,10,.6)) drop-shadow(0 0 24px rgba(255,200,110,.6));
  animation: rw-title .7s cubic-bezier(.2,1.5,.4,1) .35s both; }
.reward-sub { margin: 0; font: 600 18px/1.3 var(--sans); color: #f6eedd; text-shadow: 0 2px 10px rgba(0,0,0,.8); animation: rw-fade .5s ease .7s both; }
.reward-tap { margin: 28px 0 0; font: 600 13px/1 var(--sans); letter-spacing: .08em; color: rgba(246,238,221,.6); animation: rw-fade .5s ease 1.6s both, rw-blink 1.6s ease-in-out 2.1s infinite; }
@keyframes rw-in { from { opacity: 0; } }
@keyframes rw-spin { to { rotate: 360deg; } }
@keyframes rw-rays { from { scale: .2; opacity: 0; } }
@keyframes rw-pop { from { scale: 0; opacity: 0; } }
@keyframes rw-hop { 30% { transform: translateY(-10px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
@keyframes rw-title { from { scale: .3; opacity: 0; } }
@keyframes rw-fade { from { opacity: 0; transform: translateY(8px); } }
@keyframes rw-blink { 50% { opacity: .35; } }

/* Nissen hoppar av glädje på kartan efteråt */
.marker-current.is-cheer .pin { animation: cheer .55s ease-in-out 3; }
.marker-current.is-cheer::before, .marker-current.is-cheer::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 60px; height: 60px; margin-left: -30px;
  border-radius: 50%; border: 3px solid rgba(255,220,150,.95); box-shadow: 0 0 24px rgba(255,214,140,.9); pointer-events: none; animation: cheer-ring 1.4s ease-out 2 both; }
.marker-current.is-cheer::after { animation-delay: .35s; }
@keyframes cheer { 40% { translate: 0 -22px; } 70% { translate: 0 2px; } }
@keyframes cheer-ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .reward, .reward * { animation: none !important; } }

/* ── Slutskärm: Nordpolen ──────────────────────────────── */
.finale { position: absolute; inset: 0; z-index: 3; background: #050b16; opacity: 0; transition: opacity 1.6s ease; }
.finale.is-on { opacity: 1; }
.finale-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.finale::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(5,11,22,.55), transparent 30%, transparent 72%, rgba(5,11,22,.8) 90%); }
.finale-head { position: absolute; left: 16px; right: 16px; top: calc(var(--safe-t) + 150px); z-index: 1; display: grid; justify-items: center; gap: 10px; text-align: center; animation: rw-fade 1.2s ease 1s both; }
.finale-ui { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 22px); z-index: 1; display: grid; justify-items: center; gap: 10px; text-align: center; }
.finale-kicker { margin: 0; font: 700 12px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.8); }
.finale-title { margin: 0 0 4px; font: 700 clamp(44px, 14vw, 64px)/1 var(--serif); color: #fff8e6; text-shadow: 0 4px 24px rgba(0,0,0,.7), 0 0 30px rgba(255,210,130,.5); }
.finale-ui .btn-primary { width: min(100%, 340px); }
.finale-row { display: flex; gap: 10px; }
.finale-btn, .finale-back { min-height: 40px; padding: 0 16px; border-radius: 999px; font: 600 14px/1 var(--sans); color: var(--ink);
  background: rgba(12,20,34,.5); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.finale-back { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 24px); z-index: 4; }
@keyframes pulse-dot { 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .stop.is-new span { animation: none; } }

/* ── Nissen vandrar till dagens plats ─────────────────────────── */
.marker-current.is-walking .pin { animation: walk-hop .42s ease-in-out infinite; }
.marker-current.is-walking .pin-label, .marker-current.is-walking .pin-new { opacity: 0; }
.marker-current .pin-label, .marker-current .pin-new { transition: opacity .4s ease; }
@keyframes walk-hop { 0%, 100% { translate: 0 0; rotate: -4deg; } 50% { translate: 0 -9px; rotate: 4deg; } }


/* ── Introfilm ───────────────────────────────────────────────── */
.intro { position: fixed; inset: 0; z-index: 100; background: #04080f; color: var(--ink); overflow: hidden; opacity: 0; transition: opacity .6s ease; -webkit-user-select: none; user-select: none; }
.intro.is-on { opacity: 1; }
.intro.is-leaving { opacity: 0; transition-duration: .7s; }
.intro-stage { position: absolute; inset: 0; }
.intro-scene { position: absolute; inset: 0; opacity: 0; transition: opacity 1.1s ease; pointer-events: none; }
.intro-scene.is-on { opacity: 1; pointer-events: auto; }
.intro-img { position: absolute; inset: -4%; background: center / cover no-repeat; transform-origin: 50% 40%; }
.intro-scene::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4,8,15,.55) 0, transparent 22%, transparent 48%, rgba(4,8,15,.92) 100%); pointer-events: none; }
.intro-scene.is-on.kb-down .intro-img { animation: kb-down 7s ease-out both; }
.intro-scene.is-on.kb-in .intro-img { animation: kb-in 7s ease-out both; }
.intro-scene.is-on.kb-out .intro-img { animation: kb-out 7s ease-out both; }
.intro-scene.kb-pan .intro-img { inset: 0; background-size: auto 230%; background-position: 50% 100%; }
.intro-scene.is-on.kb-pan .intro-img { animation: kb-pan 6.4s cubic-bezier(.45,0,.3,1) both; }
@keyframes kb-down { from { transform: scale(1.18) translateY(-4%); } to { transform: scale(1.04) translateY(2%); } }
@keyframes kb-in { from { transform: scale(1.02); } to { transform: scale(1.16) translate(-2%, 1%); } }
@keyframes kb-out { from { transform: scale(1.2) rotate(-1.5deg); } to { transform: scale(1.05) rotate(0); } }
@keyframes kb-pan { from { background-position: 50% 100%; } to { background-position: 50% 18%; } }
.intro-fog { position: absolute; inset: 0; z-index: 1; background: radial-gradient(ellipse 70% 30% at 50% 20%, rgba(220,232,245,.75), transparent 70%), linear-gradient(180deg, rgba(210,225,240,.85) 0, rgba(210,225,240,.25) 45%, transparent 70%); }
.intro-scene.is-on .intro-fog { animation: fog-breathe 6s ease-in-out both; }
@keyframes fog-breathe { from { opacity: .2; } 60% { opacity: 1; } }
.intro-text { position: absolute; left: 24px; right: 24px; bottom: calc(110px + var(--safe-b)); z-index: 2; margin: 0; text-align: center; font: 500 clamp(22px, 6.4vw, 30px)/1.3 var(--serif); text-wrap: balance; text-shadow: 0 2px 14px rgba(0,0,0,.8); }
.intro-text span { display: inline-block; opacity: 0; filter: blur(6px); transform: translateY(8px); }
.intro-scene.is-on .intro-text span { animation: word-in .7s ease-out forwards; animation-delay: calc(.6s + var(--k) * .09s); }
@keyframes word-in { to { opacity: 1; filter: blur(0); transform: none; } }
/* Nissedörren: glödande portal runt Nissen */
.is-portal { display: grid; place-items: center; background: radial-gradient(circle at 50% 42%, #1d2d4d 0, #0a1322 55%, #04080f 100%); }
.portal { position: relative; width: min(62vw, 260px); aspect-ratio: 1; margin-top: -18vh; display: grid; place-items: center; }
.portal img { width: 74%; border-radius: 50%; box-shadow: 0 0 0 4px #e0b866, 0 0 60px rgba(255,200,110,.6); z-index: 1; }
.portal-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, transparent, rgba(255,214,140,.95), transparent 30%, rgba(160,220,255,.7), transparent 60%, rgba(255,214,140,.9), transparent); -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%, #000 66%, transparent 70%); mask: radial-gradient(circle, transparent 58%, #000 60%, #000 66%, transparent 70%); filter: blur(1px) drop-shadow(0 0 12px rgba(255,210,130,.8)); }
.portal-ring.r2 { inset: -12%; opacity: .55; animation-direction: reverse !important; }
.intro-scene.is-on .portal-ring { animation: rw-spin 6s linear infinite; }
.intro-scene.is-on .portal { animation: portal-in 1.6s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes portal-in { from { transform: scale(.4); opacity: 0; filter: brightness(3); } }
/* Start- och slutkort */
.intro-start, .intro-end { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 38%, #18294a 0, #0a1322 60%, #04080f 100%); }
.intro-start { position: absolute; inset: 0; z-index: 4; opacity: 0; pointer-events: none; transition: opacity .6s ease; }
.intro-start.is-on { opacity: 1; pointer-events: auto; }
.intro-end::after { display: none; }
.intro-kicker { margin: 0; font: 600 13px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.intro-logo { width: min(78vw, 340px); height: auto; filter: drop-shadow(0 8px 24px rgba(0,0,0,.6)); }
.intro-sub { margin: -6px 0 8px; font: 500 16px/1 var(--serif); color: var(--ink-dim); }
.intro-end.is-on .intro-logo { animation: rw-title .9s cubic-bezier(.2,1.4,.4,1) both; }
.intro-end.is-on .intro-sub, .intro-end.is-on .btn { animation: rw-fade .6s ease .5s both; }
.intro-play { width: 84px; height: 84px; margin-top: 18px; border-radius: 50%; border: 2px solid #e0b866; color: #ffe3a3; background: radial-gradient(circle at 40% 30%, #d9493d, #8e1f1a); box-shadow: 0 0 0 8px rgba(224,184,102,.14), 0 10px 30px rgba(0,0,0,.5); display: grid; place-items: center; animation: btn-glow 2.4s ease-in-out infinite; }
.intro-play svg { width: 36px; height: 36px; margin-left: 5px; }
.intro-hint { margin: 4px 0 0; font: 500 13px/1 var(--sans); color: var(--ink-dim); }
/* Biokänsla: svarta band som glider in */
.intro-bars i { position: absolute; left: 0; right: 0; height: 0; background: #000; z-index: 3; transition: height .9s ease; }
.intro-bars i:first-child { top: 0; }
.intro-bars i:last-child { bottom: 0; }
.intro.is-playing:not(.is-ending) .intro-bars i { height: 5vh; }
.intro-snow { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.intro-snow i { position: absolute; top: -10px; border-radius: 50%; background: #fff; animation: fall linear infinite; }
.intro-ctl { position: absolute; left: 16px; right: 16px; top: calc(12px + var(--safe-t)); z-index: 5; display: flex; align-items: center; gap: 10px; opacity: 0; transition: opacity .5s; }
.intro.is-playing .intro-ctl { opacity: 1; }
.intro.is-ending .intro-dots, .intro.is-ending .intro-mute { visibility: hidden; }
.intro-dots { flex: 1; display: flex; gap: 5px; }
.intro-dots i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.intro-dots b { display: block; height: 100%; width: 0; background: #ffe3a3; }
.intro-dots i.is-past b { width: 100%; }
.intro-dots i.is-on b { animation: dot-fill 5.6s linear forwards; }
@keyframes dot-fill { to { width: 100%; } }
.intro-skip, .intro-mute { border: 1px solid rgba(224,184,102,.5); background: rgba(10,19,34,.6); color: var(--ink); font: 600 13px/1 var(--sans); padding: 8px 12px; border-radius: 999px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.intro.is-still .intro-img, .intro.is-still .portal, .intro.is-still .portal-ring, .intro.is-still .intro-fog { animation: none !important; }
.intro.is-still .intro-text span { animation-duration: .01s !important; animation-delay: 0s !important; }
.intro.is-still .intro-snow { display: none; }
.stop[hidden] { display: none; }
