:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel2: #20242d;
  --line: #2c313c;
  --text: #e8e2d4;
  --muted: #9a9484;
  --accent: #d9a441;
  --accent-ink: #1a1303;
  --good: #6fbf73;
  --bad: #d96a5b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(var(--tabsh, 90px) + 20px); } /* nedre marginal = flikradens uppmätta höjd (sätts i app.js) */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(15,17,21,.94); backdrop-filter: blur(6px); z-index: 5; }
.brand { display: inline-flex; align-items: center; text-decoration: none; line-height: 0; }
.brand-logo { height: 46px; width: auto; display: block; filter: drop-shadow(0 0 10px rgba(217,164,65,.18)); }
.hero-mark { width: 150px; height: 150px; display: block; margin: 0 auto 10px; filter: drop-shadow(0 0 28px rgba(217,164,65,.45)); animation: heroFloat 6s ease-in-out infinite; }
@keyframes heroFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .hero-mark { animation: none; } }
.lang { display: flex; gap: 6px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.click { cursor: pointer; transition: border-color .15s, transform .1s; }
.card.click:hover { border-color: var(--accent); }
.card.click:active { transform: scale(.99); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card.flat { background: var(--panel2); }
.card.good { border-color: var(--good); }
.card.bad { border-color: var(--bad); }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; cursor: pointer; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.danger { border-color: var(--bad); color: var(--bad); }
button.big { padding: 14px 22px; font-size: 1.05rem; }
button.block { width: 100%; }
.chip { min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: .9rem; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Installationsnotisen (PWA): tydlig orange remsa överst på sidan, syns tills appen är installerad. */
.install-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #f28a1e; color: #1a0e00; border-bottom: 2px solid #b85f00; }
.install-bar .install-icon { border-radius: 10px; flex: none; box-shadow: 0 0 0 2px rgba(26,14,0,.25); }
.install-bar .install-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; line-height: 1.3; }
.install-bar .install-text strong { font-size: 1.08rem; }
.install-bar .install-text span { font-size: .86rem; color: #3a2000; }
.install-bar button { flex: none; min-height: 42px; padding: 8px 20px; font-size: 1rem; font-weight: 700; background: #1a0e00; color: #fff; border-color: #1a0e00; }
/* Got IT!-knappen i övre fältet: alltid grön bakgrund; mörkare ram när den är vald. */
.chip.gotit { background: #2e9e4f; color: #fff; border-color: #2e9e4f; font-weight: 650; }
.chip.gotit.on { background: #23813f; border-color: #fff; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.tag.active { color: var(--good); border-color: var(--good); }
.tag.expired { color: var(--bad); border-color: var(--bad); }

input[type=text], input[type=password], select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }

.code { font: 700 2.4rem/1 ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .18em; color: var(--accent); text-align: center; padding: 14px; background: var(--bg); border: 1px dashed var(--accent); border-radius: var(--radius); user-select: all; }
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: 2.4rem; color: var(--accent); }

/* Flikraden bryter rad i stället för att scrolla: alla flikar syns alltid, 4 per rad på en telefon. */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); background: rgba(24,27,34,.97); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 4px; z-index: 6; }
.tabs button { min-height: 40px; padding: 4px 6px; font-size: .8rem; line-height: 1.15; border-radius: 10px; border-color: var(--line); background: rgba(255,255,255,.04); white-space: normal; overflow-wrap: anywhere; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; }

.banner { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel2); margin-bottom: 12px; }
.banner.good { border-color: var(--good); } .banner.bad { border-color: var(--bad); } .banner.warn { border-color: var(--accent); }

.portrait, .evimg { width: 100%; max-width: 100%; border-radius: 10px; display: block; background: var(--panel2); }
.portrait { width: 84px; height: 84px; object-fit: cover; border-radius: 50%; flex: none; }
.evimg { margin-top: 10px; cursor: zoom-in; }
.audio { margin-top: 10px; }
.audio audio { width: 100%; }
/* Videobevis: 16:9-platshållare med spelknapp tills filmen hämtats, därefter själva spelaren. */
.videobox { margin-top: 10px; }
.evvideo { width: 100%; max-width: 100%; border-radius: 10px; background: #000; display: block; }
.videoholder { aspect-ratio: 16 / 9; width: 100%; border-radius: 10px; background: #0b0f14; border: 1px solid var(--panel2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; text-align: center; }
.transcript { margin-top: 10px; background: var(--panel2); border-radius: 10px; padding: 8px 12px; }
.transcript summary { cursor: pointer; font-size: 13px; color: var(--muted); }

.inspect { position: relative; display: inline-block; max-width: 100%; }
.inspect img { display: block; max-width: 100%; border-radius: 10px; }
.hotspot { position: absolute; border: 2px solid var(--accent); border-radius: 8px; background: rgba(217,164,65,.14); cursor: pointer; animation: pulse 2s infinite; }
@keyframes pulse { 50% { background: rgba(217,164,65,.32); } }

.nodes { display: flex; flex-wrap: wrap; gap: 8px; }
.node { text-align: left; max-width: 100%; border-radius: 12px; padding: 8px 12px; font-size: .92rem; }
.node.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.node small { display: block; opacity: .75; }

.tl-item { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--panel2); border-radius: 12px; border: 1px solid var(--line); }
.tl-item span { flex: 1; }
.tl-item button { min-height: 36px; padding: 4px 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 760px; max-height: 92vh; overflow: auto; width: 100%; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 30; max-width: 92vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.issue { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--panel2); margin-bottom: 6px; border-radius: 4px; overflow-wrap: anywhere; }
.issue.blocker { border-color: var(--bad); }
.countdown { font: 700 1.4rem ui-monospace, Consolas, monospace; color: var(--accent); }

@media (min-width: 720px) { .hero h1 { font-size: 3rem; } }

/* ================= Startsida: stämning, dossierer, steg ================= */
.lhero { position: relative; overflow: hidden; padding: 72px 18px 56px; text-align: center; isolation: isolate;
  background: radial-gradient(ellipse at 50% -10%, #3a2a14 0%, #1a1620 38%, var(--bg) 72%); }
.lhero::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.07) 0 1px, transparent 2px), radial-gradient(circle at 70% 60%, rgba(255,255,255,.05) 0 1px, transparent 2px);
  background-size: 90px 90px, 140px 140px; }
.lhero::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,.65) 100%); }
.lamp { position: absolute; left: 50%; top: -120px; width: 520px; height: 520px; margin-left: -260px; z-index: -1; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,164,65,.34) 0%, rgba(217,164,65,.12) 40%, transparent 70%); animation: flicker 6s infinite; }
@keyframes flicker { 0%,100% { opacity: 1; } 8% { opacity: .82; } 10% { opacity: 1; } 47% { opacity: .92; } 49% { opacity: .7; } 52% { opacity: 1; } }
.fog { position: absolute; left: -20%; width: 140%; height: 160px; z-index: -1; pointer-events: none; filter: blur(26px); opacity: .5;
  background: radial-gradient(ellipse at center, rgba(207,214,230,.28), transparent 70%); }
.fog.f1 { bottom: -30px; animation: drift 24s linear infinite alternate; }
.fog.f2 { bottom: 40px; height: 120px; opacity: .35; animation: drift 34s linear infinite alternate-reverse; }
@keyframes drift { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
.lhero-inner { max-width: 680px; margin: 0 auto; }
.eyebrow { text-transform: uppercase; letter-spacing: .28em; font-size: .74rem; color: var(--accent); margin-bottom: 14px; }
.lhero h1 { font-size: clamp(2rem, 7vw, 3.4rem); color: #f3ead4; text-shadow: 0 2px 30px rgba(217,164,65,.35); margin-bottom: .35em; }
.lede { color: #c9c2b0; font-size: 1.05rem; max-width: 56ch; margin: 0 auto 1.4em; }
.cta { justify-content: center; margin-bottom: 26px; }
button.ghost, .btn.ghost { background: transparent; border-color: rgba(232,226,212,.35); }
.joinbox { max-width: 360px; margin: 0 auto; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(15,17,21,.6); backdrop-filter: blur(4px); }
.joinbox .small { display: block; margin-bottom: 6px; }
.row.nowrap { flex-wrap: nowrap; }

.landing { padding-top: 34px; }
.landing section { margin-bottom: 44px; }
.sect { font-size: 1.5rem; color: var(--accent); }
.sect::after { content: ''; display: block; width: 46px; height: 2px; background: var(--accent); margin-top: 8px; opacity: .7; }

.dossiers { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.dossier { background: linear-gradient(180deg, #1d1b20, var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: transform .2s, border-color .2s, box-shadow .2s; }
.dossier:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 16px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(217,164,65,.25); }
.dossier-art { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.cover-photo { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.dossier:hover .cover-photo { transform: scale(1.04); }
.cover-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25) 0%, rgba(0,0,0,0) 30%, rgba(8,9,12,.92) 100%); pointer-events: none; }
.pick-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }
.cover-title { position: absolute; left: 16px; right: 16px; bottom: 12px; margin: 0; font-size: 1.9rem; letter-spacing: .03em; color: #f4ecd8; text-shadow: 0 2px 14px rgba(0,0,0,.9); }
.cover-art { display: block; width: 100%; height: 100%; }
.win-lit { animation: winflick 5s infinite; }
@keyframes winflick { 0%,100% { opacity: .95; } 50% { opacity: .6; } 53% { opacity: 1; } }
.stamp { position: absolute; top: 12px; left: 12px; padding: 2px 10px; border: 2px solid var(--accent); color: var(--accent); border-radius: 4px;
  font: 700 .72rem/1.6 ui-monospace, Consolas, monospace; letter-spacing: .2em; transform: rotate(-4deg); background: rgba(15,17,21,.55); }
.dossier-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.dossier-body h3 { font-size: 1.25rem; }
.synopsis { color: #bdb6a4; font-size: .94rem; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.dossier-body .row { margin-top: auto; padding-top: 6px; }

.steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.step .num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; margin-bottom: 8px; }
.foot { text-align: center; padding-top: 10px; border-top: 1px solid var(--line); }

/* Spelledare: inloggning och översikt */
.authcard { max-width: 440px; margin: 10px auto; }
input.pin { letter-spacing: .6em; text-align: center; font: 700 1.5rem ui-monospace, Consolas, monospace; max-width: 180px; }
input[type=email] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 44px; }
input[type=email]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-sm { font: 700 1.2rem ui-monospace, Consolas, monospace; letter-spacing: .14em; color: var(--accent); }
.tag.lobby { color: var(--accent); border-color: var(--accent); }
.tag.completed { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .lamp, .fog, .win-lit { animation: none; } }

/* ---- Chatt, närvaro och snabbknapp "klar" ---- */
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; min-height: 120px; overflow-y: auto; padding: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); }
.chat-msg { align-self: flex-start; max-width: 86%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.chat-msg.mine { align-self: flex-end; border-color: var(--accent); }
.chat-msg.host { border-style: dashed; }
.chat-meta { font-size: .72rem; color: var(--muted, #8a93a6); margin-bottom: 3px; }
.chat-sys { align-self: center; font-size: .78rem; color: var(--muted, #8a93a6); text-align: center; }
.chat-compose { flex-wrap: nowrap; }
.ready-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

/* Betalning: pris/gratis-märken, tid kvar och betalpanelen. */
.tag.price { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.tag.price.free { border-color: var(--good); color: var(--good); }
.tag.time { border-color: var(--accent); }
.card.pay { border-color: var(--accent); }
.modal.intro .box { max-width: 520px; }
.intro-list { padding-left: 20px; margin: 8px 0 0; }
.intro-list li { margin-bottom: 8px; }
