:root {
  --ink: #1c2233;
  --mist: #eef0f5;
  --paper: #ffffff;
  --line: #d5d9e4;
  --slate: #566075;
  --ok: #16815a;
  --warn: #9a5a00;
  --err: #b3261e;
  --spirit: #8a8fa3;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 17px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

/* The one accent on the page: the group's average colour. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(env(safe-area-inset-top, 0px) + 8px);
  background: var(--spirit);
  transition: background-color 0.6s;
  z-index: 5;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 48px);
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 10vw, 4.4rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
}
h2 { margin: 0 0 12px; font-size: 1.15rem; }
.lede { margin: 12px 0 20px; font-size: 1.2rem; color: var(--slate); max-width: 32ch; }
.label { margin: 0 0 4px; font-size: 0.95rem; color: var(--slate); }
.hint { margin: 8px 0; font-size: 0.95rem; color: var(--slate); }
.error { margin: 8px 0; color: var(--err); font-weight: 600; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}

.banner {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-left: 6px solid var(--warn);
  border-radius: 12px;
  background: #fff3dc;
}

.lobby, .game-grid { display: grid; gap: 16px; }
.game { display: grid; gap: 16px; }
.game[hidden], .lobby[hidden] { display: none; }
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 860px) {
  .lobby { grid-template-columns: minmax(300px, 400px) 1fr; align-items: start; }
  .game-grid { grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); align-items: start; }
  .game-grid.lower { grid-template-columns: 1fr 1fr; }
}

.qr-card { text-align: center; }
#qr {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto 8px;
  image-rendering: pixelated;
  background: #fff;
}
.qr-caption { margin: 4px 0; font-weight: 700; }
.url { margin: 4px 0 8px; font-weight: 700; word-break: break-all; }

.field { margin: 0 0 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 700; }
input[type="text"] {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}
input[type="color"] {
  width: 84px;
  min-height: 52px;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--spirit); outline-offset: 3px; }

.btn {
  min-height: 52px;
  padding: 0 22px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary { background: var(--ink); color: #fff; width: 100%; }
.btn-small { min-height: 44px; padding: 0 16px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.audio-card .btn { margin-bottom: 12px; }
.audio-card .btn-primary { margin-top: 4px; }

.meter { height: 10px; margin-top: 10px; border-radius: 5px; background: #e3e6ee; overflow: hidden; }
.meter > i { display: block; width: 0; height: 100%; background: var(--ok); transition: width 0.12s linear; }

.status { margin: 6px 0; font-size: 1rem; }
[data-level="ok"] { color: var(--ok); }
[data-level="warn"] { color: var(--warn); }
[data-level="error"] { color: var(--err); }

.neighbor { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.neighbor.empty { font-size: 1.2rem; font-weight: 600; color: var(--slate); }
.dot { display: inline-block; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(28, 34, 51, 0.25); }
.dot-lg { width: 30px; height: 30px; }

.countdown { margin: 0; font-size: 3.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown .unit { font-size: 1.1rem; font-weight: 600; color: var(--slate); }

.stage canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.participants { margin: 0; padding: 0; list-style: none; }
.participants li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.participants li:last-child { border-bottom: 0; }
.participants .me { color: var(--slate); font-size: 0.95rem; }

.spirit { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.swatch { flex: none; width: 132px; height: 132px; border-radius: 50%; background: var(--spirit); border: 1px solid rgba(28, 34, 51, 0.2); transition: background-color 0.6s; }
.rgb { margin: 0; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.diagnostics { margin-top: 24px; }
.diagnostics summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.diagnostics dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 12px 0 0; font-size: 0.95rem; }
.diagnostics dt { color: var(--slate); }
.diagnostics dd { margin: 0; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; z-index: 10; }
.toast[hidden] { display: none; }

.sink { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* Modus: zelfde Wi-Fi of online */
fieldset { border: 0; padding: 0; min-width: 0; }
fieldset[hidden], .field[hidden] { display: none; }
.mode-switch legend { padding: 0; margin-bottom: 6px; font-weight: 700; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-switch legend { grid-column: 1 / -1; }
.mode-switch label { position: relative; display: block; cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-switch span {
  display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 12px;
  border: 2px solid var(--line); border-radius: 14px; font-weight: 700; text-align: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.mode-switch input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.mode-switch input:focus-visible + span { outline: 3px solid var(--spirit); outline-offset: 3px; }

.row { display: flex; gap: 8px; align-items: stretch; }
.row input { flex: 1; min-width: 0; }
.row .btn { flex: none; min-height: 52px; }

.meter-in > i { background: var(--spirit); transition: width 0.06s linear; }
.game-head .label { margin: 0; }
.diag-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
