.dash-loading {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 18, 0.94);
  transition: opacity 0.2s ease;
}

.dash-loading[hidden] {
  display: none !important;
}

.dash-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.dash-spinner {
  width: 46px;
  height: 46px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dash-spin 0.7s linear infinite;
}

.dash-loading-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

@keyframes dash-spin {
  to {
    transform: rotate(360deg);
  }
}

:root {
  --bg: #0c1220;
  --surface: #151d2e;
  --border: #2a3a58;
  --text: #eef3ff;
  --muted: #8b9dc3;
  --accent: #3dd6c6;
  --accent-warm: #ffb347;
  --danger: #ff5c6a;
  --collect: #ffd54f;
  --font: "Segoe UI", system-ui, sans-serif;
  --stage-ratio: 520 / 480;
}

* {
  box-sizing: border-box;
}

body.game-shell {
  font-family: var(--font);
  background: radial-gradient(ellipse 120% 70% at 50% -20%, #1a2848, var(--bg) 55%);
  color: var(--text);
  line-height: 1.45;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 18, 32, 0.92);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.header-theme {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.back {
  color: #7eb8ff;
  text-decoration: none;
  font-size: 0.9rem;
}

.back:hover {
  text-decoration: underline;
}

.pad-unlock-banner {
  margin: 0;
  padding: 0.55rem 1rem;
  text-align: center;
  background: linear-gradient(90deg, #1e3050, #253a60, #1e3050);
  border-bottom: 1px solid var(--accent);
  font-size: 0.88rem;
  color: var(--accent);
}

.game-shell .hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 3.5rem;
}

.hud-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hud-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-value.small {
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-val {
  color: var(--collect);
}

.hud-base .hud-value {
  color: #8ecae6;
}

.hud-bonus .hud-value {
  color: var(--collect);
}

.hud-sub {
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 400;
  text-transform: lowercase;
  letter-spacing: 0;
}

.legend-hazard {
  color: #ff6b7a;
  font-weight: 700;
}

.legend-pickup {
  color: var(--collect);
  font-weight: 700;
}

.end-sub {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 400;
}

.speed-mult {
  color: var(--accent-warm);
}

.speed-bar {
  display: block;
  width: 4.5rem;
  height: 4px;
  margin-top: 0.2rem;
  background: #0a0f18;
  border-radius: 2px;
  overflow: hidden;
}

.speed-bar-fill {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: 2px;
  transition: width 0.12s ease-out;
}

.lives-row {
  display: flex;
  gap: 0.25rem;
}

.life-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #3a2030;
  border: 1px solid var(--danger);
  transform: rotate(45deg);
}

.life-icon.on {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 92, 106, 0.5);
}

.game-shell .stage {
  background: #1a2030;
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.game-shell #gameCanvas {
  background: #1a2030;
}

.judge-popup {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.6);
  pointer-events: none;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  z-index: 4;
  transition: opacity 0.08s, transform 0.2s;
}

.judge-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.judge-popup.great,
.judge-popup.nice {
  color: #7ee8a0;
}

.judge-popup.bonus,
.judge-popup.collect {
  color: var(--collect);
  text-shadow: 0 0 16px rgba(255, 213, 79, 0.65);
}

.judge-popup.dodge,
.judge-popup.base {
  color: #8ecae6;
  text-shadow: 0 0 12px rgba(100, 180, 255, 0.5);
}

.judge-popup.close {
  color: #90caf9;
}

.judge-popup.miss {
  color: var(--danger);
}

.judge-popup.speed {
  color: var(--accent-warm);
  font-size: 1.4rem;
}

.judge-popup.fuel {
  color: #e8c060;
  text-shadow: 0 0 12px rgba(232, 192, 96, 0.45);
}

.judge-popup.crash {
  color: #ffb74d;
  font-size: 2rem;
  text-shadow:
    0 0 20px rgba(255, 120, 60, 0.75),
    0 2px 14px rgba(0, 0, 0, 0.8);
}

.game-shell .countdown-sub {
  color: var(--accent);
}

.game-shell .countdown-num {
  color: var(--accent);
  text-shadow: 0 0 40px rgba(61, 214, 198, 0.45);
}

.game-shell .countdown-banner.speed-bump .countdown-num {
  color: var(--accent-warm);
}

.game-shell .hint {
  color: var(--muted);
}

.game-shell .hint strong {
  color: var(--text);
}

.game-shell .overlay {
  background: rgba(6, 10, 18, 0.82);
}

.game-shell .overlay.overlay-results {
  background: transparent !important;
  pointer-events: none;
  align-items: center !important;
  justify-content: center;
  padding: 1rem;
}

.overlay.overlay-results .overlay-card {
  pointer-events: auto;
  max-width: 22rem;
  width: 100%;
  min-height: 20rem;
  max-height: min(88vh, 36rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.5rem 1.6rem;
}

.overlay.overlay-results .menu-only {
  display: none;
}

.overlay.overlay-results .end-panel {
  margin-top: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.overlay.overlay-results .history-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 16rem;
  overflow-y: auto;
}

.header-nav-right {
  margin-left: auto;
  font-size: 0.85rem;
}

.overlay-card {
  background: linear-gradient(160deg, #1a2438, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.35rem 1.35rem;
  max-width: 26rem;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
}

.overlay-card > p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pick-section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

#themePick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

#themePick .pick-card {
  flex: unset;
  min-width: 0;
  width: 100%;
}

.pick-card {
  flex: 1 1 7rem;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #121a28;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, transform 0.1s, background 0.12s;
}

.pick-card:hover {
  border-color: #4a6088;
  transform: translateY(-1px);
}

.pick-card.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, #152a32, #121a28);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.25);
}

.pick-title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.pick-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.theme-card.selected .pick-title {
  color: var(--accent);
}

.pick-options .mode-toggle {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.7rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #121a28;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.pick-options .mode-toggle:hover {
  border-color: #4a6088;
}

.pick-options .mode-toggle:has(input:checked) {
  border-color: #e8a838;
  background: linear-gradient(135deg, #2a2210, #121a28);
  box-shadow: 0 0 0 1px rgba(232, 168, 56, 0.2);
}

.pick-options .mode-toggle input {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #e8a838;
  flex-shrink: 0;
}

.mode-toggle-body {
  display: block;
}

.hud-fuel-block {
  min-width: 4.5rem;
}

.fuel-pct {
  color: #e8c060;
  font-variant-numeric: tabular-nums;
}

.fuel-bar {
  display: block;
  height: 5px;
  margin-top: 0.2rem;
  border-radius: 3px;
  background: #1a2438;
  overflow: hidden;
}

.fuel-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #c89020, #f0d060);
  transition: width 0.08s linear, background 0.2s;
}

.hud-fuel-block.fuel-low .fuel-bar-fill {
  background: linear-gradient(90deg, #c06018, #f0a040);
}

.hud-fuel-block.fuel-empty .fuel-pct {
  color: #f07050;
}

.hud-fuel-block.fuel-empty .fuel-bar-fill {
  background: linear-gradient(90deg, #802818, #e05030);
  animation: fuel-blink 0.55s ease-in-out infinite alternate;
}

@keyframes fuel-blink {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.legend-fuel {
  color: #e8c060;
}

.score-save-note {
  font-size: 0.85rem;
  color: var(--accent-warm);
  margin: 0 0 0.75rem;
}

.player-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.player-row select {
  flex: 1 1 9rem;
  min-width: 8rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a28;
  color: var(--text);
  font-size: 0.9rem;
}

.player-new-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.player-new-form input {
  flex: 1 1 8rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0e1520;
  color: var(--text);
  font-size: 0.9rem;
}

.player-new-form input::placeholder {
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
  font-size: 0.85rem;
}

.btn-inline {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1a2438;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-inline:hover {
  border-color: #4a6088;
}

.player-note {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.history-title {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
}

.history-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-height: 8rem;
  overflow-y: auto;
}

.history-list time {
  opacity: 0.75;
  font-size: 0.75rem;
}

.primary {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #2a9d8f, #3dd6c6);
  color: #042018;
  transition: filter 0.12s, transform 0.08s;
}

.primary:hover {
  filter: brightness(1.08);
}

.primary:active {
  transform: scale(0.98);
}

.end-home-btn {
  margin-top: 0.4rem;
}

.overlay:not(.overlay-results) .end-home-btn {
  display: none !important;
}

.overlay:not(.overlay-paused) .pause-end-btn {
  display: none !important;
}

.overlay:not(.overlay-menu) .menu-games-btn {
  display: none !important;
}

.secondary {
  display: block;
  width: 100%;
  padding: 0.55rem;
  margin-top: 0.35rem;
  font-size: 0.88rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.device {
  margin-left: auto;
}

@media (max-width: 480px) {
  .hud {
    gap: 0.35rem 0.55rem;
  }
  .hud-block {
    min-width: 3rem;
  }
}
