* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0a0a1a;
  color: #e0e0ff;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* The Workshop thumbnail preview sits inside the publish modal: without this the global canvas
   rule made it a full-viewport layer over the modal, hiding Title, Publish and Cancel. */
#editorThumbnailCanvas {
  position: static;
  width: 100%;
  height: 100%;
}
/* Override global canvas rule for editor */
#editorCanvas {
  position: absolute !important;
  cursor: crosshair;
  z-index: 1;
}

/* Scanline overlay */
#scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 4px
    );
}

/* Loading screen */
.loading-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0a0a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.4s ease-out;
}
.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.loading-title {
  margin-bottom: 32px;
}
.loading-bar-section {
  opacity: 0;
  animation: loadBarIn 0.4s ease-out 1s forwards;
}
@keyframes loadBarIn { to { opacity: 1; } }
.loading-bar-track {
  width: 220px;
  height: 6px;
  background: #1a1a3a;
  border-radius: 3px;
  overflow: hidden;
}
.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00e5ff, #ff2d7b);
  border-radius: 3px;
  transition: width 0.2s ease-out;
}
.loading-text {
  margin-top: 14px;
  font-size: 11px;
  color: #888;
}

/* Screens */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* Main menu. The column centres above the MobX logo strip (padding-bottom) and tightens on short
   screens: at 1280x720 the logo used to cover the Quit button (AUDIT-sp). */
#menuScreen {
  background: transparent;
  padding-bottom: 4.5rem;
  box-sizing: border-box;
}
#menuScreen .title {
  margin-bottom: clamp(1rem, 5vh, 3rem);
}
#menuScreen .menu-buttons {
  gap: clamp(0.6rem, 1.9vh, 1.2rem);
}

#menuBgCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.btn-wipe {
  margin-top: 1rem;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.2vw, 0.55rem);
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid #333366;
  color: #555580;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-wipe:hover, .btn-wipe:active {
  border-color: #ff3030;
  color: #ff3030;
}

.wipe-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.wipe-modal-overlay.hidden { display: none; }

.wipe-modal {
  background: #0e0e24;
  border: 2px solid #ff3030;
  border-radius: 8px;
  padding: 2rem;
  max-width: 320px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.wipe-modal-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 2vw, 0.8rem);
  color: #ff4444;
}

.wipe-modal-body {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.35rem, 1.1vw, 0.5rem);
  color: #cc8888;
  line-height: 2;
}

.wipe-modal-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* Install app button */
.btn-install {
  position: absolute;
  bottom: 3.5rem;
  right: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: rgba(0, 200, 255, 0.08);
  border: 2px solid #00c8ff;
  border-radius: 10px;
  color: #00ffcc;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.3vw, 0.6rem);
  animation: installPulse 2.5s ease-in-out infinite;
  transition: background 0.15s;
}
.btn-install:active {
  background: rgba(0, 200, 255, 0.2);
}
.btn-install-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.btn-install-text {
  line-height: 1.4;
}
@keyframes installPulse {
  0%, 100% { border-color: #00c8ff; box-shadow: 0 0 6px rgba(0, 200, 255, 0.3); }
  50% { border-color: #00ffcc; box-shadow: 0 0 14px rgba(0, 255, 200, 0.5); }
}

.mobx-credit {
  position: absolute;
  bottom: 1.2rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.8rem;
}
.mobx-logo {
  width: clamp(80px, 12vw, 120px);
  opacity: 1.0;
}
.mobx-legal-link {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 1.5vw, 0.7rem);
  color: #445;
  text-decoration: none;
  pointer-events: all;
  padding: 0.5rem 1rem;
  transition: color 0.15s;
  cursor: pointer;
}
.mobx-legal-link:hover {
  color: #778;
}

/* Legal overlay */
.legal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(5, 5, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.legal-panel {
  position: relative;
  background: #0d0d28;
  border: 1px solid #2a2a50;
  border-radius: 8px;
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.legal-close-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
}
.legal-content {
  overflow-y: auto;
  padding: 2rem 1.5rem 1.5rem;
  -webkit-overflow-scrolling: touch;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: #a8a8c8;
}
.legal-content h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.5vw, 0.6rem);
  color: #00c8ff;
  letter-spacing: 0.1em;
  margin: 2rem 0 0.6rem;
  text-transform: uppercase;
}
.legal-content h2:first-child {
  margin-top: 0;
}
.legal-content p {
  margin-bottom: 0.6rem;
}
.legal-content ul {
  margin: 0 0 0.6rem 1.5rem;
}
.legal-content ul li {
  margin-bottom: 0.25rem;
}
.legal-content a {
  color: #00c8ff;
  text-decoration: none;
}
.legal-content a:hover {
  text-decoration: underline;
}
.legal-content .legal-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 2vw, 0.85rem);
  color: #a0a0d0;
  margin-bottom: 1.5rem;
}
.legal-content hr {
  border: none;
  border-top: 1px solid #1a1a3a;
  margin: 1.5rem 0;
}

/* iOS install banner */
.ios-install-banner {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(0, 20, 40, 0.92);
  border: 2px solid #00c8ff;
  border-radius: 10px;
  color: #00ffcc;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.2vw, 0.55rem);
  line-height: 1.6;
  animation: installPulse 2.5s ease-in-out infinite;
  white-space: nowrap;
  z-index: 10;
}
.ios-install-banner b { color: #fff; }
.ios-install-dismiss {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1.4rem;
  height: 1.4rem;
  background: #00c8ff;
  color: #000;
  border: none;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ios-share-icon { vertical-align: middle; }

.title {
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  letter-spacing: 0.15em;
  margin-bottom: 3rem;
  text-shadow: 0 0 20px rgba(0, 200, 255, 0.6), 0 0 40px rgba(0, 200, 255, 0.3), 0 0 80px rgba(0, 200, 255, 0.15);
  animation: titleSlideIn 0.8s ease-out;
  position: relative;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 20px rgba(0, 200, 255, 0.6), 0 0 40px rgba(0, 200, 255, 0.3), 0 0 80px rgba(0, 200, 255, 0.15); }
  50% { text-shadow: 0 0 30px rgba(0, 200, 255, 0.8), 0 0 60px rgba(0, 200, 255, 0.4), 0 0 100px rgba(0, 200, 255, 0.2); }
}

@keyframes titleSlideIn {
  0% { transform: translateY(-20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.accent {
  color: #ff3077;
  text-shadow: 0 0 20px rgba(255, 48, 119, 0.6), 0 0 40px rgba(255, 48, 119, 0.3), 0 0 80px rgba(255, 48, 119, 0.15);
  animation: titleSlideIn 0.8s ease-out;
}

@keyframes accentPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(255, 48, 119, 0.6), 0 0 40px rgba(255, 48, 119, 0.3); }
  50% { text-shadow: 0 0 30px rgba(255, 48, 119, 0.9), 0 0 60px rgba(255, 48, 119, 0.5), 0 0 100px rgba(255, 48, 119, 0.2); }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.menu-buttons .btn {
  background: rgba(0, 0, 0, 0.50);
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 2vw, 1rem);
  padding: 1rem 2rem;
  background: transparent;
  border: 2px solid #00c8ff;
  color: #00c8ff;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 220px;
  text-align: center;
}

.btn:hover, .btn:active {
  background: #00c8ff;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(0, 200, 255, 0.4);
}

.btn-small {
  font-size: clamp(0.5rem, 1.5vw, 0.7rem);
  padding: 0.7rem 1.5rem;
  min-width: auto;
  margin-top: 1.5rem;
}

/* Lobby screen */
#lobbyScreen {
  background: radial-gradient(ellipse at center, rgba(26, 26, 58, 0.85) 0%, rgba(10, 10, 26, 0.9) 70%);
  gap: 1rem;
  /* With the track selector the lobby can outgrow a short window: never clip the header. */
  justify-content: safe center;
  overflow-y: auto;
}

#lobbyScreen h2 {
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  color: #a0a0d0;
}

.lobby-link {
  background: rgba(0, 200, 255, 0.06);
  border: 2px solid #00c8ff;
  padding: 0.9rem 1.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-link:hover, .lobby-link:active {
  background: rgba(0, 200, 255, 0.12);
  border-color: #40d8ff;
}

#lobbyUrl {
  font-size: clamp(0.6rem, 2vw, 0.9rem);
  color: #00c8ff;
  word-break: break-all;
  text-shadow: 0 0 10px rgba(0, 200, 255, 0.4);
}

.copied-msg {
  font-size: 0.6rem;
  color: #50ff50;
  opacity: 0;
  transition: opacity 0.3s;
}

.copied-msg.show {
  opacity: 1;
}

.mp-player-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  margin-bottom: 1.5rem;
  min-width: 220px;
  border: 2px solid #00c8ff;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(0, 200, 255, 0.04) 0px,
      rgba(0, 200, 255, 0.04) 2px,
      transparent 2px,
      transparent 8px
    ),
    rgba(0, 0, 0, 0.50);
  min-height: 72px;
}

.mp-player-avatar {
  width: 52px;
  height: 52px;
  border: 2px solid #00c8ff;
  background: #1a1a3e;
  flex-shrink: 0;
  display: none;
}

.mp-player-avatar[src]:not([src=""]) {
  display: block;
}

.mp-player-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mp-player-name {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: #00c8ff;
  text-align: left;
}

.mp-player-subline {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.35rem, 0.8vw, 0.45rem);
  color: #666688;
  text-align: left;
}

.mp-player-subline:empty { display: none; }

.player-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-entry {
  font-size: clamp(0.6rem, 1.5vw, 0.85rem);
}

.player-entry.you {
  color: #00c8ff;
}

.player-entry.waiting {
  color: #555580;
}

.player-entry.joined {
  color: #ff3077;
}

.player-entry.p0 { color: #00c8ff; }
.player-entry.p1 { color: #ff3077; }
.player-entry.p2 { color: #ffcc00; }
.player-entry.p3 { color: #50ff50; }
.player-entry.p4 { color: #cc66ff; }

.btn-start-game {
  background: rgba(80, 255, 80, 0.08);
  border-color: #50ff50;
  color: #50ff50;
  animation: startPulse 1.5s ease-in-out infinite;
}

.btn-start-game:hover, .btn-start-game:active {
  background: #50ff50;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(80, 255, 80, 0.4);
}

@keyframes startPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(80, 255, 80, 0.2); }
  50% { box-shadow: 0 0 15px rgba(80, 255, 80, 0.5); }
}

.countdown {
  font-size: clamp(1rem, 4vw, 2rem);
  color: #ffcc00;
  text-shadow: 0 0 15px rgba(255, 204, 0, 0.5);
  min-height: 2.5rem;
}

/* Options screen */
#optionsScreen {
  background: radial-gradient(ellipse at center, #1a1a3a 0%, #0a0a1a 70%);
  gap: 0;
}

/* Screen header with inline back button */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 800px;
  position: relative;
  padding: 0 clamp(40px, 8vw, 60px);
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}
.screen-header h2 {
  margin: 0;
}
.screen-header .screen-back-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
.screen-back-btn {
  z-index: 10;
}

.options-scroll-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1rem 2rem;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}
.options-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: auto 0;
}

#optionsScreen h2 {
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  color: #a0a0d0;
  margin-bottom: 2rem;
}

.options-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  min-width: 260px;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #1e1e3a;
  width: 100%;
  max-width: 480px;
}

.options-section:last-of-type {
  border-bottom: none;
}

.options-label {
  font-size: clamp(0.6rem, 1.6vw, 0.85rem);
  color: #8080a0;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.options-slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.options-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 12px;
  background: #1a1a3a;
  border: 1px solid #333366;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

.options-select {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.55rem, 1.2vw, 0.7rem);
  color: #00c8ff;
  background: #1a1a3a;
  border: 1px solid #333366;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  min-width: 12rem;
  cursor: pointer;
  outline: none;
}
.options-select:focus { border-color: #00c8ff; }
.options-note {
  display: block;
  margin-top: 0.5rem;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1vw, 0.55rem);
  color: #ff3077;
}
.options-select option { background: #1a1a3a; color: #e0e0ff; }

.options-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00c8ff;
  border: 2px solid #0af;
  box-shadow: 0 0 8px rgba(0, 200, 255, 0.4);
  cursor: pointer;
  margin-top: -5px;
}

.options-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00c8ff;
  border: 2px solid #0af;
  box-shadow: 0 0 8px rgba(0, 200, 255, 0.4);
  cursor: pointer;
}

.options-slider::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 6px;
}

.options-slider::-moz-range-track {
  height: 12px;
  background: #1a1a3a;
  border: 1px solid #333366;
  border-radius: 6px;
}

.options-value {
  font-size: clamp(0.5rem, 1.6vw, 0.7rem);
  color: #00c8ff;
  min-width: 3.5em;
  text-align: right;
}

/* Name input */
.options-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-name-action {
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
}

.name-input-group,
.name-display-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.name-input-group.hidden,
.name-display-group.hidden,
.btn-name-action.hidden {
  display: none;
}

.name-input {
  font-family: inherit;
  font-size: clamp(0.5rem, 1.6vw, 0.7rem);
  background: #0a0a1a;
  border: 1px solid #333366;
  border-radius: 4px;
  color: #e0e0ff;
  padding: 0.3em 0.5em;
  width: 9em;
  outline: none;
}

.name-input:focus {
  border-color: #00c8ff;
  box-shadow: 0 0 6px rgba(0, 200, 255, 0.3);
}

.name-display {
  font-size: clamp(0.5rem, 1.6vw, 0.7rem);
  color: #00c8ff;
  letter-spacing: 0.05em;
}

.player-tag-display {
  font-family: monospace;
  font-size: clamp(0.55rem, 1.6vw, 0.75rem);
  color: #7070a0;
  letter-spacing: 0.05em;
}

.entry-tag {
  font-family: monospace;
  font-size: 0.85em;
  color: #7070a0;
}

.btn-icon {
  background: none;
  border: 1px solid #333366;
  border-radius: 4px;
  color: #00c8ff;
  font-size: clamp(1.2rem, 3.6vw, 1.6rem);
  cursor: pointer;
  padding: 0.15em 0.4em;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

.btn-icon:hover {
  border-color: #00c8ff;
}

.btn-icon-danger {
  color: #ff4466;
}

.btn-icon-danger:hover {
  border-color: #ff4466;
}

/* Join Lobby screen */
#joinScreen {
  background: radial-gradient(ellipse at center, #1a1a3a 0%, #0a0a1a 70%);
  gap: 1rem;
}

#joinScreen h2 {
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  color: #a0a0d0;
}

.join-code-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.join-label {
  font-size: clamp(0.55rem, 1.4vw, 0.75rem);
  color: #8080a0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.join-code-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.join-code-input {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 1.8vw, 1rem);
  padding: 0.8rem 1.2rem;
  width: 220px;
  text-align: center;
  background: #12122a;
  border: 2px solid #333366;
  color: #00c8ff;
  border-radius: 4px;
  outline: none;
  text-transform: lowercase;
  letter-spacing: 0.15em;
}

.btn-join-code {
  font-size: clamp(0.55rem, 1.6vw, 0.7rem);
  padding: 0.7rem 1.2rem;
  min-width: auto;
}

.join-code-input:focus {
  border-color: #00c8ff;
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.3);
}

.join-code-input::placeholder {
  color: #333366;
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
}

.join-divider {
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
  color: #555580;
  margin: 0.3rem 0;
}

.join-lobby-list-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.join-lobby-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 420px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
  background: #12122a;
  border: 1px solid #333366;
  border-radius: 4px;
}

.join-lobby-empty {
  font-size: clamp(0.55rem, 1.4vw, 0.75rem);
  color: #555580;
  text-align: center;
  padding: 0.8rem 0;
}

.join-lobby-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.7rem;
  background: rgba(0, 200, 255, 0.05);
  border: 1px solid #333366;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.join-lobby-item:hover, .join-lobby-item:active {
  border-color: #00c8ff;
  background: rgba(0, 200, 255, 0.1);
}

.join-lobby-code {
  font-size: clamp(0.5rem, 1.6vw, 0.7rem);
  color: #00c8ff;
  letter-spacing: 0.1em;
}

.join-lobby-players {
  font-size: clamp(0.4rem, 1.2vw, 0.55rem);
  color: #8080a0;
}

.join-lobby-item.lobby-full {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* HUD */
#hud {
  pointer-events: none;
  justify-content: space-between;
  padding: 1rem;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  font-size: clamp(0.55rem, 1.8vw, 0.85rem);
}

.hud-top-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  pointer-events: auto;
}

.hud-lower-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.hud-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.8rem;
}

#sessionTimer {
  color: #ffffff;
  font-size: clamp(0.75rem, 2.5vw, 1.1rem);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4), 0 0 4px #000, 0 1px 3px #000;
}

#speedDisplay {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4), 0 0 4px #000, 0 1px 3px #000;
}

.hud-speed-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Gear digit beside the speed: small, monospace, cyan (style guide accent) */
.gear-display {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85em;
  color: #00c8ff;
  border: 1px solid rgba(0, 200, 255, 0.6);
  padding: 0.2em 0.35em;
  line-height: 1;
  text-shadow: 0 0 6px rgba(0, 200, 255, 0.6), 0 1px 3px #000;
}

/* Top-right HUD area */
.hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  padding-top: calc(clamp(36px, 8vw, 48px) + 0.8rem);
  min-width: 0;
  max-width: 50vw;
  overflow: hidden;
}

/* Time list (top-right) */
.time-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  font-size: clamp(0.55rem, 1.8vw, 0.85rem);
  max-height: 40vh;
  overflow: hidden;
}

.time-entry {
  opacity: 1;
  color: #ffffff;
}

.time-entry.pb {
  opacity: 1;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  font-weight: bold;
}

.time-entry.best {
  color: #50ff50;
  text-shadow: 0 0 8px rgba(80, 255, 80, 0.4);
  opacity: 1;
}

.hint-banner {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  color: #e0e0ff;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.65rem, 1.8vw, 0.85rem);
  background: rgba(10, 10, 26, 0.7);
  border: 1px solid rgba(0, 200, 255, 0.3);
  border-radius: 6px;
  padding: 0.4rem 1.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 30;
  white-space: nowrap;
}
.hint-banner.visible { opacity: 1; }

/* Run complete flash overlay */
.run-flash {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.2rem, 5vw, 2.5rem);
  color: #50ff50;
  text-shadow: 0 0 30px rgba(80, 255, 80, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.run-flash.visible {
  opacity: 1;
  animation: flashPulse 0.5s ease-out;
}

.run-flash.new-best {
  color: #ffcc00;
  text-shadow: 0 0 30px rgba(255, 204, 0, 0.8);
}

@keyframes flashPulse {
  0% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Nitro bar is now in hud-top-left, no hud-bottom needed */


/* Fullscreen button */
.btn-fullscreen {
  font-family: Arial, sans-serif;
  font-size: 0;
  width: clamp(36px, 8vw, 48px);
  height: clamp(36px, 8vw, 48px);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.7);
  border: 2px solid #555580;
  border-radius: 6px;
  color: #8080a0;
  cursor: pointer;
  transition: all 0.15s;
  pointer-events: auto;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.btn-fullscreen::before {
  content: '';
  display: block;
  width: 16px;
  height: 12px;
  border: 2px solid currentColor;
}

.btn-icon-sq {
  font-family: Arial, sans-serif;
  font-size: 0;
  width: clamp(36px, 8vw, 48px);
  height: clamp(36px, 8vw, 48px);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.7);
  border: 2px solid #555580;
  border-radius: 6px;
  color: #8080a0;
  cursor: pointer;
  transition: all 0.15s;
  pointer-events: auto;
}
.btn-icon-sq:hover, .btn-icon-sq:active {
  border-color: #00c8ff;
  color: #00c8ff;
}

.btn-fullscreen:hover, .btn-fullscreen:active {
  border-color: #00c8ff;
  color: #00c8ff;
}

.btn-fullscreen-global {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
}

/* Multiplayer scoreboard */
.mp-scoreboard {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: clamp(0.55rem, 1.8vw, 0.85rem);
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: rgba(10, 10, 26, 0.5);
  border: 1px solid #333366;
  border-radius: 4px;
  max-width: 100%;
}

.mp-scoreboard.visible {
  display: flex;
}

.mp-score {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.mp-score.p0 { color: #00c8ff; }
.mp-score.p1 { color: #ff3077; }
.mp-score.p2 { color: #ffcc00; }
.mp-score.p3 { color: #50ff50; }
.mp-score.p4 { color: #cc66ff; }

/* Pause popup overlay */
.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 26, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: auto;
}

.pause-overlay.hidden {
  display: none;
}

.connection-status {
  position: absolute;
  top: 2%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.6rem, 1.5vw, 0.8rem);
  padding: 0.2rem 0.8rem;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 30;
}
.connection-status.reconnecting {
  opacity: 1;
  color: #ffcc00;
  background: rgba(10, 10, 26, 0.8);
}
.connection-status.lost {
  opacity: 1;
  color: #ff4466;
  background: rgba(10, 10, 26, 0.8);
}

.player-left-toast {
  position: fixed;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  color: #ff8866;
  background: rgba(10, 10, 26, 0.7);
  padding: 0.4rem 1.2rem;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 500;
}
.player-left-toast.visible {
  opacity: 1;
}

.pause-popup {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
}

.btn-pause-action {
  min-width: 260px;
  font-size: clamp(0.8rem, 2.5vw, 1.1rem);
  padding: 1.2rem 2.5rem;
}

.nitro-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nitro-label {
  font-size: clamp(0.55rem, 1.6vw, 0.8rem);
  color: #ff3077;
  text-shadow: 0 0 8px rgba(255, 48, 119, 0.4);
}

.nitro-bar-bg {
  position: relative;
  width: clamp(160px, 40vw, 200px);
  height: clamp(28px, 6vw, 42px);
  background: #1a1a3a;
  border: 1px solid #333366;
  border-radius: 2px;
  overflow: hidden;
  transition: border-color 0.1s, box-shadow 0.1s;
}

.nitro-bar-text {
  position: absolute;
  top: 0;
  white-space: nowrap;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.38rem, 2vw, 1.1rem);
  color: #fff;
  text-shadow: 0 0 4px rgba(255, 48, 119, 0.6);
  pointer-events: none;
}

.nitro-bar-bg.warn {
  border-color: #ffcc00;
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.6), inset 0 0 8px rgba(255, 204, 0, 0.15);
}

.nitro-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3077, #ff6b3d);
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(255, 48, 119, 0.4);
}

.nitro-bar-fill.charging {
  background: linear-gradient(90deg, #553040, #554030);
  box-shadow: none;
}

.nitro-bar-fill.ready {
  animation: nitroPulse 0.8s ease-in-out infinite;
}

@keyframes nitroPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 48, 119, 0.4); }
  50% { box-shadow: 0 0 20px rgba(255, 48, 119, 0.8); }
}

.race-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(2rem, 10vw, 5rem);
  color: #ffcc00;
  text-shadow: 0 0 30px rgba(255, 204, 0, 0.6);
}

/* End screen */
#endScreen {
  background: rgba(10, 10, 26, 0.92);
  gap: 1.5rem;
}

#endTitle {
  font-size: clamp(1rem, 4vw, 2rem);
}

#endTitle.win {
  color: #50ff50;
  text-shadow: 0 0 20px rgba(80, 255, 80, 0.5);
}

#endTitle.lose {
  color: #ff3030;
  text-shadow: 0 0 20px rgba(255, 48, 48, 0.5);
}

#endTime {
  font-size: clamp(0.75rem, 2vw, 1.1rem);
  color: #a0a0d0;
}

.end-rankings {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: clamp(0.65rem, 1.8vw, 0.95rem);
  padding: 0.8rem 1.5rem;
  background: rgba(10, 10, 40, 0.5);
  border: 1px solid #333366;
  border-radius: 4px;
  min-width: 320px;
}

.end-ranking-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  white-space: nowrap;
}

.end-ranking-row.is-me {
  font-weight: bold;
}

.end-ranking-pos {
  opacity: 0.6;
  margin-right: 0.3rem;
}

.end-ranking-row.p0 { color: #00c8ff; }
.end-ranking-row.p1 { color: #ff3077; }
.end-ranking-row.p2 { color: #ffcc00; }
.end-ranking-row.p3 { color: #50ff50; }
.end-ranking-row.p4 { color: #cc66ff; }

.end-ranking-status {
  font-size: clamp(0.5rem, 1.2vw, 0.7rem);
  padding: 0.15rem 0.4rem;
  border: 1px solid #333366;
  border-radius: 3px;
  color: #555580;
  margin-left: 0.5rem;
}
.end-ranking-status.ready { color: #50ff50; border-color: #50ff50; }
.end-ranking-status.left { color: #ff4466; border-color: #ff4466; }
.end-ranking-status.host { color: #ffcc00; border-color: #ffcc00; }

.end-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.end-buttons .btn {
  width: 220px;
}

.btn-ready {
  background: rgba(80, 255, 80, 0.08);
  border-color: #50ff50;
  color: #50ff50;
}
.btn-ready:hover, .btn-ready:active {
  background: #50ff50;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(80, 255, 80, 0.4);
}

.btn-return-lobby {
  background: rgba(255, 204, 0, 0.08);
  border-color: #ffcc00;
  color: #ffcc00;
}
.btn-return-lobby:hover, .btn-return-lobby:active {
  background: #ffcc00;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}


/* Item indicator in HUD */
.item-indicator {
  display: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: clamp(0.5rem, 2.5vw, 1.1rem);
  font-family: 'Press Start 2P', monospace;
  text-align: center;
  margin-top: 0.8rem;
}

.item-indicator.visible {
  display: block;
}

.item-indicator.item-emp_mine {
  background: rgba(0, 180, 255, 0.2);
  border: 2px solid #00b4ff;
  color: #00b4ff;
}

.item-indicator.item-homing_rocket {
  background: rgba(255, 50, 50, 0.2);
  border: 2px solid #ff3232;
  color: #ff3232;
}

.item-indicator.item-iron_nails {
  background: rgba(180, 180, 180, 0.2);
  border: 2px solid #b4b4b4;
  color: #b4b4b4;
}

.item-indicator.item-nitro {
  background: rgba(0, 221, 255, 0.2);
  border: 2px solid #00ddff;
  color: #00ddff;
}

/* Stun overlay */
.stun-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 150, 255, 0.15);
  pointer-events: none;
  z-index: 90;
  display: none;
}

.stun-overlay.active {
  display: block;
  animation: stun-flicker 0.15s infinite;
}

@keyframes stun-flicker {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.25; }
}

/* Flyover fade overlay */
.flyover-fade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 95;
}

/* Map-select / lobby cinematic crossfade — sits above the 3D canvas (z-index
   auto) but below the menu UI (.screen z-index 10), so only the background
   dims between shots. Opacity is driven per-frame by JS (no CSS transition). */
#menuFlyoverFade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

/* Intro flyover crossfade layer: a snapshot of the outgoing shot over the scene, its opacity
   driven per frame by JS (introFade.mix, no CSS transition). Below the title and the black. */
.flyover-xfade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 93;
}

.flyover-title {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 94;
  animation: flyoverTitleIn 0.6s ease forwards;
}
.flyover-title .entering {
  font-size: clamp(0.65rem, 2.5vw, 1rem);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(0, 200, 255, 0.7);
  font-family: var(--font-mono);
  margin-bottom: 0.75rem;
}
.flyover-title .track-name {
  font-size: clamp(1.4rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  font-family: var(--font-display);
  text-shadow: 0 0 30px rgba(0, 200, 255, 0.8), 0 0 60px rgba(0, 200, 255, 0.4);
}
@keyframes flyoverTitleIn {
  from { opacity: 0; transform: translate(-50%, -44%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}


/* Options toggle row */
.options-toggle-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.options-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.options-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #00c8ff;
  cursor: pointer;
}

.options-checkbox-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
  color: #8080a0;
}

/* Control mode selector (main menu) */
.control-mode-select {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.control-mode-select.visible {
  display: flex;
}

.control-mode-label {
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
  color: #8080a0;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.control-mode-options {
  display: flex;
  gap: 0.5rem;
}

.btn-mode {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
  padding: 0.6rem 1rem;
  background: transparent;
  border: 2px solid #333366;
  color: #555580;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-mode.active {
  border-color: #00c8ff;
  color: #00c8ff;
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.3);
}

.btn-mode:hover {
  border-color: #6060a0;
  color: #8080c0;
}

/* Split time display (checkpoint deltas) */
.split-display {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 4vw, 2rem);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  z-index: 15;
}

.split-display.visible {
  opacity: 1;
  animation: splitPop 0.3s ease-out;
}

.split-display.ahead {
  color: #50ff50;
  text-shadow: 0 0 20px rgba(80, 255, 80, 0.6);
}

.split-display.behind {
  color: #ff3030;
  text-shadow: 0 0 20px rgba(255, 48, 48, 0.6);
}

@keyframes splitPop {
  0% { transform: translateX(-50%) scale(1.5); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}


/* Map selection screen */
#mapSelectScreen {
  background: radial-gradient(ellipse at center, rgba(26, 26, 58, 0.85) 0%, rgba(10, 10, 26, 0.9) 70%);
  gap: 0.6rem;
  padding: 1rem;
  justify-content: flex-start;
  padding-top: 1.5rem;
  overflow-y: auto;
}


#mapSelectScreen h2 {
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  color: #a0a0d0;
}

/* Large centered preview canvas (override global canvas fixed positioning) */
.map-preview-large {
  position: static;
  width: 340px;
  height: 260px;
  background: #0a0a1a;
  border-radius: 8px;
  border: 2px solid #333366;
}

/* Hide 2D preview canvas in map select (3D flyover shows through) */
#mapSelectScreen > .map-preview-desktop {
  display: none !important;
}

.map-preview-info {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 1.1vw, 0.7rem);
  color: #8080a0;
  text-align: center;
  line-height: 1.8;
  min-height: 1.5em;
}

.map-preview-info .best-time {
  color: #50ff50;
}


/* Map grid carousel wrapper. Four rows of cards (a card is about as tall as it is wide) plus the
   header and the Start button must fit the viewport height without scrolling (Steam Deck 1280x800
   and 1280x720): the grid narrows with the viewport height. */
.map-grid-carousel {
  width: 100%;
  max-width: min(640px, max(300px, calc(100vh - 330px)));
  margin-bottom: 0.8rem;
}
.map-grid .map-name {
  font-size: clamp(0.5rem, calc(max(300px, 100vh - 330px) / 50), 0.9rem);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Map grid — 3 columns (desktop default) */
.map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
}

/* Landscape phones/tablets: horizontal scrollable carousel */
@media (max-width: 1023px) and (orientation: landscape) {
  .map-grid-carousel {
    max-width: none;
    width: 100vw;
    position: relative;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  }
  .map-grid {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.4rem 8vw;
  }
  .map-grid::-webkit-scrollbar { display: none; }
  .map-grid .map-card {
    flex: 0 0 calc((100% - 1.2rem) / 3);
    min-width: calc((100% - 1.2rem) / 3);
    scroll-snap-align: center;
  }
}

.map-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem;
  background: rgba(18, 18, 42, 0.8);
  border: 2px solid #333366;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
  min-width: 0;
}

.map-card:hover, .map-card:active, .map-card.selected {
  border-color: #00c8ff;
  box-shadow: 0 0 16px rgba(0, 200, 255, 0.3);
}
.map-card-disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.map-card-locked {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.map-card-locked .map-name { color: #444466; font-size: clamp(0.45rem, 1vw, 0.6rem); }

.map-card-preview {
  border-radius: 4px;
  border: 1px solid #444466;
  display: block;
  width: 100%;
  height: auto;
}

.map-card-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1vw, 0.6rem);
}

.map-card-best { color: #50ff50; }
.map-card-notime { color: #555577; }

.medal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Track detail panel */
.track-detail-panel {
  width: 100%;
  max-width: 480px;
  background: none;
  border: none;
  padding: 0.3rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
/* Medal display */
.track-medals {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  align-items: center;
}
.track-medal {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.35rem, 1.1vw, 0.5rem);
}
.track-medal-icon {
  width: clamp(14px, 3vw, 20px);
  height: clamp(14px, 3vw, 20px);
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}
.track-medal-time {
  color: #c0c0e0;
  font-variant-numeric: tabular-nums;
}
/* Map select leaderboard popup */
.ms-lb-popup {
  background: #0e0e24;
  border: 2px solid #333366;
  border-radius: 8px;
  padding: 1.5rem 2rem 2rem;
  max-width: 500px;
  width: 92vw;
  max-height: 75vh;
  overflow-y: auto;
}
.ms-lb-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.ms-lb-popup-header h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 2.2vw, 1rem);
  color: #a0a0d0;
  margin: 0;
}
.track-detail-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.track-detail-actions .btn {
  flex: 1;
  max-width: 240px;
}

.track-options-summary {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 1.8vw, 0.84rem);
  color: #8080a0;
  text-align: center;
  margin-top: 10px;
}

/* Track options popup */
.track-options-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.track-options-popup {
  background: radial-gradient(ellipse at center, #1e1e44 0%, #0e0e22 70%);
  border: 2px solid #333366;
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  min-width: 220px;
}
.track-options-popup h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.55rem, 1.8vw, 0.75rem);
  color: #a0a0d0;
  margin: 0;
}

.map-name {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.65rem, 1.8vw, 0.9rem);
  color: #00c8ff;
  text-shadow: 0 0 8px rgba(0, 200, 255, 0.4);
}

.map-meta {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.3rem, 0.9vw, 0.4rem);
  color: #8080a0;
  text-align: center;
}

.map-meta .best-time {
  color: #50ff50;
}

/* Lobby track selector (host picks track inline) */
.lobby-track-selector {
  display: flex;
  flex-direction: row;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.lobby-track-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.2vw, 0.55rem);
  padding: 0.5rem 1rem;
  background: rgba(18, 18, 42, 0.8);
  border: 2px solid #333366;
  color: #8080a0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.lobby-track-btn:hover {
  border-color: #6060a0;
  color: #b0b0d0;
}

.lobby-track-btn.active {
  border-color: #00c8ff;
  color: #00c8ff;
  box-shadow: 0 0 12px rgba(0, 200, 255, 0.3);
}

/* Lobby track info (shown for non-host) */
.lobby-track-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: clamp(0.5rem, 1.5vw, 0.7rem);
  color: #8080a0;
}

.lobby-track-info #lobbyTrackName {
  color: #00c8ff;
}

#mpModeSelectScreen h2 {
  margin-bottom: 1.5rem;
}

.lobby-mode-label {
  font-size: clamp(0.45rem, 1.3vw, 0.6rem);
  color: #ffcc00;
  text-align: center;
  margin-top: 0.2rem;
}

.lobby-mode-badge {
  display: inline-block;
  font-size: 0.5rem;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}
.lobby-mode-badge.ta { background: #00c8ff; color: #000; }

/* Current run time display */
.current-run-time {
  font-size: clamp(0.75rem, 2.5vw, 1.1rem);
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4), 0 0 4px #000, 0 1px 3px #000;
  text-align: left;
  min-height: 1.2em;
}

/* Bot count selector (menu screen) */
.vehicle-select-row { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; margin-bottom: 0.8rem; }
.vehicle-select-label { font-family: 'Press Start 2P', monospace; font-size: clamp(0.45rem, 1.4vw, 0.6rem); color: #8080a0; letter-spacing: 0.1em; text-transform: uppercase; }
.vehicle-options { display: flex; gap: 0.5rem; }
.vehicle-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; background: rgba(10,10,26,0.7); border: 2px solid #333366; border-radius: 6px; cursor: pointer; transition: all 0.15s; min-width: 70px; }
.vehicle-btn:hover { border-color: #6060a0; }
.vehicle-btn.selected { border-color: #00ffcc; box-shadow: 0 0 10px rgba(0,255,204,0.3); background: rgba(0,255,204,0.08); }
.vehicle-icon { font-size: 1.4rem; line-height: 1; }
.vehicle-name { font-family: 'Press Start 2P', monospace; font-size: 0.5rem; color: #e0e0ff; }
.vehicle-trait { font-family: 'Press Start 2P', monospace; font-size: 0.35rem; color: #00c8ff; text-transform: uppercase; }
.vehicle-swatch { width: 28px; height: 6px; border-radius: 3px; background: var(--car-trim, #00c8ff); box-shadow: 0 0 8px var(--car-trim, #00c8ff); margin: 4px 0; }
.vehicle-btn.selected { border-color: var(--car-trim, #00ffcc); }

.bot-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  margin-bottom: 0.4rem;
}

.bot-count-label {
  font-size: clamp(0.45rem, 1.4vw, 0.6rem);
  color: #8080a0;
  letter-spacing: 0.1em;
}

.bot-count-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px solid #333366;
  color: #8080a0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  line-height: 1;
}

.bot-count-btn:hover, .bot-count-btn:active {
  border-color: #00c8ff;
  color: #00c8ff;
}

.items-toggle-btn {
  width: auto;
  min-width: 52px;
  padding: 0 8px;
}

.bot-count-value {
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  color: #00c8ff;
  min-width: 1.5em;
  text-align: center;
}

/* Mode Select Screen */
#modeSelectScreen {
  background: transparent;
}

#modeSelectBgCanvas,
.screen-bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
}

.mode-cards {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 2rem 2.5rem;
  background: rgba(18, 18, 42, 0.85);
  border: 3px solid #333366;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 320px;
  flex: 1 1 0;
  max-width: 420px;
}

.mode-card:hover, .mode-card:active {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 200, 255, 0.2);
}

.mode-card-ta {
  border-color: #00c8ff;
}
.mode-card-ta:hover {
  border-color: #40d8ff;
  box-shadow: 0 8px 30px rgba(0, 200, 255, 0.3);
}

.mode-card-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.8rem, 2.5vw, 1.1rem);
  color: #fff;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.mode-card-desc {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 1.1vw, 0.65rem);
  color: #8080a0;
  text-align: center;
  line-height: 2;
}

/* Editor */
#editorScreen { background: #08081e; padding: 0; }
.editor-entry-menu { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 1.2rem; background: rgba(10, 10, 30, 0.95); border: 2px solid #333366; border-radius: 12px; padding: 2.5rem 3rem; z-index: 10; }
.editor-entry-title { font-size: clamp(0.8rem, 2.8vw, 1.2rem); color: #00ffcc; text-shadow: 0 0 15px rgba(0, 255, 204, 0.4); margin-bottom: 0.5rem; }
.editor-palette-panel { position: absolute; top: 12px; right: 12px; width: 200px; max-height: calc(100% - 24px); overflow-y: auto; overflow-x: hidden; background: rgba(10, 10, 30, 0.92); border: 1px solid #333366; border-radius: 8px; padding: 12px; z-index: 10; box-sizing: border-box; }
.editor-row { margin-bottom: 8px; }
.editor-label { font-size: 10px; color: #aaa; }
.editor-input { font-family: 'Press Start 2P', monospace; font-size: 10px; background: #1a1a3e; color: #e0e0ff; border: 1px solid #334; padding: 4px 8px; width: 100%; box-sizing: border-box; }
.editor-input[type=number]::-webkit-inner-spin-button,
.editor-input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.editor-section-label { font-size: 9px; color: #00ffcc; margin: 8px 0 4px; text-transform: uppercase; }
.editor-tile-palette { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-bottom: 8px; max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.editor-tile-category { grid-column: 1 / -1; font-size: 8px; color: #00ffcc; text-transform: uppercase; letter-spacing: 1px; padding: 4px 0 2px; border-bottom: 1px solid #333366; cursor: pointer; user-select: none; }
.editor-tile-category:hover { color: #66ffdd; }
.editor-tile-box { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; background: #12122a; border: 2px solid #333366; border-radius: 4px; cursor: pointer; transition: border-color 0.15s; }
.editor-tile-box:hover { border-color: #6060a0; }
.editor-tile-box.selected { border-color: #00ffcc; box-shadow: 0 0 8px rgba(0, 255, 204, 0.4); }
.editor-tile-box canvas { position: static !important; width: 52px !important; height: 52px !important; display: block; border-radius: 2px; }
.editor-tile-label { font-size: 7px; color: #8080a0; text-align: center; }
.editor-toolbar-vert { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.editor-toolbar-vert .btn-tiny { width: 100%; text-align: center; box-sizing: border-box; }
.btn-tiny { font-family: 'Press Start 2P', monospace; font-size: 7px; padding: 4px 6px; background: #1a1a3e; color: #e0e0ff; border: 1px solid #334; cursor: pointer; }
.btn-tiny:hover { background: #2a2a5e; border-color: #00ffcc; }
.editor-load-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 100; }
.editor-load-content { background: #0a0a2e; border: 1px solid #334; padding: 16px; min-width: 280px; max-height: 60vh; overflow-y: auto; }
.editor-load-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 10px; }
.editor-load-row span { flex: 1; }
.editor-medals-row { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.editor-medal-input { width: 42px !important; font-size: 9px !important; padding: 3px 4px !important; text-align: center; }
.editor-shortcut-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 200; }
.editor-shortcut-content { background: #0a0a2e; border: 1px solid #334; padding: 24px; min-width: 320px; max-width: 460px; border-radius: 8px; }
.editor-shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 9px; }
.editor-shortcut-list .sc-key { color: #00c8ff; font-family: monospace; }
.editor-shortcut-list .sc-desc { color: #aaa; }
.editor-mode-badge { font-family: 'Press Start 2P', monospace; font-size: 7px; padding: 3px 6px; border-radius: 3px; text-align: center; margin-bottom: 6px; }
.editor-mode-badge.official { background: rgba(0, 200, 255, 0.15); border: 1px solid #00c8ff; color: #00c8ff; }
.editor-mode-badge.user { background: rgba(255, 48, 119, 0.15); border: 1px solid #ff3077; color: #ff3077; }
.editor-official-panel { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(10, 10, 26, 0.98); z-index: 15; padding: 32px 40px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; }
.editor-official-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; width: 100%; max-width: 900px; }
.editor-official-header h2 { margin: 0; font-size: clamp(1rem, 2.5vw, 1.4rem); }
.official-track-list { margin-bottom: 28px; width: 100%; max-width: 900px; }
.official-track-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid #2a2a4a; border-radius: 6px; margin-bottom: 6px; font-family: 'Press Start 2P', monospace; font-size: clamp(0.6rem, 1.3vw, 0.8rem); color: #e0e0ff; background: rgba(18, 18, 42, 0.85); }
.official-track-row.empty { color: #333366; border-color: #1a1a3e; background: rgba(12, 12, 30, 0.4); font-size: clamp(0.5rem, 1vw, 0.65rem); }
.official-track-row .drag-handle { cursor: grab; color: #555580; font-size: 1.4em; user-select: none; }
.official-track-row .drag-handle:active { cursor: grabbing; color: #00c8ff; }
.official-track-row .track-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.official-track-row .track-meta { font-size: 0.7em; color: #8080a0; white-space: nowrap; }
.official-track-row .btn-tiny { font-size: clamp(0.45rem, 1vw, 0.6rem); padding: 6px 12px; }
.official-track-row.drag-over { border-color: #00c8ff; background: rgba(0, 200, 255, 0.08); box-shadow: 0 0 8px rgba(0, 200, 255, 0.2); }
.official-divider { width: 100%; max-width: 900px; border: none; border-top: 1px solid #222244; margin: 4px 0 20px; }
.official-unassigned-header { font-family: 'Press Start 2P', monospace; font-size: clamp(0.55rem, 1.2vw, 0.7rem); color: #ff3077; margin-bottom: 12px; text-transform: uppercase; width: 100%; max-width: 900px; }
.official-unassigned-list { width: 100%; max-width: 900px; }
.official-unassigned-row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border: 1px solid #222244; border-radius: 6px; margin-bottom: 5px; font-family: 'Press Start 2P', monospace; font-size: clamp(0.55rem, 1.2vw, 0.7rem); color: #a0a0d0; background: rgba(18, 18, 42, 0.5); }
.official-unassigned-row .track-name { flex: 1; }
.official-unassigned-row .track-meta { font-size: 0.8em; color: #555580; }
.official-unassigned-row .btn-tiny { font-size: clamp(0.45rem, 1vw, 0.6rem); padding: 6px 12px; }
#btnEditorOfficialMaps { border-color: #ffcc00; color: #ffcc00; }
#btnEditorOfficialMaps:hover { background: rgba(255, 204, 0, 0.15); box-shadow: 0 0 15px rgba(255, 204, 0, 0.3); }
.editor-confirm-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; z-index: 300; }
.editor-confirm-box { background: #0a0a2e; border: 2px solid #333366; border-radius: 10px; padding: 28px 36px; min-width: 320px; text-align: center; }
.editor-confirm-text { font-family: 'Press Start 2P', monospace; font-size: clamp(0.6rem, 1.4vw, 0.8rem); color: #e0e0ff; margin-bottom: 24px; line-height: 1.8; }
.editor-confirm-buttons { display: flex; gap: 16px; justify-content: center; }
.editor-confirm-buttons .btn { min-width: 100px; }
.editor-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); font-family: 'Press Start 2P', monospace; font-size: 10px; padding: 8px 20px; background: rgba(0, 255, 204, 0.15); border: 1px solid #00ffcc; color: #00ffcc; border-radius: 6px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 200; }
.editor-toast.visible { opacity: 1; }
.editor-toast.error { background: rgba(255, 68, 68, 0.15); border-color: #ff4444; color: #ff4444; }

/* Leaderboard screen */
.lb-screen { justify-content: flex-start; padding: 1.5rem 0 1rem; gap: 0; background: radial-gradient(ellipse at center, rgba(26, 26, 58, 0.85) 0%, rgba(10, 10, 26, 0.9) 70%); overflow-y: auto; }
.lb-tabs { display: flex; gap: 0; justify-content: center; margin-bottom: 1.5rem; }
.lb-tab { font-family: 'Press Start 2P', monospace; font-size: clamp(0.5rem, 1.3vw, 0.75rem); padding: 0.9rem 2rem; background: rgba(26, 26, 62, 0.6); color: #6666aa; border: 1px solid #2a2a4a; border-bottom: 2px solid #2a2a4a; cursor: pointer; transition: all 0.15s; }
.lb-tab:hover { color: #a0a0dd; border-bottom-color: #00c8ff; }
.lb-tab.active { color: #00c8ff; border-bottom: 2px solid #00c8ff; background: rgba(0, 200, 255, 0.05); }
.lb-body { display: flex; gap: 2rem; width: 100%; max-width: 860px; padding: 0 2rem; box-sizing: border-box; flex: 1 1 0; min-height: 0; align-self: center; }
.lb-sidebar { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; flex-shrink: 0; }
.lb-preview { width: 240px; height: 240px; background: #08081a; border: 1px solid #2a2a4a; border-radius: 6px; position: static; }
.lb-track-name { font-family: 'Press Start 2P', monospace; font-size: clamp(0.5rem, 1.2vw, 0.7rem); color: #8888aa; text-transform: uppercase; letter-spacing: 0.1em; }
.lb-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lb-period-toggle { display: flex; gap: 0; margin-bottom: 1rem; }
.lb-period-tab { font-family: 'Press Start 2P', monospace; font-size: clamp(0.4rem, 1vw, 0.55rem); padding: 0.6rem 1.2rem; background: rgba(26, 26, 62, 0.4); color: #6666aa; border: 1px solid #2a2a4a; cursor: pointer; transition: all 0.15s; flex: 1; text-align: center; }
.lb-period-tab:first-child { border-radius: 4px 0 0 4px; }
.lb-period-tab:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.lb-period-tab:hover { color: #c0c0ff; }
.lb-period-tab.active { color: #ff3077; border-color: #ff3077; background: rgba(255, 48, 119, 0.08); }
.lb-table { width: 100%; flex: 1; overflow-y: auto; }
.lb-row { display: flex; align-items: center; padding: 0.6rem 0.8rem; font-family: 'Press Start 2P', monospace; font-size: clamp(0.45rem, 1.2vw, 0.65rem); border-bottom: 1px solid rgba(42, 42, 74, 0.5); }
.lb-row.lb-header { color: #6666aa; font-size: clamp(0.35rem, 0.9vw, 0.48rem); border-bottom: 1px solid #334; margin-bottom: 0.3rem; padding: 0.4rem 0.8rem; }
.lb-rank { width: 2.5rem; text-align: center; }
.lb-rank-1 { color: #ffd700; }
.lb-rank-2 { color: #c0c0c0; }
.lb-rank-3 { color: #cd7f32; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 0.3rem; }
.lb-time { width: 5.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.lb-empty { text-align: center; color: #555; padding: 2rem 0; font-size: clamp(0.4rem, 1.1vw, 0.55rem); }
.lb-empty-friends { text-align: center; padding: 1.5rem 0 0.5rem; }
.lb-empty-msg { font-family: 'Press Start 2P', monospace; font-size: clamp(0.45rem, 1.2vw, 0.6rem); color: #6666aa; margin-bottom: 0.6rem; }
.lb-empty-hint { font-family: 'Press Start 2P', monospace; font-size: clamp(0.3rem, 0.85vw, 0.42rem); color: #444466; }
.lb-global-fallback { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid #2a2a4a; }
.lb-fallback-label { font-family: 'Press Start 2P', monospace; font-size: clamp(0.3rem, 0.85vw, 0.42rem); color: #555580; text-align: center; margin-bottom: 0.5rem; letter-spacing: 0.12em; }

.lb-row.lb-me, .ms-lb-row.lb-me { color: #00ff88; background: rgba(0,255,136,0.05); border-color: rgba(0,255,136,0.15); }
.lb-row.lb-me .lb-rank-1, .lb-row.lb-me .lb-rank-2, .lb-row.lb-me .lb-rank-3,
.ms-lb-row.lb-me .lb-rank-1, .ms-lb-row.lb-me .lb-rank-2, .ms-lb-row.lb-me .lb-rank-3,
.ms-lb-row.lb-me .ms-lb-rank { color: #00ff88; }
.lb-row.lb-me .entry-tag, .ms-lb-row.lb-me .entry-tag { color: #00cc66; }

.lb-pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 0.6rem 0; margin-top: 0.2rem; }
.lb-page-info { font-family: 'Press Start 2P', monospace; font-size: clamp(0.35rem, 1vw, 0.5rem); color: #8888aa; }
.lb-page-btn { font-size: clamp(0.7rem, 2vw, 1rem); padding: 0.15em 0.5em; }
.lb-page-btn:disabled { opacity: 0.25; cursor: default; pointer-events: none; }

.lb-player-section { margin-top: 0.8rem; border-top: 1px solid #2a2a4a; padding-top: 0.5rem; }
.lb-player-divider { font-family: 'Press Start 2P', monospace; font-size: clamp(0.28rem, 0.75vw, 0.38rem); color: #445566; text-align: center; margin-bottom: 0.3rem; letter-spacing: 0.12em; }

/* Mini leaderboard on map cards */
.map-card-lb { display: flex; flex-direction: column; gap: 1px; margin-top: 0.2rem; width: 100%; }
.map-card-lb-row { display: flex; font-size: clamp(0.45rem, 1.5vw, 0.55rem); color: #6666aa; gap: 0.3rem; }
.map-card-lb-row .lb-rank-1 { color: #ffd700; }
.map-card-lb-row .lb-rank-2 { color: #c0c0c0; }
.map-card-lb-row .lb-rank-3 { color: #cd7f32; }
.map-card-lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-card-lb-time { font-variant-numeric: tabular-nums; }

.map-select-lb { width: 100%; max-width: 460px; background: rgba(18,18,42,0.85); border: 1px solid #333366; border-radius: 8px; padding: 0.8rem 1rem; margin: 0.5rem 0; }
.ms-lb-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.ms-lb-title { font-family: 'Press Start 2P', monospace; font-size: clamp(0.55rem, 1.5vw, 0.7rem); color: #ff3077; }
.ms-lb-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }
.ms-lb-tab { font-family: 'Press Start 2P', monospace; font-size: clamp(0.4rem, 1vw, 0.5rem); padding: 0.3rem 0.6rem; background: #1a1a3e; color: #8888aa; border: 1px solid #334; cursor: pointer; }
.ms-lb-tab:hover { border-color: #ff3077; color: #c0c0ff; }
.ms-lb-tab.active { background: #22224a; color: #ff3077; border-color: #ff3077; }
.ms-lb-rows { display: flex; flex-direction: column; gap: 0.3rem; }
.ms-lb-row { display: flex; font-family: 'Press Start 2P', monospace; font-size: clamp(0.5rem, 1.3vw, 0.65rem); color: #a0a0cc; gap: 0.5rem; align-items: center; }
.ms-lb-rank { min-width: 1rem; } .ms-lb-rank.lb-rank-1 { color: #ffd700; } .ms-lb-rank.lb-rank-2 { color: #c0c0c0; } .ms-lb-rank.lb-rank-3 { color: #cd7f32; }
.ms-lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-lb-time { font-variant-numeric: tabular-nums; }
.ms-lb-loading, .ms-lb-empty { font-family: 'Press Start 2P', monospace; font-size: clamp(0.45rem, 1vw, 0.55rem); color: #555580; text-align: center; padding: 0.3rem 0; }

/* Name prompt modal */
.name-prompt-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.name-prompt-content { background: #0a0a2e; border: 2px solid #334; padding: 1.5rem; text-align: center; max-width: 300px; }
.name-prompt-title { font-family: 'Press Start 2P', monospace; font-size: clamp(0.4rem, 1.2vw, 0.55rem); color: #c0c0ff; margin-bottom: 1rem; }
.name-prompt-buttons { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.8rem; }

/* Tutorial prompt overlay */
.tutorial-prompt {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  text-align: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.6);
  padding: 1.2rem 2.8rem;
  border: 1px solid rgba(80, 255, 80, 0.3);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s;
  min-width: clamp(280px, 55vw, 480px);
}
.tutorial-prompt.visible {
  opacity: 1;
}
.tutorial-key {
  color: #ffaa00;
}
.tutorial-step {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 1.4vw, 0.7rem);
  color: #ffffff;
  margin-bottom: 0.8rem;
}
.tutorial-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.77rem, 2.5vw, 1.19rem);
  color: #50ff50;
  text-shadow: 0 0 12px rgba(80, 255, 80, 0.5);
  margin-bottom: 0.8rem;
}
.tutorial-subtext {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.56rem, 1.7vw, 0.77rem);
  color: #ffffff;
}

/* Desktop/tablet: center content on scrollable screens when space allows */
@media (min-height: 600px) and (min-width: 768px) {
  #mapSelectScreen {
    justify-content: safe center;
  }
  .lb-screen {
    justify-content: flex-start;
    padding-top: 2rem;
  }
}

/* Desktop: no longer needed — game is desktop-only */

/* Touch layer (spec 2026-10-10-mobile-controls 4): shown only while touch is the active input.
   Zones are below the HUD band; buttons are at least 48 px; safe areas pad the corners. */
#touchLayer {
  --tz-btn: 24vh;
  --tz-alpha: 0.45;
  --tz-pad: 12px;
  --tz-corner: max(48px, 11vh);
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
#touchLayer.hidden { display: none; }
#touchLayer.tz-size-small { --tz-btn: 18vh; }
#touchLayer.tz-size-medium { --tz-btn: 24vh; }
#touchLayer.tz-size-large { --tz-btn: 30vh; }

.tz-steer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  top: 22%;
  pointer-events: auto;
}
.tz-steer.glow { box-shadow: inset 0 0 40px rgba(0, 200, 255, 0.35); }
.tz-ring {
  position: fixed;
  left: 0;
  top: 0;
  width: 144px;
  height: 144px;
  border: 2px solid rgba(0, 200, 255, 0.55);
  border-radius: 50%;
  background: rgba(0, 200, 255, 0.06);
  box-shadow: 0 0 14px rgba(0, 200, 255, 0.35);
  pointer-events: none;
  display: none;
}
.tz-ring.active { display: block; }
.tz-ring::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 15%;
  bottom: 15%;
  width: 2px;
  margin-left: -1px;
  background: rgba(0, 200, 255, 0.35);
}
.tz-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgba(0, 200, 255, 0.55);
  border: 2px solid #00c8ff;
  box-shadow: 0 0 16px rgba(0, 200, 255, 0.7);
}

.tz-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  color: #ffffff;
  background: rgba(10, 10, 26, var(--tz-alpha));
  border: 3px solid rgba(0, 200, 255, 0.85);
  border-radius: 50%;
  outline: none;
  pointer-events: auto;
  touch-action: none;
  text-shadow: 0 1px 3px #000;
  -webkit-tap-highlight-color: transparent;
}
.tz-btn.pressed { background: rgba(0, 200, 255, 0.35); }
.tz-btn .tz-label { position: relative; font-size: clamp(0.5rem, 2.2vh, 0.8rem); pointer-events: none; }
.tz-btn svg { width: 50%; height: 50%; fill: #00c8ff; stroke: #00c8ff; pointer-events: none; position: relative; }

.tz-race {
  width: max(64px, var(--tz-btn));
  height: max(64px, var(--tz-btn));
}
.tz-brake {
  right: calc(var(--tz-pad) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--tz-pad) + env(safe-area-inset-bottom, 0px));
  border-color: rgba(255, 48, 119, 0.9);
  box-shadow: 0 0 12px rgba(255, 48, 119, 0.4);
}
.tz-brake.pressed { background: rgba(255, 48, 119, 0.4); }
.tz-nitro {
  right: calc(var(--tz-pad) * 2 + max(64px, var(--tz-btn)) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--tz-pad) + max(64px, var(--tz-btn)) * 0.45 + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 0 12px rgba(0, 200, 255, 0.4);
}
.tz-nitro.charging { opacity: 0.55; }
.tz-gas {
  display: none;
  right: calc(var(--tz-pad) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--tz-pad) * 2 + max(64px, var(--tz-btn)) + env(safe-area-inset-bottom, 0px));
  border-color: rgba(80, 255, 80, 0.85);
}
#touchLayer.tz-throttle-pad .tz-gas { display: flex; }
.tz-charge, .tz-hold {
  --p: 0;
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(#00c8ff calc(var(--p) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  pointer-events: none;
}
.tz-hold { background: conic-gradient(#ff3077 calc(var(--p) * 1turn), transparent 0); }

.tz-corner {
  width: var(--tz-corner);
  height: var(--tz-corner);
  top: calc(var(--tz-pad) + env(safe-area-inset-top, 0px));
}
.tz-pause { left: calc(var(--tz-pad) + env(safe-area-inset-left, 0px)); }
.tz-restart { right: calc(var(--tz-pad) + env(safe-area-inset-right, 0px)); border-color: rgba(255, 48, 119, 0.85); }
.tz-restart svg { fill: #ff3077; stroke: #ff3077; }

/* Left-handed: steer zone right, race buttons left, pause and restart swap corners. */
#touchLayer.touch-mirror .tz-steer { left: auto; right: 0; }
#touchLayer.touch-mirror .tz-brake { right: auto; left: calc(var(--tz-pad) + env(safe-area-inset-left, 0px)); }
#touchLayer.touch-mirror .tz-nitro { right: auto; left: calc(var(--tz-pad) * 2 + max(64px, var(--tz-btn)) + env(safe-area-inset-left, 0px)); }
#touchLayer.touch-mirror .tz-gas { right: auto; left: calc(var(--tz-pad) + env(safe-area-inset-left, 0px)); }
#touchLayer.touch-mirror .tz-pause { left: auto; right: calc(var(--tz-pad) + env(safe-area-inset-right, 0px)); }
#touchLayer.touch-mirror .tz-restart { right: auto; left: calc(var(--tz-pad) + env(safe-area-inset-left, 0px)); }
.tz-nitro.pulse, .tz-steer.pulse { animation: tzPulse 0.9s ease-in-out infinite; }
@keyframes tzPulse { 50% { box-shadow: 0 0 28px rgba(0, 200, 255, 0.9); } }

/* Portrait prompt: covers the race on a touch device held upright (spec section 5). */
.rotate-prompt {
  z-index: 100;
  background: #0a0a1a;
  gap: 1.5rem;
  text-align: center;
  padding: 1rem;
}
.rotate-prompt .title { margin-bottom: 0; font-size: clamp(1.4rem, 8vw, 2.4rem); }
.rotate-icon {
  width: 96px;
  height: 96px;
  fill: none;
  stroke: #00c8ff;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(0, 200, 255, 0.6));
  animation: rotateHint 2s ease-in-out infinite;
}
@keyframes rotateHint { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
.rotate-text { color: #00c8ff; font-size: clamp(0.6rem, 3.5vw, 0.9rem); line-height: 1.8; }

/* Touch HUD (body.hud-touch): nothing under a thumb. Run time and session clock top centre,
   best and splits top right under the restart button, speed and gear bottom centre between the
   thumbs, the nitro bar gone (the NITRO button is the bar), the scoreboard above NITRO. */
body.hud-touch #hud { padding: 0; }
body.hud-touch .hud-info {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  flex-direction: row;
  align-items: baseline;
  gap: 0.8rem;
  z-index: 21;
  pointer-events: none;
}
body.hud-touch #currentRunTime {
  font-size: clamp(1rem, 5.5vh, 1.6rem);
  text-align: center;
}
body.hud-touch #sessionTimer {
  font-size: clamp(0.5rem, 2.6vh, 0.75rem);
  opacity: 0.85;
}
body.hud-touch .nitro-container { display: none !important; }
body.hud-touch .hud-lower-group { margin: 0; }
body.hud-touch .hud-speed-row {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  font-size: clamp(0.9rem, 5vh, 1.5rem);
  z-index: 21;
  pointer-events: none;
}
body.hud-touch .hud-top-right {
  position: fixed;
  top: calc(max(48px, 11vh) + 20px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  padding-top: 0;
  max-width: 34vw;
  z-index: 21;
}
body.hud-touch .time-list { font-size: clamp(0.45rem, 2.4vh, 0.7rem); max-height: 30vh; }
body.hud-touch #mpScoreboard {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + max(64px, 24vh) * 1.45 + env(safe-area-inset-bottom, 0px));
  max-width: 30vw;
  font-size: clamp(0.4rem, 2vh, 0.6rem);
}
body.hud-touch .split-display { top: calc(12px + 9vh + env(safe-area-inset-top, 0px)); font-size: clamp(0.9rem, 6vh, 1.6rem); }
body.hud-touch .hint-banner { top: auto; bottom: calc(24px + 6vh + env(safe-area-inset-bottom, 0px)); }
/* The achievement toast (inline styles, top right) would cover the restart button. */
body.hud-touch #achievementToast { top: calc(max(48px, 11vh) + 20px + env(safe-area-inset-top, 0px)) !important; right: auto !important; left: calc(12px + env(safe-area-inset-left, 0px)) !important; padding: 8px 12px !important; font-size: 11px !important; }
body.hud-touch .tutorial-prompt { top: 38%; min-width: 0; max-width: 46vw; padding: 0.8rem 1.2rem; }

/* Phones in landscape (412 px tall or less): the menu column does not fit, so the buttons go in
   two columns of tap-sized (48 px) buttons and the MobX logo moves to the bottom-right corner. */
@media (max-height: 520px) and (orientation: landscape) {
  #menuScreen { padding: calc(8px + env(safe-area-inset-top, 0px)) 16px calc(8px + env(safe-area-inset-bottom, 0px)); justify-content: center; }
  #menuScreen .title { font-size: clamp(1.2rem, 8vh, 2rem); margin-bottom: 4vh; }
  #menuScreen .menu-buttons { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 10px 14px; }
  #menuScreen .menu-buttons .btn { min-width: 0; min-height: 48px; margin: 0; padding: 0.4rem 1rem; font-size: clamp(0.55rem, 3.4vh, 0.8rem); }
  #menuScreen .mobx-credit { left: auto; right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  #menuScreen .mobx-logo { width: 64px; }
}
/* No mouse cursor sprite while touch is the active input. */
body.hud-touch #game-cursor { display: none !important; }

/* Options: Touch section (spec section 7), shown only while touch is the active input. */
.options-sublabel { font-size: clamp(0.45rem, 1.3vw, 0.6rem); color: #a0a0d0; letter-spacing: 0.1em; }
.options-touch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; }
.options-touch-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem 1rem; width: 100%; }
.options-touch .options-checkbox-label { min-height: 48px; display: flex; align-items: center; }
.options-touch .options-select { min-height: 48px; }
.options-touch .options-slider { height: 24px; }
.touch-test-strip {
  position: relative;
  width: 100%;
  height: 120px;
  border: 2px solid #333366;
  border-radius: 12px;
  background: rgba(0, 200, 255, 0.05);
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.touch-test-strip::before { content: ''; position: absolute; left: 50%; top: 12px; bottom: 12px; width: 2px; background: rgba(0, 200, 255, 0.35); }
.touch-test-bar { position: absolute; left: calc(50% - 6px); width: 12px; top: 20%; height: 60%; background: #00c8ff; border-radius: 6px; box-shadow: 0 0 12px rgba(0, 200, 255, 0.7); pointer-events: none; }
.touch-test-label { position: absolute; top: 8px; left: 12px; font-size: 0.45rem; color: #8080a0; pointer-events: none; }
.touch-test-value { position: absolute; top: 8px; right: 12px; font-size: clamp(0.6rem, 1.6vw, 0.85rem); color: #00c8ff; pointer-events: none; }
.hud-speed-row.pulse { animation: tzPulseText 0.9s ease-in-out infinite; }
@keyframes tzPulseText { 50% { transform: translateX(-50%) scale(1.12); } }
