/* Kahtoken – Kahoot-aktig utforming i VLFK sin grafiske profil.
   Fargar, skrift og hjørne frå profilen; tekst alltid i --ink. */
@font-face { font-family: "Roboto"; src: url("fonts/Roboto-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Roboto"; src: url("fonts/Roboto-wght-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Roboto Slab"; src: url("fonts/RobotoSlab-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --lyseblaa: #9adbe8;
  --mork-rosa: #e06287;
  --lilla: #caa2dd;
  --limegronn: #e1d555;
  --turkis: #00c7b1;
  --lysegronn: #b7dd79;
  --gul: #fdda25;
  --rod-oransje: #ff5c39;
  --morkegronn: #50a684;
  --mint: #3cdbc0;
  --oransje: #ff9e1b;
  --lys-rosa: #f8b5c4;

  --ink: #1d1d1b;
  --ink-muted: #5c5c59;
  --surface: #ffffff;
  --surface-muted: #f4f4f2;
  --line: #e0e0e0;
  --line-strong: #8a8a86;

  --font-slab: "Roboto Slab", Georgia, serif;
  --font-sans: "Roboto", system-ui, sans-serif;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;

  /* Spelflata: lilla i konkurranse (nikk til Kahoot), lyseblå i samskriving. */
  --field: var(--lilla);
  --a0: var(--mork-rosa);
  --a1: var(--lyseblaa);
  --a2: var(--gul);
  --a3: var(--morkegronn);
  color-scheme: light;
}
body.mode-samskriving { --field: var(--lyseblaa); --a1: var(--lilla); }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--surface); color: var(--ink); }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
#app { flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ------------------------------------------------------------ Topplinje -- */
.topbar {
  background: var(--lilla);
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  min-height: 72px;
}
.brand { height: 52px; width: auto; display: block; }
.brand-link { display: block; }
.topbar .pin-mini { margin-left: auto; font-weight: 700; font-size: 16px; background: var(--surface); padding: 4px 12px; border-radius: var(--radius-md); }

/* ---------------------------------------------------------- Spelflata -- */
.field {
  flex: 1;
  background: var(--field);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 24px;
}
/* Skarpe diagonale former, inspirert av våpenskjoldet. */
.field::before, .field::after {
  content: "";
  position: absolute;
  background: var(--surface);
  opacity: 0.22;
  pointer-events: none;
}
.field::before { width: 60vmax; height: 60vmax; left: -30vmax; bottom: -42vmax; transform: rotate(45deg); }
.field::after { width: 40vmax; height: 40vmax; right: -22vmax; top: -26vmax; transform: rotate(45deg); }
.field > * { position: relative; z-index: 1; }

.center { margin: auto; width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.wide { width: 100%; max-width: 1200px; margin: 0 auto; }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 0 rgba(29, 29, 27, 0.25);
}
.card h1, .card h2 { margin-top: 0; }

h1 { font-family: var(--font-slab); font-size: 32px; line-height: 40px; font-weight: 600; margin: 0 0 16px; }
h2 { font-family: var(--font-slab); font-size: 24px; line-height: 32px; font-weight: 600; margin: 0 0 8px; }
h3 { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0 0 8px; }
.muted { color: var(--ink-muted); }
.small { font-size: 14px; line-height: 20px; }
.caption { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }

/* --------------------------------------------------------------- Knappar -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  line-height: 24px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(29, 29, 27, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(29, 29, 27, 0.35); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); }
.btn.accent { background: var(--gul); border-color: var(--ink); color: var(--ink); }
.btn.block { width: 100%; }
.btn.small { font-size: 14px; padding: 6px 12px; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 18px;
}
textarea { resize: vertical; min-height: 140px; line-height: 26px; }
input.big { font-size: 24px; font-weight: 700; text-align: center; padding: 14px; }
label { font-weight: 500; display: block; margin-bottom: 4px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.error { background: var(--lys-rosa); border-left: 6px solid var(--mork-rosa); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; }
.note { background: var(--surface-muted); padding: 8px 12px; border-radius: var(--radius-sm); }

/* Modusval */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  margin: 0;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  font-weight: 400;
  height: 100%;
}
.choice label strong { display: block; font-size: 18px; margin-bottom: 4px; }
.choice input:checked + label { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); background: var(--surface-muted); }
.choice input:checked + label strong::before { content: "✓ "; }
.choice input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }
.choice .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 1px solid var(--ink); vertical-align: middle; }

/* ------------------------------------------------------------- Lobby -- */
.join-banner {
  background: var(--surface);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  box-shadow: 0 4px 0 rgba(29, 29, 27, 0.25);
  overflow: hidden;
  max-width: 900px;
  width: 100%;
}
.join-banner .how { padding: 16px 24px; font-size: 20px; line-height: 28px; flex: 1; }
.join-banner .how strong { display: block; font-size: 28px; line-height: 36px; word-break: break-all; }
.join-banner .pin { padding: 16px 24px; background: var(--surface-muted); border-left: 1px solid var(--line); text-align: center; }
.join-banner .pin .num { font-family: var(--font-slab); font-weight: 700; font-size: 64px; line-height: 72px; letter-spacing: 0.04em; }
.lobby-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
.count-badge { background: var(--surface); border-radius: var(--radius-md); padding: 8px 16px; font-weight: 700; font-size: 20px; }
.players { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 1200px; margin: 0 auto; }
.player-chip {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 3px 0 rgba(29, 29, 27, 0.25);
  animation: pop 0.25s ease-out;
  border: none;
  cursor: pointer;
}
.player-chip:hover { text-decoration: line-through; }
.player-chip.off { opacity: 0.5; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ------------------------------------------------------- Spørsmål -- */
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.pill { background: var(--surface); border-radius: var(--radius-md); padding: 6px 14px; font-weight: 700; }
.prompt-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  font-family: var(--font-slab);
  font-size: clamp(28px, 4.2vw, 56px);
  line-height: 1.25;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 0 rgba(29, 29, 27, 0.25);
  overflow-wrap: anywhere;
}
.prompt-card.long { font-size: clamp(22px, 2.6vw, 36px); text-align: left; font-family: var(--font-sans); font-weight: 400; line-height: 1.5; }
.cursor { display: inline-block; width: 0.5em; height: 0.95em; background: var(--field); border: 2px solid var(--ink); vertical-align: -0.1em; margin-left: 0.1em; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.added { background: var(--gul); box-shadow: 0 0 0 2px var(--gul); border-radius: var(--radius-sm); }
.answer-token { background: var(--gul); border-bottom: 4px solid var(--ink); padding: 0 4px; }

.q-mid { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; flex: 1; }
.timer {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  font-family: var(--font-slab); font-weight: 700; font-size: 48px;
  position: relative;
  box-shadow: 0 4px 0 rgba(29, 29, 27, 0.25);
}
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: butt; transition: stroke-dashoffset 0.25s linear; }
.answers-count { background: var(--surface); border-radius: var(--radius-md); padding: 12px 20px; text-align: center; box-shadow: 0 4px 0 rgba(29, 29, 27, 0.25); }
.answers-count .n { font-family: var(--font-slab); font-weight: 700; font-size: 48px; line-height: 56px; display: block; }
.hint-big { text-align: center; font-size: 28px; line-height: 36px; font-weight: 700; background: var(--surface); border-radius: var(--radius-lg); padding: 24px; }

/* Svarfelt i Kahoot-stil: fire fargar + fire former. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 16px;
  min-height: 96px;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: clamp(22px, 2.6vw, 36px);
  font-weight: 700;
  text-align: left;
  box-shadow: 0 5px 0 rgba(29, 29, 27, 0.35);
  color: var(--ink);
  overflow-wrap: anywhere;
}
button.tile { cursor: pointer; }
button.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(29, 29, 27, 0.35); }
.tile .shape { width: 40px; height: 40px; flex: none; }
.tile.c0 { background: var(--a0); }
.tile.c1 { background: var(--a1); }
.tile.c2 { background: var(--a2); }
.tile.c3 { background: var(--a3); }
.tile.dim { opacity: 0.35; }
.tile.win { outline: 4px solid var(--ink); outline-offset: 2px; }
.tile .count { margin-left: auto; font-size: 0.8em; display: flex; align-items: center; gap: 4px; }

/* Token-visning: synleg mellomrom. */
.tok { white-space: pre; }
.tok .sp { color: var(--ink-muted); font-weight: 400; font-size: 0.7em; margin-right: 0.08em; }

/* ----------------------------------------------------------- Fasit -- */
.reveal { display: grid; grid-template-columns: 1fr; gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(120px, 28%) 1fr 120px; align-items: center; gap: 12px; }
.bar .label { font-size: 24px; font-weight: 700; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.bar .track { background: var(--surface-muted); height: 40px; border-radius: var(--radius-sm); position: relative; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--a3); border-right: 2px solid var(--ink); transition: width 0.8s ease-out; }
.bar:first-child .fill { background: var(--gul); }
.bar .pct { font-weight: 700; font-size: 20px; }
.bar .who { font-size: 14px; color: var(--ink-muted); display: block; font-weight: 500; }
.others { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.others .o { background: var(--surface-muted); border: 1px solid var(--line); padding: 4px 10px; border-radius: var(--radius-sm); font-weight: 500; }

/* -------------------------------------------------- Resultattavle -- */
.scores { display: flex; flex-direction: column; gap: 10px; max-width: 800px; width: 100%; margin: 0 auto; }
.score-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 24px; font-weight: 700;
  box-shadow: 0 3px 0 rgba(29, 29, 27, 0.25);
  animation: slide 0.35s ease-out both;
}
.score-row .r { font-family: var(--font-slab); width: 40px; }
.score-row .s { margin-left: auto; }
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin-top: auto; }
.podium .step { width: min(28vw, 240px); text-align: center; display: flex; flex-direction: column; gap: 8px; }
.podium .name { font-size: 24px; font-weight: 700; background: var(--surface); padding: 8px; border-radius: var(--radius-md); overflow-wrap: anywhere; }
.podium .block { border: 2px solid var(--ink); border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 12px; font-family: var(--font-slab); font-weight: 700; animation: rise 0.8s ease-out both; }
.podium .block .place { font-size: 56px; line-height: 64px; }
.podium .p1 .block { background: var(--gul); height: 260px; animation-delay: 1.2s; }
.podium .p2 .block { background: var(--surface); height: 190px; animation-delay: 0.6s; }
.podium .p3 .block { background: var(--oransje); height: 140px; }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }

.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* -------------------------------------------------------- Spelar -- */
.player-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.player-prompt { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; font-size: 20px; line-height: 28px; box-shadow: 0 3px 0 rgba(29, 29, 27, 0.25); max-height: 40vh; overflow: auto; }
.player-tiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 12px; min-height: 260px; }
.player-tiles .tile { flex-direction: column; justify-content: center; text-align: center; font-size: 24px; gap: 8px; min-height: 120px; }
.player-tiles .tile .shape { width: 56px; height: 56px; }
.status-block { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; max-width: 480px; width: 100%; }
.status-block .big { font-family: var(--font-slab); font-size: 36px; line-height: 44px; font-weight: 700; }
.result-banner { width: 100%; border-radius: var(--radius-lg); padding: 24px; border: 2px solid var(--ink); }
.result-banner.good { background: var(--lysegronn); }
.result-banner.half { background: var(--gul); }
.result-banner.bad { background: var(--lys-rosa); }
.result-banner .icon { font-size: 56px; line-height: 64px; display: block; }
.points-pill { background: var(--ink); color: var(--surface); border-radius: var(--radius-md); padding: 8px 16px; font-weight: 700; font-size: 24px; }
.spinner { width: 56px; height: 56px; border: 6px solid var(--surface); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bottom-bar { background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-weight: 700; border-top: 1px solid var(--line); }
.bottom-bar .score { background: var(--ink); color: var(--surface); padding: 4px 12px; border-radius: var(--radius-md); }

/* -------------------------------------------------------- Mobil -- */
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; min-height: 56px; }
  .brand { height: 38px; }
  .field { padding: 16px; gap: 16px; }
  .choice { grid-template-columns: 1fr; }
  .join-banner { flex-direction: column; }
  .join-banner .pin { border-left: none; border-top: 1px solid var(--line); }
  .join-banner .pin .num { font-size: 48px; line-height: 56px; }
  .q-mid { grid-template-columns: auto auto; justify-content: space-between; }
  .q-mid > .spacer { display: none; }
  .timer { width: 88px; height: 88px; font-size: 36px; }
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 64px; }
  .bar { grid-template-columns: 96px 1fr 64px; }
  .bar .label { font-size: 18px; }
  .bar .pct { font-size: 16px; }
  .score-row { font-size: 18px; }
  .podium .name { font-size: 16px; }
}
.field:has(.podium) { padding-bottom: 0; }

.hero-logo { display: block; width: min(440px, 80%); height: auto; margin: auto auto 0; }
a { color: var(--ink); text-underline-offset: 2px; }
.sound-btn { background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius-md); padding: 4px 12px; font-weight: 700; font-size: 16px; cursor: pointer; }
