:root {
  --amber: #ff8b3d;
  --amber-hot: #ffb35c;
  --cyan: #3ef0ff;
  --red: #ff3b28;
  --green: #38ff88;
  --panel-bg: rgba(14, 17, 24, 0.72);
  --panel-border: rgba(255, 148, 72, 0.34);
  --text-main: #f4efe9;
  --text-dim: #b4aba2;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #140e12;
  color: var(--text-main);
  font-family: 'Inter', 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* ---- Atmospheric & Damage FX Layer ---- */
#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.vignette-base {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 56%, rgba(10, 6, 8, 0.48) 100%);
}

.fx-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

.fx-shield {
  background:
    repeating-linear-gradient(60deg, rgba(62, 240, 255, 0.08) 0 2px, transparent 2px 18px),
    repeating-linear-gradient(-60deg, rgba(62, 240, 255, 0.08) 0 2px, transparent 2px 18px),
    radial-gradient(circle at 50% 50%, transparent 45%, rgba(62, 240, 255, 0.46) 100%);
}

.fx-hp {
  background: radial-gradient(circle at 50% 50%, transparent 40%, rgba(220, 26, 20, 0.65) 100%);
}

.fx-dash {
  background: radial-gradient(circle at 50% 50%, transparent 56%, rgba(62, 240, 255, 0.28) 100%);
  transition: opacity 0.06s ease-out;
}

.fx-low-hp {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, transparent 42%, rgba(165, 14, 14, 0.72) 100%);
}

.fx-low-hp.active {
  animation: pulseDanger 1.05s ease-in-out infinite;
}

@keyframes pulseDanger {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.85; }
}

#damage-arcs {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%);
}

.damage-arc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid transparent;
  border-top-color: rgba(255, 45, 30, 0.92);
  filter: drop-shadow(0 0 8px rgba(255, 45, 30, 0.8));
  pointer-events: none;
}

/* ---- In-Game HUD ---- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.hud-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 9px 14px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.hud-top-left {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wave-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.label-tag {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--amber);
  font-weight: 700;
}

.wave-num {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.wave-max {
  font-size: 13px;
  color: var(--text-dim);
}

.wave-subtitle {
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.hostile-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.dot-alert {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.score-val {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.combo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.combo-mult {
  font-size: 13px;
  font-weight: 800;
  color: var(--amber-hot);
}

.combo-track {
  width: 88px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.combo-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--amber), #ffe08a);
}

.hud-top-center {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(440px, 52vw);
}

.boss-bar {
  width: 100%;
  background: rgba(24, 10, 12, 0.82);
  border: 1px solid rgba(255, 62, 40, 0.55);
  padding: 8px 12px;
}

.boss-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ff9c88;
  margin-bottom: 5px;
}

.boss-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
}

.boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #b81d13, #ff4b2b);
  transition: width 0.08s linear;
}

.wave-banner {
  pointer-events: auto;
  background: rgba(16, 20, 28, 0.86);
  border: 1px solid var(--amber);
  padding: 10px 18px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.banner-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.08em;
}

.banner-sub {
  font-size: 13px;
  color: var(--text-main);
  margin: 4px 0 8px;
}

.btn-mini {
  background: rgba(255, 139, 61, 0.22);
  border: 1px solid var(--amber);
  color: #fff;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.wave-toast {
  background: rgba(16, 20, 28, 0.78);
  border-left: 3px solid var(--amber);
  border-right: 3px solid var(--amber);
  padding: 8px 24px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
}

.hud-top-right {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  pointer-events: auto;
}

.btn-hud-pause {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.btn-hud-pause:hover {
  border-color: var(--amber);
  color: var(--amber-hot);
}

/* ---- Center Reticle ---- */
#center-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair {
  position: relative;
  width: 4px;
  height: 4px;
  transition: opacity 0.1s;
}

.ch-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}

.ch-tick {
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.85);
}

.ch-top, .ch-bottom {
  width: 2px;
  height: 10px;
  left: 50%;
  transform: translateX(-50%);
}
.ch-left, .ch-right {
  width: 10px;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.ch-top { bottom: 10px; }
.ch-bottom { top: 10px; }
.ch-left { right: 10px; }
.ch-right { left: 10px; }

.hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%) scale(0.84);
  opacity: 0;
  transition: transform 0.08s ease-out, opacity 0.08s ease-out;
}

.hitmarker.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hm-kill-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 48, 32, 0.9);
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  box-shadow: 0 0 10px rgba(255, 34, 17, 0.7);
}

.hitmarker.kill .hm-kill-ring {
  opacity: 0.95;
  transform: translate(-50%, -50%) scale(1.18);
}

.hitmarker.kill.weakpoint .hm-kill-ring {
  border-color: #ff9a22;
  box-shadow: 0 0 12px rgba(255, 136, 20, 0.85);
}

.hm-arm {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 2px;
  border-radius: 1px;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}

.hm-tl { transform: translate(-50%, -50%) rotate(-135deg) translateX(10px); }
.hm-tr { transform: translate(-50%, -50%) rotate(-45deg) translateX(10px); }
.hm-bl { transform: translate(-50%, -50%) rotate(135deg) translateX(10px); }
.hm-br { transform: translate(-50%, -50%) rotate(45deg) translateX(10px); }

.hitmarker.shield .hm-arm {
  background: var(--cyan);
  box-shadow: 0 0 7px rgba(82, 242, 255, 0.78);
}

.hitmarker.weakpoint .hm-arm {
  background: #ffbe2e;
  width: 11px;
  height: 2.5px;
  box-shadow: 0 0 9px rgba(255, 110, 16, 0.9);
}
.hitmarker.weakpoint {
  transform: translate(-50%, -50%) scale(1.18);
}

.hitmarker.kill .hm-arm {
  background: #ff3624;
  width: 12px;
  height: 3px;
  box-shadow: 0 0 12px rgba(255, 28, 14, 0.95);
}
.hitmarker.kill {
  transform: translate(-50%, -50%) scale(1.34);
}

.rg-scope {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: min(76vh, 520px);
  height: min(76vh, 520px);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.scope-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(110, 235, 255, 0.58);
  box-shadow:
    0 0 0 200vmax rgba(3, 5, 8, 0.94),
    inset 0 0 38px 10px rgba(0, 0, 0, 0.84),
    inset 0 0 2px 1px rgba(82, 242, 255, 0.36);
}

.scope-line-l, .scope-line-r, .scope-line-t, .scope-line-b,
.scope-stadia-h, .scope-stadia-v {
  position: absolute;
  background: rgba(165, 248, 255, 0.58);
}
.scope-line-l { left: 3%; top: 50%; width: 41.5%; height: 1px; transform: translateY(-50%); }
.scope-line-r { right: 3%; top: 50%; width: 41.5%; height: 1px; transform: translateY(-50%); }
.scope-line-t { left: 50%; top: 3%; height: 41.5%; width: 1px; transform: translateX(-50%); }
.scope-line-b { left: 50%; bottom: 3%; height: 41.5%; width: 1px; transform: translateX(-50%); }
.scope-stadia-h { left: 46%; top: 56%; width: 8%; height: 1px; opacity: 0.65; }
.scope-stadia-v { left: 47.5%; top: 62%; width: 5%; height: 1px; opacity: 0.5; }

.scope-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #8ff8ff;
  box-shadow: 0 0 6px rgba(82, 242, 255, 0.9);
}

.reload-ring-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reload-ring-wrap svg {
  transform: rotate(-90deg);
}

.rr-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 4;
}

.rr-fg {
  fill: none;
  stroke: var(--amber-hot);
  stroke-width: 4;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 119.4;
}

.rr-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--amber-hot);
  margin-top: -2px;
}

.hud-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -68px);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--green);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

/* ---- Bottom Left Vitals & Dash ---- */
.hud-bottom-left {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  width: min(260px, 34vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vitals-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dash-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
}

.dash-icon {
  font-size: 11px;
  font-weight: 900;
  color: var(--text-dim);
  letter-spacing: -0.06em;
}

.dash-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.dash-panel.ready .dash-icon,
.dash-panel.ready .dash-label {
  color: var(--cyan);
}

.dash-panel.dashing .dash-icon,
.dash-panel.dashing .dash-label {
  color: #fff;
}

.dash-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.dash-fill {
  height: 100%;
  background: linear-gradient(90deg, #b86224, var(--amber-hot));
  transition: width 0.05s linear;
}

.dash-panel.ready .dash-fill {
  background: linear-gradient(90deg, #1aa3c8, var(--cyan));
  box-shadow: 0 0 6px rgba(62, 240, 255, 0.55);
}

.dash-panel.dashing .dash-fill {
  background: #fff;
}

.dash-status {
  min-width: 28px;
  text-align: right;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.dash-panel.ready .dash-status {
  color: var(--cyan);
}

.dash-panel.dashing .dash-status {
  color: #fff;
}

.hud-sprint-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.36);
}

.hud-sprint-badge.active {
  border-color: var(--amber);
  background: rgba(255, 139, 61, 0.24);
  color: var(--amber-hot);
  text-shadow: 0 0 6px rgba(255, 139, 61, 0.5);
}

.vital-row {
  display: grid;
  grid-template-columns: 56px 1fr 34px;
  align-items: center;
  gap: 8px;
}

.vital-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.shield-label { color: var(--cyan); }
.hp-label { color: #e8e2dc; }

.vital-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.vital-fill {
  height: 100%;
  transition: width 0.08s linear;
}

.shield-fill {
  background: linear-gradient(90deg, #1aa3c8, var(--cyan));
}

.hp-fill {
  background: linear-gradient(90deg, #cfcbc7, #ffffff);
}

.hp-fill.danger {
  background: linear-gradient(90deg, #b81a14, #ff3d2e);
}

.vital-num {
  text-align: right;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---- Bottom Right Weapon & Ammo ---- */
.hud-bottom-right {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  min-width: 225px;
  text-align: right;
  pointer-events: auto;
}

.weapon-title-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.weapon-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--amber-hot);
}

.reload-prompt {
  font-size: 11px;
  font-weight: 800;
  color: var(--red);
  animation: pulseDanger 0.7s infinite;
}

.ammo-readout {
  margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}

.ammo-mag {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.ammo-sep {
  font-size: 18px;
  color: var(--text-dim);
  margin: 0 3px;
}

.ammo-reserve {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
}

.weapon-strip {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.wslot {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-dim);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.wslot.active {
  background: rgba(255, 139, 61, 0.25);
  border-color: var(--amber);
  color: #fff;
}

/* ---- Mobile Multi-Touch Layer ---- */
.touch-layer {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: fixed;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 24, 32, 0.35);
  border: 2px solid rgba(255, 160, 92, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s;
}

.joystick-base.visible {
  opacity: 1;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 178, 108, 0.9), rgba(255, 120, 48, 0.65));
  border: 1px solid #fff;
}

.sprint-badge {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.sprint-badge.active {
  color: var(--amber-hot);
  text-shadow: 0 0 8px var(--amber);
}

.touch-actions {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 245px;
  height: 220px;
  pointer-events: none;
}

.touch-actions > * {
  pointer-events: auto;
}

.touch-weapons {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 8px;
}

.touch-wpill {
  background: rgba(16, 20, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-dim);
  padding: 6px 11px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 800;
}

.touch-wpill.active {
  border-color: var(--amber);
  background: rgba(255, 139, 61, 0.35);
  color: #fff;
}

.tbtn {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(18, 22, 30, 0.56);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.tbtn-fire {
  width: 78px;
  height: 78px;
  right: 6px;
  bottom: 58px;
  background: rgba(220, 74, 30, 0.55);
  border-color: var(--amber-hot);
  font-size: 15px;
  letter-spacing: 0.08em;
  box-shadow: 0 0 18px rgba(255, 110, 40, 0.35);
}
.tbtn-fire.active {
  background: rgba(255, 92, 36, 0.85);
  transform: scale(0.95);
}

.tbtn-ads {
  width: 56px;
  height: 56px;
  right: 12px;
  bottom: 148px;
}
.tbtn-ads.active {
  border-color: var(--cyan);
  background: rgba(62, 240, 255, 0.32);
  color: var(--cyan);
}

.tbtn-reload {
  width: 54px;
  height: 54px;
  right: 100px;
  bottom: 72px;
  font-size: 22px;
}

.tbtn-jump {
  width: 58px;
  height: 58px;
  right: 96px;
  bottom: 0;
}

.tbtn-sprint {
  width: 56px;
  height: 56px;
  right: 168px;
  bottom: 96px;
  flex-direction: column;
  gap: 1px;
  border-color: rgba(255, 160, 92, 0.48);
  color: rgba(255, 255, 255, 0.88);
}
.tbtn-sprint-icon {
  font-size: 10px;
  line-height: 1;
  color: var(--amber-hot);
  pointer-events: none;
}
.tbtn-sprint-label {
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.tbtn-sprint-state {
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
.tbtn-sprint.active {
  border-color: var(--amber-hot);
  background: rgba(255, 139, 61, 0.45);
  color: #fff;
  box-shadow: 0 0 14px rgba(255, 139, 61, 0.55);
}
.tbtn-sprint.active .tbtn-sprint-icon,
.tbtn-sprint.active .tbtn-sprint-state {
  color: #fff;
}

.tbtn-dash {
  width: 58px;
  height: 58px;
  right: 168px;
  bottom: 24px;
  overflow: hidden;
  border-color: rgba(62, 240, 255, 0.65);
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.tbtn-dash.cooldown {
  border-color: rgba(255, 255, 255, 0.24);
  color: rgba(255, 255, 255, 0.62);
}
.tbtn-dash.active {
  border-color: #fff;
  background: rgba(62, 240, 255, 0.36);
  color: #fff;
  transform: scale(0.95);
}
.tbtn-dash-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  background: rgba(62, 240, 255, 0.18);
  pointer-events: none;
}
.tbtn-dash-label {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

/* ---- Screens / Overlays ---- */
.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-loading {
  background: radial-gradient(circle at 50% 45%, #2b1a1b 0%, #120d10 100%);
  z-index: 40;
}

.loading-box {
  width: min(460px, 88vw);
  text-align: center;
}

.loading-bar-track {
  margin: 22px 0 12px;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 148, 72, 0.35);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber), #ffd288);
  transition: width 0.12s linear;
}

.loading-status {
  font-size: 13px;
  color: var(--text-dim);
}

.screen-title {
  justify-content: flex-start;
  padding: 24px clamp(20px, 5vw, 68px);
  background: linear-gradient(90deg, rgba(12, 10, 14, 0.84) 0%, rgba(12, 10, 14, 0.45) 48%, rgba(12, 10, 14, 0.08) 100%);
}

.title-card {
  width: min(500px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--amber);
}

.brand-title {
  font-size: clamp(36px, 5.4vw, 62px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.02;
  color: #fff;
  text-shadow: 0 4px 24px rgba(255, 110, 40, 0.35);
}

.brand-desc {
  font-size: 14px;
  line-height: 1.55;
  color: #d6cdc5;
}

.records-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(18, 20, 26, 0.72);
  border: 1px solid var(--panel-border);
  padding: 10px 12px;
}

.rec-item {
  display: flex;
  flex-direction: column;
}

.rec-lbl {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.rec-item strong {
  font-size: 17px;
  color: var(--amber-hot);
  font-variant-numeric: tabular-nums;
}

.title-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.opt-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 20, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}

.opt-group select, .setting-row select {
  background: #1a1e26;
  color: #fff;
  border: 1px solid rgba(255, 148, 72, 0.45);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.controls-guide {
  background: rgba(16, 19, 25, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 12px;
}

.guide-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.guide-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 6px;
  cursor: pointer;
}

.guide-tab.active {
  color: var(--amber-hot);
  border-bottom-color: var(--amber);
}

.guide-body {
  font-size: 12px;
  line-height: 1.65;
  color: #d6cdc5;
}

.guide-body b {
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, #e85a20, #ff993b);
  border: 1px solid #ffd29d;
  color: #150b07;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.14em;
  padding: 14px 26px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  transition: transform 0.08s, filter 0.12s;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
  transform: none;
}

.btn-secondary {
  background: rgba(24, 28, 36, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 9px 16px;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--amber);
  color: var(--amber-hot);
}

/* ---- Pause & Result Modals ---- */
.screen-modal {
  background: rgba(10, 11, 15, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-card {
  width: min(490px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(18, 21, 28, 0.94);
  border: 1px solid var(--panel-border);
  padding: 24px 26px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.modal-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--amber);
}

.modal-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 4px 0 16px;
}

.modal-title.victory { color: var(--amber-hot); }
.modal-title.gameover { color: var(--red); }

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.setting-row input[type="range"] {
  width: 150px;
  accent-color: var(--amber);
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
}

.setting-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--amber);
}

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

.modal-actions .btn-primary {
  flex: 1 1 180px;
  padding: 12px 18px;
  font-size: 14px;
}

.new-record-badge {
  display: inline-block;
  background: rgba(255, 160, 48, 0.22);
  border: 1px solid var(--amber-hot);
  color: #ffe28a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  margin-bottom: 12px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-cell {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.stat-cell span {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.stat-cell strong {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---- Orientation Guard ---- */
.orientation-guard {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 10, 14, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.guard-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.guard-box h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--amber-hot);
}

.guard-box p {
  font-size: 14px;
  color: var(--text-dim);
}

/* On touch UI, keep bottom-right ammo readout cleanly left of touch action cluster */
body.touch-ui .hud-bottom-right {
  right: 274px;
  min-width: 168px;
}
body.touch-ui .weapon-strip {
  display: none;
}

/* ---- Compact Landscape Smartphone Responsive Rules ---- */
@media (max-height: 500px) {
  .hud-panel {
    padding: 5px 10px;
  }
  .wave-num { font-size: 17px; }
  .score-val { font-size: 16px; }
  .ammo-mag { font-size: 24px; }
  .hud-bottom-left { width: 206px; gap: 4px; }
  .dash-panel { padding: 4px 9px; gap: 5px; }
  .hud-sprint-badge { display: none; }
  body.touch-ui .hud-bottom-right {
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .screen-title {
    padding: 10px 24px;
  }
  .title-card {
    gap: 7px;
  }
  .brand-title { font-size: 30px; }
  .brand-desc { font-size: 12px; line-height: 1.4; }
  .records-strip { padding: 6px 10px; }
  .controls-guide { padding: 7px 10px; }
  .btn-primary { padding: 9px 18px; font-size: 14px; }

  .modal-card {
    width: min(640px, 92vw);
    max-height: 94vh;
    padding: 12px 18px;
  }
  .modal-title {
    font-size: 21px;
    margin: 2px 0 8px;
  }
  .new-record-badge {
    padding: 2px 8px;
    margin-bottom: 6px;
    font-size: 11px;
  }
  .result-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
  }
  .stat-cell {
    padding: 5px 8px;
  }
  .stat-cell span { font-size: 9px; }
  .stat-cell strong { font-size: 15px; }
  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 14px;
    margin-bottom: 10px;
  }
  .setting-row, .setting-check { font-size: 12px; }
  .setting-row input[type="range"] { width: 105px; }
  .modal-actions .btn-primary { padding: 9px 14px; font-size: 13px; }
  .modal-actions .btn-secondary { padding: 8px 14px; font-size: 12px; }
}
