:root {
  --bg: #150f28;
  --panel: #241a47;
  --btn: #3d2a66;
  --gold: #ffc400;
  --teal: #00d2a0;
  --red: #ff5a5f;
  --purple: #7c1fff;
  --text-dim: #c9bfe8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, system-ui, "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  background: var(--bg);
  color: #fff;
  min-height: 100vh;
}
/* slow-drifting color wash behind everything, dimmed way down so it never
   competes with foreground content */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(296deg, #d93c3c, #8853f1, #2da1c4);
  background-size: 600% 600%;
  opacity: 0.2;
  animation: bg-gradient-shift 40s ease infinite;
}
@keyframes bg-gradient-shift {
  0% { background-position: 0% 35%; }
  50% { background-position: 100% 66%; }
  100% { background-position: 0% 35%; }
}
#app { padding: 10px; max-width: 480px; margin: 0 auto; position: relative; z-index: 1; }
.screen { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; }
.hidden { display: none !important; }

h1, h2 { margin: 2px 0; }

.btn {
  padding: 12px;
  font-size: 18px;
  border-radius: 10px;
  border: none;
  background: var(--btn);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.btn.primary { background: var(--gold); color: #1a1230; font-weight: 600; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.locked { background: var(--teal); color: #0a2620; }
.btn.big { font-size: 22px; padding: 18px; border-radius: 14px; }

.name-inputs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.name-inputs input {
  width: 100%;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  padding: 10px;
  background: var(--panel);
  color: #fff;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.character-card {
  background: transparent;
  border-radius: 10px;
  padding: 2px;
  cursor: pointer;
  border: 3px solid transparent;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.character-card img { width: 100%; display: block; }
.character-card .select-check {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: #0a2620;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.character-card.selected {
  border-color: var(--teal);
  transform: scale(1.04);
}
.character-card.selected .select-check { opacity: 1; transform: scale(1); }
.character-card.taken { opacity: 0.3; cursor: default; }

.round-header { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
#countdown {
  font-weight: bold;
  font-size: clamp(36px, 14vw, 64px);
  color: var(--gold);
  line-height: 1;
}
@keyframes countdown-pulse {
  0% { text-shadow: 0 0 0 rgba(255, 90, 95, 0); transform: scale(1); }
  30% { text-shadow: 0 0 14px var(--red), 0 0 30px var(--red); transform: scale(1.18); }
  100% { text-shadow: 0 0 0 rgba(255, 90, 95, 0); transform: scale(1); }
}
#countdown.pulse { animation: countdown-pulse 0.6s ease-out; color: var(--red); }

textarea#answer-input {
  width: 100%;
  min-height: 80px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  padding: 10px;
  resize: none;
  background: var(--panel);
  color: #fff;
}

.bubble-list { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.bubble .bubble-text { flex: 1; text-align: left; }
.bubble .select-check {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal);
  color: #0a2620;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.bubble.own { opacity: 0.35; cursor: default; }
.bubble.selected { border-color: var(--teal); transform: scale(1.02); }
.bubble.selected .select-check { opacity: 1; transform: scale(1); }

.status { color: var(--text-dim); min-height: 1.2em; }

.error-banner {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: var(--red);
  color: #2a0a0a;
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
}

.reconnect-banner {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  background: var(--gold);
  color: #1a1230;
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  z-index: 10;
}

/* "3...2...1" before round 1, dims the whole screen behind it */
.start-countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(2, 1, 8, 0.85);
}
.start-countdown-label { color: var(--text-dim); font-size: 18px; margin: 0; }
.start-countdown-number {
  font-weight: 800;
  font-size: 38vh;
  line-height: 1;
  color: var(--gold);
}
@keyframes start-countdown-pulse {
  0% { text-shadow: 0 0 0 rgba(255, 196, 0, 0); transform: scale(0.8); }
  35% { text-shadow: 0 0 30px var(--gold), 0 0 70px var(--gold); transform: scale(1.08); }
  100% { text-shadow: 0 0 0 rgba(255, 196, 0, 0); transform: scale(1); }
}
.start-countdown-number.pulse { animation: start-countdown-pulse 0.7s ease-out; }

.max-logo {
  position: relative;
  width: min(90vw, 480px);
  aspect-ratio: 1000 / 600;
  margin: 0 auto;
}
.max-logo-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  transition: background-color 0.25s ease;
}
.max-logo-rear { -webkit-mask-image: url(/images/logo/max-logo-rear.png); mask-image: url(/images/logo/max-logo-rear.png); z-index: 1; }
.max-logo-mid { -webkit-mask-image: url(/images/logo/max-logo-mid.png); mask-image: url(/images/logo/max-logo-mid.png); z-index: 2; }
.max-logo-top { -webkit-mask-image: url(/images/logo/max-logo-top.png); mask-image: url(/images/logo/max-logo-top.png); z-index: 3; }
.max-logo-tothe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 4;
}
