* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --ink: #1d2b3a;
  --panel: rgba(18, 26, 38, 0.92);
  --gold: #ffd35c;
}
html, body { height: 100%; }
body{
  font-family: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(120% 90% at 50% 0%, #2c4a6b 0%, #16283f 55%, #0f1d2e 100%);
  color: #fff;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.page{
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 10px;
}

/* ---------- top bar ---------- */
.topbar{ display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 10px; }
.logo{ font-size: 1.25rem; font-weight: 800; letter-spacing: .4px; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.logo .accent{ color: var(--gold); }
.race-meta{ display: flex; align-items: center; gap: 8px; }
.dist-chip, .timer{
  background: var(--panel); border: 2px solid rgba(255,255,255,.14);
  padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: .8rem;
}
.dist-chip{ color: var(--gold); }
.timer{ font-variant-numeric: tabular-nums; min-width: 66px; text-align: center; }

/* ---------- stage / canvas ---------- */
.stage{
  position: relative;
  flex: 1;
  min-height: 460px;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid var(--ink);
  box-shadow: 0 20px 45px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.06);
}
#race{ position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden{ display: none !important; }

/* ---------- HUD ---------- */
.hud{
  position: absolute; top: 10px; left: 10px; z-index: 5;
  display: flex; flex-direction: column; gap: 5px;
  max-width: calc(100% - 130px);
}
.chip{
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 2px solid rgba(255,255,255,.12);
  padding: 4px 10px 4px 6px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  animation: chipIn .25s ease both;
}
@keyframes chipIn { from { transform: translateX(-14px); opacity: 0; } }
.chip-dot{
  width: 15px; height: 15px; border-radius: 50%; background: var(--c); flex: none;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.28), inset 0 2px 0 rgba(255,255,255,.35);
}
.chip-name{ white-space: nowrap; }
.chip-prog{ margin-left: auto; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- minimap ---------- */
.minimap-wrap{
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 88px; height: 46%;
  border-radius: 10px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
#minimap{ width: 100%; height: 100%; display: block; }

/* ---------- finish banner ---------- */
.banner{
  position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%);
  text-align: center; z-index: 6; pointer-events: none;
}
.banner-big{
  display: block; font-size: clamp(2.6rem, 12vw, 4rem); font-weight: 800; line-height: 1;
  text-shadow: 0 4px 0 rgba(0,0,0,.28), 0 10px 24px rgba(0,0,0,.35);
}
.banner-sub{
  display: inline-block; margin-top: 8px;
  background: var(--panel); border: 2px solid rgba(255,255,255,.16);
  padding: 3px 16px; border-radius: 999px; font-weight: 700; font-size: .95rem;
}
.banner.pop{ animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop{
  from { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------- overlay cards ---------- */
.overlay-card{
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 16, 26, .55);
  backdrop-filter: blur(3px);
  padding: 18px;
}
.card{
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 3px solid #3c5370;
  border-radius: 16px;
  padding: 24px 24px 26px;
  text-align: center;
  box-shadow: 0 26px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08);
  animation: cardIn .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes cardIn{ from { transform: translateY(26px) scale(.94); opacity: 0; } }
.card h2{ font-size: 1.5rem; letter-spacing: .3px; }
.card p{ color: #c3d2e2; font-size: .92rem; line-height: 1.45; margin-top: 8px; }
.card p strong{ color: var(--gold); }

.lineup{ list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 18px 0 20px; }
.lineup li{
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: .68rem; font-weight: 700; color: #dbe7f2;
}
.pv-dot{
  width: 26px; height: 26px; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.3), inset 0 3px 0 rgba(255,255,255,.4);
}

/* ---------- buttons ---------- */
.btn-start{
  font-family: inherit; font-weight: 800; font-size: 1.2rem; letter-spacing: 1.5px;
  color: var(--ink); background: var(--gold);
  border: 3px solid var(--ink);
  padding: 13px 40px; border-radius: 12px;
  cursor: pointer; width: 100%;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%);
  filter: drop-shadow(0 5px 0 var(--ink)) drop-shadow(0 14px 26px rgba(0,0,0,.45));
  transition: transform .12s ease, filter .12s ease;
}
.btn-start:hover{ transform: translateY(-2px) scale(1.02); filter: drop-shadow(0 7px 0 var(--ink)) drop-shadow(0 18px 30px rgba(0,0,0,.5)); }
.btn-start:active{ transform: translateY(3px) scale(.98); filter: drop-shadow(0 2px 0 var(--ink)); }

/* ---------- results ---------- */
.results-list{ list-style: none; margin: 18px 0 20px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.result-row{
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.08);
  border-left: 7px solid var(--c);
  border-radius: 12px; padding: 8px 12px;
  animation: rowIn .4s ease both;
}
.result-row:nth-child(2){ animation-delay: .08s; }
.result-row:nth-child(3){ animation-delay: .16s; }
.result-row:nth-child(4){ animation-delay: .24s; }
.result-row:nth-child(5){ animation-delay: .32s; }
@keyframes rowIn{ from { transform: translateX(-20px); opacity: 0; } }
.medal{ font-size: 1.25rem; width: 28px; text-align: center; flex: none; }
.r-name{ font-weight: 700; font-size: 1rem; }
.r-time{ margin-left: auto; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.foot{ text-align: center; color: #8fa9c2; font-size: .72rem; padding: 10px 0 2px; letter-spacing: .4px; }

/* ---------- mobile ---------- */
@media (max-width: 420px){
  .page{ padding: 8px 8px 6px; }
  .logo{ font-size: 1.05rem; }
  .stage{ min-height: 430px; border-radius: 12px; }
  .hud{ top: 8px; left: 8px; }
  .minimap-wrap{ width: 74px; top: 8px; right: 8px; }
  .chip{ font-size: .7rem; padding: 3px 8px 3px 5px; }
  .card{ padding: 20px 16px 22px; }
}
