:root {
  --ink: #fff3c8;
  --bg: #0a0f26;
  --panel: rgba(14, 22, 52, 0.92);
  --accent: #f4d06a;
  --hot: #b52a35;
  --sea: #9cc8f0;
  --muted: #c2c3c7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Press Start 2P", monospace;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
}

#stage {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(100dvh, calc(100vw * 16 / 9));
  width: auto;
  max-width: 100vw;
  overflow: hidden;
  background: #000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.screen.active { display: flex; }

#menu { justify-content: flex-start; padding-top: 18%; padding-bottom: 10px; background: linear-gradient(transparent 68%, rgba(0,0,0,.55)); }
/* Knappene ligger mellom fyret og Einar/Thea (paret står fra 74 % ned på skjermen) */
#menu .buttons {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(26% + 6px); margin: 0;
  width: calc(100% - 32px); max-width: 240px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
#menu .buttons button { padding: 8px 4px; font-size: 9px; }
#menu .buttons button.big { grid-column: 1 / -1; padding: 10px; font-size: 13px; }
#menu .corner { position: absolute; top: 10px; right: 10px; padding: 6px 8px; font-size: 7px; gap: 6px; }
#menu .corner canvas { width: 22px; height: 16px; }
#menu .foot { margin-top: auto; }

h1 {
  margin: 8px 0 6px;
  font-size: clamp(22px, 8.5vmin, 40px);
  line-height: 1.25;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--hot), 6px 6px 0 #000;
}
h2 { margin: 0 0 10px; font-size: 16px; color: var(--accent); line-height: 1.4; }
.kicker { font-size: 9px; color: var(--muted); margin: 0; }
.sub { font-size: 11px; color: var(--sea); margin: 0 0 18px; text-shadow: 2px 2px 0 #000; }
.foot { margin-top: auto; font-size: 8px; color: var(--muted); line-height: 1.6; text-shadow: 1px 1px 0 #000; }
.small { font-size: 9px; line-height: 1.6; }
.muted { color: var(--muted); }

.buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 260px; margin: 8px auto; }
.buttons.row { flex-direction: row; justify-content: center; }

button, .btn {
  font: inherit;
  font-size: 11px;
  color: #000;
  background: var(--ink);
  border: 0;
  padding: 12px 10px;
  box-shadow: 0 4px 0 #6e5a2a, inset -3px -3px 0 #d8c9a0;
  cursor: pointer;
  touch-action: manipulation;
}
button:active, .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #5f574f; }
button.big { background: linear-gradient(#ffe08a, #e0a83a); font-size: 14px; padding: 14px; }
button:disabled { opacity: .5; }

.panel {
  width: 100%;
  max-height: 100%;
  background: var(--panel);
  border: 3px solid #d4af5a;
  box-shadow: 0 0 0 3px #000;
  padding: 16px 14px;
}
.panel.scroll { overflow-y: auto; }

#intro { cursor: pointer; justify-content: flex-end; padding-bottom: 22%; }
#intro-text { white-space: pre-line; font-size: 11px; line-height: 1.8; text-align: left; min-height: 7em; margin: 0 0 10px; }
.blink { font-size: 8px; color: var(--accent); animation: blink 1s steps(2) infinite; margin: 8px 0 0; }
@keyframes blink { 50% { opacity: 0; } }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; font-size: 8px; margin-bottom: 6px; }
.legend .col { display: flex; flex-direction: column; gap: 6px; padding: 8px 6px; min-width: 0; }
.legend .good { border: 2px solid #d4af5a; background: rgba(244, 208, 106, 0.08); }
.legend .bad { border: 2px solid #ff2a3a; background: rgba(255, 42, 58, 0.14); color: #ffb3ba; }
.legend h3 { margin: 0 0 2px; font-size: 9px; letter-spacing: 1px; }
.legend .good h3 { color: #f4d06a; }
.legend .bad h3 { color: #ff5a64; }
.legend span { display: flex; align-items: center; gap: 6px; line-height: 1.4; }
.legend img { width: 24px; height: 24px; image-rendering: pixelated; flex: none; border-radius: 50%; }
.legend .good img { background: rgba(255, 224, 138, 0.3); }
.legend .bad img { background: rgba(255, 42, 58, 0.45); box-shadow: 0 0 0 2px #ff2a3a; }

.score { font-size: 26px; color: var(--accent); margin: 4px 0; text-shadow: 3px 3px 0 var(--hot); }

.field { display: block; text-align: left; font-size: 9px; margin: 14px 0 10px; }
.field input {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 14px;
  padding: 10px; border: 3px solid var(--ink); background: #000; color: var(--ink);
}

.selfie .frame {
  width: 144px; height: 144px; margin: 6px auto;
  border: 3px solid var(--ink); background: #000;
  display: grid; place-items: center; overflow: hidden;
}
.selfie video, .selfie img { width: 100%; height: 100%; object-fit: cover; }
.selfie video { transform: scaleX(-1); }
.selfie img { image-rendering: pixelated; }
#selfie-empty { font-size: 8px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 9px; line-height: 1.6; margin: 8px 0 4px; }
.check input { width: 20px; height: 20px; flex: none; margin: 0; }

#board-list { list-style: none; padding: 0; margin: 0 0 10px; text-align: left; }
#board-list li { display: grid; grid-template-columns: 22px 40px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 2px dashed #5f574f; font-size: 9px; }
#board-list li:nth-child(1) .rank { color: var(--accent); }
#board-list .pic { width: 40px; height: 40px; image-rendering: pixelated; background: #1d2b53; display: block; }
#board-list .who { line-height: 1.6; overflow: hidden; }
#board-list .who small { display: block; color: var(--muted); font-size: 7px; }
#board-list .pts { color: var(--accent); }
#board-list .me { background: rgba(255, 236, 39, 0.12); }

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.lang-btn { display: flex; align-items: center; gap: 8px; font-size: 8px; padding: 10px 8px; text-align: left; min-width: 0; }
.lang-btn canvas, .with-flag canvas { width: 33px; height: 24px; image-rendering: pixelated; flex: none; box-shadow: 0 0 0 2px #14101e; }
.lang-btn span { min-width: 0; overflow-wrap: anywhere; }
.lang-btn:last-child:nth-child(odd) { grid-column: 1 / -1; justify-content: center; }
.with-flag { display: flex; align-items: center; justify-content: center; gap: 10px; }
#menu-flag { display: inline-flex; }
