html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070812;
  color: #f0f6ff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

canvas#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

.hd-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hd-interactive {
  pointer-events: auto;
}

/* Title & Character Select */
.hd-title-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 28px 24px;
  box-sizing: border-box;
  background: linear-gradient(90deg, rgba(7, 8, 22, 0.86) 0%, rgba(7, 8, 22, 0.35) 45%, rgba(7, 8, 22, 0.1) 100%);
  z-index: 20;
}

.hd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.hd-logo {
  font-size: clamp(28px, 4.5vw, 54px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  line-height: 0.95;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #6ef3ff 48%, #ff3d9a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(0, 245, 255, 0.55));
}

.hd-subtitle {
  margin-top: 6px;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #9ed8ff;
}

.hd-top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hd-pill-btn {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(110, 243, 255, 0.5);
  background: rgba(12, 18, 38, 0.82);
  color: #e8f8ff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.hd-pill-btn:hover {
  transform: translateY(-1px);
  background: rgba(0, 229, 255, 0.22);
  border-color: #6ef3ff;
}

.hd-select-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.hd-roster-panel {
  width: min(390px, 46vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.hd-char-card {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(14, 18, 36, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.hd-char-card:hover {
  transform: translateX(4px);
  border-color: rgba(110, 243, 255, 0.55);
}

.hd-char-card.selected {
  transform: translateX(8px);
  border-color: var(--accent, #00f5ff);
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.32), inset 0 0 18px rgba(255, 255, 255, 0.08);
  background: rgba(20, 28, 56, 0.92);
}

.hd-char-badge {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: #08101c;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}

.hd-char-meta {
  flex: 1;
  min-width: 0;
}

.hd-char-name {
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.hd-char-desc {
  font-size: 12px;
  color: #a8bbd8;
  margin-top: 2px;
}

.hd-stats-card {
  width: min(320px, 38vw);
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(10, 14, 30, 0.82);
  border: 1px solid rgba(110, 243, 255, 0.35);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  align-self: flex-end;
}

.hd-stats-title {
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.hd-stats-taunt {
  font-size: 12px;
  font-style: italic;
  color: #ffd166;
  margin-bottom: 12px;
}

.hd-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hd-stat-label {
  width: 62px;
  color: #a7c4e5;
}

.hd-stat-bar {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.hd-stat-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.hd-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  pointer-events: auto;
}

.hd-diff-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hd-diff-btn {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(14, 18, 36, 0.8);
  color: #c7d7f0;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hd-diff-btn.active {
  background: linear-gradient(135deg, #00e5ff, #3b82f6);
  color: #06101c;
  border-color: #9bf6ff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.45);
}

.hd-start-btn {
  cursor: pointer;
  border: none;
  padding: 14px 36px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #090d18;
  background: linear-gradient(135deg, #ffe600 0%, #ff7b00 55%, #ff2e93 100%);
  box-shadow: 0 0 28px rgba(255, 123, 0, 0.55);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.hd-start-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 36px rgba(255, 230, 0, 0.75);
}

.hd-best-tag {
  font-size: 12px;
  color: #93c5fd;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Racing HUD */
.hd-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}

.hd-speed-lines {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 12;
}

.hd-hud-top-left {
  position: fixed;
  top: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.hd-pos-badge {
  min-width: 78px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 22, 48, 0.9), rgba(10, 14, 30, 0.85));
  border: 2px solid #00f5ff;
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.35);
  text-align: center;
}

.hd-pos-num {
  font-size: 32px;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  color: #ffe600;
}

.hd-pos-sub {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #9ed8ff;
}

.hd-lap-box {
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(10, 14, 30, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hd-lap-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #93c5fd;
  text-transform: uppercase;
}

.hd-lap-val {
  font-size: 22px;
  font-weight: 900;
  font-style: italic;
}

.hd-score-box {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(10, 14, 30, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.hd-hud-top-center {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hd-item-slot {
  width: 78px;
  height: 78px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 35%, rgba(45, 70, 130, 0.85), rgba(10, 14, 30, 0.92));
  border: 3px solid #6ef3ff;
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hd-item-icon {
  font-size: 32px;
  line-height: 1;
}

.hd-item-name {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #e0f2fe;
  margin-top: 3px;
}

.hd-hud-top-right {
  position: fixed;
  top: 16px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hd-hud-controls-row {
  display: flex;
  gap: 8px;
}

.hd-minimap-wrap {
  width: 148px;
  height: 148px;
  border-radius: 14px;
  background: rgba(8, 12, 26, 0.78);
  border: 1px solid rgba(110, 243, 255, 0.35);
  padding: 6px;
  box-sizing: border-box;
}

.hd-minimap-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hd-hud-bottom-left {
  position: fixed;
  bottom: 18px;
  left: 18px;
  width: min(290px, 42vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hd-energy-wrap {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 14, 30, 0.84);
  border: 1px solid rgba(0, 245, 255, 0.35);
}

.hd-energy-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.hd-energy-track {
  width: 100%;
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.hd-energy-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #00c6ff, #00f5a0);
  transition: width 0.08s linear;
}

.hd-energy-fill.low {
  background: linear-gradient(90deg, #ff2e63, #ff8c00);
}

.hd-drift-bar-wrap {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.hd-drift-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #38bdf8;
}

.hd-controls-hint {
  font-size: 11px;
  color: rgba(205, 225, 255, 0.78);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.hd-hud-bottom-right {
  position: fixed;
  bottom: 18px;
  right: 22px;
  text-align: right;
}

.hd-speed-num {
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.9;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(0, 245, 255, 0.65);
}

.hd-speed-unit {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: #6ef3ff;
}

.hd-boost-badge {
  margin-top: 6px;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: rgba(0, 245, 255, 0.18);
  border: 1px solid #00f5ff;
  color: #6ef3ff;
}

/* Countdown & Center Callouts */
.hd-center-banner {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(44px, 8vw, 96px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #ffe600;
  text-shadow: 0 0 32px rgba(255, 136, 0, 0.85), 0 6px 0 rgba(10, 14, 30, 0.85);
  pointer-events: none;
  z-index: 25;
  display: none;
}

/* Cutscene Dialogue Banner */
.hd-dialogue-banner {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, 90vw);
  padding: 14px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(12, 16, 36, 0.94), rgba(24, 14, 44, 0.92));
  border: 2px solid #00f5ff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 245, 255, 0.32);
  display: none;
  align-items: center;
  gap: 16px;
  z-index: 30;
  pointer-events: auto;
}

.hd-portrait {
  width: 68px;
  height: 68px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
  color: #09101f;
}

.hd-dialogue-content {
  flex: 1;
}

.hd-dialogue-speaker {
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #ffe600;
}

.hd-dialogue-text {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.35;
}

.hd-skip-hint {
  font-size: 11px;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* Rivalry PiP Flash */
.hd-rivalry-banner {
  position: fixed;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 86vw);
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(255, 36, 108, 0.92), rgba(16, 18, 42, 0.95));
  border: 2px solid #ffe600;
  box-shadow: 0 0 30px rgba(255, 36, 108, 0.65);
  display: none;
  align-items: center;
  gap: 14px;
  z-index: 28;
}

/* Podium Finale Overlay */
.hd-podium-overlay {
  position: fixed;
  top: 24px;
  right: 28px;
  width: min(360px, 88vw);
  padding: 20px 22px;
  border-radius: 16px;
  background: rgba(10, 14, 30, 0.88);
  border: 2px solid #ffe600;
  box-shadow: 0 0 32px rgba(255, 230, 0, 0.35);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
  pointer-events: auto;
}

.hd-podium-title {
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  color: #ffe600;
  letter-spacing: 1.5px;
}

.hd-podium-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hd-podium-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 14px;
  font-weight: 700;
}

.hd-podium-row.player {
  border: 1px solid #00f5ff;
  background: rgba(0, 245, 255, 0.14);
}

.hd-podium-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
