:root {
  --bg: #0b0614;
  --panel: #160c27;
  --line: #3a1f66;
  --text: #f3eaff;
  --muted: #a993c9;
  --pink: #ff3ea5;
  --cyan: #22e6ff;
  --lime: #9dff3a;
  --purple: #8b3dff;
  --me: var(--pink);
}
* { 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); }
.lime { color: var(--lime); text-shadow: 0 0 18px rgba(157, 255, 58, .6); }

/* Lobby */
#lobby {
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(139, 61, 255, .35), 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(40px, 12vw, 64px); line-height: 1; margin: 0 0 12px; font-weight: 900; letter-spacing: -.02em; }
.tag { color: var(--muted); margin: 0 0 28px; }
.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: #12041f;
  background: linear-gradient(90deg, var(--lime), var(--cyan) 50%, var(--pink));
  box-shadow: 0 0 24px rgba(34, 230, 255, .45);
}
.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: #0f0820; 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); }
.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 { background: radial-gradient(70% 60% at 50% 40%, #170b30, var(--bg)); touch-action: none; }
#pit { 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: 14px;
}
.me { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--me); box-shadow: 0 0 10px var(--me); flex: none; }
.hunger {
  position: relative; flex: 1; height: 18px; border-radius: 9px; overflow: hidden;
  background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
}
.hunger i {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: linear-gradient(90deg, var(--lime), #ffc81f);
  box-shadow: 0 0 12px rgba(157, 255, 58, .6);
  transition: width .12s linear;
}
.hunger.low i { background: linear-gradient(90deg, #ff3b3b, #ff8a1f); animation: blink .5s steps(2) infinite; }
.hunger span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: rgba(0, 0, 0, .65);
}
.hunger.low span { color: #fff; }
@keyframes blink { 50% { opacity: .45; } }
.alive { display: flex; gap: 4px; flex: none; }
.alive b { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.alive b.out { background: transparent; border: 1px solid var(--c); box-shadow: none; opacity: .5; }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: clamp(32px, 12vw, 72px); font-weight: 900; text-align: center; pointer-events: none;
  text-shadow: 0 0 24px rgba(255, 255, 255, .5); white-space: nowrap;
}
.banner.small { font-size: clamp(18px, 5vw, 28px); top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); }
.hint {
  position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom));
  margin: 0; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none;
}

/* Room panel */
.room {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 4, 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(22, 12, 39, .92);
  border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px;
  box-shadow: 0 0 40px rgba(139, 61, 255, .35);
}
.result { font-size: 28px; font-weight: 900; margin: 0 0 12px; }
#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: #0f0820; border: 1px solid var(--line); font-size: 14px; text-align: left; min-height: 40px;
}
.seats li.empty { color: var(--muted); border-style: dashed; }
.seats li.away { opacity: .5; }
.seats li .dot { background: var(--c); box-shadow: 0 0 8px var(--c); }
.seats li.empty .dot { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
.seats li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats li small { color: var(--muted); font-size: 11px; }
.seats li .wins { font-weight: 800; color: #ffc81f; }
.share { display: flex; gap: 8px; margin-bottom: 10px; }
.share .btn { flex: 1; }
