/* Shared styles. Mobile first: 360-430px wide, one hand, big tap targets. */

:root {
  --bg: #1b120a;
  --surface: #2b1d11;
  --surface-2: #3a2816;
  --line: #5a4026;
  --text: #fff7e8;
  --muted: #d9c4a3;
  --accent: #f5b942;
  --accent-ink: #2b1608;
  --ok: #5fd38d;
  --danger: #ff6b5e;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
}
.topbar .who, .topbar .where { grid-column: 1; min-width: 0; }
.topbar .who {
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .where { font-size: 20px; font-weight: 800; }
.topbar .timer {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 92px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.topbar .timer.low { background: var(--danger); color: #fff; }

.banner {
  padding: 8px 16px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

/* ---------- layout ---------- */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
}

.status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 8px;
  text-align: center;
}
.status .icon { font-size: 64px; line-height: 1; }
.status h1 { font-size: 30px; line-height: 1.15; }
.status p { font-size: 19px; color: var(--muted); }
.status.ok h1 { color: var(--ok); }
.status.bad h1 { color: var(--danger); }

.prompt { font-size: 22px; font-weight: 800; }
.hint { font-size: 16px; color: var(--muted); }
.error { font-size: 17px; font-weight: 700; color: var(--danger); min-height: 24px; }

.actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 22%);
}

/* ---------- controls ---------- */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  min-height: 64px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 22px;
}
.btn:disabled { opacity: 0.4; cursor: default; }

.field {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.35); }
.field .affix {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 26px;
  font-weight: 800;
}
.field input {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  padding: 8px 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1b120a;
  font-size: 26px;
  font-weight: 700;
}
.field input::placeholder { color: #9a8b78; font-weight: 500; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  min-height: 104px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 44px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- confirm dialog ---------- */

dialog {
  width: min(92vw, 440px);
  padding: 20px;
  border: 2px solid var(--accent);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { font-size: 24px; margin-bottom: 8px; }
dialog p { font-size: 18px; color: var(--muted); margin-bottom: 6px; }
dialog .answer { font-size: 22px; font-weight: 800; color: var(--text); overflow-wrap: anywhere; }
dialog .warn { color: var(--danger); font-weight: 700; }
dialog .row { display: grid; gap: 10px; margin-top: 16px; }

/* ---------- two-bin sorter (round 4) ---------- */

.sorter { display: flex; flex-direction: column; gap: 12px; }
.sort-targets {
  position: sticky;
  top: 74px;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 6px 0;
  background: var(--bg);
}
.sort-target {
  min-height: 64px;
  padding: 6px 8px;
  border: 3px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.sort-target small { display: block; font-size: 14px; font-weight: 600; color: var(--muted); }
.sorter.has-selection .sort-target,
.sort-target.over { border-color: var(--accent); border-style: solid; background: var(--surface-2); }
.sort-pool, .sort-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 60px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.sort-pool:empty::after, .sort-list:empty::after { color: var(--muted); font-size: 15px; padding: 10px 4px; }
.sort-pool:empty::after { content: "Alles is geplaatst"; }
.sort-list:empty::after { content: "Nog leeg"; }
.sort-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sort-lists h3 { font-size: 15px; color: var(--muted); margin: 0 0 4px 4px; }
.sort-list { flex-direction: column; flex-wrap: nowrap; }
.chip {
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.chip.selected { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

/* ---------- admin ---------- */

.btn.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.small { min-height: 48px; padding: 8px 12px; font-size: 17px; }
.btn.on { border-color: var(--accent); color: var(--accent); }

.admin main { padding-bottom: 170px; }

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 2px solid var(--line);
}
.bottombar .secondary { display: flex; gap: 8px; }
.bottombar .secondary .btn { flex: 1; }
.bottombar .main { display: flex; gap: 8px; }
.bottombar .main .btn.primary { flex: 1; }
.bottombar .menu { width: 64px; min-height: 64px; flex: none; font-size: 28px; padding: 0; position: relative; }
.badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 13px;
  background: var(--danger);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.card {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card h2 { font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.card .big { font-size: 26px; font-weight: 800; overflow-wrap: anywhere; }
.card .note { font-size: 16px; color: var(--muted); margin-top: 4px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.item .name { font-weight: 800; overflow-wrap: anywhere; }
.item .sub { grid-column: 1; font-size: 16px; color: var(--muted); overflow-wrap: anywhere; }
.item .side { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 6px; }
.item .buttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.item .buttons .btn { flex: 1; width: auto; }
.item.flag { border-color: var(--accent); }
.item.dim { opacity: 0.55; }
button.item { width: 100%; min-height: var(--tap); text-align: left; cursor: pointer; font-size: 18px; }
.points { min-width: 44px; font-size: 24px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.step {
  width: 48px;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 26px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); font-size: 14px; font-weight: 700; }
.pill.warn { background: var(--accent); color: var(--accent-ink); }
.pill.bad { background: var(--danger); color: #fff; }
.pill.ok { background: var(--ok); color: #0c2b18; }
.count { font-size: 44px; font-weight: 900; line-height: 1; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
}
.sheet-head h1 { flex: 1; font-size: 22px; }
.sheet-head .btn { width: auto; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet-body h2 { font-size: 18px; margin-top: 8px; }
.segmented { display: flex; gap: 8px; }
.segmented .btn { flex: 1; padding: 8px 6px; font-size: 17px; }
label.stack { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.field.dark { background: var(--surface); }
.field.dark input, .field.dark select { color: var(--text); }
.field select {
  flex: 1;
  min-height: 56px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
}
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 700; }
.check input { width: 28px; height: 28px; accent-color: var(--accent); }

.toasts {
  position: fixed;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px;
  border: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}
.toast .name { font-size: 20px; font-weight: 800; }
.toast .sub { color: var(--muted); }
.toast .buttons { display: flex; gap: 8px; margin-top: 8px; }
.toast .buttons .btn { flex: 1; }

/* dragging in the sorter */
.chip { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chip.dragging { opacity: 0.3; }
.chip.ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  margin: 0;
  pointer-events: none;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  will-change: transform;
}
.sorter.is-dragging .sort-target { border-color: var(--accent); }
.sorter .over { border-style: solid; border-color: var(--accent); background: var(--surface-2); box-shadow: inset 0 0 0 3px var(--accent); }
