:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --panel: rgba(8, 18, 13, 0.7);
  --accent: #ffd166;
  --green: #75c46b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 28% 16%, rgba(255, 210, 111, 0.28), transparent 24%),
    linear-gradient(180deg, #7fc1f7 0%, #14301f 100%);
}

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

#game-root {
  position: relative;
  isolation: isolate;
}

.sun-glow,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px 24px;
  background:
    linear-gradient(180deg, rgba(5, 12, 8, 0.08), rgba(5, 12, 8, 0.7)),
    url("./newtitile.png") center / cover no-repeat,
    radial-gradient(circle at 50% 35%, rgba(255, 209, 102, 0.24), transparent 26%),
    linear-gradient(180deg, rgba(5, 12, 8, 0.62), rgba(5, 12, 8, 0.88));
  backdrop-filter: blur(8px) saturate(125%);
  transition: opacity 240ms ease, visibility 240ms ease;
}

.pause-menu {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 6, 0.48);
  backdrop-filter: blur(6px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.pause-menu.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pause-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)),
    rgba(8, 18, 13, 0.88);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  text-align: center;
}

.pause-card h2 {
  margin: 4px 0 10px;
  font-size: clamp(34px, 5vw, 54px);
}

.pause-card button {
  display: block;
  width: 100%;
  margin-top: 12px;
}

.pause-layout {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(360px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.pause-scoreboard {
  margin: 0;
}

.title-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-card {
  width: min(780px, 100%);
  max-height: none;
  overflow: visible;
  padding: clamp(18px, 2.1vh, 24px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.045)),
    rgba(8, 18, 13, 0.88);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  text-align: center;
}

.title-layout {
  width: min(1120px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
}

.title-card h1 {
  margin: 2px 0 8px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
}

.title-tagline {
  max-width: 560px;
  margin: 0 auto;
  color: #f1f8e8;
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.creator-credit {
  margin: -4px 0 8px;
  color: #fff7d6;
  font-weight: 900;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}

.version-line {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: -4px 0 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(4, 10, 7, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #dce8d6;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.version-line strong {
  color: var(--accent);
}

.primary-title-button {
  margin: 0;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd166, #8df185);
  color: #142010;
  font-weight: 1000;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28), 0 0 26px rgba(255, 209, 102, 0.22);
}

.secondary-button {
  margin: 0;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff7d6;
  font-weight: 900;
  cursor: pointer;
}

.secondary-button:disabled,
.disabled-button {
  cursor: not-allowed;
  opacity: 0.48;
  filter: grayscale(0.9);
}

.title-actions {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) repeat(3, minmax(130px, 1fr));
  gap: 10px;
  align-items: stretch;
  margin: 12px auto 6px;
}

.title-actions button {
  width: 100%;
}

.title-boards {
  width: min(940px, 100%);
  display: block;
  margin-top: 0;
}

.global-scoreboard {
  margin: 0;
  max-width: none;
  padding: 12px;
  border-radius: 18px;
  background: rgba(4, 10, 7, 0.74);
  border: 1px solid rgba(141, 241, 133, 0.22);
  text-align: left;
  min-height: 100%;
  min-width: 0;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.global-scoreboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.global-scoreboard h2 {
  margin: 0;
  color: var(--green);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mini-button {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff7d6;
  font-weight: 900;
  cursor: pointer;
}

.global-stats-content {
  color: #e6f6df;
  font-size: 12px;
  font-weight: 800;
}

.global-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 7px;
}

.global-summary-grid span,
.global-leaderboard li {
  padding: 5px 7px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.global-summary-grid strong {
  display: block;
  color: var(--accent);
  font-size: 13px;
}

.global-leaderboard {
  margin: 0;
  padding-left: 22px;
}

.global-leaderboard li {
  margin: 4px 0;
}

.title-log-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  width: min(360px, calc(100vw - 36px));
  margin: 0;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(91, 200, 255, 0.12);
  text-align: left;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  opacity: 0.38;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16);
  transition: opacity 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.title-log-panel:hover,
.title-log-panel:not(.collapsed) {
  opacity: 0.96;
  background: rgba(0, 0, 0, 0.58);
  border-color: rgba(91, 200, 255, 0.28);
}

.title-log-panel.collapsed {
  width: auto;
  transform: translateY(4px);
}

.title-log-panel.collapsed .title-log-lines {
  display: none;
}

.title-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.title-log-header h2 {
  margin: 0;
  color: #9ee7ff;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-log-lines {
  overflow: visible;
  margin: 8px 0 0;
  padding-left: 20px;
  color: #d8f4ff;
  font: 700 9px/1.18 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.title-log-lines li {
  margin: 2px 0;
}

.title-log-lines span {
  color: #ffd166;
}

.title-log-lines strong {
  color: #8df185;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .title-card {
    padding: 22px;
  }

  .title-actions {
    grid-template-columns: 1fr;
  }

  .pause-layout {
    grid-template-columns: 1fr;
  }

  .global-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.player-name-field {
  display: grid;
  gap: 8px;
  margin: 16px auto 0;
  max-width: 280px;
  color: #fff7d6;
  font-weight: 900;
}

.player-name-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(4, 10, 7, 0.66);
  color: #fff;
  font: inherit;
  text-align: center;
}

.start-hint,
.record-line {
  margin: 8px 0 0;
}

.sun-glow {
  background:
    radial-gradient(circle at 22% 14%, rgba(255, 226, 155, 0.5), rgba(255, 226, 155, 0.14) 9%, transparent 23%),
    linear-gradient(180deg, rgba(255, 244, 214, 0.08), transparent 40%);
  mix-blend-mode: screen;
}

.vignette {
  background:
    radial-gradient(circle at center, transparent 45%, rgba(4, 8, 6, 0.36) 100%),
    linear-gradient(180deg, transparent 65%, rgba(6, 13, 8, 0.34));
}

#hud {
  position: fixed;
  inset: 16px 16px auto 16px;
  z-index: 3;
  pointer-events: none;
}

.hud-card,
.combo-banner,
.help-menu,
.stats-panel,
#panel,
#minimap {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.035)),
    rgba(6, 14, 12, 0.78);
  backdrop-filter: blur(18px) saturate(145%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.hud-card { position: fixed; pointer-events: auto; }

.mission-card {
  left: 16px;
  top: 16px;
  width: min(340px, calc(100vw - 32px));
  padding: 16px;
  border-radius: 24px;
}

.brand {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 0 22px rgba(255, 209, 102, 0.55);
  white-space: nowrap;
}

.combo-banner {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  max-width: min(620px, calc(100vw - 380px));
  min-width: 390px;
  padding: 12px 24px;
  border-radius: 999px;
  border-color: rgba(255, 209, 102, 0.42);
  color: #fff;
  text-align: center;
  pointer-events: none;
  overflow: visible;
}

.combo-banner strong {
  color: var(--accent);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 0.9;
  font-weight: 1000;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.5);
}

.combo-main {
  display: grid;
  justify-items: start;
  gap: 2px;
}

.combo-kicker {
  color: #dfffe2;
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.combo-banner span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dfffe2;
  font-weight: 900;
}

.score-burst-label {
  position: absolute;
  left: 50%;
  top: -12px;
  transform: translate(-50%, 0) scale(0.9);
  opacity: 0;
  color: #8df185;
  font-size: 24px;
  font-weight: 1000;
  text-shadow: 0 0 18px rgba(141, 241, 133, 0.74), 0 3px 0 rgba(0, 0, 0, 0.25);
}

.combo-banner.score-pop {
  animation: score-pop 260ms cubic-bezier(.2, 1.6, .4, 1);
}

.combo-banner.score-pop .score-burst-label {
  animation: score-float 680ms ease-out;
}

.combo-banner.combo-hot strong {
  color: #ffe66d;
  text-shadow: 0 0 20px rgba(255, 209, 102, 0.85), 0 0 44px rgba(141, 241, 133, 0.32);
}

@keyframes score-pop {
  0% { transform: translateX(-50%) scale(1); }
  45% { transform: translateX(-50%) scale(1.07); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes score-float {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.85); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1.24); }
}

.combo-banner.combo-hot {
  animation: arcade-pop 0.9s ease-in-out infinite alternate;
  box-shadow: 0 0 42px rgba(255, 209, 102, 0.22), 0 24px 70px rgba(0, 0, 0, 0.34);
}

@keyframes arcade-pop {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.035); }
}

.status-cluster {
  right: 16px;
  bottom: 16px;
  width: min(430px, calc(100vw - 32px));
  padding: 16px;
  border-radius: 30px;
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 14px;
  align-items: center;
}

.speed-ring {
  --speed-fill: 0%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(5, 9, 8, 0.94) 49%, transparent 51%),
    conic-gradient(from 225deg, #75c46b 0 var(--speed-fill), rgba(255,255,255,.12) var(--speed-fill) 100%);
  border: 4px solid rgba(255, 209, 102, 0.62);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.44), 0 0 30px rgba(255, 209, 102, 0.18);
}

.speed-ring strong {
  color: #fff;
  font-size: 42px;
  line-height: 0.95;
  font-weight: 1000;
}

.speed-ring span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #dce8d6;
  font-size: 13px;
  font-weight: 800;
}

.stat-pill strong {
  color: #fff7d6;
  text-shadow: 0 0 12px rgba(255, 247, 214, 0.4);
}

.score-pill,
.high-score-pill,
.money-pill { margin-top: 12px; }

.score-pill strong,
.high-score-pill strong { color: var(--accent); }

.achievement-heading {
  margin: 12px 0 8px;
  color: #fff7d6;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.achievement-list {
  display: grid;
  gap: 6px;
  max-height: min(54vh, 520px);
  margin: 0 0 12px;
  padding-right: 4px;
  overflow: auto;
}

.achievement-mini {
  display: grid;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.065);
}

.achievement-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #dce8d6;
  font-size: 12px;
  font-weight: 900;
}

.achievement-mini-row strong { color: #fff7d6; }

.achievement-mini-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.achievement-mini-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #75c46b, #ffd166);
}

.help-button {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd166, #8df185);
  color: #142010;
  font-weight: 1000;
  cursor: pointer;
}

.fuel-alert {
  border-color: rgba(255, 85, 85, 0.72);
  background: rgba(172, 34, 34, 0.36);
  box-shadow: 0 0 24px rgba(255, 68, 68, 0.28);
  animation: fuel-pulse 0.9s ease-in-out infinite alternate;
}

.pallet-alert {
  border-color: rgba(255, 209, 102, 0.72);
  background: rgba(178, 103, 27, 0.36);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.26);
  animation: fuel-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes fuel-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.045); }
}

.help-menu {
  position: fixed;
  left: 16px;
  top: 170px;
  z-index: 5;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 18px;
  border-radius: 24px;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.help-menu.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}

.help-menu h2,
.help-menu h3 { margin: 0 0 8px; }

.help-menu h2 { color: var(--accent); }

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}

.help-mode-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(141, 241, 133, 0.14);
  border: 1px solid rgba(141, 241, 133, 0.22);
  color: #dfffe2;
  font-size: 12px;
  font-weight: 1000;
  white-space: nowrap;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.help-card {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.help-card h3 {
  color: #fff7d6;
}

.help-menu ul { margin: 0; padding-left: 18px; }

.help-menu li { margin: 6px 0; }

.help-hint { margin-top: 0; color: #fff7d6; }

.stats-panel {
  position: fixed;
  right: 16px;
  top: 92px;
  z-index: 5;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 132px);
  overflow: auto;
  padding: 18px;
  border-radius: 24px;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.stats-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}

.stats-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.stats-panel h2 {
  margin: 0;
  color: var(--accent);
}

.stats-panel-header span {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff7d6;
  font-weight: 900;
}

.stats-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-section {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.075);
  color: #dce8d6;
  font-size: 13px;
  font-weight: 800;
}

.stat-row strong { color: #fff7d6; }

#panel {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 3;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  min-width: 330px;
  padding: 12px;
  border-radius: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-header h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 28px);
}

.panel-header span {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  color: #dce8d6;
  font-size: 11px;
  font-weight: 900;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  background: linear-gradient(90deg, #ffffff, #ffdf86 52%, #8df185);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

p, ul {
  color: #dce8d6;
  line-height: 1.45;
}

ul {
  margin: 12px 0;
  padding-left: 20px;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
  color: #fff;
  text-align: center;
  font-weight: 700;
}

.hint {
  margin: 8px 0 0;
  color: var(--accent);
  font-weight: 700;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid rgba(255, 209, 102, 0.18);
}

#panel .panel-copy {
  margin: 6px 0 8px;
  color: rgba(220, 232, 214, 0.78);
  font-size: 12px;
}

#upgrades {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0;
}

#upgrades span {
  display: block;
  min-height: 42px;
  padding: 8px 9px;
  border: 1px solid rgba(141, 241, 133, 0.18);
  border-radius: 12px;
  background: rgba(117, 196, 107, 0.1);
  color: #ddffd8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  transition: opacity 160ms ease, filter 160ms ease, background 160ms ease, border-color 160ms ease;
}

#upgrades span.upgrade-ready {
  border-color: rgba(141, 241, 133, 0.3);
  background: rgba(117, 196, 107, 0.16);
  color: #ddffd8;
}

#upgrades span.upgrade-locked {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(10, 14, 12, 0.34);
  color: rgba(220, 232, 214, 0.62);
  filter: grayscale(0.95);
  opacity: 0.54;
}

#upgrades span.upgrade-max {
  border-color: rgba(255, 209, 102, 0.28);
  background: rgba(255, 209, 102, 0.12);
  color: #fff7d6;
}

#toast-layer {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 4;
  pointer-events: none;
}

.toast {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(11, 22, 14, 0.78);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: #ffd166;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.35);
  animation: float-away 1.25s ease-out forwards;
  white-space: nowrap;
}

@keyframes float-away {
  from { opacity: 0; transform: translate(-50%, 8px) scale(0.85); }
  15% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -70px) scale(1.1); }
}

#minimap {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 3;
  width: min(420px, 32vw);
  height: min(310px, 34vh);
  border-radius: 18px;
}

.touch-controls {
  position: fixed;
  inset: auto 0 0;
  z-index: 6;
  display: none;
  pointer-events: none;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  touch-action: none;
}

.touch-steer,
.touch-drive,
.touch-actions {
  position: absolute;
  pointer-events: auto;
}

.touch-steer {
  left: max(12px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
}

.touch-drive {
  right: max(12px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: end;
  gap: 12px;
}

.touch-actions {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 8px;
  width: min(340px, calc(100vw - 250px));
}

.touch-btn {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(7, 15, 13, 0.78);
  color: #fff;
  font-weight: 1000;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255,255,255,.16);
  backdrop-filter: blur(12px);
  touch-action: none;
  user-select: none;
}

.touch-btn:active,
.touch-btn.active {
  transform: translateY(2px) scale(0.97);
  background: rgba(255, 209, 102, 0.88);
  color: #191103;
}

.steer-btn,
.drive-btn { width: 76px; height: 76px; font-size: 28px; }

.gas { height: 96px; background: rgba(70, 184, 82, 0.82); }
.brake { background: rgba(199, 51, 47, 0.82); }
.action-btn { min-height: 44px; font-size: 12px; border-radius: 14px; }

@media (max-width: 760px) {
  #hud { inset: 10px; }
  .mission-card {
    left: 10px;
    top: 10px;
    width: min(260px, calc(100vw - 20px));
    padding: 12px;
  }
  .money-pill { display: none; }
  .achievement-list { max-height: 38vh; }
  .combo-banner {
    top: 10px;
    right: 10px;
    left: auto;
    transform: none;
    min-width: 0;
    width: 190px;
    max-width: 42vw;
    padding: 10px 12px;
    animation: none;
  }
  .combo-banner strong { font-size: 24px; }
  .combo-kicker { font-size: 9px; }
  .combo-banner span { display: none; }
  .status-cluster {
    right: 10px;
    bottom: 128px;
    width: 178px;
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .speed-ring { width: 76px; justify-self: end; }
  .speed-ring strong { font-size: 26px; }
  .status-pills .stat-pill:nth-child(n+5) { display: none; }
  #panel { display: none; }
  #minimap { display: none; }
  .help-menu { top: 72px; max-height: calc(100vh - 210px); }
  .help-grid { grid-template-columns: 1fr; }
  .stats-panel { top: 72px; right: 10px; max-height: calc(100vh - 210px); }
  .stats-content { grid-template-columns: 1fr; }
}

@media (pointer: coarse), (max-width: 900px) {
  .touch-controls { display: block; }
}

@media (max-width: 1100px) {
  #panel { display: none; }
  #minimap { width: 300px; height: 220px; }
  .status-cluster { width: 360px; }
  .combo-banner { max-width: min(440px, calc(100vw - 360px)); }
}
