/* Sunset Ridge GP — HUD and menus */

:root {
  --ink: #f4f6fb;
  --dim: #a5adc4;
  --panel: rgba(12, 15, 26, 0.82);
  --panel-edge: rgba(255, 255, 255, 0.12);
  --hot: #ff8a3d;
  --hot-2: #ffd23f;
  --cool: #35d1ff;
  --violet: #b07cff;
  --danger: #ff4d6d;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --font: 'Rajdhani', 'Eurostile', 'DIN Alternate', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #05070e;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }

#scene { display: block; width: 100%; height: 100%; }

[hidden] { display: none !important; }

/* ============================ HUD ============================ */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.corner { position: absolute; }
.top-left { top: 18px; left: 18px; }
.top-right { top: 18px; right: 18px; text-align: right; }
.bottom-left { bottom: 18px; left: 18px; }
.bottom-right { bottom: 18px; right: 18px; }

/* --- Position + lap --- */

.place {
  font-size: 78px;
  font-weight: 800;
  line-height: 0.86;
  letter-spacing: -3px;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 26px rgba(255, 138, 61, 0.5);
}

.place #place-suffix {
  font-size: 30px;
  letter-spacing: 0;
  margin-left: 3px;
  color: var(--hot-2);
}

.lap-box {
  margin-top: 6px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 13px 4px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-left: 3px solid var(--hot);
  border-radius: 4px;
  font-size: 26px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.lap-box .label {
  font-size: 13px;
  letter-spacing: 2.5px;
  color: var(--dim);
  font-weight: 600;
}

.lap-box .slash { color: var(--dim); font-weight: 400; }
.lap-box.final { border-left-color: var(--danger); animation: pulse-final 0.9s ease-in-out infinite; }

@keyframes pulse-final {
  50% { background: rgba(255, 77, 109, 0.22); }
}

.race-time {
  margin-top: 6px;
  font-size: 17px;
  letter-spacing: 1.5px;
  color: var(--dim);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* --- Item slot --- */

.item-slot {
  width: 104px;
  height: 104px;
  border-radius: 14px;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.item-slot.empty { opacity: 0.42; }

.item-slot.filled {
  border-color: var(--hot-2);
  box-shadow: var(--shadow), 0 0 26px rgba(255, 210, 63, 0.35);
}

.item-slot.rolling { animation: roll-shake 0.09s linear infinite; }

@keyframes roll-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-1.5px, 1px) rotate(-1.5deg); }
  75% { transform: translate(1.5px, -1px) rotate(1.5deg); }
}

.item-slot.pop { transform: scale(1.16); }

.item-icon { width: 74px; height: 74px; }
.item-icon svg { width: 100%; height: 100%; display: block; }

.item-name {
  margin-top: 7px;
  font-size: 13px;
  letter-spacing: 2.2px;
  font-weight: 700;
  color: var(--hot-2);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  min-height: 16px;
}

/* --- Speedometer --- */

.speedo { position: relative; width: 168px; height: 168px; }

.speedo-svg {
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55));
}

.speedo-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.13);
  stroke-width: 9;
  stroke-linecap: round;
}

.speedo-fill {
  fill: none;
  stroke: url(#none);
  stroke: var(--cool);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 245;
  stroke-dashoffset: 245;
  transition: stroke 0.2s ease;
}

.speedo.boosting .speedo-fill { stroke: var(--hot-2); }

.speedo-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 6px;
}

#speed-num {
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.8);
}

.speedo-unit {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--dim);
  margin-top: 2px;
}

.gear-badge {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 2.5px;
  font-weight: 700;
  color: var(--hot-2);
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.gear-badge.on { opacity: 1; }

/* --- Minimap --- */

#minimap {
  width: 200px;
  height: 200px;
  background: rgba(8, 10, 18, 0.55);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* --- Standings --- */

.standings {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
}

.standings .row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 5px;
  background: rgba(10, 13, 22, 0.6);
  border-radius: 4px;
  border-left: 3px solid transparent;
  transition: background 0.2s ease;
}

.standings .row.me {
  background: rgba(53, 209, 255, 0.2);
  border-left-color: var(--cool);
}

.standings .row .n { color: var(--dim); width: 14px; text-align: right; }
.standings .row .dot { width: 9px; height: 9px; border-radius: 50%; }
.standings .row .name { min-width: 52px; }
.standings .row .gap { color: var(--dim); font-size: 12px; min-width: 40px; text-align: right; }
.standings .row.done .gap { color: var(--hot-2); }

/* --- Centre messaging --- */

.center-msg {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 62px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.3), 0 0 42px rgba(255, 138, 61, 0.65);
  opacity: 0;
  white-space: nowrap;
}

.center-msg.show { animation: msg-pop 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.center-msg.hot { color: var(--hot-2); }
.center-msg.cool { color: var(--cool); }
.center-msg.bad { color: var(--danger); }

@keyframes msg-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  26% { transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.03); }
}

.countdown {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 170px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 60px rgba(255, 138, 61, 0.9), 0 8px 0 rgba(0, 0, 0, 0.32);
  opacity: 0;
}

.countdown.tick { animation: count-pop 0.85s ease-out forwards; }
.countdown.go { color: var(--hot-2); animation: count-pop 0.75s ease-out forwards; }

@keyframes count-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.1); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
}

/* --- Full-screen feedback --- */

.screen-tint {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.18s ease;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(255, 60, 60, 0.55) 100%);
}

.screen-tint.hurt { opacity: 1; transition: opacity 0.06s ease; }

.speed-lines {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.22s ease;
  background:
    radial-gradient(ellipse at center, transparent 34%, rgba(255, 190, 80, 0.28) 100%),
    repeating-conic-gradient(from 0deg at 50% 50%,
      rgba(255, 255, 255, 0.11) 0deg 1.1deg, transparent 1.1deg 5deg);
  mask-image: radial-gradient(ellipse at center, transparent 30%, #000 88%);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 30%, #000 88%);
}

.speed-lines.on { opacity: 1; }

/* ============================ Overlays ============================ */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 40%, rgba(30, 14, 40, 0.72), rgba(4, 5, 12, 0.94));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 10;
  animation: fade-in 0.35s ease;
}

@keyframes fade-in { from { opacity: 0; } }

.panel {
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 34px 40px 30px;
  background: linear-gradient(160deg, rgba(24, 20, 42, 0.94), rgba(10, 12, 22, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.panel.small { width: min(380px, 100%); }

.eyebrow {
  font-size: 13px;
  letter-spacing: 5px;
  color: var(--hot);
  font-weight: 700;
  margin-bottom: 10px;
}

.title {
  margin: 0 0 6px;
  font-size: clamp(38px, 7vw, 68px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -1px;
  background: linear-gradient(100deg, var(--hot) 5%, var(--hot-2) 42%, var(--cool) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.title span { display: inline-block; margin: 0 0.3em; }

.tagline {
  margin: 0 0 22px;
  color: var(--dim);
  font-size: 17px;
  letter-spacing: 0.6px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px 18px;
  margin-bottom: 20px;
  text-align: left;
}

.ctrl {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  color: var(--dim);
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.035);
  border-radius: 7px;
}

.ctrl span { margin-left: 2px; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, #33384c, #1e2131);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.hint-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
}

.hint {
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dim);
  background: rgba(53, 209, 255, 0.07);
  border-left: 3px solid var(--cool);
  border-radius: 0 8px 8px 0;
}

.hint b { color: var(--ink); }
.hint kbd { min-width: 22px; height: 22px; font-size: 12px; }

.cta {
  display: inline-block;
  margin: 4px 6px 0;
  padding: 15px 46px;
  font-family: var(--font);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #14121c;
  background: linear-gradient(100deg, var(--hot), var(--hot-2));
  border: none;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(255, 138, 61, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(255, 138, 61, 0.55); }
.cta:active { transform: translateY(1px); }

.cta.ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
  font-size: 15px;
  padding: 11px 26px;
  letter-spacing: 2px;
}

.cta.ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.4); }

.fineprint {
  margin-top: 16px;
  font-size: 12.5px;
  letter-spacing: 1.6px;
  color: #6f7690;
}

h2 {
  margin: 0 0 18px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--hot-2);
}

/* --- Results --- */

.results-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 24px;
}

.results-list .row {
  display: grid;
  grid-template-columns: 46px 16px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.045);
  border-radius: 9px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-align: left;
  animation: row-in 0.4s backwards;
}

@keyframes row-in { from { opacity: 0; transform: translateX(-16px); } }

.results-list .row.me {
  background: linear-gradient(90deg, rgba(53, 209, 255, 0.26), rgba(53, 209, 255, 0.06));
  box-shadow: inset 0 0 0 1px rgba(53, 209, 255, 0.4);
}

.results-list .row .pos { font-size: 22px; font-weight: 800; color: var(--hot-2); }
.results-list .row .dot { width: 14px; height: 14px; border-radius: 50%; }
.results-list .row .time { color: var(--dim); font-size: 15px; font-variant-numeric: tabular-nums; }
.results-list .row.dnf .time { color: var(--danger); }

/* ============================ Touch ============================ */

#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.touch-cluster {
  position: absolute;
  bottom: 22px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  pointer-events: auto;
}

.touch-cluster.left { left: 22px; }
.touch-cluster.right { right: 22px; flex-wrap: wrap; width: 190px; justify-content: flex-end; }

.tbtn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(14, 17, 28, 0.62);
  color: var(--ink);
  font-family: var(--font);
  font-size: 26px;
  font-weight: 800;
  touch-action: none;
  user-select: none;
}

.tbtn:active { background: rgba(255, 138, 61, 0.55); }
.tbtn.small { width: 62px; height: 62px; font-size: 12px; letter-spacing: 1px; }
.tbtn.accel { width: 92px; height: 92px; background: rgba(255, 138, 61, 0.34); font-size: 20px; }

/* ============================ Small screens ============================ */

@media (max-width: 780px) {
  .place { font-size: 54px; }
  .place #place-suffix { font-size: 22px; }
  .lap-box { font-size: 20px; }
  .item-slot { width: 76px; height: 76px; }
  .item-icon { width: 54px; height: 54px; }
  .speedo { width: 118px; height: 118px; }
  #speed-num { font-size: 32px; }
  #minimap { width: 128px; height: 128px; }
  .standings { display: none; }
  .center-msg { font-size: 38px; }
  .countdown { font-size: 110px; }
  .panel { padding: 24px 20px; }
}
