:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #172033;
  --panel-2: #202a3f;
  --text: #f8fafc;
  --muted: #9ca3af;
  --line: #334155;
  --good: #22c55e;
  --bad: #ef4444;
  --accent: #f59e0b;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #111827;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input,
select {
  width: 100%;
  background: #0f172a;
  color: var(--text);
  padding: 0 12px;
}

.shell {
  width: min(760px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: calc(100dvh - 36px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent);
  color: #111827;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

.brand p,
.muted {
  color: var(--muted);
}

.panel,
.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.join-row,
.topbar,
.player-line,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.join-row input {
  text-transform: uppercase;
}

.join-row button {
  width: 130px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.topbar strong {
  display: block;
  font-size: 28px;
  letter-spacing: 2px;
}

.secondary {
  padding: 0 18px;
  background: #38bdf8;
}

.danger {
  padding: 0 14px;
  background: #ef4444;
  color: #fff;
}

.scoreboard {
  display: grid;
  gap: 10px;
}

.player {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.player.me {
  border-color: var(--accent);
}

.player-line {
  justify-content: space-between;
}

.avatar {
  font-size: 26px;
}

.status {
  min-height: 48px;
  margin: 16px 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: center;
  padding: 10px;
}

.question-card {
  transition: filter .2s ease;
  margin-bottom: 14px;
}

.question-card.blurred {
  filter: blur(3px);
}

.question-meta {
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 8px;
}

.question-card h2 {
  font-size: 22px;
  line-height: 1.2;
  margin-bottom: 14px;
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.answers button {
  min-height: 72px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  text-align: center;
  overflow-wrap: anywhere;
}

.answers button.correct {
  background: color-mix(in srgb, var(--good) 70%, #0f172a);
}

.answers button.wrong {
  background: color-mix(in srgb, var(--bad) 62%, #0f172a);
}

.answers button.erased {
  visibility: hidden;
}

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 56px;
  margin-top: 14px;
}

.inventory .bonus-button {
  position: relative;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 50%;
  background: #38bdf8;
  font-size: 24px;
}

.inventory .bonus-button b {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  background: var(--accent);
  color: #111827;
  font-size: 12px;
}

.progress {
  margin: 16px 0 8px;
}

.progress-scale {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  position: relative;
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(90deg, #0f172a, #1f2937);
}

.progress-track::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, var(--accent), var(--good));
}

.progress-player {
  position: absolute;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 64px;
  transform: translate(-50%, -50%);
  transition: left .65s cubic-bezier(.2, .8, .2, 1);
  z-index: 1;
}

.progress-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 22px;
  box-shadow: 0 8px 22px rgb(0 0 0 / 35%);
  transition: transform .25s ease, box-shadow .25s ease;
}

.progress-player.me .progress-avatar,
.progress-player:hover .progress-avatar {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgb(0 0 0 / 45%);
}

.progress-player.me .progress-avatar {
  border-color: var(--accent);
}

.progress-name {
  max-width: 86px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.victory-screen {
  display: grid;
  place-items: center;
  position: relative;
}

.victory-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.victory-avatar {
  font-size: 64px;
}

.victory-panel h2 {
  font-size: 30px;
}

.victory-panel p:not(.muted) {
  color: var(--text);
}

.powerups {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.powerup {
  position: absolute;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  font-size: 24px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 35%);
  animation: powerup-drift var(--drift-time, 2.8s) infinite alternate ease-in-out;
  will-change: transform;
}

.powerup.fly {
  background: #f8fafc;
}

.powerup b {
  position: absolute;
  right: -8px;
  bottom: -5px;
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #111827;
  font-size: 12px;
}

.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.confetti span {
  position: absolute;
  top: -40px;
  font-size: 22px;
  animation: confetti-fall 3s linear forwards;
}

.water,
.balls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.water {
  background-image: radial-gradient(circle at 20% 20%, rgb(125 211 252 / .35) 0 12px, transparent 13px),
    radial-gradient(circle at 70% 40%, rgb(125 211 252 / .3) 0 18px, transparent 19px),
    radial-gradient(circle at 50% 80%, rgb(125 211 252 / .25) 0 14px, transparent 15px);
}

.balls::before,
.balls::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ef4444;
  animation: bounce 1s infinite alternate ease-in-out;
}

.balls::before {
  left: 20%;
  top: 25%;
}

.balls::after {
  right: 18%;
  bottom: 20%;
  background: #38bdf8;
  animation-delay: .25s;
}

.shake {
  animation: shake .08s infinite;
}

.letters-move {
  animation: wiggle .5s infinite alternate;
}

@keyframes shake {
  from { transform: translate(-2px, 1px); }
  to { transform: translate(2px, -1px); }
}

@keyframes wiggle {
  from { letter-spacing: 0; transform: rotate(-1deg); }
  to { letter-spacing: 1px; transform: rotate(1deg); }
}

@keyframes pop {
  from { scale: .96; }
  to { scale: 1.05; }
}

@keyframes powerup-drift {
  from { transform: translate(calc(-50% - var(--drift-x, 14px)), calc(-50% - var(--drift-y, 10px))) scale(.96); }
  to { transform: translate(calc(-50% + var(--drift-x, 14px)), calc(-50% + var(--drift-y, 10px))) scale(1.06); }
}

@keyframes bounce {
  from { transform: translateY(-20px); }
  to { transform: translateY(80px); }
}

@keyframes confetti-fall {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(110dvh) rotate(540deg); opacity: 0; }
}

@media (min-width: 680px) {
  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }
}
