:root {
  --bg: #060914;
  --panel: #0e1430;
  --line: #233166;
  --text: #eef3ff;
  --muted: #95a3c9;
  --pink: #ff3ea5;
  --cyan: #22e6ff;
  --lime: #9dff3a;
  --gold: #ffc81f;
  --me: #ff3ea5;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
.screen { position: fixed; inset: 0; }
.pink { color: var(--pink); text-shadow: 0 0 18px rgba(255, 62, 165, .7); }
.cyan { color: var(--cyan); text-shadow: 0 0 18px rgba(34, 230, 255, .7); }

/* Lobby */
#lobby {
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(255, 62, 165, .22), transparent 70%),
    radial-gradient(50% 40% at 100% 100%, rgba(34, 230, 255, .16), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(255, 200, 31, .1), transparent 70%),
    var(--bg);
}
.lobby-card { width: min(420px, 100%); text-align: center; }
.brand { letter-spacing: .3em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
h1 { font-size: clamp(38px, 11vw, 60px); line-height: 1; margin: 0 0 6px; font-weight: 900; letter-spacing: -.02em; }
/* a single glowing round, spinning slowly */
.logo-shell { position: relative; width: 64px; height: 64px; margin: 14px auto 12px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 22px rgba(255, 200, 31, .55), inset 0 0 14px rgba(255, 200, 31, .35); animation: spin 6s linear infinite; }
.logo-shell::before, .logo-shell::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; border: 2px solid rgba(255, 200, 31, .35); transform: rotate(var(--r)) translateY(-19px); }
.logo-shell::before { --r: 120deg; } .logo-shell::after { --r: 240deg; }
.logo-shell i { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 14px var(--gold); transform: translateY(-19px); }
@keyframes spin { to { transform: rotate(360deg); } }
.tag { color: var(--muted); margin: 0 0 24px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 700; padding: 14px 20px; border-radius: 14px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  border: 0; color: #120414;
  background: linear-gradient(90deg, var(--pink), #ff8a3a 50%, var(--gold));
  box-shadow: 0 0 24px rgba(255, 62, 165, .45);
}
.btn.ghost { background: transparent; margin-top: 8px; }
.btn.wide { width: 100%; }
#create { width: 100%; font-size: 18px; }
.join { display: flex; gap: 8px; margin-top: 12px; }
.join input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; letter-spacing: .12em; text-transform: uppercase;
  background: #090e24; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; min-height: 48px;
}
.join input:focus { outline: 2px solid var(--pink); outline-offset: 1px; }
.msg { min-height: 1.4em; color: var(--pink); margin: 12px 0 0; }
.msg.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; margin: 18px 0 0; }
.link { display: inline-block; color: var(--muted); }
.rules { text-align: left; color: var(--muted); font-size: 14px; padding-left: 20px; margin: 20px 0 0; }
.rules li { margin: 6px 0; }
.rules b { color: var(--text); }

/* Game */
#game { touch-action: none; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; pointer-events: none; font-size: 15px; height: 52px;
}
.me-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lives { color: var(--me); text-shadow: 0 0 10px var(--me); font-size: 18px; letter-spacing: 2px; white-space: nowrap; }
.lives .gone { color: #3a4266; text-shadow: none; }
.chamber {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid #4a5480; position: relative; flex: none;
}
.chamber.full { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.chamber.full::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--gold); }
.clock { flex: 1; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .06em; color: var(--muted); }
.clock.sudden { color: #ff4060; text-shadow: 0 0 12px #ff4060; }
.icon-btn {
  pointer-events: auto; appearance: none; border: 1px solid var(--line); background: rgba(14, 20, 48, .7); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; font: inherit; font-size: 15px; cursor: pointer; display: grid; place-items: center;
}
#sound::before { content: "🔊"; }
#sound[aria-pressed="false"]::before { content: "🔇"; }
.feed {
  position: absolute; right: 10px; top: 56px; margin: 0; padding: 0; list-style: none; pointer-events: none;
  display: grid; gap: 4px; justify-items: end; font-size: 13px; font-weight: 700;
}
.feed li { background: rgba(6, 9, 20, .72); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; transition: opacity .6s; white-space: nowrap; }
.feed li.old { opacity: 0; }
.feed b { text-shadow: 0 0 8px currentColor; }
.feed i { font-style: normal; color: var(--muted); padding: 0 4px; }
.banner {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  font-size: clamp(32px, 11vw, 76px); font-weight: 900; text-align: center; pointer-events: none; white-space: nowrap;
  text-shadow: 0 0 28px currentColor;
}
.banner.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.1); } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* Room panel */
.room {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(3, 5, 14, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto;
}
.room-card {
  width: min(420px, 100%); text-align: center; background: rgba(14, 20, 48, .94);
  border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; box-shadow: 0 0 40px rgba(255, 62, 165, .2);
}
.result { font-size: 26px; font-weight: 900; margin: 0 0 8px; text-shadow: 0 0 20px currentColor; }
.board { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.board li { display: flex; gap: 8px; align-items: center; padding: 4px 10px; border-radius: 10px; background: #090e24; }
.board .pl { flex: 1; text-align: left; font-weight: 800; }
.board small { color: var(--muted); }
#room-code { color: var(--text); letter-spacing: .15em; }
.seats { list-style: none; margin: 6px 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seats li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px;
  background: #090e24; border: 1px solid var(--line); font-size: 14px; text-align: left; min-height: 44px;
}
.seats li.empty { color: var(--muted); border-style: dashed; }
.seats li.away { opacity: .5; }
.seats li.bot { color: var(--muted); }
.seats .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.seats li.empty .dot { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
.seats .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats small { color: var(--muted); font-size: 11px; }
.seats .wins { font-weight: 800; color: var(--gold); }
.share { display: flex; gap: 8px; margin-bottom: 12px; }
.share .btn { flex: 1; }
.rulebox { display: grid; gap: 6px; margin: 0 0 12px; text-align: left; }
.rule { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.rule > span { width: 52px; flex: none; }
.seg { flex: 1; display: flex; background: #090e24; border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button {
  flex: 1; appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  padding: 7px 4px; border-radius: 8px; cursor: pointer; min-height: 34px;
}
.seg button[aria-pressed="true"] { background: var(--line); color: var(--text); box-shadow: inset 0 0 0 1px var(--pink); }
.rulebox.readonly .seg button { cursor: default; }
.rulebox.readonly .seg button:disabled:not([aria-pressed="true"]) { opacity: .45; }
.custom { text-align: left; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; background: #090e24; }
.custom summary { cursor: pointer; padding: 11px 0; font-weight: 700; font-size: 14px; }
.custom[open] { padding-bottom: 12px; }
.pick-label { margin: 8px 0 6px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pick-label small { text-transform: none; letter-spacing: 0; }
.how { margin: 0; font-size: 13px; color: var(--muted); }
.how b { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; min-height: 34px;
}
.chip[aria-pressed="true"] { border-color: var(--w, var(--pink)); box-shadow: 0 0 10px var(--w, var(--pink)); }

.lock-hint, .keys-hint {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0;
  padding: 7px 14px; border-radius: 999px; background: rgba(14, 20, 48, .85); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; white-space: nowrap; pointer-events: none;
}
.keys-hint { color: var(--muted); background: rgba(6, 9, 20, .6); }
.lock-hint:not([hidden]) + .keys-hint { bottom: calc(52px + env(safe-area-inset-bottom)); }

/* Room code: big, easy to read out loud, split in two halves */
.code-chip {
  display: block; width: 100%; margin: 0 0 12px; padding: 10px 8px 12px; user-select: none; -webkit-user-select: none;
  background: rgba(0, 0, 0, .35); border: 2px dashed var(--cc, #ff3ea5); border-radius: 16px; color: #fff;
}
.code-chip small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; opacity: .75; margin-bottom: 4px; }
.code-chip b {
  display: block; font: 800 clamp(24px, 8vw, 34px)/1.1 ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  letter-spacing: .14em; color: #fff; text-shadow: 0 0 14px var(--cc, #ff3ea5); white-space: nowrap;
}
