/* Brætspilsquizzen! */
:root {
  --bg: #2b2350;
  --bg2: #3a2f6b;
  --card: #fffaf0;
  --ink: #2a2440;
  --muted: #6f6890;
  --line: #e6dcc8;
  --primary: #c8460a;
  --primary-ink: #fff;
  --secondary: #6c5ce7;
  --good: #1d8350;
  --bad: #cf3439;
  --a0: #cf3439;
  --a1: #2f66e0;
  --a2: #f2b705;
  --a3: #1d8350;
  --radius: 16px;
  --shadow: 0 4px 0 rgba(0,0,0,.18), 0 10px 24px rgba(0,0,0,.18);
  --font-head: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html {
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.07) 0 2px, transparent 3px) 0 0 / 34px 34px,
    linear-gradient(160deg, var(--bg2), var(--bg)) var(--bg);
  min-height: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0 0 .5em; line-height: 1.15; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }
.card :focus-visible, .shop-card :focus-visible { outline-color: var(--secondary); }
.loading { font-size: 4rem; text-align: center; padding-top: 30vh; animation: spin 1.2s linear infinite; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1100px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* knapper */
.btn {
  font: 700 1rem var(--font-head);
  border: 0;
  border-radius: 12px;
  padding: .75em 1.2em;
  cursor: pointer;
  background: #ddd;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.secondary { background: var(--secondary); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; color: inherit; text-decoration: underline; }
.btn.small { padding: .5em .9em; font-size: .9rem; }
.btn.big { font-size: 1.25rem; padding: .85em 1.6em; }
.icon-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; width: 36px; height: 36px; font-size: 1rem; cursor: pointer; }

input, select {
  font: 600 1rem var(--font);
  width: 100%;
  padding: .7em .8em;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:not([type=checkbox]):focus, select:focus { outline: none; border-color: var(--secondary); }
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 10px; }
label > input, label > select { margin-top: 4px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
label.check input { width: 22px; height: 22px; flex: none; margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { background: #fff3cd; padding: 8px 10px; border-radius: 8px; font-size: .85rem; }

/* top */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; color: #fff;
  background: rgba(0,0,0,.18);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(6px);
}
.topbar .brand { font-size: 1.4rem; }
.topbar .where { font: 600 .95rem var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,.15); color: inherit;
  padding: 4px 10px; border-radius: 999px; font-size: .85rem; white-space: nowrap;
}
.card .chip, .q-meta .chip { background: #efe6d6; color: var(--ink); }
.chip.big { font-size: 1rem; padding: 6px 14px; }
.chip.tokens b { color: #ffd166; }
.card .chip.tokens b, .shop-meta .chip.tokens b { color: inherit; }

/* start */
.home { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; }
.logo { text-align: center; color: #fff; margin: 10px 0 24px; }
.logo h1 { font-size: clamp(1.5rem, 8.5vw, 3.4rem); text-shadow: 0 4px 0 rgba(0,0,0,.25); margin: 0; }
.dice { font-size: 4rem; display: inline-block; animation: wobble 3s ease-in-out infinite; }
.tagline { opacity: .85; margin: .4em 0 0; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.home-grid .card { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.home-grid .card .btn { margin-top: auto; }
.home-grid + .card, .home .howto { margin-top: 16px; }
.code-input { text-align: center; font: 700 1.8rem var(--font-head); letter-spacing: .25em; text-transform: uppercase; }
.howto summary { cursor: pointer; font: 600 1.05rem var(--font-head); }
.howto ul { margin: 10px 0 0; padding-left: 20px; }
.howto li { margin-bottom: 6px; }

/* lobby */
.code-card { text-align: center; }
.big-code { font: 700 clamp(3rem, 14vw, 4.5rem) var(--font-head); letter-spacing: .15em; color: var(--secondary); }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lobby-grid .card { margin: 0; }
.player-list { list-style: none; margin: 0; padding: 0; }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 700; animation: pop .3s; }
.player-list li.inactive { opacity: .4; }
.player-list li.me { color: var(--secondary); }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c, #999); color: #fff; font: 700 1rem var(--font-head);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.2);
}
.avatar.big { width: 56px; height: 56px; font-size: 1.6rem; }
.avatar.img { background: #fff; overflow: hidden; box-shadow: 0 0 0 2px rgba(0,0,0,.08); }
.avatar.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pod .avatar.big { width: 64px; height: 64px; }
.avatar-picker { margin-top: 12px; }
.av-label { font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.av-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.av-tile {
  position: relative; padding: 3px; border: 3px solid transparent; border-radius: 50%;
  background: none; cursor: pointer; line-height: 0; transition: transform .1s;
}
.av-tile .avatar { width: 48px; height: 48px; font-size: 1.3rem; }
.av-tile:hover { transform: scale(1.08); }
.av-tile.selected { border-color: var(--secondary); }
.av-tile.selected::after {
  content: '✓'; position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; line-height: 20px;
  border-radius: 50%; background: var(--secondary); color: #fff; font-size: .75rem; font-weight: 800;
}
.av-none {
  position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%); line-height: 1.2;
  font-size: .65rem; font-weight: 800; background: var(--card); color: var(--muted); padding: 0 5px; border-radius: 6px;
}
.avatar-change { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
.avatar-change .btn.ghost { padding-left: 0; }
.avatar-change .avatar-picker { margin-top: 4px; }
.summary { list-style: none; padding: 0; margin: 0; }
.summary li { padding: 4px 0; }
.start-area { text-align: center; margin: 20px 0; }
.wait { color: #fff; font: 600 1.1rem var(--font-head); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* spørgsmål */
.timer { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.bar { flex: 1; height: 14px; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ffd166, var(--primary)); border-radius: 999px; transition: background .3s; }
.bar .fill.low { background: var(--bad); }
.time-num { color: #fff; font: 700 1.4rem var(--font-head); min-width: 2ch; text-align: right; }
.lead { text-align: center; color: #fff; padding: 40px 0; }
.lead-title { font: 700 2rem var(--font-head); }
.lead-num { font: 700 6rem var(--font-head); animation: pop .5s; }
.banners { display: grid; gap: 8px; margin-bottom: 12px; }
.banner {
  background: var(--bad); color: #fff; font-weight: 800;
  padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow);
  animation: shake .5s;
}
.q-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.q-text {
  background: var(--card); padding: 20px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: clamp(1.15rem, 4vw, 1.5rem); text-align: center;
}
.q-text.small { font-size: 1.1rem; }
.answers-wrap { position: relative; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ans {
  display: flex; align-items: center; gap: 10px;
  min-height: 72px; padding: 12px 14px;
  border: 0; border-radius: 14px;
  font: 700 1.05rem var(--font); color: #fff; text-align: left;
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
  cursor: pointer; transition: transform .08s, opacity .2s, filter .2s;
}
.ans .shape { font-size: 1.2rem; opacity: .8; }
.ans .txt { flex: 1; overflow-wrap: anywhere; }
.ans-0 { background: var(--a0); }
.ans-1 { background: var(--a1); }
.ans-2 { background: var(--a2); color: var(--ink); }
.ans-3 { background: var(--a3); }
.ans:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.ans:disabled { cursor: default; }
.answers.locked .ans:not(.picked), .ans.removed { opacity: .25; }
.ans.removed { visibility: hidden; }
.ans.picked { outline: 4px solid #fff; transform: scale(1.03); }
.ans.wrong-first { opacity: .35; text-decoration: line-through; }
.q-status { color: #fff; text-align: center; font-weight: 700; min-height: 1.4em; }
.q-status.alert { color: #ffd166; font-size: 1.1rem; }
.freeze {
  position: absolute; inset: -6px; border-radius: 18px;
  display: grid; place-items: center;
  background: rgba(170, 220, 255, .75); backdrop-filter: blur(3px);
  font: 700 1.8rem var(--font-head); color: #0b4a75;
}
.powerbar { background: rgba(0,0,0,.18); border-radius: var(--radius); padding: 10px 12px; color: #fff; }
.powerbar:empty { display: none; }
.pw-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pw {
  font: 700 .95rem var(--font); border: 0; border-radius: 999px; padding: 8px 14px;
  background: #ffd166; color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.pw:disabled { opacity: .45; cursor: default; }
.pw.used { background: var(--good); color: #fff; opacity: 1; }
.pw.passive { background: rgba(255,255,255,.2); color: #fff; cursor: default; box-shadow: none; }
.pw .qty { margin-left: 6px; background: rgba(0,0,0,.15); border-radius: 999px; padding: 0 7px; font-size: .8rem; }

/* sabotage-effekter */
.fx-fog .q-text, .fx-fog .ans .txt { animation: fog 8s ease-out forwards; }
.fx-flip .q-text, .fx-flip .answers { transform: rotate(180deg); }
.answers .ans { transition: order 0s, transform .2s; }

/* afsløring */
.result { text-align: center; }
.result.good { background: #e3f8ec; }
.result.bad { background: #fde7e8; }
.result-big { font: 700 1.4rem var(--font-head); }
.answers.reveal { margin-bottom: 16px; }
.answers.reveal .ans { cursor: default; flex-wrap: wrap; }
.ans.dim { opacity: .35; }
.ans.correct { outline: 4px solid #fff; animation: pop .4s; }
.ans.mine:not(.correct) { opacity: .7; outline: 3px dashed #fff; }
.ans .who { width: 100%; font-size: .8rem; font-weight: 600; opacity: .95; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.log li:last-child { border: 0; }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.board li.me { font-weight: 800; color: var(--secondary); }
.board .rank { width: 1.6em; font: 700 1rem var(--font-head); color: var(--muted); }
.board .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .tok { font-size: .8rem; color: var(--muted); }
p.center.muted { color: rgba(255,255,255,.8); }

/* butik */
.shop-head { color: #fff; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.shop-head h2 { margin: 0; font-size: 1.5rem; }
.shop-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.shop-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.shop-layout > * { min-width: 0; }
.shop-section { margin-bottom: 18px; color: #fff; }
.shop-section h3 { margin: 0; }
.shop-section .muted { color: rgba(255,255,255,.7); margin: 2px 0 10px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.shop-card {
  background: var(--card); color: var(--ink); border-radius: 14px; padding: 12px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
  border-top: 6px solid var(--secondary);
}
.shop-card.kind-sabotage { border-top-color: var(--bad); }
.shop-card.kind-self { border-top-color: #ffb100; }
.shop-card.kind-passive { border-top-color: var(--a1); }
.sc-top { display: flex; justify-content: space-between; align-items: center; }
.sc-emoji { font-size: 2rem; }
.price { font: 700 1rem var(--font-head); background: #efe6d6; border-radius: 999px; padding: 2px 10px; }
.sc-name { font: 700 1.1rem var(--font-head); }
.sc-desc { font-size: .85rem; color: var(--muted); flex: 1; }
.owned { font-size: .8rem; font-weight: 800; color: var(--good); min-height: 1em; }
.sc-actions { display: flex; flex-direction: column; gap: 6px; }
.sc-actions select { padding: .45em .6em; font-size: .9rem; }
.ready-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px; background: rgba(43,35,80,.92); border-radius: var(--radius) var(--radius) 0 0;
}
.ready-bar .muted { color: rgba(255,255,255,.8); }

/* slut */
.screen-final h1 { color: #fff; font-size: 2.2rem; margin-top: 10px; }
.winner { color: #ffd166; font: 700 1.4rem var(--font-head); margin-top: 0; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 20px 0; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; width: 30%; max-width: 160px; animation: rise .7s ease-out backwards; }
.pod-1 { animation-delay: .6s; }
.pod-2 { animation-delay: .3s; }
.pod-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.pod-score { font: 700 1.1rem var(--font-head); color: #ffd166; }
.pod-block {
  width: 100%; display: grid; place-items: start center; padding-top: 10px;
  background: var(--card); border-radius: 12px 12px 0 0; font-size: 2rem; box-shadow: var(--shadow);
}
.pod-1 .pod-block { height: 130px; background: #ffd166; }
.pod-2 .pod-block { height: 95px; background: #dfe4ea; }
.pod-3 .pod-block { height: 70px; background: #f0b58a; }
.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.award { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.aw-emo { font-size: 2rem; }
.final-table { width: 100%; border-collapse: collapse; }
.final-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.final-table tr:last-child td { border: 0; }
.final-table tr.me { color: var(--secondary); font-weight: 800; }
.final-table .num { text-align: right; white-space: nowrap; }
.final-table .rank { width: 2em; color: var(--muted); font-weight: 800; }
.final-table .ft-name { font-weight: 700; overflow-wrap: anywhere; }
.board li.gap { border-top: 2px dashed var(--line); margin-top: 4px; }

/* toasts */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 700; animation: pop .25s; transition: opacity .4s, transform .4s; }
.toast.good { background: var(--good); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(10px); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-6px); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
@keyframes fog { from { filter: blur(9px); } to { filter: blur(0); } }

@media (max-width: 760px) {
  .shop-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .home-grid, .lobby-grid { grid-template-columns: 1fr; }
  .answers { grid-template-columns: 1fr; }
  .ans { min-height: 58px; }
  .shop-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .shop-grid { grid-template-columns: 1fr; }
  .topbar .where { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.screen-final .btn.ghost { color: rgba(255,255,255,.8); }
