:root {
  --bg: #f3f1ec;
  --ink: #1c1c1c;
  --muted: #6b6b66;
  --card: #ffffff;
  --line: #d8d5cc;
  --accent: #2b5fd9;
  --error: #b3261e;
  --bank-black: #111111;
  --bank-green: #1e9e43;
  --bank-red: #d0261e;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .5rem; font-weight: 650; }
button, input { font: inherit; }

.screen { max-width: 960px; margin: 0 auto; padding-block: 24px 56px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; }
.status { color: var(--muted); margin-top: 1.2rem; }
.big { font-size: 1.4rem; text-align: center; margin: .5rem 0; }
.error { color: var(--error); min-height: 1.4em; }

/* join */
#join-form { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 12px; }
#join-form input {
  padding: 12px 14px; font-size: 1.4rem; letter-spacing: .12em; text-transform: uppercase;
  text-align: center; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
button.primary, #join-form button, #next-btn {
  padding: 12px 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
#instr-text p { margin: 0 0 1em; }

/* game board (Figure 1 of the paper) */
.board { display: grid; grid-template-columns: minmax(104px, 1fr) minmax(0, 1.4fr) minmax(104px, 1fr); gap: 12px; align-items: start; }
.col { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.col.me { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.col h2 { font-size: 1rem; }
.you { color: var(--accent); font-weight: 500; margin-left: .35em; }
.total-label { color: var(--muted); font-size: .8rem; }
.bank { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 10px; color: var(--bank-black); }
.bank.green { color: var(--bank-green); }
.bank.red { color: var(--bank-red); }

.crystals { display: grid; gap: 10px; justify-items: center; }
.crystal { width: 76px; height: 76px; padding: 0; border: 0; background: none; border-radius: 12px; position: relative; transition: transform .08s; }
.crystal svg { width: 100%; height: 100%; display: block; }
.crystal.active { filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); }
.crystal:not(.active) { filter: grayscale(1) opacity(.35); }
.col.me .crystal.active { cursor: pointer; }
.col.me .crystal.active:hover { transform: translateY(-2px); }
.col.me .crystal.active:active { transform: translateY(1px); }
.col:not(.me) .crystal { pointer-events: none; }
.crystal .key {
  position: absolute; right: 2px; bottom: 2px; font-size: .7rem; text-transform: uppercase;
  background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted);
}

.stage { display: flex; justify-content: space-between; min-height: 200px; padding-top: 70px; }
.slot { width: 48%; text-align: center; }
.slot .shown { width: 84px; height: 84px; margin: 0 auto; }
.slot .shown svg { width: 100%; height: 100%; }
.slot .pts { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot .pts.pos { color: var(--bank-green); }
.slot .pts.neg { color: var(--bank-red); }

#nextbar { text-align: center; margin-top: 18px; }
#nextbar p { margin: 0 0 8px; color: var(--muted); }
#next-btn { padding: 12px 28px; font-size: 1.1rem; position: relative; }

#overlay {
  position: fixed; inset: 0; background: rgba(243,241,236,.92); display: grid; place-items: center; z-index: 10; padding: 16px;
}
#overlay .card { max-width: 420px; text-align: center; }
#footer {
  position: fixed; left: 0; right: 0; bottom: 0; text-align: center; font-size: .75rem; color: var(--muted);
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 11;
}

@media (max-width: 560px) {
  .crystal { width: 60px; height: 60px; }
  .bank { font-size: 1.9rem; }
  .slot .shown { width: 56px; height: 56px; }
  .slot .pts { font-size: 1.3rem; }
  .board { gap: 6px; }
}

/* ------------------------------------------------------------ experimenter page */
.admin { max-width: 1100px; margin: 0 auto; padding-block: 24px 48px; display: grid; gap: 16px; }
.admin h1 { font-size: 1.4rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin input[type=text], .admin input[type=password], .admin select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.admin button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.admin button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin button.danger { color: var(--error); border-color: var(--error); }
.admin table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin th, .admin td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.scroll { overflow-x: auto; }
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.seat .code { font: 700 1.6rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; background: #eee; }
.pill.ok { background: #d7f0de; color: #14612b; }
.pill.warn { background: #fff0c9; color: #7a5600; }
.pill.bad { background: #fadcd9; color: #8f1d17; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.kv div b { display: block; font-size: 1.25rem; }
.events { font: .78rem/1.5 ui-monospace, Consolas, monospace; max-height: 240px; overflow: auto; }
