:root {
  --bg: #050b1a;
  --panel: #0c1430;
  --line: #1f3366;
  --text: #eaf4ff;
  --muted: #93a8cc;
  --pink: #ff3ea5;
  --cyan: #22e6ff;
  --lime: #9dff3a;
  --me: #ff3ea5;
  --them: #9dff3a;
}
* { 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(34, 230, 255, .25), transparent 70%),
    radial-gradient(50% 40% at 100% 100%, rgba(157, 255, 58, .12), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(255, 62, 165, .18), 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; }
.logo-puck {
  appearance: none; border: 0; padding: 0; cursor: pointer; display: block; margin: 10px auto 12px;
  width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 22%, #22e6ff 23% 34%, #0c1430 35% 62%, #22e6ff 63% 70%, #0c1430 71%);
  box-shadow: 0 0 24px rgba(34, 230, 255, .7);
  animation: glide 3.2s ease-in-out infinite;
}
.logo-puck.kiwi {
  background: radial-gradient(circle, #f6f2c8 0 16%, #9fd84a 17% 55%, #6aa82a 56% 74%, #7a5230 75%);
  box-shadow: 0 0 24px rgba(157, 255, 58, .7);
}
.logo-puck.wiggle { animation: wiggle .35s ease-in-out; }
@keyframes glide { 0%, 100% { transform: translateX(-26px); } 50% { transform: translateX(26px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-18deg) scale(1.1); } 70% { transform: rotate(18deg) scale(1.1); } }
.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: #031022;
  background: linear-gradient(90deg, var(--cyan), #a86bff 50%, var(--pink));
  box-shadow: 0 0 24px rgba(34, 230, 255, .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: #08102a; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; min-height: 48px;
}
.join input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.msg { min-height: 1.4em; color: var(--pink); margin: 12px 0 0; }
.msg.muted { color: var(--muted); }
.msg.kiwi { color: var(--lime); }
.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; }
#table { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.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;
}
.score { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.score b { font-size: 22px; font-variant-numeric: tabular-nums; }
.score i { color: var(--muted); font-style: normal; }
.me-c { color: var(--me); text-shadow: 0 0 10px var(--me); }
.them-c { color: var(--them); text-shadow: 0 0 10px var(--them); }
.target { flex: 1; text-align: right; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.icon-btn {
  pointer-events: auto; appearance: none; border: 1px solid var(--line); background: rgba(12, 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: "🔇"; }
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(36px, 13vw, 84px); 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, 6, 16, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto;
}
.room-card {
  width: min(400px, 100%); text-align: center; background: rgba(12, 20, 48, .93);
  border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; box-shadow: 0 0 40px rgba(34, 230, 255, .25);
}
.result { font-size: 26px; font-weight: 900; margin: 0 0 12px; text-shadow: 0 0 20px currentColor; }
#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: #08102a; 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 .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: #ffc81f; }
.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: 62px; flex: none; }
.seg { flex: 1; display: flex; background: #08102a; 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(--cyan); }
.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: #08102a; }
.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; }
.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: #0c1430; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; min-height: 34px;
}
.chip[aria-pressed="true"] { border-color: var(--w, var(--cyan)); box-shadow: 0 0 10px var(--w, var(--cyan)); }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.swatch {
  appearance: none; aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  background: var(--c); box-shadow: 0 0 10px var(--c); min-height: 28px; padding: 0;
}
.swatch.auto { background: conic-gradient(var(--pink), var(--cyan), var(--lime), var(--pink)); font-size: 0; }
.swatch[aria-pressed="true"] { border-color: #fff; outline: 2px solid var(--c, #fff); outline-offset: 2px; }
