/* Touch / Game Boy pad + mobile race controls */
/* === GAMEBOY FIX v4 === */
body.desktop-ui #touchControls { display: none !important; }
/* live board shown on start; hidden in-race below */
body.touch-ui.in-race-controls { --gb-h: 120px; }
body.touch-ui.in-race-controls #game,
body.touch-ui.in-race-controls canvas#game {
  height: calc(100dvh - var(--gb-h)) !important;
  max-height: calc(100dvh - var(--gb-h)) !important;
  width: 100% !important;
}
body.touch-ui #touchControls {
  display: none !important;
  position: fixed !important;
  left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
  width: 100% !important; height: var(--gb-h, 120px) !important;
  z-index: 2147483000 !important;
  pointer-events: auto !important;
  background: #000 !important;
  border-top: 2px solid #222 !important;
  padding: 0 !important; margin: 0 !important; box-sizing: border-box !important;
}
body.touch-ui #touchControls.in-race { display: block !important; }
body.touch-ui #touchControls .gb-bar {
  width: 100% !important; height: 100% !important;
  display: flex !important; flex-direction: row !important;
  align-items: center !important; justify-content: space-between !important;
  padding: 8px 16px max(10px, env(safe-area-inset-bottom)) !important;
  box-sizing: border-box !important; background: #000 !important; pointer-events: auto !important;
}
body.touch-ui #touchControls .gb-pad {
  display: flex !important; flex-direction: row !important; gap: 12px !important; pointer-events: auto !important;
}
body.touch-ui #touchControls .gb-btn {
  pointer-events: auto !important; touch-action: none !important;
  -webkit-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  color: #fff !important; font-weight: 900 !important; font-family: system-ui, sans-serif !important;
  background: #222 !important; border: 3px solid #555 !important; box-shadow: 0 4px 0 #000 !important;
  margin: 0 !important; padding: 0 !important;
}
body.touch-ui #touchControls .gb-left,
body.touch-ui #touchControls .gb-right {
  width: 76px !important; height: 76px !important; border-radius: 14px !important; font-size: 28px !important;
}
body.touch-ui #touchControls .gb-go {
  width: 92px !important; height: 92px !important; border-radius: 50% !important; font-size: 32px !important;
  background: #333 !important; border: 4px solid #777 !important;
}
body.touch-ui #touchControls .gb-btn.is-pressed {
  transform: translateY(3px) !important; background: #0a7ad9 !important; box-shadow: 0 1px 0 #000 !important;
}
body.touch-ui #touchControls .gb-go.is-pressed { background: #c62828 !important; }

/* === TOP 10 visible before race (above start overlay) === */
.live-leaderboard {
  z-index: 25 !important;
  opacity: 1 !important;
  visibility: visible !important;
  color: #fff !important;
  background: rgba(0, 24, 58, 0.94) !important;
}
.live-leaderboard.hud-live,
body.desktop-ui .live-leaderboard,
body.touch-ui .live-leaderboard.hud-live {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  filter: none !important;
}
.live-leaderboard h3,
.live-leaderboard .lb-name,
.live-leaderboard .lb-num,
.live-leaderboard .lb-score,
.live-leaderboard li,
.live-leaderboard ol {
  opacity: 1 !important;
  color: #fff !important;
}
/* Keep it out of the way of the Game Boy bar while racing on phones */
body.touch-ui.in-race-controls .live-leaderboard {
  display: none !important;
}
/* === VIEW LEADERBOARD BTN + KEY ICONS === */
.btn-view-leaderboard {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  padding: 11px 12px;
  text-align: center;
  text-decoration: none !important;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #0b1f3a !important;
  background: #ffd400;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.btn-view-leaderboard:hover,
.btn-view-leaderboard:active {
  filter: brightness(1.05);
  color: #0b1f3a !important;
}
.live-leaderboard .btn-view-leaderboard {
  margin-top: 12px;
}
.side-key .btn-view-leaderboard--key {
  margin-top: 12px;
}

/* Bigger KEY icons */
.side-key .key-icon {
  width: 44px !important;
  height: 44px !important;
  border-radius: 10px !important;
  font-size: 20px !important;
}
.side-key .key-icon svg,
.key-icon svg {
  width: 34px !important;
  height: 34px !important;
}
.side-key .key-label {
  font-size: 13px !important;
}
.side-key .key-item {
  gap: 8px !important;
  align-items: center !important;
}

/* replaced by DESKTOP LB/KEY ALIGN */
/* === DESKTOP LB/KEY ALIGN === */
body.desktop-ui .live-leaderboard,
body.desktop-ui .side-key {
  width: 240px !important;
  max-width: 240px !important;
  box-sizing: border-box !important;
}
body.desktop-ui .live-leaderboard {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
  z-index: 30 !important;
  right: 12px !important;
  top: 12px !important;
  background: rgba(0, 24, 58, 0.96) !important;
}
body.desktop-ui .side-key {
  right: 12px !important;
  width: 240px !important;
  max-width: 240px !important;
}
/* Desktop: button under TOP 10 only */
body.desktop-ui .live-leaderboard .btn-view-leaderboard {
  display: block !important;
  margin-top: 12px !important;
}
body.desktop-ui .side-key .btn-view-leaderboard--key {
  display: none !important;
}
/* Mobile/touch: button under KEY only */
body.touch-ui .live-leaderboard .btn-view-leaderboard {
  display: none !important;
}
body.touch-ui .side-key .btn-view-leaderboard--key {
  display: block !important;
}
/* === DESKTOP RIGHT SIDEBAR === */
body.desktop-ui {
  --sidebar-w: 260px;
}
body.desktop-ui .desktop-sidebar {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: var(--sidebar-w) !important;
  z-index: 40 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom)) !important;
  box-sizing: border-box !important;
  background: rgba(4, 18, 40, 0.92) !important;
  border-left: 2px solid rgba(255,255,255,0.18) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  pointer-events: auto !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard {
  position: static !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
  background: rgba(0, 30, 70, 0.95) !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard ol {
  max-height: none !important;
  overflow: visible !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard li {
  padding: 5px 6px !important;
  font-size: 12px !important;
}
body.desktop-ui .btn-view-leaderboard--sidebar {
  display: block !important;
  width: 100% !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  padding: 12px 10px !important;
  text-align: center !important;
  text-decoration: none !important;
  font-weight: 900 !important;
  font-size: 13px !important;
  color: #0b1f3a !important;
  background: #ffd400 !important;
  border-radius: 12px !important;
  box-shadow: 0 3px 0 rgba(0,0,0,.3) !important;
}
body.desktop-ui .desktop-sidebar .side-key {
  position: static !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  overflow: visible !important;
  margin: 0 !important;
  flex: 1 1 auto !important;
}
body.desktop-ui .btn-view-leaderboard--key {
  display: none !important;
}

/* Push game + HUD left of sidebar */
body.desktop-ui .game-shell /*ok*/ {
  width: calc(100vw - var(--sidebar-w)) !important;
  max-width: calc(100vw - var(--sidebar-w)) !important;
  margin-right: var(--sidebar-w) !important;
}
body.desktop-ui #game,
body.desktop-ui canvas#game {
  width: calc(100vw - var(--sidebar-w)) !important;
  max-width: calc(100vw - var(--sidebar-w)) !important;
}
body.desktop-ui .hud {
  max-width: calc(100vw - var(--sidebar-w) - 24px) !important;
}
body.desktop-ui .screen-overlay, body.desktop-ui #startScreen, body.desktop-ui #gameOverScreen {
  width: calc(100vw - var(--sidebar-w)) !important;
  right: var(--sidebar-w) !important;
  left: 0 !important;
}

/* Mobile: sidebar is not a fixed column */
/* replaced: hide sidebar on touch */
body.touch-ui .btn-view-leaderboard--sidebar {
  display: none !important;
}
body.touch-ui .btn-view-leaderboard--key {
  display: block !important;
}
/* === DESKTOP SIDEBAR + START MODAL FIX === */
body.desktop-ui {
  --sidebar-w: 270px;
}
body.desktop-ui .desktop-sidebar {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: var(--sidebar-w) !important;
  z-index: 50 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 12px !important;
  box-sizing: border-box !important;
  background: #071a33 !important;
  border-left: 2px solid rgba(255,255,255,.2) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard {
  position: static !important;
  width: 100% !important;
  max-height: none !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard ol {
  max-height: none !important;
  overflow: visible !important;
}
body.desktop-ui .btn-view-leaderboard--sidebar {
  display: block !important;
  width: 100% !important;
  flex: 0 0 auto !important;
  text-align: center !important;
  padding: 12px 10px !important;
  font-weight: 900 !important;
  color: #0b1f3a !important;
  background: #ffd400 !important;
  border-radius: 12px !important;
  text-decoration: none !important;
}
body.desktop-ui .desktop-sidebar .side-key {
  position: static !important;
  width: 100% !important;
  max-height: none !important;
  overflow: visible !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
}
body.desktop-ui .btn-view-leaderboard--key { display: none !important; }

/* Game + start modal use left area only */
body.desktop-ui #game,
body.desktop-ui canvas#game {
  width: calc(100vw - var(--sidebar-w)) !important;
  max-width: calc(100vw - var(--sidebar-w)) !important;
}
body.desktop-ui #startScreen.screen-overlay,
body.desktop-ui #gameOverScreen.screen-overlay,
body.desktop-ui #settingsPanel {
  left: 0 !important;
  right: var(--sidebar-w) !important;
  width: auto !important;
  max-width: none !important;
}
body.desktop-ui #startScreen .start-panel,
body.desktop-ui #startScreen .panel {
  position: relative !important;
  z-index: 60 !important;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  margin: 4vh auto 0 !important;
  max-width: min(420px, calc(100vw - var(--sidebar-w) - 48px)) !important;
}

/* Mobile: don't use fixed sidebar */
/* replaced: hide sidebar on touch */
body.touch-ui .btn-view-leaderboard--sidebar { display: none !important; }
body.touch-ui .btn-view-leaderboard--key { display: block !important; }
/* === KEY FIT + MOBILE START EXTRAS === */
/* Desktop: compress TOP10 + KEY so all fit without clipping */
body.desktop-ui .desktop-sidebar {
  gap: 8px !important;
  padding: 10px 10px 8px !important;
  overflow-y: auto !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard {
  padding: 8px 8px 6px !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard h3 {
  font-size: 13px !important;
  margin: 0 0 4px !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard .lb-head {
  font-size: 10px !important;
  margin-bottom: 2px !important;
}
body.desktop-ui .desktop-sidebar .live-leaderboard li {
  padding: 2px 4px !important;
  font-size: 11px !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
}
body.desktop-ui .btn-view-leaderboard--sidebar {
  padding: 10px 8px !important;
  font-size: 12px !important;
  margin: 0 !important;
}
body.desktop-ui .desktop-sidebar .side-key,
body.desktop-ui .desktop-sidebar .game-key {
  padding: 8px !important;
  max-height: none !important;
  overflow: visible !important;
}
body.desktop-ui .desktop-sidebar .game-key > strong {
  font-size: 12px !important;
  margin: 0 0 6px !important;
}
body.desktop-ui .desktop-sidebar .key-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 6px !important;
}
body.desktop-ui .desktop-sidebar .key-item {
  gap: 6px !important;
  align-items: center !important;
}
body.desktop-ui .desktop-sidebar .key-icon {
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px !important;
}
body.desktop-ui .desktop-sidebar .key-icon svg {
  width: 22px !important;
  height: 22px !important;
}
body.desktop-ui .desktop-sidebar .key-label {
  font-size: 10px !important;
  line-height: 1.15 !important;
}

/* Mobile start: show KEY + button under the start card */
.mobile-start-extras {
  display: none;
}
body.touch-ui #startScreen.visible .mobile-start-extras,
body.touch-ui #startScreen.screen-overlay.visible .mobile-start-extras {
  display: block !important;
  width: min(420px, calc(100vw - 24px)) !important;
  margin: 10px auto 16px !important;
  position: relative !important;
  z-index: 70 !important;
}
body.touch-ui .mobile-start-extras .side-key {
  display: block !important;
  position: static !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
  background: rgba(0, 24, 58, 0.94) !important;
  border-radius: 14px !important;
  padding: 12px !important;
}
body.touch-ui .mobile-start-extras .btn-view-leaderboard--key {
  display: block !important;
  width: 100% !important;
  margin-top: 10px !important;
  padding: 14px 12px !important;
  text-align: center !important;
  font-weight: 900 !important;
  font-size: 15px !important;
  color: #0b1f3a !important;
  background: #ffd400 !important;
  border-radius: 12px !important;
  text-decoration: none !important;
}
body.touch-ui #startScreen.visible {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  align-items: flex-start !important;
  padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
}
/* Hide the desktop sidebar copies of KEY/TOP10 on phones (keep TOP10 for race CSS as before) */
body.touch-ui .desktop-sidebar > .live-leaderboard,
body.touch-ui .desktop-sidebar > .btn-view-leaderboard--sidebar,
body.touch-ui .desktop-sidebar > .side-key {
  display: none !important;
}
body.desktop-ui .mobile-start-extras {
  display: none !important;
}
/* === MOBILE START ORDER FIX === */
/* Never let the desktop sidebar leak into the mobile start layout */
body.touch-ui .desktop-sidebar {
  display: none !important;
}

body.touch-ui #startScreen.visible {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: center !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 12px 12px max(20px, env(safe-area-inset-bottom)) !important;
}

body.touch-ui #startScreen .panel,
body.touch-ui #startScreen .start-panel {
  order: 1 !important;
  position: relative !important;
  width: min(420px, 100%) !important;
  margin: 0 auto 12px !important;
  flex: 0 0 auto !important;
}

body.touch-ui #startScreen .mobile-start-extras {
  order: 2 !important;
  display: block !important;
  width: min(420px, 100%) !important;
  margin: 0 auto 16px !important;
  position: relative !important;
  z-index: 5 !important;
}

body.touch-ui #startScreen .mobile-start-extras .side-key {
  display: block !important;
  position: static !important;
  width: 100% !important;
  margin: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

body.touch-ui #startScreen .mobile-start-extras .btn-view-leaderboard--key {
  display: block !important;
  width: 100% !important;
  margin-top: 10px !important;
}

body.desktop-ui .mobile-start-extras {
  display: none !important;
}
/* === MOBILE START COMPACT FIT === */
body.touch-ui #startScreen.visible {
  padding: 6px 10px max(8px, env(safe-area-inset-bottom)) !important;
  gap: 8px !important;
  justify-content: flex-start !important;
}
body.touch-ui #startScreen .panel,
body.touch-ui #startScreen .start-panel {
  margin: 0 auto !important;
  padding: 10px 12px 8px !important;
  width: min(420px, 100%) !important;
  gap: 6px !important;
}
body.touch-ui #startScreen .start-logo {
  width: min(160px, 42vw) !important;
  max-height: 72px !important;
  object-fit: contain !important;
  margin: 0 auto 2px !important;
}
body.touch-ui #startScreen h1 {
  display: none !important; /* logo already carries the title */
}
body.touch-ui #startScreen .subtitle {
  margin: 0 0 6px !important;
  font-size: 12px !important;
  line-height: 1.2 !important;
}
body.touch-ui #startScreen .setup-grid,
body.touch-ui #startScreen .setup-row {
  gap: 6px !important;
  margin: 0 0 6px !important;
}
body.touch-ui #startScreen label {
  font-size: 11px !important;
  margin: 0 !important;
  gap: 2px !important;
}
body.touch-ui #startScreen input {
  padding: 8px 10px !important;
  font-size: 14px !important;
  min-height: 36px !important;
}
body.touch-ui #startScreen #startGame,
body.touch-ui #startScreen button#startGame {
  margin: 4px 0 6px !important;
  padding: 11px 12px !important;
  font-size: 15px !important;
}
body.touch-ui #startScreen .controls-block {
  margin: 0 !important;
  padding: 6px 8px !important;
}
body.touch-ui #startScreen .controls-title {
  display: none !important;
}
body.touch-ui #startScreen .controls-hint {
  margin: 0 !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
}
body.touch-ui #startScreen .controls-hint:not(.touch-only-hint) {
  display: none !important; /* desktop key hints off on phone */
}
body.touch-ui #startScreen .mobile-start-extras {
  margin: 0 auto !important;
  width: min(420px, 100%) !important;
}
body.touch-ui #startScreen .mobile-start-extras .side-key,
body.touch-ui #startScreen .mobile-start-extras .game-key {
  padding: 8px 10px !important;
  margin: 0 !important;
}
body.touch-ui #startScreen .mobile-start-extras .game-key > strong {
  font-size: 11px !important;
  margin: 0 0 4px !important;
}
body.touch-ui #startScreen .mobile-start-extras .key-grid {
  grid-template-columns: 1fr 1fr !important;
  gap: 4px 8px !important;
}
body.touch-ui #startScreen .mobile-start-extras .key-item {
  gap: 6px !important;
  min-height: 0 !important;
}
body.touch-ui #startScreen .mobile-start-extras .key-icon {
  width: 26px !important;
  height: 26px !important;
}
body.touch-ui #startScreen .mobile-start-extras .key-icon svg {
  width: 20px !important;
  height: 20px !important;
}
body.touch-ui #startScreen .mobile-start-extras .key-label {
  font-size: 10px !important;
  line-height: 1.15 !important;
}
body.touch-ui #startScreen .mobile-start-extras .btn-view-leaderboard--key {
  margin-top: 8px !important;
  padding: 10px 12px !important;
  font-size: 13px !important;
}
/* === MOBILE START HIDE ON PLAY === */
body.touch-ui #startScreen:not(.visible),
body.touch-ui #startScreen:not(.visible) .mobile-start-extras,
body.touch-ui #startScreen:not(.visible) .side-key,
body.touch-ui #startScreen:not(.visible) .panel {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}
body.touch-ui #startScreen.visible {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 40 !important;
}
body.touch-ui #startScreen:not(.visible) {
  display: none !important;
}

/* ============================================================
   === PORTRAIT PLAY + GB DECK v1 ===
   Consistent phone-like play column; Pet Farm–style controller.
   Appended overrides — !important where old rules fight.
   ============================================================ */

:root {
  --play-w: min(420px, 100vw, calc(100dvh * 0.5625));
  --gb-deck-h: 0px;
  --gb-purple-1: #2a2347;
  --gb-purple-2: #17132a;
  --gb-pad: #4a4170;
  --gb-pad-deep: #352e55;
  --gb-arrow: #c9bfff;
}

/* --- Portrait play column (all devices) --- */
.game-shell {
  display: flex !important;
  justify-content: center !important;
  align-items: stretch !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  margin: 0 !important;
  background: #063a66 !important; /* letterbox beside play column */
}

.play-col {
  position: relative !important;
  width: var(--play-w) !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  flex: 0 0 auto !important;
  margin: 0 auto !important;
  overflow: hidden !important;
  background: #0c87d5 !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 12px 40px rgba(0,0,0,0.35);
}

body.desktop-ui .play-col {
  /* Phone-like portrait width, centred; sidebar no longer steals canvas width */
  width: min(420px, 100vw, calc(100dvh * 0.5625)) !important;
  height: 100dvh !important;
}

body.touch-ui .play-col {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  box-shadow: none !important;
}

body.touch-ui.in-race-controls .play-col {
  height: calc(100dvh - var(--gb-deck-h, 168px)) !important;
  max-height: calc(100dvh - var(--gb-deck-h, 168px)) !important;
}

/* Canvas fills the play column only */
body.desktop-ui #game,
body.desktop-ui canvas#game,
body.touch-ui #game,
body.touch-ui canvas#game,
.play-col #game,
.play-col canvas#game {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  display: block !important;
}

/* Kill old “push game left of sidebar” width math */
body.desktop-ui .game-shell {
  width: 100vw !important;
  max-width: 100vw !important;
  margin-right: 0 !important;
}
body.desktop-ui #game,
body.desktop-ui canvas#game {
  width: 100% !important;
  max-width: none !important;
}

/* HUD inside play column */
.play-col .hud {
  position: absolute !important;
  top: 10px !important;
  left: 10px !important;
  right: 10px !important;
  max-width: none !important;
  z-index: 5 !important;
}

/* Overlays cover the centred play column on desktop */
body.desktop-ui #startScreen.screen-overlay,
body.desktop-ui #gameOverScreen.screen-overlay,
body.desktop-ui #settingsPanel {
  left: 50% !important;
  right: auto !important;
  width: var(--play-w) !important;
  max-width: 100vw !important;
  transform: translateX(-50%) !important;
}
body.desktop-ui #startScreen .start-panel,
body.desktop-ui #startScreen .panel {
  max-width: min(420px, calc(100% - 24px)) !important;
  margin: 4vh auto 0 !important;
}

/* --- Collapsible TOP 10 / KEY panel (desktop) --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 60;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  background: rgba(7, 26, 51, 0.92);
  color: #fff;
  font-family: "Montserrat", system-ui, sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
  pointer-events: auto;
}
.sidebar-toggle i { color: #ffd400; }
body.desktop-ui .sidebar-toggle {
  display: inline-flex !important;
}
body.touch-ui .sidebar-toggle {
  display: none !important;
}

body.desktop-ui .desktop-sidebar {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: min(300px, 92vw) !important;
  z-index: 55 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 56px 12px 12px !important;
  box-sizing: border-box !important;
  background: rgba(7, 26, 51, 0.97) !important;
  border-left: 2px solid rgba(255,255,255,0.18) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(105%) !important;
  transition: transform 0.22s ease !important;
  pointer-events: auto !important;
  box-shadow: -12px 0 40px rgba(0,0,0,0.35) !important;
}
body.desktop-ui.sidebar-open .desktop-sidebar {
  transform: translateX(0) !important;
}
body.desktop-ui.sidebar-open .sidebar-toggle {
  background: #0c87d5 !important;
  border-color: rgba(255,255,255,0.55) !important;
}

/* Keep inner sidebar content usable when open */
body.desktop-ui .desktop-sidebar .live-leaderboard {
  position: static !important;
  width: 100% !important;
  max-height: none !important;
  overflow: visible !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}
body.desktop-ui .desktop-sidebar .side-key {
  position: static !important;
  width: 100% !important;
  display: block !important;
}
body.desktop-ui .btn-view-leaderboard--sidebar {
  display: block !important;
}

/* --- Pet Farm–style Game Boy deck (touch / in-race only) --- */
body.desktop-ui #touchControls {
  display: none !important;
}

body.touch-ui #touchControls {
  display: none !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  z-index: 2147483000 !important;
  pointer-events: auto !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}
body.touch-ui #touchControls.in-race {
  display: block !important;
}

body.touch-ui #touchControls .gb-deck {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  grid-template-rows: 1fr auto !important;
  width: 100% !important;
  min-height: 150px !important;
  padding: 8px calc(env(safe-area-inset-right) + 4vw) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 4vw) !important;
  box-sizing: border-box !important;
  background: linear-gradient(180deg, var(--gb-purple-1), var(--gb-purple-2)) !important;
  border-top: 1px solid rgba(255,255,255,0.12) !important;
  pointer-events: auto !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
}

body.touch-ui #touchControls .gb-padL {
  grid-column: 1 !important;
  grid-row: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 0 !important;
}
body.touch-ui #touchControls .gb-padR {
  grid-column: 2 !important;
  grid-row: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 0 !important;
}
body.touch-ui #touchControls .gb-padM {
  grid-column: 1 / 3 !important;
  grid-row: 2 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 14px !important;
  padding-top: 4px !important;
  pointer-events: none !important;
}

/* Cross D-pad */
body.touch-ui #touchControls .gb-dpad {
  --s: min(15vw, 11vh, 68px);
  display: grid !important;
  grid-template: repeat(3, var(--s)) / repeat(3, var(--s)) !important;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45));
  pointer-events: auto !important;
}
body.touch-ui #touchControls .gb-dpad .d {
  background: linear-gradient(var(--gb-pad), var(--gb-pad-deep)) !important;
  border: none !important;
  position: relative !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  margin: 0 !important;
  padding: 0 !important;
  color: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  width: auto !important;
  height: auto !important;
  font-size: 0 !important;
}
body.touch-ui #touchControls .gb-dpad .d i {
  position: absolute !important;
  inset: 0 !important;
  margin: auto !important;
  width: 0 !important;
  height: 0 !important;
  border: calc(var(--s) * 0.11) solid transparent !important;
  pointer-events: none !important;
}
body.touch-ui #touchControls .gb-dpad .up {
  grid-area: 1 / 2 !important;
  border-radius: 14px 14px 0 0 !important;
}
body.touch-ui #touchControls .gb-dpad .up i {
  border-bottom-color: var(--gb-arrow) !important;
  border-top: 0 !important;
  top: -8% !important;
}
body.touch-ui #touchControls .gb-dpad .down {
  grid-area: 3 / 2 !important;
  border-radius: 0 0 14px 14px !important;
}
body.touch-ui #touchControls .gb-dpad .down i {
  border-top-color: var(--gb-arrow) !important;
  border-bottom: 0 !important;
  top: 8% !important;
}
body.touch-ui #touchControls .gb-dpad .left {
  grid-area: 2 / 1 !important;
  border-radius: 14px 0 0 14px !important;
}
body.touch-ui #touchControls .gb-dpad .left i {
  border-right-color: var(--gb-arrow) !important;
  border-left: 0 !important;
  left: -8% !important;
}
body.touch-ui #touchControls .gb-dpad .right {
  grid-area: 2 / 3 !important;
  border-radius: 0 14px 14px 0 !important;
}
body.touch-ui #touchControls .gb-dpad .right i {
  border-left-color: var(--gb-arrow) !important;
  border-right: 0 !important;
  left: 8% !important;
}
body.touch-ui #touchControls .gb-dpad .mid {
  grid-area: 2 / 2 !important;
  background: var(--gb-pad-deep) !important;
  pointer-events: none !important;
}
body.touch-ui #touchControls .gb-dpad .mid::after {
  content: "" !important;
  position: absolute !important;
  inset: 30% !important;
  border-radius: 50% !important;
  background: var(--gb-purple-1) !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

/* A / B cluster (tilted like Pet Farm) */
body.touch-ui #touchControls .gb-ab {
  --b: min(14vw, 11vh, 68px);
  display: flex !important;
  gap: calc(var(--b) * 0.22) !important;
  transform: rotate(-18deg) !important;
  pointer-events: auto !important;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.4));
}
body.touch-ui #touchControls .gb-ab .btn {
  width: var(--b) !important;
  height: var(--b) !important;
  border-radius: 50% !important;
  border: none !important;
  color: #fff !important;
  font-weight: 900 !important;
  font-size: calc(var(--b) * 0.34) !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 -6px 10px rgba(0,0,0,0.2), inset 0 4px 8px rgba(255,255,255,0.3) !important;
}
body.touch-ui #touchControls .gb-ab .btn.a {
  background: radial-gradient(circle at 35% 30%, #ff8fb5, #ff3d7f 60%, #c21f5c) !important;
}
body.touch-ui #touchControls .gb-ab .btn.b {
  background: radial-gradient(circle at 35% 30%, #a9a0ff, #7a68f0 60%, #4c3cbc) !important;
  margin-top: calc(var(--b) * 0.55) !important;
}

body.touch-ui #touchControls .gb-logo {
  color: #cfc6ff !important;
  text-shadow: 0 1px 0 rgba(0,0,0,0.65), 0 -1px 0 rgba(255,255,255,0.2);
  font-weight: 900 !important;
  font-style: italic !important;
  letter-spacing: 2px !important;
  font-size: 12px !important;
}
body.touch-ui #touchControls .gb-pills {
  display: flex !important;
  gap: 8px !important;
}
body.touch-ui #touchControls .gb-pill {
  background: #5a4f8f !important;
  color: #fff !important;
  border-radius: 999px !important;
  padding: 6px 12px !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

/* Pressed states */
body.touch-ui #touchControls .d.is-pressed,
body.touch-ui #touchControls .btn.is-pressed {
  filter: brightness(1.25) !important;
  transform: translateY(3px) !important;
}
body.touch-ui #touchControls .gb-ab .btn.is-pressed {
  box-shadow: 0 2px 0 rgba(0,0,0,0.4), inset 0 -4px 8px rgba(0,0,0,0.2) !important;
  transform: translateY(3px) !important;
}
/* Keep A/B tilt while pressed */
body.touch-ui #touchControls .gb-ab .btn.a.is-pressed,
body.touch-ui #touchControls .gb-ab .btn.b.is-pressed {
  /* parent already rotated; only nudge */
}

/* Hide legacy flat bar bits if any linger */
body.touch-ui #touchControls .gb-bar,
body.touch-ui #touchControls .gb-pad,
body.touch-ui #touchControls .gb-btn {
  /* superseded by .gb-deck — keep harmless if missing */
}

/* Override old fixed 120px Game Boy bar height */
body.touch-ui.in-race-controls {
  --gb-h: var(--gb-deck-h, 168px) !important;
}
body.touch-ui.in-race-controls #game,
body.touch-ui.in-race-controls canvas#game {
  height: 100% !important;
  max-height: none !important;
  width: 100% !important;
}

/* Short phones: slightly tighter deck */
@media (max-height: 700px) and (orientation: portrait) {
  body.touch-ui #touchControls .gb-dpad { --s: min(13vw, 10vh, 58px); }
  body.touch-ui #touchControls .gb-ab { --b: min(12vw, 10vh, 58px); }
  body.touch-ui #touchControls .gb-deck { min-height: 132px !important; padding-top: 6px !important; }
}

/* Landscape phones: still show deck under play column */
@media (orientation: landscape) and (max-height: 500px) {
  body.touch-ui #touchControls .gb-dpad { --s: min(8vw, 14vh, 48px); }
  body.touch-ui #touchControls .gb-ab { --b: min(9vw, 16vh, 52px); }
  body.touch-ui #touchControls .gb-logo { font-size: 10px !important; }
  body.touch-ui #touchControls .gb-pills { display: none !important; }
}

/* Samsung / forced dark mode colour lock */
body.touch-ui #touchControls .gb-deck,
body.touch-ui #touchControls .gb-dpad .d,
body.touch-ui #touchControls .gb-ab .btn {
  color-scheme: only light;
}


/* ============================================================
   === PET FARM PAD ALIGN v2 ===
   Exact pad from /workspace/pet-game/ (pocket-pal): #deck layout,
   colours, sizes, pressed states, light-scheme lock.
   ============================================================ */

/* Letterbox beside portrait column — Pet Farm shell tone on touch */
body.touch-ui .game-shell {
  background: #1d1830 !important;
}
body.desktop-ui .game-shell {
  background: #1d1830 !important;
}
body.desktop-ui .play-col {
  background: #0c87d5 !important;
}

/* Hide pad on desktop (already desktop-ui) */
body.desktop-ui #touchControls,
body.desktop-ui #deck {
  display: none !important;
}

body.touch-ui #touchControls.in-race #deck,
body.touch-ui #touchControls.in-race .gb-deck {
  display: grid !important;
}

/* Deck shell — Pet Farm #deck */
body.touch-ui #deck,
body.touch-ui #touchControls .gb-deck {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  grid-template-rows: 1fr auto !important;
  min-height: 0 !important;
  width: 100% !important;
  background: linear-gradient(180deg, #2a2347, #17132a) !important;
  border-top: 1px solid rgba(255,255,255,0.1) !important;
  padding: 6px calc(env(safe-area-inset-right) + 6vw) calc(env(safe-area-inset-bottom) + 8px) calc(env(safe-area-inset-left) + 6vw) !important;
  box-sizing: border-box !important;
  color-scheme: only light !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  forced-color-adjust: none !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
}

body.touch-ui #deck .zone,
body.touch-ui #padL,
body.touch-ui #padR,
body.touch-ui #padM {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 0 !important;
}
body.touch-ui #padL { grid-column: 1 !important; grid-row: 1 !important; }
body.touch-ui #padR { grid-column: 2 !important; grid-row: 1 !important; }
body.touch-ui #padM {
  grid-column: 1 / 3 !important;
  grid-row: 2 !important;
  gap: 18px !important;
  padding-top: 6px !important;
}

/* D-pad — Pet Farm #dpad */
body.touch-ui #dpad {
  --s: min(15vw, 11vh, 72px) !important;
  display: grid !important;
  grid-template: repeat(3, var(--s)) / repeat(3, var(--s)) !important;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45)) !important;
  touch-action: none !important;
}
body.touch-ui #dpad .d {
  background: linear-gradient(#4a4170, #352e55) !important;
  border: none !important;
  position: relative !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  margin: 0 !important;
  padding: 0 !important;
  color: transparent !important;
  box-shadow: none !important;
  width: auto !important;
  height: auto !important;
  font-size: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  forced-color-adjust: none !important;
  color-scheme: only light !important;
}
body.touch-ui #dpad .d i {
  position: absolute !important;
  inset: 0 !important;
  margin: auto !important;
  width: 0 !important;
  height: 0 !important;
  border: calc(var(--s) * 0.11) solid transparent !important;
  pointer-events: none !important;
}
body.touch-ui #dpad .up { grid-area: 1 / 2 !important; border-radius: 16px 16px 0 0 !important; }
body.touch-ui #dpad .up i { border-bottom-color: #c9bfff !important; border-top: 0 !important; top: -8% !important; }
body.touch-ui #dpad .down { grid-area: 3 / 2 !important; border-radius: 0 0 16px 16px !important; }
body.touch-ui #dpad .down i { border-top-color: #c9bfff !important; border-bottom: 0 !important; top: 8% !important; }
body.touch-ui #dpad .left { grid-area: 2 / 1 !important; border-radius: 16px 0 0 16px !important; }
body.touch-ui #dpad .left i { border-right-color: #c9bfff !important; border-left: 0 !important; left: -8% !important; }
body.touch-ui #dpad .right { grid-area: 2 / 3 !important; border-radius: 0 16px 16px 0 !important; }
body.touch-ui #dpad .right i { border-left-color: #c9bfff !important; border-right: 0 !important; left: 8% !important; }
body.touch-ui #dpad .mid {
  grid-area: 2 / 2 !important;
  background: #352e55 !important;
  pointer-events: none !important;
}
body.touch-ui #dpad .mid::after {
  content: "" !important;
  position: absolute !important;
  inset: 30% !important;
  border-radius: 50% !important;
  background: #2a2347 !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4) !important;
}

/* A/B — Pet Farm #ab */
body.touch-ui #ab {
  --b: min(14vw, 11vh, 72px) !important;
  display: flex !important;
  gap: calc(var(--b) * 0.22) !important;
  transform: rotate(-18deg) !important;
  touch-action: none !important;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.4)) !important;
}
body.touch-ui #ab .btn {
  width: var(--b) !important;
  height: var(--b) !important;
  border-radius: 50% !important;
  border: none !important;
  color: #fff !important;
  font-weight: 900 !important;
  font-size: calc(var(--b) * 0.34) !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  forced-color-adjust: none !important;
  color-scheme: only light !important;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 -6px 10px rgba(0,0,0,0.2), inset 0 4px 8px rgba(255,255,255,0.3) !important;
}
body.touch-ui #ab .btn.a {
  background: radial-gradient(circle at 35% 30%, #ff8fb5, #ff3d7f 60%, #c21f5c) !important;
}
body.touch-ui #ab .btn.b {
  background: radial-gradient(circle at 35% 30%, #a9a0ff, #7a68f0 60%, #4c3cbc) !important;
  margin-top: calc(var(--b) * 0.55) !important;
}

/* Centre pills + logo */
body.touch-ui #padM .pill {
  background: #5a4f8f !important;
  color: #fff !important;
  min-height: 44px !important;
  border: none !important;
  border-radius: 999px !important;
  padding: 12px 20px !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
  box-shadow: 0 3px 0 rgba(0,0,0,0.4) !important;
  touch-action: none !important;
  min-width: 84px !important;
  pointer-events: none !important; /* decorative for Slip & Slide */
  forced-color-adjust: none !important;
  color-scheme: only light !important;
  font-family: "Montserrat", system-ui, sans-serif !important;
}
body.touch-ui #padM .logo {
  color: #cfc6ff !important;
  text-shadow: 0 1px 0 rgba(0,0,0,0.65), 0 -1px 0 rgba(255,255,255,0.2) !important;
  font-weight: 900 !important;
  font-style: italic !important;
  letter-spacing: 2px !important;
  font-size: 13px !important;
  pointer-events: none !important;
}

/* Pressed — Pet Farm brightness + translateY(3px) */
body.touch-ui #deck button:active,
body.touch-ui #deck .pressed,
body.touch-ui #deck .is-pressed {
  filter: brightness(1.25) !important;
  transform: translateY(3px) !important;
}
body.touch-ui #ab .btn.pressed,
body.touch-ui #ab .btn.is-pressed {
  box-shadow: 0 2px 0 rgba(0,0,0,0.4), inset 0 -4px 8px rgba(0,0,0,0.2) !important;
  /* keep cluster tilt; nudge only the button */
  transform: translateY(3px) !important;
}

/* Measure target for resizeCanvas */
body.touch-ui.in-race-controls {
  --gb-deck-h: var(--gb-deck-h, 168px);
}

@media (max-height: 640px) and (orientation: portrait) {
  body.touch-ui #dpad { --s: min(13vw, 10vh, 60px) !important; }
  body.touch-ui #ab { --b: min(12vw, 10vh, 60px) !important; }
  body.touch-ui #padM .pill { min-height: 36px !important; padding: 8px 14px !important; font-size: 11px !important; min-width: 70px !important; }
  body.touch-ui #padM .logo { font-size: 11px !important; }
}
@media (orientation: landscape) and (max-height: 480px) {
  body.touch-ui #dpad { --s: min(7vw, 16vh, 56px) !important; }
  body.touch-ui #ab { --b: min(8vw, 18vh, 60px) !important; }
  body.touch-ui #padM .logo { display: none !important; }
  body.touch-ui #padM .pill { min-height: 34px !important; padding: 6px 10px !important; font-size: 10px !important; min-width: 64px !important; }
}


/* === FORCE PAD PREVIEW (desktop testing + always-on touch) === */
html.force-pad body #touchControls.in-race,
html.force-pad body #touchControls {
  /* shown when JS adds .in-race; force-pad only unlocks desktop hide */
}
html.force-pad body.desktop-ui #touchControls.in-race {
  display: block !important;
}
html.force-pad body.desktop-ui #deck,
html.force-pad body.desktop-ui #touchControls .gb-deck {
  display: grid !important;
}


/* ============================================================
   === CSS PAD v2 + phone-width play + desktop landscape ===
   Premium on-brand controller; HUD reserved above play;
   desktop uses the same 390px slide width with side panels.
   ============================================================ */

:root {
  --play-w: 390px;
  --css-navy: #17324d;
  --css-navy-deep: #102536;
  --css-orange: #ef863d;
  --css-blue: #3270b7;
  --css-sky: #4db7ea;
}

.play-col {
  display: flex !important;
  flex-direction: column !important;
}

.play-col .hud {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 6px 10px !important;
  background: rgba(23, 50, 77, 0.96) !important;
  color: #fff !important;
  border: 0 !important;
  border-bottom: 3px solid #ef863d !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  z-index: 6 !important;
  font-family: "League Spartan", "Montserrat", system-ui, sans-serif !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  letter-spacing: 0.04em !important;
}

.play-col .hud .game-brand {
  width: 100% !important;
  font-family: "Luckiest Guy", cursive !important;
  font-size: 15px !important;
  letter-spacing: 0.08em !important;
  color: #ffd24d !important;
  line-height: 1.1 !important;
}

.play-col #game,
.play-col canvas#game {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: auto !important;
}

/* --- Premium mobile controller --- */
body.desktop-ui #touchControls {
  display: none !important;
}

body.touch-ui #touchControls {
  display: none !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  z-index: 2147483000 !important;
  pointer-events: auto !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  touch-action: none !important;
}

body.touch-ui #touchControls.in-race {
  display: block !important;
}

body.touch-ui #touchControls .css-pad-deck,
body.touch-ui #touchControls #deck {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px !important;
  width: 100% !important;
  min-height: 0 !important;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  box-sizing: border-box !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent 32%),
    linear-gradient(180deg, #234e73 0%, #17324d 52%, #102536 100%) !important;
  border-top: 4px solid #ef863d !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 -10px 28px rgba(0,0,0,0.35) !important;
  pointer-events: auto !important;
  font-family: "League Spartan", "Montserrat", system-ui, sans-serif !important;
}

body.touch-ui #touchControls .css-pad-steer,
body.touch-ui #touchControls .css-pad-actions {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  pointer-events: auto !important;
}

body.touch-ui #touchControls .css-pad-dir,
body.touch-ui #touchControls .css-pad-act {
  pointer-events: auto !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  appearance: none !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  color: #fff !important;
  border: 0 !important;
  cursor: pointer !important;
}

body.touch-ui #touchControls .css-pad-dir {
  width: 78px !important;
  height: 86px !important;
  min-width: 78px !important;
  min-height: 86px !important;
  padding: 8px 6px !important;
  border-radius: 22px !important;
  background:
    linear-gradient(180deg, #6ec8f2 0%, #3a95d6 48%, #2a6eae 100%) !important;
  box-shadow:
    0 7px 0 #16324f,
    0 12px 16px rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.38),
    inset 0 -4px 8px rgba(0,30,60,0.25) !important;
}

body.touch-ui #touchControls .css-pad-dir .css-pad-arrow {
  width: 34px !important;
  height: 34px !important;
  display: block !important;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.25));
}

body.touch-ui #touchControls .css-pad-dir-label,
body.touch-ui #touchControls .css-pad-act-name {
  font-family: "League Spartan", "Montserrat", system-ui, sans-serif !important;
  font-weight: 800 !important;
  letter-spacing: 0.08em !important;
  line-height: 1 !important;
  pointer-events: none !important;
}

body.touch-ui #touchControls .css-pad-dir-label {
  font-size: 11px !important;
  margin-top: 2px !important;
}

body.touch-ui #touchControls .css-pad-brake {
  width: 72px !important;
  height: 72px !important;
  min-width: 72px !important;
  min-height: 72px !important;
  border-radius: 50% !important;
  background:
    radial-gradient(circle at 32% 28%, #8fd4f6, #3270b7 58%, #1d4e86) !important;
  box-shadow:
    0 7px 0 #14345a,
    0 12px 16px rgba(0,0,0,0.3),
    inset 0 3px 0 rgba(255,255,255,0.4),
    inset 0 -5px 8px rgba(0,20,50,0.28) !important;
}

body.touch-ui #touchControls .css-pad-slide {
  width: 96px !important;
  height: 96px !important;
  min-width: 96px !important;
  min-height: 96px !important;
  border-radius: 50% !important;
  background:
    radial-gradient(circle at 32% 28%, #ffc48a, #ef863d 55%, #d15e18) !important;
  box-shadow:
    0 8px 0 #a84812,
    0 14px 18px rgba(0,0,0,0.32),
    inset 0 4px 0 rgba(255,255,255,0.42),
    inset 0 -6px 10px rgba(120,40,0,0.28) !important;
}

body.touch-ui #touchControls .css-pad-brake .css-pad-act-name {
  font-size: 13px !important;
}

body.touch-ui #touchControls .css-pad-slide .css-pad-act-name {
  font-family: "Luckiest Guy", cursive !important;
  font-size: 20px !important;
  letter-spacing: 0.06em !important;
  text-shadow: 0 2px 0 rgba(120,40,0,0.35) !important;
}

body.touch-ui #touchControls .css-pad-dir.is-pressed,
body.touch-ui #touchControls .css-pad-dir.pressed {
  transform: translateY(5px) !important;
  filter: brightness(1.08) !important;
  box-shadow:
    0 2px 0 #16324f,
    0 4px 8px rgba(0,0,0,0.28),
    inset 0 2px 6px rgba(0,20,40,0.28) !important;
}

body.touch-ui #touchControls .css-pad-brake.is-pressed,
body.touch-ui #touchControls .css-pad-brake.pressed {
  transform: translateY(5px) !important;
  box-shadow:
    0 2px 0 #14345a,
    0 4px 8px rgba(0,0,0,0.28),
    inset 0 2px 6px rgba(0,20,40,0.3) !important;
}

body.touch-ui #touchControls .css-pad-slide.is-pressed,
body.touch-ui #touchControls .css-pad-slide.pressed {
  transform: translateY(6px) !important;
  filter: brightness(1.06) !important;
  box-shadow:
    0 2px 0 #a84812,
    0 5px 8px rgba(0,0,0,0.28),
    inset 0 2px 6px rgba(100,30,0,0.3) !important;
}

@media (max-width: 360px) {
  body.touch-ui #touchControls .css-pad-dir { width: 68px !important; height: 76px !important; min-width: 68px !important; min-height: 76px !important; }
  body.touch-ui #touchControls .css-pad-brake { width: 64px !important; height: 64px !important; min-width: 64px !important; min-height: 64px !important; }
  body.touch-ui #touchControls .css-pad-slide { width: 84px !important; height: 84px !important; min-width: 84px !important; min-height: 84px !important; }
  body.touch-ui #touchControls .css-pad-slide .css-pad-act-name { font-size: 17px !important; }
}

@media (max-height: 700px) and (orientation: portrait) {
  body.touch-ui #touchControls .css-pad-deck,
  body.touch-ui #touchControls #deck { padding-top: 10px !important; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important; }
  body.touch-ui #touchControls .css-pad-dir { width: 70px !important; height: 76px !important; min-width: 70px !important; min-height: 76px !important; }
  body.touch-ui #touchControls .css-pad-slide { width: 86px !important; height: 86px !important; min-width: 86px !important; min-height: 86px !important; }
}

@media (orientation: landscape) and (max-height: 500px) {
  body.touch-ui #touchControls .css-pad-deck,
  body.touch-ui #touchControls #deck { padding: 8px 18px calc(6px + env(safe-area-inset-bottom, 0px)) !important; }
  body.touch-ui #touchControls .css-pad-dir { width: 64px !important; height: 58px !important; min-width: 64px !important; min-height: 58px !important; flex-direction: row !important; gap: 6px !important; }
  body.touch-ui #touchControls .css-pad-dir-label { display: none !important; }
  body.touch-ui #touchControls .css-pad-brake { width: 58px !important; height: 58px !important; min-width: 58px !important; min-height: 58px !important; }
  body.touch-ui #touchControls .css-pad-slide { width: 70px !important; height: 70px !important; min-width: 70px !important; min-height: 70px !important; }
  body.touch-ui #touchControls .css-pad-slide .css-pad-act-name { font-size: 15px !important; }
}

