* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #10162b;
  --bg-mid: #1a2348;
  --accent: #ffcf3f;
  --accent2: #ff5f6d;
  --accent3: #35c9c1;
  --text: #f5f6fa;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Verdana, sans-serif;
  background: radial-gradient(circle at 50% 0%, #24316b 0%, #0c1024 70%);
  color: var(--text);
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.screen.active { display: flex; }

/* ---------- Title screen ---------- */
.title-wrap {
  text-align: center;
  z-index: 2;
}
.game-title {
  font-size: clamp(2.5rem, 7vw, 5rem);
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 207, 63, 0.5), 4px 4px 0 #0006;
}
.game-title span { color: var(--accent2); }
.subtitle {
  margin-top: 14px;
  font-size: 1.1rem;
  color: #c9cff0;
}
.bg-shapes {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 95, 109, 0.15), transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(53, 201, 193, 0.15), transparent 40%);
  pointer-events: none;
}

.big-btn, .mid-btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: 50px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.big-btn {
  margin-top: 32px;
  padding: 16px 42px;
  font-size: 1.3rem;
  background: linear-gradient(135deg, var(--accent), #ff9f43);
  color: #241a00;
  box-shadow: 0 6px 0 #a56f00, 0 10px 20px rgba(0,0,0,0.4);
}
.mid-btn {
  padding: 12px 26px;
  font-size: 1rem;
  background: #2c3768;
  color: var(--text);
  box-shadow: 0 4px 0 #131a3a;
}
.big-btn:hover, .mid-btn:hover { transform: translateY(-2px); }
.big-btn:active, .mid-btn:active { transform: translateY(2px); box-shadow: none; }
.big-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Character select ---------- */
#screen-select h2 {
  font-size: 1.8rem;
  letter-spacing: 1px;
}
.select-subtitle {
  margin-top: 6px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  color: #9aa2d1;
}
.roster {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  max-width: 900px;
  width: 100%;
}
.hero-card {
  background: linear-gradient(160deg, #202a55, #141a38);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.hero-card:hover { transform: translateY(-4px); }
.hero-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(255, 207, 63, 0.5);
}
.hero-card.cpu-tag { opacity: 0.85; }
.hero-card canvas {
  display: block;
  margin: 0 auto 8px;
  background: radial-gradient(circle, #2c3768 0%, #161c3a 80%);
  border-radius: 10px;
}
.hero-card .hname {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}
.hero-card .htag {
  font-size: 0.7rem;
  color: #9aa2d1;
  margin-top: 2px;
}
.hero-card .htag.you-tag {
  color: #10162b;
  background: var(--accent);
  border-radius: 8px;
  padding: 3px 6px;
  font-weight: 700;
  display: inline-block;
  margin-top: 4px;
}
.select-actions {
  margin-top: 22px;
  display: flex;
  gap: 16px;
}

/* ---------- Countdown ---------- */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(255,207,63,0.7);
  z-index: 50;
  pointer-events: none;
}
.countdown.hidden { display: none; }

/* ---------- Race screen ---------- */
#screen-race { justify-content: flex-start; padding-top: 14px; }
#race-hud {
  width: 1000px;
  max-width: 96vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.hud-label {
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #9aa2d1;
  margin-bottom: 4px;
}
#mash-meter {
  width: 220px;
  height: 16px;
  background: #141a38;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #2c3768;
}
#mash-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent3), var(--accent));
  transition: width 0.05s linear;
}
#placement-hud {
  font-size: 0.85rem;
  color: #c9cff0;
  text-align: right;
}
#race-canvas-wrap {
  position: relative;
  width: 1000px;
  max-width: 96vw;
}
#race-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1000 / 640;
  background: linear-gradient(180deg, #2b3a6b 0%, #1a2348 60%, #12183a 100%);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.race-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 32, 0.88);
  border: 1px solid rgba(255, 207, 63, 0.5);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 18px;
  border-radius: 30px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}
.race-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}
#race-tip {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #9aa2d1;
  letter-spacing: 1px;
}

/* ---------- Results ---------- */
.results-title {
  font-size: 2.2rem;
  margin-bottom: 18px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255,207,63,0.4);
}
#podium {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 24px;
}
.podium-step {
  width: 130px;
  text-align: center;
  background: linear-gradient(160deg, #202a55, #141a38);
  border-radius: 12px 12px 0 0;
  padding: 10px 8px;
  border: 2px solid #2c3768;
}
.podium-step.gold { order: 2; padding-bottom: 50px; border-color: #ffcf3f; }
.podium-step.silver { order: 1; padding-bottom: 30px; border-color: #c9d0e0; }
.podium-step.bronze { order: 3; padding-bottom: 16px; border-color: #cd7f32; }
.podium-step canvas { display: block; margin: 0 auto 6px; }
.podium-step .pname { font-size: 0.85rem; font-weight: 700; }
.podium-step .prank { font-size: 1.4rem; margin-bottom: 4px; }

#results-list {
  width: 480px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #161c3a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
}
.result-row .rank { width: 24px; font-weight: 700; color: var(--accent); }
.result-row .rname { flex: 1; }
.result-row.is-player { border: 2px solid var(--accent3); }
.result-row .rtag {
  font-size: 0.7rem;
  color: #9aa2d1;
  background: #0e1330;
  padding: 2px 8px;
  border-radius: 10px;
}
