:root {
  --blue: #1d2bd6;
  --navy: #0a1270;
  --ink: #060b47;
  --sun: #ffd23f;
  --pink: #ff3e8a;
  --mint: #2ee6a6;
  --paper: #fff6e5;
  --display: "Bungee", "Rubik", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--blue) repeating-conic-gradient(from 0deg at 50% 60%, rgb(255 255 255 / 0.06) 0deg 7.5deg, transparent 7.5deg 15deg) fixed;
  color: var(--paper);
  font-family: "Rubik", system-ui, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

#conn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--pink);
  color: var(--ink);
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 99px;
}
#conn[hidden] { display: none; }

.logo {
  font-family: var(--display);
  font-size: 56px;
  margin: 8px 0 0;
  color: var(--sun);
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--navy);
  transform: rotate(-4deg);
}

/* Join form */
.join { width: 100%; max-width: 440px; display: grid; gap: 20px; justify-items: center; }
.join label { width: 100%; display: grid; gap: 8px; font-weight: 800; }
.join input {
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 14px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}
.join fieldset { width: 100%; border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.join legend { font-weight: 800; margin-bottom: 8px; padding: 0; }
.emojis .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emojis button { font-size: 30px; aspect-ratio: 1; border-radius: 14px; background: rgb(6 11 71 / 0.45); }
.emojis button[aria-pressed="true"] { background: var(--sun); box-shadow: 0 4px 0 var(--navy); }
.sounds .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sounds button { padding: 12px 10px; border-radius: 12px; background: rgb(6 11 71 / 0.45); font-weight: 600; text-align: left; }
.sounds button[aria-pressed="true"] { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--navy); }
.sounds .note { font-size: 14px; opacity: 0.85; font-weight: 400; }
.go {
  width: 100%;
  font-family: var(--display);
  font-size: 24px;
  padding: 18px;
  border-radius: 18px;
  background: var(--mint);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--navy);
}
.go:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--navy); }
.link { background: none; text-decoration: underline; font-weight: 600; opacity: 0.85; padding: 8px; }

.mode { background: var(--pink); color: var(--ink); font-weight: 800; font-size: 14px; padding: 6px 12px; border-radius: 99px; }

/* In game */
.me { width: 100%; max-width: 480px; display: flex; align-items: center; gap: 12px; }
.me .face { width: 48px; height: 48px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font-size: 28px; flex: none; }
.me .name { font-weight: 800; font-size: 20px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .score { font-family: var(--display); font-size: 24px; color: var(--sun); }
.me .score small { font-family: "Rubik", sans-serif; font-size: 14px; color: var(--paper); margin-left: 4px; }

.status { text-align: center; max-width: 440px; display: grid; gap: 6px; }
.status .kicker { font-weight: 600; opacity: 0.8; }
.status h2 { font-family: var(--display); font-size: 30px; margin: 0; line-height: 1.1; }
.status p { margin: 0; font-size: 18px; line-height: 1.35; }

.stage { flex: 1; width: 100%; max-width: 480px; display: grid; place-items: center; align-content: center; gap: 18px; }

.buzzer {
  --size: min(80vw, 52dvh);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgb(255 255 255 / 0.55) 0 7%, transparent 8%), var(--c);
  box-shadow: 0 18px 0 color-mix(in srgb, var(--c) 50%, #000), 0 26px 40px rgb(0 0 0 / 0.45);
  font-family: var(--display);
  font-size: calc(var(--size) * 0.17);
  color: var(--ink);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  transition: transform 0.06s, box-shadow 0.06s;
  touch-action: none;
}
.buzzer .em { font-size: calc(var(--size) * 0.22); line-height: 1; }
.buzzer.pressed { transform: translateY(14px); box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 50%, #000), 0 8px 16px rgb(0 0 0 / 0.4); }
.buzzer:disabled { --c: #8b90c4; opacity: 0.6; }
.buzzer.small { --size: min(46vw, 28dvh); }

.options { width: 100%; display: grid; gap: 10px; }
.options.emoji { grid-template-columns: repeat(3, 1fr); }
.options button {
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: 16px 14px;
  font-size: 19px;
  font-weight: 800;
  text-align: left;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 5px 0 var(--navy);
}
.options.emoji button { font-size: 52px; justify-content: center; aspect-ratio: 1; padding: 0; }
.options button .l { font-family: var(--display); background: var(--sun); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; flex: none; font-size: 16px; }
.options button:disabled { opacity: 0.3; text-decoration: line-through; }
.options button.chosen { background: var(--sun); }
.options button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--navy); }

.countdown { width: 100%; height: 14px; background: rgb(6 11 71 / 0.6); border-radius: 99px; overflow: hidden; }
.countdown div { height: 100%; background: var(--sun); width: 100%; }

.verdict { font-family: var(--display); font-size: 64px; line-height: 1; }
.flash-right { animation: flash 0.6s; color: var(--mint); }
.flash-wrong { animation: shake 0.5s; color: var(--pink); }
@keyframes flash { from { transform: scale(1.6); } }
@keyframes shake { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
.big-face { width: 120px; height: 120px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font-size: 72px; }
.answer { background: var(--paper); color: var(--ink); border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 22px; text-align: center; }
.answer.emoji { font-size: 60px; padding: 4px 18px; }
.rank { font-family: var(--display); font-size: 72px; color: var(--sun); line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  .flash-right, .flash-wrong { animation: none; }
}
