@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/rajdhani-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/rajdhani-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/rajdhani-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --blue: #2f7dff;
  --blue-hot: #6fb1ff;
  --orange: #ff7a1a;
  --orange-hot: #ffb066;
  --ink: #eaf2ff;
  --ink-dim: #93a7c4;
  --panel: rgba(8, 14, 28, 0.82);
  --panel-line: rgba(122, 164, 255, 0.22);
  --accent: #ffd257;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #05080f; }
body {
  font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#scoreboard {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}
.sb-team {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px;
  font-weight: 700; font-size: 20px; letter-spacing: .08em;
}
.sb-blue { color: var(--blue-hot); border-right: 1px solid var(--panel-line); }
.sb-orange { color: var(--orange-hot); border-left: 1px solid var(--panel-line); }
.sb-score { font-size: 28px; min-width: 30px; text-align: center; }
.sb-clock {
  display: flex; align-items: center; padding: 6px 14px;
  font-size: 26px; font-weight: 700; letter-spacing: .06em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.sb-clock.ot { color: var(--accent); animation: pulse 1s infinite; }
.sb-clock.final { color: #ff5b5b; }
@keyframes pulse { 50% { opacity: .55; } }

#speedo {
  position: absolute; right: 26px; bottom: 26px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 12px 18px 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  min-width: 130px;
}
#speed-num { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#speed-unit { font-size: 13px; color: var(--ink-dim); letter-spacing: .2em; margin-bottom: 6px; }
#boost-wrap { position: relative; width: 86px; height: 86px; }
#boost-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 9; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 0;
  transition: stroke .2s;
}
#boost-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: var(--accent);
}
#ballcam-ind {
  margin-top: 4px; font-size: 12px; letter-spacing: .18em; color: var(--blue-hot);
  font-weight: 600;
}

#announce {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%) scale(1);
  font-size: 64px; font-weight: 700; letter-spacing: .12em; text-align: center;
  text-shadow: 0 0 30px rgba(120,180,255,.8), 0 4px 10px rgba(0,0,0,.7);
  animation: pop-in .35s cubic-bezier(.2,1.6,.4,1);
  white-space: nowrap;
}
#announce.blue { color: var(--blue-hot); }
#announce.orange { color: var(--orange-hot); }
#announce.gold { color: var(--accent); }
#subannounce {
  position: absolute; top: calc(22% + 78px); left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 600; letter-spacing: .3em; color: var(--ink);
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
@keyframes pop-in {
  0% { transform: translateX(-50%) scale(.4); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
#countdown {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%,-50%);
  font-size: 96px; font-weight: 700; color: var(--ink);
  text-shadow: 0 0 50px rgba(120,180,255,.9), 0 6px 16px rgba(0,0,0,.7);
  animation: cd-zoom .9s cubic-bezier(.2,1.4,.4,1);
}
@keyframes cd-zoom {
  0% { transform: translate(-50%,-50%) scale(1.8); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); }
}
#hint-bar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  font-size: 15px; font-weight: 600; letter-spacing: .12em; color: var(--ink-dim);
  text-shadow: 0 2px 6px rgba(0,0,0,.8); white-space: nowrap;
}
#pause-btn {
  position: absolute; top: 14px; right: 16px; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--panel-line); color: var(--ink);
  width: 42px; height: 42px; border-radius: 10px; font-size: 14px; cursor: pointer;
}
#pause-btn:hover { border-color: var(--blue-hot); color: var(--blue-hot); }

/* ---------- Menus ---------- */
.menu {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 30px;
  background: radial-gradient(ellipse at 50% 26%, rgba(10,18,40,.38), rgba(4,7,14,.82) 82%);
}
.menu.overlay { background: rgba(4, 7, 14, .72); backdrop-filter: blur(6px); }
.menu h2 {
  font-size: 40px; font-weight: 700; letter-spacing: .22em;
  color: var(--ink); text-shadow: 0 0 24px rgba(120,180,255,.5);
}
.title-block { text-align: center; margin-bottom: 6px; }
.game-logo {
  font-size: 92px; font-weight: 700; letter-spacing: .1em; line-height: .95;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(110,170,255,.9), 0 0 60px rgba(60,120,255,.55), 0 6px 14px rgba(0,0,0,.8);
}
.game-logo span { color: var(--accent); text-shadow: 0 0 18px rgba(255,210,90,.9), 0 0 60px rgba(255,150,40,.5), 0 6px 14px rgba(0,0,0,.8); }
.game-sub { font-size: 19px; font-weight: 600; letter-spacing: .52em; color: var(--ink-dim); margin-top: 10px; }
.title-foot { position: absolute; bottom: 24px; font-size: 14px; color: var(--ink-dim); letter-spacing: .14em; }
.menu-list { display: flex; flex-direction: column; gap: 12px; min-width: 320px; }
.mitem {
  font-family: inherit; font-size: 22px; font-weight: 700; letter-spacing: .2em;
  padding: 13px 34px; cursor: pointer; color: var(--ink);
  background: linear-gradient(180deg, rgba(30,48,86,.75), rgba(14,24,48,.75));
  border: 1px solid var(--panel-line); border-radius: 8px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.mitem:hover, .mitem:focus-visible {
  border-color: var(--accent); color: var(--accent);
  transform: translateX(6px) scale(1.02);
  box-shadow: 0 0 22px rgba(255,210,87,.25);
  outline: none;
}
.mitem.small { font-size: 17px; padding: 10px 26px; }
.menu-btns { margin-top: 10px; }

.opt-row { display: flex; align-items: center; gap: 18px; min-width: 480px; }
.opt-row label { width: 150px; text-align: right; font-size: 18px; font-weight: 600; letter-spacing: .1em; color: var(--ink-dim); }
.seg { display: flex; border: 1px solid var(--panel-line); border-radius: 8px; overflow: hidden; }
.seg button {
  font-family: inherit; font-size: 16px; font-weight: 600; letter-spacing: .08em;
  padding: 9px 18px; background: rgba(10,18,36,.7); color: var(--ink-dim);
  border: none; cursor: pointer; border-right: 1px solid var(--panel-line);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: linear-gradient(180deg, rgba(255,210,87,.25), rgba(255,150,40,.15)); color: var(--accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; max-width: 340px; }
.swatches button {
  width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer;
}
.swatches button.on { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,.5); }

.help-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 34px;
  font-size: 18px; font-weight: 500; color: var(--ink);
  background: var(--panel); padding: 22px 30px; border-radius: 12px; border: 1px solid var(--panel-line);
}
kbd {
  display: inline-block; min-width: 26px; text-align: center;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25);
  border-bottom-width: 3px; border-radius: 5px; padding: 1px 7px;
  font-family: inherit; font-weight: 700; font-size: 15px;
}
.help-note { max-width: 640px; text-align: center; font-size: 16px; color: var(--ink-dim); line-height: 1.5; }

#end-score { font-size: 52px; font-weight: 700; letter-spacing: .1em; }
#end-stats { font-size: 18px; color: var(--ink-dim); letter-spacing: .12em; text-align: center; line-height: 1.7; }
#end-result { animation: pop-in .4s cubic-bezier(.2,1.6,.4,1); }

#boot-error {
  position: absolute; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: #05080f; color: #ff8080; font-size: 18px; padding: 40px; text-align: center;
}

@media (max-width: 700px) {
  .game-logo { font-size: 54px; }
  .opt-row { min-width: 0; flex-direction: column; gap: 8px; }
  .opt-row label { text-align: center; width: auto; }
  #announce { font-size: 40px; }
  #speedo { right: 12px; bottom: 12px; padding: 8px 12px; min-width: 100px; }
  #speed-num { font-size: 24px; }
  #boost-wrap { width: 60px; height: 60px; }
  #boost-num { font-size: 18px; }
  .help-grid { grid-template-columns: 1fr; }
}
