:root {
  /* palette taken from the summit logo gradient */
  --purple: #9b3cff;
  --orange: #ff8a3d;
  --yellow: #ffc21a;
  --teal: #3fb4c0;
  --green: #3dff9a;
  --brand-grad: linear-gradient(90deg, var(--purple), var(--orange) 40%, var(--yellow) 60%, var(--teal) 80%, var(--green));

  --bg: #0d0a1f;
  --bg-2: #18133a;
  --panel: #1c1744;
  --line: #342c6b;
  --text: #f6f4ff;
  --muted: #b3acd9;
  --accent: var(--green);
  --accent-ink: #04281a;
  --hot: var(--yellow);
  --hot-ink: #2e1d00;
  --bad: #ff5d7a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 0% -150px, rgba(155, 60, 255, .22), transparent 70%) fixed,
    radial-gradient(900px 500px at 100% -150px, rgba(61, 255, 154, .12), transparent 70%) fixed,
    var(--bg);
  color: var(--text);
  font: 16px/1.4 "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }

.wrap { max-width: 560px; margin: 0 auto; padding: 14px 16px 32px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand .logo { height: 40px; width: auto; flex: none; }
.brand h1 { margin: 0; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.brand h1 span {
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.brand .side-info { margin-left: auto; color: var(--muted); font-size: .85rem; text-align: right; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--green), var(--teal)); color: var(--accent-ink); font-weight: 700;
}
.btn.huge { background: linear-gradient(135deg, var(--purple), var(--orange)); color: #fff; }
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

/* ---------- player ---------- */
.card { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg-2); color: var(--text); padding: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 600; font-size: clamp(10px, 3.3vw, 17px); line-height: 1.15; min-width: 0;
  overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; user-select: none;
  transition: transform .08s ease, background .15s ease;
  position: relative;
}
.tile:active { transform: scale(.96); }
.tile.marked {
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: var(--accent-ink); border-color: var(--green);
}
.tile.marked::after {
  content: ""; position: absolute; inset: 14%; border-radius: 50%;
  border: 3px solid rgba(4, 40, 26, .14);
}
.tile.win {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: var(--hot-ink); border-color: var(--purple); box-shadow: 0 0 0 2px var(--purple);
}
.tile.shake { animation: shake .35s; border-color: var(--bad); }
@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.cardmeta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); font-size: .9rem; }
.cardmeta b { color: var(--text); font-family: ui-monospace, Consolas, monospace; letter-spacing: .12em; }

.bingo {
  display: none; margin-top: 14px; text-align: center;
  background: linear-gradient(135deg, var(--yellow), var(--orange)); color: var(--hot-ink);
  border-radius: var(--radius); padding: 14px; box-shadow: 0 0 0 3px var(--purple);
}
.bingo.show { display: block; animation: pop .4s ease; }
.bingo h2 { margin: 0 0 4px; font-size: 2rem; letter-spacing: .04em; }
.bingo .code { font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; font-weight: 800; letter-spacing: .2em; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

details.history { margin-top: 14px; }
details.history summary { cursor: pointer; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }

.help { color: var(--muted); font-size: .85rem; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #000c; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0;
  transition: .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- game master ---------- */
.gm { max-width: 1280px; }
.gm-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 900px) { .gm-grid { grid-template-columns: 1fr; } }

.stage { text-align: center; padding: 28px 16px; }
.stage .label { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: .9rem; }
.stage .big {
  font-size: clamp(2.4rem, 8vw, 6.5rem); font-weight: 900; line-height: 1.05; margin: 14px 0;
  overflow-wrap: anywhere; min-height: 1.1em;
  background: linear-gradient(90deg, var(--orange), var(--yellow) 50%, var(--green));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stage .big.reveal { animation: pop .45s ease; }
.stage .stats { color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.btn.huge { font-size: 1.4rem; padding: 16px 40px; border-radius: 14px; }

.side { display: flex; flex-direction: column; gap: 16px; }
.side h3 { margin: 0 0 10px; font-size: 1rem; }
#qr { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; }
#qr img, #qr canvas { display: block; width: 180px; height: 180px; }
.join-url { word-break: break-all; color: var(--muted); font-size: .85rem; margin-top: 8px; }

.verify-row { display: flex; gap: 8px; }
.verify-row input, .login input {
  flex: 1; min-width: 0; background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; text-transform: uppercase; letter-spacing: .12em;
}
.login input { text-transform: none; letter-spacing: normal; }
.mini-card { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 10px; }
.mini-card div {
  aspect-ratio: 1; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line);
  font-size: 10px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 2px; overflow-wrap: anywhere; line-height: 1.1;
}
.mini-card div.hit { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mini-card div.win { background: var(--hot); color: var(--hot-ink); border-color: var(--hot); }
.verdict { margin-top: 10px; font-weight: 800; }
.verdict.yes { color: var(--accent); }
.verdict.no { color: var(--bad); }

.login { max-width: 380px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--bad); min-height: 1.2em; }
.hidden { display: none !important; }
