:root {
  --bg: #03101f;
  --ink: #eef9ff;
  --muted: #9cc3d9;
  --frost: #ffffff;
  --ice: #8ee8ff;
  --glacier: #3aa8ff;
  --deep: #0a2c4a;
  --aqua: #6dffe0;
  --lavender: #b59cff;
  --blush: #ffc4ec;
  --glass: rgba(170, 225, 255, 0.09);
  --glass-strong: rgba(8, 30, 52, 0.62);
  --line: rgba(200, 240, 255, 0.28);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
}
canvas { display: block; position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; }
.hidden { display: none !important; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 1px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  font: 600 12px 'Space Grotesk', system-ui, sans-serif; color: var(--ink);
  background: var(--glass); text-align: center;
}
.frosted {
  background: linear-gradient(160deg, rgba(220, 245, 255, 0.14), rgba(120, 190, 255, 0.05) 45%, rgba(8, 30, 52, 0.55));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 12px 40px rgba(0, 10, 25, 0.5), 0 0 30px rgba(142, 232, 255, 0.12);
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 18px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.label span { color: var(--frost); font-weight: 700; }
.big {
  font-family: 'Bungee', sans-serif; font-size: 32px; line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 20%, var(--ice) 60%, var(--glacier));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 8px rgba(142, 232, 255, 0.55));
}
.hud-mid { text-align: center; }
.best { font-family: 'Bungee', sans-serif; font-size: 18px; color: var(--lavender); text-shadow: 0 0 10px rgba(181, 156, 255, 0.6); }
.hud-right { text-align: right; }
.combo {
  font-family: 'Bungee', sans-serif; font-size: 16px; color: var(--aqua);
  text-shadow: 0 0 10px rgba(109, 255, 224, 0.7);
  min-height: 20px; transition: transform 0.12s;
}
.combo.pop { transform: scale(1.35); }
.lives { margin-top: 6px; display: flex; gap: 6px; justify-content: flex-end; }
.lives i {
  width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 16px solid var(--ice); filter: drop-shadow(0 0 5px var(--ice));
}
.powers { margin-top: 6px; font-size: 12px; font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
.powers .t { color: var(--lavender); }
.powers .s { color: var(--ice); }

/* Commentator booth */
.booth {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3;
  width: min(640px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 10px; border-radius: 18px;
}
.booth::before { /* icicles hanging off the panel */
  content: ''; position: absolute; left: 22px; right: 22px; top: 100%; height: 11px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(225, 247, 255, 0.75), rgba(142, 232, 255, 0.15));
  -webkit-mask: conic-gradient(from -18deg at 50% 100%, #000 36deg, transparent 0) 0 0 / 17px 100% repeat-x;
          mask: conic-gradient(from -18deg at 50% 100%, #000 36deg, transparent 0) 0 0 / 17px 100% repeat-x;
}
.avatar {
  position: relative; flex: 0 0 44px; height: 44px; border-radius: 50%; margin-top: 6px;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cdeeff 45%, #7cc4f0);
  box-shadow: 0 0 14px rgba(142, 232, 255, 0.6), inset -3px -4px 0 rgba(58, 168, 255, 0.25);
}
.avatar::before { /* bobble hat */
  content: ''; position: absolute; left: 2px; right: 2px; top: -9px; height: 20px;
  border-radius: 22px 22px 4px 4px;
  background: repeating-linear-gradient(90deg, var(--lavender) 0 6px, #8e72f0 6px 9px);
  box-shadow: 0 3px 0 #ffffff;
}
.avatar::after { /* bobble */
  content: ''; position: absolute; left: 50%; top: -16px; width: 11px; height: 11px; margin-left: -5.5px;
  border-radius: 50%; background: #ffffff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}
.avatar .eye {
  position: absolute; top: 18px; width: 8px; height: 5px; background: #0a2c4a;
  border-radius: 0 0 8px 8px; /* half-lidded: unimpressed */
}
.avatar .eye.l { left: 11px; }
.avatar .eye.r { right: 11px; }
.avatar .mouth {
  position: absolute; left: 50%; bottom: 8px; width: 14px; height: 3px; margin-left: -7px;
  background: #0a2c4a; border-radius: 3px; transition: height 0.08s;
}
.booth.talk .mouth { animation: yap 0.18s infinite alternate; }
@keyframes yap { from { height: 3px; } to { height: 9px; border-radius: 0 0 8px 8px; } }
.booth-text { flex: 1; min-width: 0; }
.booth-name { font-family: 'Bungee', sans-serif; font-size: 12px; color: var(--ice); letter-spacing: 0.06em; }
.booth-name span { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-left: 6px; }
.quip { font-size: 15px; line-height: 1.35; min-height: 2.7em; }
.voice {
  flex: 0 0 auto; align-self: center; cursor: pointer;
  font: 700 10px 'Space Grotesk', sans-serif; letter-spacing: 0.12em;
  color: var(--ink); background: var(--glass);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px;
}
.voice.off { color: var(--muted); }

/* Screens */
.screen {
  position: fixed; inset: 0; z-index: 4; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; text-align: center;
  background: radial-gradient(ellipse at center, rgba(3, 16, 31, 0.2), rgba(3, 16, 31, 0.78));
}
.logo { margin: 0; font-family: 'Bungee', sans-serif; font-weight: 400; line-height: 0.95; font-size: clamp(48px, 13vw, 120px); position: relative; }
.logo span { display: block; -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .w1 {
  background-image: linear-gradient(180deg, #ffffff 15%, #cdf3ff 45%, var(--ice) 60%, var(--glacier) 95%);
  filter: drop-shadow(0 0 18px rgba(142, 232, 255, 0.55));
  animation: float 4s ease-in-out infinite;
}
.logo .w2 {
  background-image: linear-gradient(180deg, #ffffff 10%, #e2d8ff 45%, var(--lavender) 65%, #6f6cff 95%);
  filter: drop-shadow(0 0 18px rgba(181, 156, 255, 0.5));
  animation: float 4s ease-in-out 0.6s infinite;
}
.logo .w1, .logo .w2 { background-size: 100% 100%; }
@keyframes float { 50% { transform: translateY(-5px) rotate(-0.8deg); } }
.tag { color: var(--muted); font-size: 16px; margin: 14px 0 22px; }
.keys { color: var(--muted); font-size: 13px; line-height: 2; margin: 16px 0 0; }
.btn {
  cursor: pointer; font-family: 'Bungee', sans-serif; font-size: 22px; color: var(--deep);
  padding: 12px 34px; border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #c9f1ff 45%, var(--ice) 55%, #5cc8ff);
  box-shadow: 0 0 24px rgba(142, 232, 255, 0.6), inset 0 -3px 0 rgba(58, 168, 255, 0.5);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover, .btn:focus-visible { transform: scale(1.06); outline: none; box-shadow: 0 0 34px rgba(142, 232, 255, 0.85), inset 0 -3px 0 rgba(58, 168, 255, 0.5); }
.btn.small { font-size: 14px; padding: 10px 18px; }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.board { margin-top: 24px; width: min(380px, 100%); border-radius: 18px; padding: 14px 18px; }
.board h2 { margin: 0 0 8px; font-family: 'Bungee', sans-serif; font-weight: 400; font-size: 16px; color: var(--ice); text-shadow: 0 0 10px rgba(142, 232, 255, 0.6); }
.board ol { list-style: none; margin: 0; padding: 0; text-align: left; font-variant-numeric: tabular-nums; }
.board li { display: flex; align-items: baseline; gap: 10px; padding: 5px 4px; border-bottom: 1px solid rgba(200, 240, 255, 0.1); }
.board li:last-child { border-bottom: 0; }
.board li .rk { width: 22px; font-family: 'Bungee', sans-serif; color: var(--muted); }
.board li:nth-child(1) .rk { color: #ffffff; text-shadow: 0 0 8px var(--ice); }
.board li:nth-child(2) .rk { color: var(--ice); }
.board li:nth-child(3) .rk { color: var(--lavender); }
.board li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board li .wv { color: var(--muted); font-size: 12px; }
.board li .sc { font-weight: 700; color: var(--ice); }
.board li.me { background: rgba(109, 255, 224, 0.12); border-radius: 8px; }
.board li.me .nm { color: var(--aqua); }
.board .empty { color: var(--muted); justify-content: center; }

.over-h {
  margin: 0; font-family: 'Bungee', sans-serif; font-weight: 400; font-size: clamp(40px, 10vw, 80px);
  background: linear-gradient(180deg, #ffffff 15%, var(--ice) 55%, var(--lavender));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(142, 232, 255, 0.5));
}
.final { font-size: 18px; margin: 8px 0 0; }
.final b { color: var(--ice); }
.name-form { margin-top: 18px; width: min(380px, 100%); }
.name-form label { display: block; color: var(--aqua); font-weight: 600; margin-bottom: 8px; }
.name-form .row { display: flex; gap: 8px; }
.name-form input {
  flex: 1; min-width: 0; font: 600 18px 'Space Grotesk', sans-serif; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  -webkit-user-select: text; user-select: text;
}
.name-form input::placeholder { color: var(--muted); }
.name-form input:focus { outline: 2px solid var(--ice); outline-offset: 1px; }
.form-msg { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
#over .btn { margin-top: 22px; }

/* Touch controls */
.touch { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: space-between; padding: 0 12px 14px; pointer-events: none; }
.touch .pad { display: flex; gap: 10px; pointer-events: auto; }
.touch button {
  width: 64px; height: 64px; border-radius: 50%; font-size: 22px; color: var(--ink);
  background: rgba(142, 232, 255, 0.16); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.touch button.fire { background: rgba(181, 156, 255, 0.28); }
.touch button.on { background: rgba(255, 255, 255, 0.4); }
body.is-touch .booth { bottom: 92px; }
body.is-touch .quip { font-size: 13px; min-height: 2.6em; }

@media (max-width: 560px) {
  .big { font-size: 24px; }
  .best { font-size: 15px; }
  .avatar { flex-basis: 36px; height: 36px; }
  .avatar .eye { top: 15px; }
  .avatar .eye.l { left: 8px; } .avatar .eye.r { right: 8px; }
  .avatar .mouth { bottom: 6px; }
}
