/* ============ XENOMINE — HUD & UI ============ */
@font-face {
  font-family: 'Rajdhani';
  src: url('./assets/fonts/rajdhani-500.woff2') format('woff2');
  font-weight: 500;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('./assets/fonts/rajdhani-600.woff2') format('woff2');
  font-weight: 600;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('./assets/fonts/rajdhani-700.woff2') format('woff2');
  font-weight: 700;
}

:root {
  --amber: #ffb020;
  --amber-dim: #c9871a;
  --white: #f2f2f0;
  --panel-bg: rgba(8, 8, 10, 0.55);
  --panel-brd: rgba(255, 255, 255, 0.14);
  --font: 'Rajdhani', 'Segoe UI', Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--white); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }

#app { position: relative; width: 100%; height: 100%; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.screen { position: absolute; inset: 0; z-index: 10; }
.hidden { display: none !important; }

/* ================= HUD ================= */
#hud { z-index: 5; pointer-events: none; }

.panel {
  position: absolute;
  background: var(--panel-bg);
  border: 1px solid var(--panel-brd);
  backdrop-filter: blur(3px);
  padding: 10px 14px;
}

/* --- top left objectives --- */
#hud-objectives { top: 18px; left: 22px; min-width: 300px; border-left: 3px solid var(--amber); }
.obj-block { margin-bottom: 10px; }
.obj-block:last-of-type { margin-bottom: 6px; }
.obj-title {
  font-size: 15px; font-weight: 700; letter-spacing: 2.5px;
  color: var(--amber); display: flex; align-items: center; gap: 8px;
}
.obj-title.sub { color: var(--amber-dim); font-size: 13px; }
.obj-icon.diamond {
  width: 9px; height: 9px; background: var(--amber);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  flex: 0 0 auto;
}
.obj-line { font-size: 15px; font-weight: 600; letter-spacing: 0.6px; color: var(--white); display: flex; align-items: center; gap: 8px; margin-top: 2px; text-shadow: 0 1px 2px #000; }
.obj-marker { width: 10px; height: 10px; border: 1.5px solid rgba(255,255,255,0.85); border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.obj-marker.done { background: var(--amber); border-color: var(--amber); }
.gold-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 16px; font-weight: 700; letter-spacing: 1.5px; color: var(--white);
  padding: 2px 0 0; text-shadow: 0 1px 2px #000;
}
.gold-icon {
  width: 12px; height: 12px; background: linear-gradient(135deg, #ffd75e, #b8860b);
  clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%);
  display: inline-block;
}
.gold-unit { font-size: 11px; color: rgba(255,255,255,0.55); letter-spacing: 2px; }

/* --- top center compass --- */
#hud-compass { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
#compass-canvas { display: block; margin: 0 auto; }
#hud-waydist {
  font-size: 22px; font-weight: 700; letter-spacing: 1px; margin-top: 0px;
  text-shadow: 0 1px 3px #000;
}

/* --- minimap --- */
#hud-minimap { top: 16px; right: 22px; padding: 6px; }
#minimap-canvas { display: block; }

/* --- speedometer --- */
/* --- ammo / weapon --- */
#hud-ammo {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  min-width: 168px; padding: 7px 14px 9px;
  background: rgba(8, 8, 10, 0.62); border: 1px solid var(--panel-brd);
  border-left: 3px solid var(--amber);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  text-align: center; letter-spacing: 2px;
}
.ammo-label { font-size: 11px; color: rgba(255,255,255,0.55); font-weight: 600; margin-right: 8px; }
#ammo-count { font-size: 22px; font-weight: 700; color: var(--white); }
#ammo-count.low { color: #ff5330; }
.ammo-of { font-size: 12px; color: rgba(255,255,255,0.45); margin-left: 4px; }
.ammo-reload { height: 3px; margin-top: 5px; background: rgba(255,255,255,0.12); }
#ammo-reload-fill { height: 100%; width: 0; background: var(--amber); transition: width 0.08s linear; }
#hud-ammo.reloading .ammo-label { color: var(--amber); }

#hud-speedo { position: absolute; bottom: 24px; left: 26px; width: 200px; height: 200px; }
#speedo-canvas { position: absolute; inset: 0; }
.speedo-read { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding-top: 26px; }
.speedo-unit { font-size: 13px; letter-spacing: 3px; color: rgba(255,255,255,0.75); font-weight: 600; }
#speedo-num { font-size: 44px; font-weight: 700; line-height: 0.95; text-shadow: 0 0 12px rgba(0,0,0,0.8); }

/* --- status bars (bottom right) --- */
#hud-status { bottom: 22px; right: 22px; padding: 12px 14px; border-radius: 10px; }
.status-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.st-icon { width: 22px; height: 22px; flex: 0 0 auto; opacity: 0.95; }
.st-bar { width: 150px; height: 11px; background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18); border-radius: 2px; overflow: hidden; position: relative; }
.st-fill { height: 100%; width: 100%; transition: width 0.25s ease-out; }
.st-fill.cond  { background: #d8d8d4; }
.st-fill.fuel  { background: var(--amber); }
.st-fill.rep   { background: #2f9bff; }
.st-fill.vital { background: #e04b3a; }
.st-count { font-size: 13px; font-weight: 700; color: #9fcbe8; min-width: 20px; text-align: right; }

/* icon glyphs (inline SVG masks) */
#ic-train, #ic-fuel, #ic-repair, #ic-vitals { background-color: #e8e8e4; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; }
#ic-train  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 2C7.6 2 4 2.9 4 6v9c0 1.8 1.5 3.2 3.2 3.2L5.5 20.7v.8h2.3l2-2h4.4l2 2h2.3v-.8l-1.7-2.5C18.5 18.2 20 16.8 20 15V6c0-3.1-3.6-4-8-4zM7.5 15A1.5 1.5 0 1 1 9 13.5 1.5 1.5 0 0 1 7.5 15zm9 0a1.5 1.5 0 1 1 1.5-1.5 1.5 1.5 0 0 1-1.5 1.5zM6 10V6.8C6 5.6 8.2 5 12 5s6 .6 6 1.8V10z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 2C7.6 2 4 2.9 4 6v9c0 1.8 1.5 3.2 3.2 3.2L5.5 20.7v.8h2.3l2-2h4.4l2 2h2.3v-.8l-1.7-2.5C18.5 18.2 20 16.8 20 15V6c0-3.1-3.6-4-8-4zM7.5 15A1.5 1.5 0 1 1 9 13.5 1.5 1.5 0 0 1 7.5 15zm9 0a1.5 1.5 0 1 1 1.5-1.5 1.5 1.5 0 0 1-1.5 1.5zM6 10V6.8C6 5.6 8.2 5 12 5s6 .6 6 1.8V10z'/%3E%3C/svg%3E"); }
#ic-fuel   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M19.8 7.7 17.6 5.5a1 1 0 0 0-1.4 1.4l2.2 2.2c.2.2.2.5 0 .7l-2.9 2.9a1 1 0 0 1-1.4 0L12 10.6 5.4 17.2A2 2 0 0 0 6.8 20h8.4a2 2 0 0 0 2-2v-2.2l3.3-3.3a2.4 2.4 0 0 0-.7-3.8zM6 8V4h8v4H6z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M19.8 7.7 17.6 5.5a1 1 0 0 0-1.4 1.4l2.2 2.2c.2.2.2.5 0 .7l-2.9 2.9a1 1 0 0 1-1.4 0L12 10.6 5.4 17.2A2 2 0 0 0 6.8 20h8.4a2 2 0 0 0 2-2v-2.2l3.3-3.3a2.4 2.4 0 0 0-.7-3.8zM6 8V4h8v4H6z'/%3E%3C/svg%3E"); }
#ic-repair { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M22 6.5a5.4 5.4 0 0 1-7.4 5L8 18.1A2.6 2.6 0 0 1 4.3 14.4l6.6-6.6a5.4 5.4 0 0 1 7-7L14.5 4.2l3.7 3.7L21.7 4.4A5.3 5.3 0 0 1 22 6.5z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M22 6.5a5.4 5.4 0 0 1-7.4 5L8 18.1A2.6 2.6 0 0 1 4.3 14.4l6.6-6.6a5.4 5.4 0 0 1 7-7L14.5 4.2l3.7 3.7L21.7 4.4A5.3 5.3 0 0 1 22 6.5z'/%3E%3C/svg%3E"); }
#ic-vitals { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 21s-8-5.3-8-11a4.6 4.6 0 0 1 8-3.1A4.6 4.6 0 0 1 20 10c0 5.7-8 11-8 11z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 21s-8-5.3-8-11a4.6 4.6 0 0 1 8-3.1A4.6 4.6 0 0 1 20 10c0 5.7-8 11-8 11z'/%3E%3C/svg%3E"); }

/* --- center messages --- */
#hud-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; }
#hud-prompt {
  position: absolute; bottom: 21%; left: 50%; transform: translateX(-50%);
  background: rgba(5,5,6,0.72); border: 1px solid var(--panel-brd);
  padding: 7px 18px; font-size: 16px; font-weight: 700; letter-spacing: 2px;
  color: var(--white);
}
#hud-prompt b { color: var(--amber); }
#hud-warning {
  position: absolute; top: 15%; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 700; letter-spacing: 5px; color: #ff5330;
  text-shadow: 0 0 14px rgba(255,60,20,0.6);
  animation: warnpulse 0.9s ease-in-out infinite;
}
@keyframes warnpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

#hud-toasts { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: rgba(5,5,6,0.65); border-left: 3px solid var(--amber);
  padding: 5px 16px; font-size: 14px; font-weight: 600; letter-spacing: 1px;
  animation: toastin 0.3s ease-out;
  white-space: nowrap;
}
.toast.fade { opacity: 0; transition: opacity 0.8s; }
@keyframes toastin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

#hud-stagecard {
  position: absolute; top: 34%; text-align: center; opacity: 0;
  transition: opacity 1.2s ease; pointer-events: none;
}
#hud-stagecard.show { opacity: 1; }
#stagecard-num { font-size: 15px; letter-spacing: 6px; color: var(--amber); font-weight: 600; }
#stagecard-title { font-size: 42px; letter-spacing: 10px; font-weight: 700; text-shadow: 0 2px 18px #000; }

/* --- vignette & damage --- */
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0,0,0,0.55) 100%);
}
#damage-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,20,0,0.12) 40%, rgba(160,0,0,0.45) 100%);
  transition: opacity 0.12s;
}
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 4px; height: 4px;
  margin: -2px; background: rgba(255,255,255,0.65); border-radius: 50%;
  box-shadow: 0 0 3px rgba(0,0,0,0.8);
  transition: transform 0.06s, background-color 0.06s, box-shadow 0.06s;
}
#crosshair.hit {
  transform: scale(2.1);
  background: #ffb020;
  box-shadow: 0 0 8px rgba(255,176,32,0.95);
}
#crosshair.kill {
  transform: scale(2.8);
  background: #d63cff;
  box-shadow: 0 0 12px rgba(214,60,255,0.95);
}
#perf-overlay {
  position: absolute; top: 8px; left: 8px; z-index: 30;
  font: 12px/1.4 monospace; color: #0f0; background: rgba(0,0,0,0.6); padding: 4px 8px;
}

#fade { position: absolute; inset: 0; background: #000; z-index: 40; pointer-events: none; opacity: 0; transition: opacity 0.8s; }
#click-catch {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  font-size: 18px; letter-spacing: 3px; color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.35); cursor: pointer;
}

/* ================= MENUS ================= */
#menu, #pause, #gameover, #victory { z-index: 15; }
.menu-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.7) 100%); pointer-events: none; }

.menu-content, .pause-content, .go-content, .vic-content {
  position: absolute; left: 6%; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; max-width: 460px;
}
.vic-content { left: 50%; transform: translate(-50%, -50%); text-align: center; align-items: center; }
.go-content { left: 50%; transform: translate(-50%, -50%); text-align: center; align-items: center; }

.game-title {
  font-size: 74px; font-weight: 700; letter-spacing: 22px; line-height: 1;
  color: var(--white); text-shadow: 0 0 30px rgba(255,176,32,0.25), 0 2px 6px #000;
  margin-left: 10px;
}
.game-subtitle {
  font-size: 20px; font-weight: 600; letter-spacing: 9px; color: var(--amber);
  margin: 2px 0 34px 12px; text-shadow: 0 1px 4px #000;
}
.menu-buttons { display: flex; flex-direction: column; gap: 10px; width: 300px; }
.mbtn {
  font-family: var(--font); font-size: 17px; font-weight: 700; letter-spacing: 3.5px;
  color: var(--white); background: rgba(10,10,12,0.6); border: 1px solid var(--panel-brd);
  padding: 11px 0; cursor: pointer; text-align: center;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mbtn:hover { background: rgba(255,176,32,0.16); border-color: var(--amber); color: var(--amber); }
.mbtn.primary { border-color: var(--amber); color: var(--amber); }
.mbtn.primary:hover { background: rgba(255,176,32,0.28); }
.mbtn:disabled { opacity: 0.35; cursor: default; }
.mbtn:disabled:hover { background: rgba(10,10,12,0.6); border-color: var(--panel-brd); color: var(--white); }
.menu-hint { margin-top: 26px; font-size: 12.5px; letter-spacing: 1.5px; color: rgba(255,255,255,0.45); }

.menu-panel {
  position: absolute; left: 6%; top: 50%; transform: translateY(-50%);
  width: 420px; background: rgba(6,6,8,0.82); border: 1px solid var(--panel-brd);
  padding: 26px 30px; display: flex; flex-direction: column; gap: 12px;
}
.menu-panel h2 { font-size: 22px; letter-spacing: 5px; color: var(--amber); font-weight: 700; margin-bottom: 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; font-size: 15px; letter-spacing: 1.5px; font-weight: 600; }
.set-row input[type="range"] { width: 180px; accent-color: var(--amber); }
.tgl {
  font-family: var(--font); font-size: 14px; font-weight: 700; letter-spacing: 2px;
  background: rgba(255,255,255,0.08); color: var(--white); border: 1px solid var(--panel-brd);
  padding: 4px 14px; cursor: pointer; min-width: 64px;
}
.tgl.on { color: var(--amber); border-color: var(--amber-dim); }
.mbtn.back { margin-top: 12px; }

.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.howto-grid div { display: flex; gap: 10px; align-items: baseline; }
.howto-grid b { color: var(--amber); font-size: 15px; letter-spacing: 1px; min-width: 62px; }
.howto-grid span { font-size: 14px; color: rgba(255,255,255,0.85); }
.howto-note { font-size: 13.5px; color: rgba(255,255,255,0.55); letter-spacing: 0.5px; margin-top: 8px; line-height: 1.5; }

.pause-title { font-size: 40px; letter-spacing: 14px; font-weight: 700; margin-bottom: 18px; text-shadow: 0 2px 10px #000; }
.pause-stats { margin-top: 22px; font-size: 14px; letter-spacing: 2px; color: rgba(255,255,255,0.6); line-height: 1.8; }

.go-title {
  font-size: 54px; letter-spacing: 16px; font-weight: 700; color: #ff4433;
  text-shadow: 0 0 30px rgba(255,30,10,0.4); margin-bottom: 8px;
}
.go-reason { font-size: 16px; letter-spacing: 2px; color: rgba(255,255,255,0.7); margin-bottom: 30px; }

.vic-kicker { font-size: 15px; letter-spacing: 5px; color: var(--amber); font-weight: 600; }
.vic-title { font-size: 46px; letter-spacing: 12px; font-weight: 700; margin: 6px 0 24px; text-shadow: 0 0 34px rgba(255,176,32,0.3); }
.vic-stats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 30px; }
.vic-stats .vrow {
  display: flex; justify-content: space-between; gap: 40px; min-width: 320px;
  font-size: 16px; letter-spacing: 2px; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 5px;
}
.vic-stats .vrow span:last-child { color: var(--amber); }


/* ================= TOUCHSCREEN & MOBILE PHONE MODE ================= */
#touch-controls {
  position: absolute; inset: 0; z-index: 12;
  pointer-events: none; touch-action: none;
}
#touch-look {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: auto; touch-action: none;
}

.tbtn {
  pointer-events: auto; touch-action: none;
  font-family: var(--font); font-weight: 700; color: var(--white);
  background: rgba(10, 12, 16, 0.52);
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; cursor: pointer;
  transition: transform 0.06s ease, background 0.08s ease, border-color 0.08s ease;
  text-shadow: 0 1px 3px #000;
}
.tbtn.active, .tbtn:active {
  transform: scale(0.93);
  background: rgba(255, 176, 32, 0.28);
  border-color: var(--amber);
  color: var(--amber);
}

/* --- Left thumb: Lean + Gas + Reverse + Emergency Brake --- */
#touch-left {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex; flex-direction: column; gap: 7px; width: 146px;
}
.touch-lean-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tbtn-lean { height: 34px; font-size: 15px; border-radius: 9px; }
.tbtn-gas {
  height: 64px; flex-direction: column; gap: 1px;
  border-color: rgba(255, 176, 32, 0.45);
  background: rgba(14, 14, 16, 0.58);
}
.tbtn-gas .tbtn-arrow { font-size: 18px; line-height: 1; color: var(--amber); }
.tbtn-gas .tbtn-lbl { font-size: 14px; letter-spacing: 2.5px; }
.touch-brake-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tbtn-rev, .tbtn-stop { height: 42px; font-size: 12px; letter-spacing: 1px; border-radius: 10px; }
.tbtn-stop { border-color: rgba(255, 90, 60, 0.45); color: #ffb3a6; }
.tbtn-stop.active { background: rgba(255, 70, 40, 0.35); border-color: #ff5330; color: #fff; }

/* --- Right thumb: Interact + Big Fire Trigger (supports drag-to-aim) --- */
#touch-right {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.tbtn-interact {
  min-width: 112px; height: 38px; padding: 0 12px;
  font-size: 12px; letter-spacing: 1.4px; border-radius: 10px;
  opacity: 0.45; border-style: dashed;
}
.tbtn-interact.ready {
  opacity: 1; border-style: solid;
  border-color: var(--amber); color: var(--amber);
  background: rgba(34, 22, 6, 0.82);
  box-shadow: 0 0 14px rgba(255, 176, 32, 0.45);
  animation: touchpulse 1.1s ease-in-out infinite;
}
@keyframes touchpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

.tbtn-fire {
  width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid rgba(255, 176, 32, 0.65);
  background: radial-gradient(circle, rgba(255,176,32,0.18) 0%, rgba(12,12,16,0.68) 72%);
  position: relative; flex-direction: column; gap: 2px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}
.tbtn-fire .fire-ring {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--amber);
  box-shadow: inset 0 0 8px rgba(255, 176, 32, 0.4);
}
.tbtn-fire .fire-lbl { font-size: 12px; letter-spacing: 2px; color: var(--amber); }
.tbtn-fire.active {
  background: radial-gradient(circle, rgba(255,176,32,0.45) 0%, rgba(45,24,6,0.82) 75%);
  box-shadow: 0 0 22px rgba(255, 176, 32, 0.6);
}

/* --- Top-Right utility cluster (Headlights, Repair Kit, Pause) --- */
#touch-top-right {
  position: absolute;
  top: 106px;
  right: max(12px, env(safe-area-inset-right));
  z-index: 3;
  display: flex; gap: 6px;
}
.tbtn-util {
  height: 34px; padding: 0 10px; border-radius: 9px;
  font-size: 12px; letter-spacing: 1.2px; gap: 4px;
}
.tbtn-util.on { border-color: var(--amber); color: var(--amber); background: rgba(40, 28, 10, 0.68); }
.tbtn-util.empty { opacity: 0.42; }
.tbtn-pause { min-width: 38px; letter-spacing: 0; font-size: 13px; }

#rotate-hint {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%);
  z-index: 4; background: rgba(12, 10, 6, 0.85);
  border: 1px solid var(--amber-dim); color: var(--amber);
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  padding: 4px 12px; border-radius: 16px; white-space: nowrap;
}

/* --- Compact Phone HUD layout when Touch Controls active --- */
body.touch-ui #hud-objectives {
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  min-width: 0; max-width: 210px; padding: 6px 9px;
}
body.touch-ui .obj-block { margin-bottom: 4px; }
body.touch-ui .obj-title { font-size: 11px; letter-spacing: 1.4px; }
body.touch-ui .obj-title.sub { font-size: 10px; }
body.touch-ui .obj-line { font-size: 12px; gap: 6px; }
body.touch-ui .gold-chip { font-size: 12px; }

body.touch-ui #hud-compass {
  top: max(4px, env(safe-area-inset-top));
  transform: translateX(-50%) scale(0.68);
  transform-origin: top center;
}
body.touch-ui #hud-minimap {
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  transform: scale(0.56); transform-origin: top right;
}
body.touch-ui #hud-speedo {
  top: 98px; left: max(10px, env(safe-area-inset-left)); bottom: auto;
  transform: scale(0.44); transform-origin: top left;
}
body.touch-ui #hud-ammo {
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 48px));
  min-width: 128px; padding: 4px 10px 6px;
}
body.touch-ui #ammo-count { font-size: 17px; }
body.touch-ui #hud-status {
  left: 50%; right: auto; bottom: max(8px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 5px 10px; border-radius: 8px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
}
body.touch-ui .status-row { margin: 0; gap: 5px; }
body.touch-ui .st-icon { width: 14px; height: 14px; }
body.touch-ui .st-bar { width: 58px; height: 7px; }
body.touch-ui .st-count { font-size: 11px; min-width: 12px; }

/* --- Responsive Menus & Small Phone Viewports --- */
@media (max-width: 960px), (max-height: 540px) {
  .menu-content, .pause-content {
    left: max(5%, env(safe-area-inset-left));
    max-width: 90vw; gap: 6px;
  }
  .game-title { font-size: 46px; letter-spacing: 12px; margin-left: 4px; }
  .game-subtitle { font-size: 14px; letter-spacing: 5px; margin: 2px 0 18px 6px; }
  .menu-buttons { width: 240px; gap: 8px; }
  .mbtn { font-size: 14px; letter-spacing: 2.5px; padding: 9px 0; }
  .menu-hint { margin-top: 12px; font-size: 11px; }
  .menu-panel {
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(420px, 92vw); max-height: 86vh; overflow-y: auto;
    padding: 18px 20px; gap: 9px;
  }
  .menu-panel h2 { font-size: 18px; letter-spacing: 3px; }
  .set-row { font-size: 13px; }
  .set-row input[type="range"] { width: 130px; }
  .howto-grid { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .howto-grid b { font-size: 12px; min-width: 48px; }
  .howto-grid span, .howto-note { font-size: 12px; }
  .pause-title { font-size: 30px; letter-spacing: 9px; margin-bottom: 10px; }
  .go-title { font-size: 38px; letter-spacing: 10px; }
  .vic-title { font-size: 32px; letter-spacing: 7px; margin: 4px 0 14px; }
  .vic-stats .vrow { min-width: 240px; font-size: 13px; gap: 18px; }
  #stagecard-title { font-size: 26px; letter-spacing: 5px; }
  #hud-warning { font-size: 15px; letter-spacing: 3px; }
  .toast { font-size: 12px; padding: 4px 10px; }
}

@media (max-width: 600px) and (orientation: portrait) {
  body.touch-ui #hud-objectives { max-width: 52vw; }
  body.touch-ui #hud-compass { top: 68px; transform: translateX(-50%) scale(0.58); }
  body.touch-ui #hud-speedo { top: 108px; }
  body.touch-ui #touch-top-right { top: 100px; flex-direction: column; align-items: flex-end; }
  body.touch-ui #hud-ammo { bottom: 185px; }
  body.touch-ui #hud-status { bottom: 140px; }
}
