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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1208;
  font-family: system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
}

#viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#world,
#overlay,
#three-layer,
#celebration-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#world {
  z-index: 0;
}

#overlay {
  z-index: 1;
  pointer-events: none;
}

#three-layer {
  z-index: 2;
  pointer-events: none;
}

#celebration-layer {
  z-index: 5;
  pointer-events: none;
}

.mission-hud-stack {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

#hud.hud-mission-panel {
  position: relative;
  top: auto;
  left: auto;
  z-index: 1;
  min-width: 248px;
  padding: 0;
  background: rgba(6, 14, 18, 0.38);
  border: 1px solid rgba(90, 180, 200, 0.22);
  border-radius: 10px;
  color: rgba(210, 235, 240, 0.92);
  font-size: 12px;
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

body.game-paused #hud.hud-mission-panel {
  cursor: default;
}

.hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border-right: 1px solid rgba(90, 180, 200, 0.12);
  border-bottom: 1px solid rgba(90, 180, 200, 0.12);
  background: rgba(255, 255, 255, 0.015);
}

.hud-cell:nth-child(2n) {
  border-right: none;
}

.hud-cell:nth-child(n + 3) {
  border-bottom: none;
}

.hud-label {
  font: 600 9px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(130, 190, 205, 0.72);
}

.hud-value {
  font: 700 15px/1.15 system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: rgba(232, 248, 252, 0.96);
}

.hud-value-status {
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 0.05em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

#status.flying {
  color: #7ec8e3;
}

.hud-cell-score .hud-value {
  color: #c8e880;
}

.hud-cell-time .hud-value {
  color: #7ec8e3;
  font-variant-numeric: tabular-nums;
}

#mission-timer.mission-timer-urgent {
  color: #ff5c5c;
}

.hud-cell-rescued .hud-value {
  color: #ffb347;
}

.hud-sub {
  font: 600 10px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: rgba(255, 179, 71, 0.78);
}

.hud-sub[hidden] {
  display: none !important;
}

.hud-missiles {
  padding: 7px 12px 9px;
  border-top: 1px solid rgba(90, 180, 200, 0.14);
  background: rgba(255, 80, 80, 0.06);
  font: 700 11px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #ff8a8a;
}

.hud-missiles[hidden] {
  display: none !important;
}

#minimap-wrap {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  padding: 6px;
  background: rgba(6, 14, 18, 0.38);
  border: 1px solid rgba(90, 180, 200, 0.22);
  border-radius: 10px;
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#minimap {
  display: block;
  width: 200px;
  height: 200px;
}

body.mission-won #mission-hud-stack,
body.mission-failed #mission-hud-stack,
body.mission-won #minimap-wrap,
body.mission-failed #minimap-wrap,
body.mission-won #touch-controls,
body.mission-failed #touch-controls {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

body.splash-active #mission-hud-stack,
body.splash-active #minimap-wrap,
body.splash-active #touch-controls,
body.splash-active #btn-start-mission,
body.splash-active #scoreboard-panel,
body.splash-active #btn-lock-target,
body.splash-active #btn-unlock-target {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

body.mission-won #pause-menu,
body.mission-failed #pause-menu {
  display: none !important;
}

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(126, 200, 227, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(196, 74, 42, 0.15) 0%, transparent 50%),
    rgba(12, 8, 4, 0.88);
  backdrop-filter: blur(3px);
  animation: splash-in 0.5s ease-out both;
}

body:not(.splash-active) #splash-screen {
  display: none;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.splash-title {
  margin: 0;
  padding: 18px 28px;
  border: 3px solid rgba(255, 220, 120, 0.55);
  border-radius: 12px;
  background: linear-gradient(
    180deg,
    rgba(196, 74, 42, 0.92) 0%,
    rgba(138, 40, 24, 0.95) 100%
  );
  box-shadow:
    0 6px 0 rgba(74, 20, 8, 0.55),
    0 12px 40px rgba(0, 0, 0, 0.45);
  font: 800 clamp(1.5rem, 6vw, 2.25rem) system-ui, sans-serif;
  letter-spacing: 0.06em;
  line-height: 1.15;
  color: #fff8e8;
  text-shadow: 0 2px 0 rgba(74, 20, 8, 0.4);
}

.splash-high-score {
  margin: -8px 0 0;
  font: 700 14px system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #c8e880;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

#btn-splash-start {
  min-width: 180px;
  padding: 18px 36px;
  border: 2px solid rgba(255, 220, 120, 0.55);
  border-radius: 14px;
  font: 700 16px system-ui, sans-serif;
  letter-spacing: 0.14em;
  color: #fff8e8;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(
    180deg,
    rgba(156, 204, 32, 0.92) 0%,
    rgba(90, 130, 28, 0.95) 100%
  );
  box-shadow: 0 5px 0 rgba(40, 60, 12, 0.55), 0 8px 24px rgba(0, 0, 0, 0.35);
}

#btn-splash-start:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(40, 60, 12, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.splash-secondary-btn {
  min-width: 180px;
  padding: 12px 28px;
  border: 2px solid rgba(210, 170, 90, 0.45);
  border-radius: 12px;
  font: 600 13px system-ui, sans-serif;
  letter-spacing: 0.12em;
  color: rgba(255, 248, 232, 0.92);
  background: rgba(40, 32, 20, 0.55);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.splash-secondary-btn:active {
  transform: translateY(2px);
  background: rgba(60, 48, 30, 0.65);
}

.splash-credit {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-align: center;
  color: rgba(232, 212, 168, 0.75);
}

.splash-dev-link {
  color: #7ec8e3;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s ease;
}

.splash-dev-link:hover,
.splash-dev-link:focus-visible {
  color: #a8dff0;
  text-decoration: underline;
}

@keyframes splash-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#btn-start-mission {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 25;
  transform: translateX(-50%);
  min-width: 200px;
  padding: 18px 28px;
  border: 2px solid rgba(255, 220, 120, 0.55);
  border-radius: 14px;
  font: 700 15px system-ui, sans-serif;
  letter-spacing: 0.1em;
  color: #fff8e8;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(
    180deg,
    rgba(156, 204, 32, 0.88) 0%,
    rgba(90, 130, 28, 0.92) 100%
  );
  box-shadow: 0 5px 0 rgba(40, 60, 12, 0.55), 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: mission-btn-in 0.45s ease-out both;
}

#btn-start-mission.visible {
  display: block;
}

#btn-start-mission:active {
  transform: translateX(-50%) translateY(3px);
  box-shadow: 0 2px 0 rgba(40, 60, 12, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes mission-btn-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

#touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  touch-action: none;
}

@media (pointer: coarse) {
  #touch-controls {
    display: block;
  }

  .hint {
    display: none;
  }

  #mission-hud-stack {
    top: 8px;
    left: 8px;
  }

  #hud.hud-mission-panel {
    min-width: 0;
    max-width: min(168px, calc(100vw - 132px));
    border-radius: 8px;
  }

  .hud-cell {
    min-height: 40px;
    padding: 5px 7px;
    gap: 2px;
  }

  .hud-label {
    font-size: 7px;
    letter-spacing: 0.1em;
  }

  .hud-value {
    font-size: 12px;
  }

  .hud-value-status {
    font-size: 8px;
    line-height: 1.2;
  }

  .hud-sub {
    font-size: 8px;
  }

  .hud-missiles {
    padding: 4px 7px 5px;
    font-size: 9px;
    letter-spacing: 0.05em;
  }

  #minimap-wrap {
    top: 8px;
    right: 8px;
    padding: 4px;
  }

  #minimap {
    width: 118px;
    height: 118px;
  }
}

@media (pointer: coarse) and (max-width: 380px) {
  #hud.hud-mission-panel {
    max-width: min(152px, calc(100vw - 124px));
  }

  .hud-cell {
    min-height: 36px;
    padding: 4px 6px;
  }

  .hud-value {
    font-size: 11px;
  }

  .hud-value-status {
    font-size: 7px;
    -webkit-line-clamp: 2;
  }
}

#joystick-column {
  position: fixed;
  left: 20px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#btn-fullscreen-splash {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

body:not(.splash-active) #btn-fullscreen-splash {
  display: none;
}

.btn-fullscreen {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(210, 170, 90, 0.4);
  border-radius: 10px;
  color: rgba(255, 248, 232, 0.95);
  background: linear-gradient(
    180deg,
    rgba(60, 52, 40, 0.72) 0%,
    rgba(32, 26, 18, 0.68) 100%
  );
  box-shadow: 0 3px 0 rgba(20, 14, 6, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(4px);
}

.btn-fullscreen svg {
  width: 22px;
  height: 22px;
  display: block;
}

.btn-fullscreen .icon-exit {
  display: none;
}

.btn-fullscreen.is-fullscreen {
  display: none;
}

.btn-fullscreen.is-fullscreen .icon-enter {
  display: none;
}

.btn-fullscreen.is-fullscreen .icon-exit {
  display: block;
}

.btn-fullscreen:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(20, 14, 6, 0.45);
}

#joystick {
  position: relative;
  width: 150px;
  height: 150px;
  pointer-events: auto;
}

#joystick-turn {
  position: relative;
  width: 150px;
  height: 150px;
  pointer-events: auto;
}

#joystick-column-right {
  position: fixed;
  right: 20px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

body.gimbals-swapped #joystick-column {
  left: auto;
  right: 20px;
}

body.gimbals-swapped #joystick-column-right {
  right: auto;
  left: 20px;
}

#btn-land,
#btn-fire,
#btn-fire-missile,
#btn-lock-target,
#btn-unlock-target,
#touch-controls .btn-fullscreen {
  min-width: 72px;
  padding: 12px 10px;
  border: 2px solid rgba(210, 170, 90, 0.28);
  border-radius: 12px;
  font: 700 12px system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: rgba(255, 248, 232, 0.88);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(3px);
  background: rgba(12, 10, 6, 0.18);
  box-shadow: none;
}

#btn-land {
  background: rgba(42, 90, 120, 0.22);
}

#btn-land:active {
  transform: translateY(2px);
  background: rgba(42, 90, 120, 0.32);
}

#btn-fire {
  background: rgba(138, 40, 24, 0.22);
}

.fire-buttons {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.fire-btn {
  min-width: 56px !important;
  width: 56px;
  height: 56px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fire-btn-icon {
  width: 28px;
  height: 28px;
  display: block;
}

#btn-fire-missile {
  background: rgba(150, 30, 24, 0.22);
}

#btn-fire-missile:active,
#btn-fire-missile.pressed {
  transform: translateY(2px);
  background: rgba(150, 30, 24, 0.34);
}

#btn-fire-missile[hidden] {
  display: none !important;
}

#btn-fire:active,
#btn-fire.pressed {
  transform: translateY(2px);
  background: rgba(138, 40, 24, 0.34);
}

#btn-lock-target {
  background: rgba(160, 110, 20, 0.22);
}

#btn-lock-target:active {
  transform: translateY(2px);
  background: rgba(160, 110, 20, 0.32);
}

#btn-unlock-target {
  background: rgba(70, 70, 80, 0.22);
}

#btn-unlock-target:active {
  transform: translateY(2px);
  background: rgba(70, 70, 80, 0.32);
}

#btn-lock-target[hidden],
#btn-unlock-target[hidden] {
  display: none !important;
}

#touch-controls .btn-fullscreen {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  background: rgba(32, 26, 18, 0.2);
}

#touch-controls .btn-fullscreen:active {
  background: rgba(32, 26, 18, 0.32);
}

/* Shared gimbal visuals (the HTML uses .joystick-base / .joystick-knob classes). */
.joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(20, 14, 6, 0.22);
  border: 2px solid rgba(210, 170, 90, 0.28);
  box-shadow: none;
}

.joystick-base::before,
.joystick-base::after {
  content: "";
  position: absolute;
  background: rgba(210, 170, 90, 0.2);
}

.joystick-base::before {
  left: 50%;
  top: 12%;
  width: 2px;
  height: 76%;
  transform: translateX(-50%);
}

.joystick-base::after {
  top: 50%;
  left: 12%;
  height: 2px;
  width: 76%;
  transform: translateY(-50%);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(126, 200, 227, 0.75), rgba(42, 106, 136, 0.65));
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
  pointer-events: none;
}

/* Right gimbal (rotation): purple. */
#joystick-turn .joystick-base {
  border-color: rgba(180, 150, 230, 0.3);
  box-shadow: none;
  background: rgba(20, 14, 6, 0.18);
}

#joystick-turn-knob {
  background: radial-gradient(circle at 35% 30%, rgba(184, 160, 232, 0.75), rgba(90, 72, 136, 0.65));
}

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(20, 14, 6, 0.22);
  border: 2px solid rgba(210, 170, 90, 0.28);
  box-shadow: none;
}

#joystick-base::before,
#joystick-base::after {
  content: "";
  position: absolute;
  background: rgba(210, 170, 90, 0.2);
}

#joystick-base::before {
  left: 50%;
  top: 12%;
  width: 2px;
  height: 76%;
  transform: translateX(-50%);
}

#joystick-base::after {
  top: 50%;
  left: 12%;
  height: 2px;
  width: 76%;
  transform: translateY(-50%);
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(126, 200, 227, 0.75), rgba(42, 106, 136, 0.65));
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
  pointer-events: none;
}


/* ── Settings gear button on splash ─────────────────────────────── */
#btn-settings-splash {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(210, 170, 90, 0.4);
  border-radius: 10px;
  color: rgba(255, 248, 232, 0.9);
  background: linear-gradient(180deg, rgba(60, 52, 40, 0.72) 0%, rgba(32, 26, 18, 0.68) 100%);
  cursor: pointer;
  touch-action: manipulation;
}

#btn-settings-splash:active {
  background: linear-gradient(180deg, rgba(80, 70, 52, 0.8) 0%, rgba(48, 40, 28, 0.75) 100%);
}

body:not(.splash-active) #btn-settings-splash {
  display: none;
}

/* ── Settings panel ─────────────────────────────────────────────── */
#settings-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 5, 2, 0.82);
  backdrop-filter: blur(4px);
  animation: splash-in 0.2s ease-out both;
}

#settings-panel[hidden] {
  display: none !important;
}

.settings-inner {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 360px;
  padding: 28px 24px;
  background: linear-gradient(160deg, rgba(28, 22, 14, 0.97) 0%, rgba(18, 12, 6, 0.97) 100%);
  border: 1px solid rgba(210, 170, 90, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.settings-title {
  margin: 0;
  font: 700 18px system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #fff8e8;
  text-align: center;
}

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

.settings-row-col {
  flex-direction: column;
  align-items: flex-start;
}

.settings-label {
  font: 600 14px system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.9);
  letter-spacing: 0.04em;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  touch-action: manipulation;
}

.toggle-track {
  position: relative;
  width: 48px;
  height: 26px;
  border-radius: 13px;
  background: rgba(80, 68, 50, 0.7);
  border: 1.5px solid rgba(210, 170, 90, 0.3);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.settings-toggle[aria-checked="true"] .toggle-track {
  background: rgba(80, 160, 60, 0.75);
  border-color: rgba(120, 200, 80, 0.45);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(200, 180, 140, 0.85);
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.settings-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(22px);
  background: #c8e880;
}

.toggle-text {
  font: 600 12px system-ui, sans-serif;
  color: rgba(200, 180, 140, 0.7);
  min-width: 24px;
  text-align: left;
  letter-spacing: 0.04em;
}

.mode-options {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 2px solid rgba(210, 170, 90, 0.25);
  background: rgba(40, 32, 20, 0.7);
  color: rgba(200, 180, 140, 0.7);
  font: 700 14px system-ui, sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mode-btn-active {
  border-color: rgba(156, 204, 32, 0.7);
  background: rgba(60, 88, 20, 0.5);
  color: #c8e880;
}

.mode-desc {
  font: 400 10px system-ui, sans-serif;
  letter-spacing: 0.02em;
  opacity: 0.7;
  text-transform: none;
}

.settings-reset {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(210, 170, 90, 0.35);
  background: rgba(40, 32, 20, 0.55);
  color: rgba(255, 248, 232, 0.88);
  font: 600 13px system-ui, sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
}

.settings-reset:active {
  transform: translateY(2px);
  background: rgba(60, 48, 30, 0.65);
}

.settings-close {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 220, 120, 0.4);
  background: linear-gradient(180deg, rgba(80, 64, 40, 0.8) 0%, rgba(48, 38, 22, 0.8) 100%);
  color: #fff8e8;
  font: 700 14px system-ui, sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
  touch-action: manipulation;
}

.settings-close:active {
  transform: translateY(2px);
}

/* ── How to Play guide ───────────────────────────────────────────── */
#howto-panel {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 5, 2, 0.82);
  backdrop-filter: blur(4px);
  animation: splash-in 0.2s ease-out both;
}

#howto-panel[hidden] {
  display: none !important;
}

.howto-inner {
  max-width: 420px;
  max-height: min(88vh, 720px);
  gap: 16px;
}

.howto-section {
  margin: 0;
}

.howto-heading {
  margin: 0 0 6px;
  font: 700 13px system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffb347;
}

.howto-section p {
  margin: 0;
  font: 400 13px/1.45 system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.88);
}

.howto-list {
  margin: 0;
  padding-left: 18px;
  font: 400 13px/1.45 system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.88);
}

.howto-list li {
  margin-bottom: 6px;
}

.howto-list li:last-child {
  margin-bottom: 0;
}

.howto-list strong {
  color: #fff8e8;
  font-weight: 600;
}

/* ── Pause menu (opened via HUD tap) ───────────────────────────── */
#pause-menu {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
  width: 100%;
  padding: 10px;
  background: rgba(20, 14, 6, 0.35);
  border: 1px solid rgba(210, 170, 90, 0.28);
  border-radius: 12px;
  box-shadow: none;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

#pause-menu[hidden] {
  display: none !important;
}

#pause-menu button {
  padding: 12px 14px;
  border: 2px solid rgba(210, 170, 90, 0.28);
  border-radius: 10px;
  font: 700 12px system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: rgba(255, 248, 232, 0.88);
  background: rgba(12, 10, 6, 0.22);
  backdrop-filter: blur(3px);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: none;
}

#btn-pause-resume {
  border-color: rgba(156, 204, 32, 0.55) !important;
  color: #c8e880 !important;
}

body.game-paused #touch-controls {
  pointer-events: none;
  opacity: 0.35;
}

/* ── Settings sliders ────────────────────────────────────────────── */
.settings-scroll {
  max-height: min(88vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-section-title {
  margin: 8px 0 0;
  font: 700 13px system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffb347;
  width: 100%;
}

.settings-hint {
  margin: 0;
  font-size: 11px;
  color: rgba(200, 180, 140, 0.65);
  width: 100%;
}

.settings-slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.settings-slider-row label {
  display: flex;
  justify-content: space-between;
  font: 600 13px system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.92);
}

.settings-slider-row input[type="range"] {
  width: 100%;
  accent-color: #9ccc20;
}

.slider-hint {
  font-size: 10px;
  color: rgba(200, 180, 140, 0.55);
  letter-spacing: 0.02em;
}

#scoreboard-panel {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 5, 2, 0.82);
  backdrop-filter: blur(4px);
  animation: splash-in 0.2s ease-out both;
}

#scoreboard-panel[hidden] {
  display: none !important;
}

.scoreboard-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 380px;
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: 24px 22px;
  background: linear-gradient(160deg, rgba(28, 22, 14, 0.97) 0%, rgba(18, 12, 6, 0.97) 100%);
  border: 1px solid rgba(210, 170, 90, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.scoreboard-title {
  margin: 0;
  font: 700 18px system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #fff8e8;
  text-align: center;
}

.scoreboard-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(210, 170, 90, 0.2);
}

.scoreboard-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scoreboard-score-row-high .scoreboard-value {
  color: #c8e880;
}

.scoreboard-label {
  font: 600 13px system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.85);
}

.scoreboard-value {
  font: 800 22px system-ui, sans-serif;
  color: #ffb347;
  letter-spacing: 0.04em;
}

.scoreboard-breakdown {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scoreboard-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font: 500 12px system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.82);
}

.scoreboard-breakdown li span:last-child {
  color: rgba(200, 232, 128, 0.95);
  font-weight: 700;
  white-space: nowrap;
}

.scoreboard-name-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scoreboard-name-row label {
  font: 600 13px system-ui, sans-serif;
  color: rgba(232, 212, 168, 0.9);
}

.scoreboard-name-row input {
  width: 100%;
  padding: 10px 12px;
  font: 600 14px system-ui, sans-serif;
  color: #fff8e8;
  background: rgba(40, 32, 20, 0.9);
  border: 1.5px solid rgba(210, 170, 90, 0.35);
  border-radius: 10px;
}

.scoreboard-name-row input:focus {
  outline: none;
  border-color: rgba(156, 204, 32, 0.65);
  box-shadow: 0 0 0 2px rgba(156, 204, 32, 0.15);
}

.scoreboard-actions {
  display: flex;
  gap: 10px;
}

.scoreboard-btn-primary,
.scoreboard-btn-secondary {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  font: 700 13px system-ui, sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
}

.scoreboard-btn-primary {
  border: 2px solid rgba(156, 204, 32, 0.55);
  color: #fff8e8;
  background: linear-gradient(180deg, rgba(156, 204, 32, 0.88) 0%, rgba(90, 130, 28, 0.92) 100%);
}

.scoreboard-btn-secondary {
  border: 1.5px solid rgba(210, 170, 90, 0.35);
  color: rgba(232, 212, 168, 0.92);
  background: rgba(40, 32, 20, 0.75);
}
