:root {
  --bg: #0b0d17;
  --bg2: #12162a;
  --card: #181d36;
  --card2: #20264a;
  --line: #2b3264;
  --text: #eef0ff;
  --muted: #9aa1c9;
  --gold: #f5c542;
  --gold2: #ffdf7e;
  --ok: #3ddc97;
  --bad: #ff5d73;
  --warn: #ffb347;
  --blue: #6c8cff;
  --e1: #3ddc97;
  --e2: #ffb347;
  --e3: #ff5d73;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #1c2350 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; font-size: 64px; animation: pulse 1.2s infinite; }

#app { max-width: 520px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(32px + var(--safe-bot)); }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 28px; letter-spacing: .5px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-top: 22px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.gold { color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }
.spacer { height: 16px; }
a { color: var(--gold2); }

/* ---------- logo ---------- */
.logo { text-align: center; margin: 18px 0 22px; }
.logo .badge { font-size: 56px; display: block; margin-bottom: 6px; filter: drop-shadow(0 6px 18px rgba(245,197,66,.35)); }
.logo .title { font-size: 36px; font-weight: 800; letter-spacing: 2px; }
.logo .title span { color: var(--gold); }
.logo .tag { color: var(--muted); margin-top: 4px; }

/* ---------- kort ---------- */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.card + .card { margin-top: 12px; }
.card.hl { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 10px 30px rgba(245,197,66,.12); }
.card.danger { border-color: var(--bad); background: linear-gradient(180deg, #3a1626 0%, #1d1022 100%); }
.card.blitz { border-color: var(--warn); background: linear-gradient(180deg, #3b2a12 0%, #1e1710 100%); }

/* ---------- knappar ---------- */
.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 16px;
  font-weight: 700; font-size: 17px; cursor: pointer; text-align: center;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1b1503; border: 0; }
.btn.ok { background: var(--ok); color: #05261a; border: 0; }
.btn.bad { background: var(--bad); color: #2b0710; border: 0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 10px 12px; font-size: 15px; border-radius: 12px; }
.btn.xs { padding: 7px 10px; font-size: 13px; border-radius: 10px; width: auto; display: inline-block; }
.btn .sub { display: block; font-weight: 500; font-size: 12px; opacity: .8; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px; font-size: 14px; }

/* ---------- formulär ---------- */
.field { display: block; margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; font-size: 18px; outline: none;
}
.input:focus { border-color: var(--gold); }
.input.code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; font-size: 26px; }

.choice { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--bg2); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer;
}
.opt .ico { font-size: 26px; }
.opt .t { font-weight: 700; }
.opt .d { font-size: 13px; color: var(--muted); }
.opt.sel { border-color: var(--gold); background: #2a2a2a10; box-shadow: 0 0 0 1px var(--gold) inset; }

.yn { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.yn:last-child { border-bottom: 0; }
.yn .q { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: 0 0 auto; }
.seg button { border: 0; background: var(--bg2); padding: 9px 14px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--gold); color: #1b1503; }

.steps { display: flex; gap: 6px; justify-content: center; margin: 4px 0 16px; }
.steps i { width: 26px; height: 5px; border-radius: 4px; background: var(--line); display: block; }
.steps i.on { background: var(--gold); }

/* ---------- lobby ---------- */
.codebox { text-align: center; }
.codebox .code { font-size: 46px; font-weight: 900; letter-spacing: 10px; color: var(--gold); }
.qr { background: #fff; border-radius: 14px; padding: 10px; display: inline-block; margin: 10px auto 4px; }
.qr svg, .qr img { display: block; width: 180px; height: 180px; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--card2); border: 1px solid var(--line); }
.pill.ok { background: rgba(61,220,151,.15); color: var(--ok); border-color: rgba(61,220,151,.4); }
.pill.wait { color: var(--muted); }
.pill.gold { background: rgba(245,197,66,.15); color: var(--gold); border-color: rgba(245,197,66,.4); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--ok); }

/* ---------- huvudskärm ---------- */
.top { text-align: center; padding: 6px 0 14px; }
.top .brand { font-size: 13px; letter-spacing: 3px; color: var(--muted); font-weight: 800; }
.top .clock { font-size: 54px; font-weight: 900; letter-spacing: 1px; line-height: 1.05; margin: 4px 0; }
.top .clock.sprint { color: var(--bad); animation: pulse 1s infinite; }
.top .sub { color: var(--muted); font-size: 14px; }
.scorepill { display: inline-flex; gap: 6px; align-items: center; margin-top: 10px; padding: 6px 14px; border-radius: 99px; background: rgba(245,197,66,.12); border: 1px solid rgba(245,197,66,.35); color: var(--gold); font-weight: 800; }

.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.banner > span { flex: 1; }
.banner.sprint { background: linear-gradient(90deg, #ff5d73, #ff9a5d); color: #2b0710; }
.banner.pause { background: var(--warn); color: #2b1a03; }
.banner.blitz { background: var(--warn); color: #2b1a03; }

.mission { position: relative; }
.mission .lvl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.mission .lvl i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lvl1 i { background: var(--e1); } .lvl1 { color: var(--e1); }
.lvl2 i { background: var(--e2); } .lvl2 { color: var(--e2); }
.lvl3 i { background: var(--e3); } .lvl3 { color: var(--e3); }
.mission .txt { font-size: 19px; font-weight: 700; line-height: 1.3; margin-bottom: 14px; }
.mission .txt b { color: var(--gold); }
.mission.hidden-txt .txt { filter: blur(9px); user-select: none; }
.reveal-hint { position: absolute; inset: 40px 16px auto; text-align: center; font-weight: 700; color: var(--muted); pointer-events: none; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.actions .btn { padding: 12px 6px; font-size: 14px; }
.actions .btn .big { display: block; font-size: 24px; margin-bottom: 2px; }
.badge-n { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 12px; margin-left: 4px; }

.qcard .q { font-size: 18px; font-weight: 700; margin-bottom: 12px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 22px; text-align: center; }
.feed .tm { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; gap: 8px; }
.hist li:last-child { border-bottom: 0; }

.footer-links { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- countdown / paus ---------- */
.big-center { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.huge { font-size: 140px; font-weight: 900; color: var(--gold); line-height: 1; animation: pop .9s ease infinite; }
.pause-ico { font-size: 80px; }

/* ---------- resultat ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 18px 0; }
.podium .pl { flex: 1; text-align: center; }
.podium .bar { border-radius: 12px 12px 0 0; background: var(--card2); border: 1px solid var(--line); padding: 10px 4px; font-weight: 900; font-size: 22px; }
.podium .p1 .bar { height: 130px; background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1b1503; }
.podium .p2 .bar { height: 95px; }
.podium .p3 .bar { height: 70px; }
.podium .nm { font-weight: 800; margin-bottom: 6px; word-break: break-word; }
.award { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.award:last-child { border-bottom: 0; }
.award .ico { font-size: 30px; }
.award .t { font-weight: 800; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log .tm { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 44px; }

/* ---------- modal ---------- */
#modal:empty { display: none; }
.overlay {
  position: fixed; inset: 0; background: rgba(5,6,14,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg2);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bot)); animation: up .2s ease;
}
.sheet.full { border-radius: 0; max-height: 100vh; height: 100vh; border: 0; padding-top: calc(20px + var(--safe-top)); }
.sheet .x { float: right; background: var(--card2); border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.pick { display: grid; gap: 8px; margin-top: 12px; }
.pick .opt { font-size: 16px; }
.penalty-big { text-align: center; padding: 20px 0; }
.penalty-big .ico { font-size: 70px; }
.penalty-big .t { font-size: 26px; font-weight: 900; margin: 12px 0; }
.cp-head { text-align: center; padding: 10px 0 6px; }
.cp-head .ico { font-size: 54px; }
.cp-items { list-style: none; padding: 0; margin: 0; }
.cp-items li { padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; font-weight: 600; }
.board { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.board li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.board li::before { counter-increment: r; content: counter(r) "."; color: var(--muted); width: 28px; }
.board li span:first-of-type { flex: 1; }
.rules ol { padding-left: 22px; margin: 0 0 12px; }
.rules li { margin-bottom: 8px; font-size: 17px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: calc(10px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast {
  max-width: 500px; width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: drop .25s ease; pointer-events: auto;
}
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); }
.toast.warn { border-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: all .3s; }

.offline { position: fixed; bottom: calc(10px + var(--safe-bot)); left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 8px 14px; border-radius: 99px; font-weight: 700; font-size: 13px; z-index: 90; }

@keyframes pulse { 50% { opacity: .55; } }
@keyframes pop { 0% { transform: scale(.6); opacity: .2; } 40% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

/* röstning om checkpointintervall */
.cp-vote { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cp-vote button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 0; border-radius: 14px; border: 1px solid var(--line, #2a3150);
  background: var(--card, #161b2e); color: inherit; font: inherit; cursor: pointer;
}
.cp-vote button b { font-size: 1.25rem; }
.cp-vote button span { font-size: .75rem; opacity: .7; }
.cp-vote button.on { border-color: var(--gold, #f5c84b); background: var(--gold, #f5c84b); color: #1a1408; }

/* avslöja – kategorier */
.acc-cats { display: grid; gap: 8px; margin: 12px 0; }
.acc-cat {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.acc-cat .ico { font-size: 22px; text-align: center; }
.acc-cat .t { font-weight: 700; }
.acc-cat .n { min-width: 26px; padding: 2px 8px; border-radius: 99px; background: var(--card2); color: var(--gold); font-weight: 800; text-align: center; }
.acc-cat:active { border-color: var(--gold); }
.acc-h { margin: 16px 0 8px; font-size: 15px; color: var(--muted); }
.acc-back { margin: 4px 0 0; }
.acc-opt .who { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.accuse-go { position: sticky; bottom: -1px; padding: 12px 0 2px; background: linear-gradient(transparent, var(--bg2) 30%); }
.acc-dig { margin: -4px 0 6px; color: var(--gold2); }

/* trivia */
.tv-groups { display: grid; gap: 8px; }
.tv-group { border: 1px solid var(--line); border-radius: 14px; background: var(--card); overflow: hidden; }
.tv-group.has { border-color: var(--gold); }
.tv-head { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; width: 100%;
  padding: 13px 14px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.tv-head .ico { font-size: 22px; text-align: center; }
.tv-head .t { font-weight: 700; }
.tv-head .chev { color: var(--muted); }
.tv-subs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 14px; }
.tv-sub { padding: 9px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.tv-sub.on { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 800; }
.tv-chosen { margin-bottom: 10px; }
.tv-rounds { grid-template-columns: repeat(7, 1fr); margin-top: 8px; }
.tv-card { border-color: #7c5cff; background: linear-gradient(180deg, rgba(124, 92, 255, .14), var(--card) 60%); margin-top: 14px; }
.tv-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; letter-spacing: 1px; color: #b9a8ff; }
.tv-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.tv-q { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.tv-opts { display: grid; gap: 8px; }
.tv-wait { margin-top: 10px; color: var(--muted); }
.tv-review { list-style: none; padding: 0; margin: 10px 0 12px; display: grid; gap: 10px; }
.tv-review li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
