:root {
  --ink: #f3eee3;
  --muted: #a6b0bc;
  --amber: #e6a844;
  --amber-soft: rgba(230, 168, 68, 0.22);
  --cyan: #5ed4ff;
  --emerald: #44e298;
  --crimson: #ff4e42;
  --panel: rgba(11, 14, 19, 0.74);
  --border: rgba(243, 238, 227, 0.14);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #070a0f;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* ==================== TITLE SCREEN ==================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.title-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px 40px 22px;
  background:
    linear-gradient(90deg, rgba(7, 10, 15, 0.82) 0%, rgba(7, 10, 15, 0.44) 44%, rgba(7, 10, 15, 0.08) 100%),
    linear-gradient(180deg, rgba(7, 10, 15, 0.58) 0%, rgba(7, 10, 15, 0) 24%, rgba(7, 10, 15, 0.72) 100%);
}

.title-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 12px;
  letter-spacing: 0.18em;
}

.brand-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--amber);
}

.brand-sub {
  font-size: 12px;
  font-weight: 600;
  color: rgba(243, 238, 227, 0.78);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meta-sep {
  opacity: 0.4;
}

.title-hero {
  max-width: 560px;
  margin-top: auto;
  margin-bottom: auto;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--amber);
  margin-bottom: 14px;
}

.kicker-dot {
  width: 6px;
  height: 6px;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.hero-title {
  font-size: clamp(44px, 6.2vw, 76px);
  font-weight: 800;
  line-height: 0.94;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}

.hero-cn {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--amber);
}

.hero-desc {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(243, 238, 227, 0.8);
  max-width: 470px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 14px 26px;
  background: var(--amber);
  color: #101216;
  font-size: 13px;
}

.primary-btn:hover {
  background: #f3bc5f;
  transform: translateY(-1px);
}

.primary-btn.compact {
  padding: 10px 18px;
}

.secondary-btn {
  padding: 14px 20px;
  background: rgba(16, 20, 27, 0.72);
  border-color: var(--border);
  color: var(--ink);
  font-size: 12px;
  backdrop-filter: blur(10px);
}

.secondary-btn:hover {
  background: rgba(28, 35, 46, 0.86);
  border-color: rgba(243, 238, 227, 0.35);
}

.ghost-btn {
  padding: 8px 14px;
  background: rgba(12, 16, 22, 0.56);
  border-color: var(--border);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
}

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

.controls-strip {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.controls-strip b {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 600;
  margin-right: 4px;
}

.touch-hint-strip {
  display: none;
  margin-top: 18px;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.touch-hint-strip b {
  color: var(--amber);
  font-weight: 600;
  margin-right: 3px;
}

.portrait-tip {
  display: none;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(94, 212, 255, 0.9);
  background: rgba(9, 14, 22, 0.62);
  border: 1px solid rgba(94, 212, 255, 0.28);
  padding: 6px 10px;
  width: fit-content;
}

body.is-touch .controls-strip {
  display: none;
}

body.is-touch .touch-hint-strip {
  display: flex;
}

body.is-touch .touch-only-setting {
  display: flex;
}

.touch-only-setting {
  display: none;
}

.title-footer {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(166, 176, 188, 0.65);
  border-top: 1px solid rgba(243, 238, 227, 0.08);
  padding-top: 12px;
}

/* ==================== IN-GAME TACTICAL HUD ==================== */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.hud-objective {
  position: absolute;
  top: 24px;
  left: 28px;
  padding: 12px 16px;
  min-width: 240px;
  background: linear-gradient(90deg, rgba(9, 12, 17, 0.72), rgba(9, 12, 17, 0.22));
  border-left: 2px solid var(--amber);
  backdrop-filter: blur(6px);
}

.obj-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--amber);
}

.obj-title {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.obj-detail {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.override-bar {
  margin-top: 8px;
  height: 4px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.override-fill {
  height: 100%;
  width: 0%;
  background: var(--amber);
  transition: width 0.12s linear;
}

.hud-telemetry {
  position: absolute;
  top: 24px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(243, 238, 227, 0.72);
  background: rgba(9, 12, 17, 0.56);
  padding: 5px 8px 5px 12px;
  border: 1px solid rgba(243, 238, 227, 0.12);
  pointer-events: auto;
}

.hud-pause-btn {
  appearance: none;
  margin-left: 8px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(243, 238, 227, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hud-pause-btn:hover,
.hud-pause-btn:active {
  background: rgba(230, 168, 68, 0.2);
  border-color: var(--amber);
  color: var(--amber);
}

.tel-sep {
  margin: 0 6px;
  opacity: 0.4;
}

/* Dynamic Crosshair */
.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  --gap: 10px;
  transition: opacity 0.12s ease;
}

.ch-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(243, 238, 227, 0.92);
  top: -1px;
  left: -1px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}

.ch-line {
  position: absolute;
  background: rgba(243, 238, 227, 0.85);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}

.ch-top    { width: 1.5px; height: 8px; left: -0.75px; bottom: var(--gap); }
.ch-bottom { width: 1.5px; height: 8px; left: -0.75px; top: var(--gap); }
.ch-left   { height: 1.5px; width: 8px; top: -0.75px; right: var(--gap); }
.ch-right  { height: 1.5px; width: 8px; top: -0.75px; left: var(--gap); }

/* Crisp Hitmarker */
.hitmarker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: opacity 0.08s ease, transform 0.08s ease;
}

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

.hitmarker.crit .hm-arm {
  background: var(--crimson);
  box-shadow: 0 0 10px var(--crimson);
}

.hm-arm {
  position: absolute;
  width: 8px;
  height: 2px;
  background: var(--ink);
  top: 50%;
  left: 50%;
}
.hm-1 { transform: translate(-11px, -1px) rotate(45deg); }
.hm-2 { transform: translate(3px, -1px) rotate(-45deg); }
.hm-3 { transform: translate(-11px, -1px) rotate(-45deg); }
.hm-4 { transform: translate(3px, -1px) rotate(45deg); }

/* Directional Damage Indicator */
.damage-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170px;
  height: 170px;
  margin-left: -85px;
  margin-top: -85px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: rgba(255, 68, 52, 0.92);
  filter: drop-shadow(0 0 10px rgba(255, 68, 52, 0.7));
  opacity: 0;
  transition: opacity 0.14s ease;
}

.interact-prompt {
  appearance: none;
  position: absolute;
  top: 61%;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: rgba(9, 13, 19, 0.84);
  border: 1px solid rgba(94, 212, 255, 0.45);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
  pointer-events: auto;
  cursor: pointer;
}

.prompt-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--cyan);
  color: #081018;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}

.hud-toast {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 20px;
  background: rgba(11, 15, 22, 0.82);
  border: 1px solid var(--amber-soft);
  border-bottom: 2px solid var(--amber);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink);
}

body.fallback-look[data-view-mode="playing"] #game-canvas {
  cursor: crosshair;
}

.fallback-hint {
  display: none;
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(9, 12, 17, 0.72);
  border: 1px solid rgba(230, 168, 68, 0.28);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: rgba(243, 238, 227, 0.84);
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.fallback-hint b {
  color: var(--amber);
  font-weight: 600;
}

body.fallback-look:not(.is-touch) .fallback-hint {
  display: block;
}

@media (max-width: 1020px) {
  .fallback-hint {
    bottom: 162px;
    font-size: 10px;
    padding: 5px 12px;
    max-width: calc(100vw - 24px);
    white-space: nowrap;
    text-align: center;
  }
}

@media (max-width: 600px) {
  .fallback-hint {
    white-space: normal;
  }
}

/* Bottom-Left Vitals */
.hud-vitals {
  position: absolute;
  bottom: 26px;
  left: 28px;
  width: 230px;
  padding: 12px 14px;
  background: linear-gradient(90deg, rgba(9, 12, 17, 0.72), rgba(9, 12, 17, 0.22));
  border-left: 2px solid rgba(243, 238, 227, 0.28);
  backdrop-filter: blur(6px);
}

.vital-row {
  display: grid;
  grid-template-columns: 52px 1fr 28px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.vital-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

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

.vital-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease;
}

.armor-fill { background: var(--cyan); }
.hp-fill { background: var(--ink); }
.hp-fill.low { background: var(--crimson); }

.vital-num {
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  font-weight: 600;
}

.stance-strip {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.badge-on { color: var(--amber); }
.badge-off { opacity: 0.55; }

/* Bottom-Right Weapon Panel */
.hud-weapon {
  position: absolute;
  bottom: 26px;
  right: 28px;
  text-align: right;
  padding: 12px 16px;
  background: linear-gradient(270deg, rgba(9, 12, 17, 0.72), rgba(9, 12, 17, 0.18));
  border-right: 2px solid var(--amber);
  backdrop-filter: blur(6px);
}

.weapon-slots {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 8px;
  pointer-events: auto;
}

.weapon-slot {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: rgba(14, 19, 27, 0.72);
  border: 1px solid rgba(243, 238, 227, 0.14);
  color: rgba(243, 238, 227, 0.62);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.weapon-slot:hover {
  border-color: rgba(230, 168, 68, 0.45);
  color: var(--ink);
}

.weapon-slot.active {
  background: rgba(230, 168, 68, 0.22);
  border-color: var(--amber);
  color: var(--ink);
  box-shadow: 0 0 12px rgba(230, 168, 68, 0.22);
}

.slot-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.weapon-slot.active .slot-key {
  background: var(--amber);
  color: #0c0f15;
}

.slot-name {
  font-family: var(--font-sans);
  font-weight: 600;
}

.slot-ammo {
  font-size: 9px;
  opacity: 0.72;
}

.weapon-slot.active .slot-ammo {
  color: var(--amber);
  opacity: 1;
}

.weapon-name {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.ammo-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-family: var(--font-mono);
}

.ammo-mag {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.ammo-mag.low {
  color: var(--crimson);
}

.ammo-slash {
  color: rgba(243, 238, 227, 0.35);
  font-size: 18px;
}

.ammo-res {
  font-size: 16px;
  color: var(--muted);
}

.weapon-flags {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.flag-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

/* ==================== PHOTO MODE & MODALS ==================== */
.photo-bar {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 24px);
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  backdrop-filter: blur(12px);
}

.photo-bar b {
  color: var(--amber);
}

.photo-touch-hint,
.photo-touch-btn {
  display: none;
}

.photo-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

body.is-touch .photo-desktop-hint {
  display: none;
}

body.is-touch .photo-touch-hint {
  display: inline;
}

body.is-touch .photo-touch-btn {
  display: inline-flex;
}

.modal-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(12px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  touch-action: pan-y;
}

.modal-card {
  width: min(540px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(13, 17, 24, 0.94);
  border: 1px solid var(--border);
  padding: 26px 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
  touch-action: pan-y;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-card h2 {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.setting-item b {
  color: var(--amber);
}

.setting-item select,
.setting-item input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}

.setting-item select {
  background: #141923;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 10px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.setting-toggle input {
  accent-color: var(--amber);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.debrief-sub {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.stats-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 10px;
  text-align: center;
}

.stat-k {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-box strong {
  font-family: var(--font-mono);
  font-size: 20px;
}

.rank-gold {
  color: var(--amber);
}

/* ==================== ERGONOMIC MOBILE FPS TOUCH CONTROLS ==================== */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.touch-weapon-bar {
  pointer-events: auto;
  position: absolute;
  bottom: max(58px, calc(env(safe-area-inset-bottom) + 52px));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.t-weapon {
  min-width: 56px;
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
}

.touch-stick-zone {
  pointer-events: auto;
  position: absolute;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  left: max(16px, calc(env(safe-area-inset-left) + 10px));
  width: 142px;
  height: 142px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.touch-stick {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 22, 32, 0.25) 0%, rgba(10, 14, 21, 0.56) 100%);
  border: 1.5px solid rgba(243, 238, 227, 0.28);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(255, 255, 255, 0.05);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.touch-stick.sprinting {
  border-color: rgba(230, 168, 68, 0.85);
  box-shadow: 0 0 22px rgba(230, 168, 68, 0.32), inset 0 0 14px rgba(230, 168, 68, 0.18);
}

.touch-sprint-tag {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--amber);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.touch-stick.sprinting .touch-sprint-tag {
  opacity: 1;
}

.touch-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f5c774, #c98628);
  border: 2px solid rgba(255, 245, 226, 0.72);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.touch-right-cluster {
  pointer-events: none;
  position: absolute;
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.touch-aux-row {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.touch-combat-grid {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}

.touch-stance-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.touch-move-row {
  display: flex;
  gap: 8px;
}

.t-btn {
  appearance: none;
  pointer-events: auto;
  touch-action: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 22, 0.68);
  border: 1px solid rgba(243, 238, 227, 0.28);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  border-radius: 10px;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.t-btn:active,
.t-btn.pressed {
  transform: scale(0.93);
  background: rgba(230, 168, 68, 0.28);
  border-color: var(--amber);
}

.t-btn.active {
  background: rgba(230, 168, 68, 0.88);
  color: #101216;
  border-color: #f6c976;
  box-shadow: 0 0 14px rgba(230, 168, 68, 0.45);
}

.t-mini {
  min-width: 48px;
  height: 36px;
  padding: 0 8px;
}

.t-round {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 12px;
}

.t-fire {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(246, 195, 102, 0.95), rgba(206, 134, 34, 0.92));
  color: #101216;
  border: 2px solid rgba(255, 240, 208, 0.85);
  box-shadow: 0 8px 24px rgba(230, 168, 68, 0.35);
  font-size: 14px;
  font-weight: 800;
}

.t-fire .fire-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(230, 168, 68, 0.45);
  pointer-events: none;
}

.t-fire.firing {
  transform: scale(0.94);
  background: radial-gradient(circle at 35% 30%, #ffe09e, #e89b2c);
  box-shadow: 0 0 26px rgba(255, 174, 56, 0.72);
}

.t-use {
  position: absolute;
  bottom: max(168px, calc(env(safe-area-inset-bottom) + 162px));
  right: max(18px, calc(env(safe-area-inset-right) + 12px));
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  background: rgba(12, 34, 48, 0.9);
  border: 1.5px solid var(--cyan);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 0 22px rgba(94, 212, 255, 0.42);
}

/* ==================== TOUCH HUD REPOSITIONING (ZERO THUMB OVERLAP!) ==================== */
body.is-touch .hud-vitals {
  bottom: max(10px, env(safe-area-inset-bottom));
  left: calc(50% - 140px);
  width: 146px;
  padding: 6px 8px;
  border-left-width: 2px;
}

body.is-touch .hud-vitals .vital-row {
  grid-template-columns: 38px 1fr 22px;
  gap: 5px;
  margin-bottom: 4px;
}

body.is-touch .hud-vitals .vital-label {
  font-size: 9px;
  letter-spacing: 0.04em;
}

body.is-touch .hud-vitals .vital-num {
  font-size: 10px;
}

body.is-touch .hud-vitals .stance-strip {
  display: none;
}

body.is-touch .hud-weapon {
  bottom: max(10px, env(safe-area-inset-bottom));
  right: auto;
  left: calc(50% + 14px);
  width: 126px;
  padding: 6px 9px;
  text-align: left;
  border-right: none;
  border-left: 2px solid var(--amber);
  background: linear-gradient(90deg, rgba(9, 12, 17, 0.72), rgba(9, 12, 17, 0.22));
}

body.is-touch .hud-weapon .weapon-slots,
body.is-touch .hud-weapon .weapon-name,
body.is-touch .hud-weapon .weapon-flags {
  display: none;
}

body.is-touch .hud-weapon .ammo-line {
  justify-content: flex-start;
  margin-top: 0;
}

body.is-touch .hud-weapon .ammo-mag {
  font-size: 24px;
}

body.is-touch .hud-weapon .ammo-slash {
  font-size: 14px;
}

body.is-touch .hud-weapon .ammo-res {
  font-size: 13px;
}

body.is-touch .interact-prompt {
  top: 56%;
  padding: 8px 14px;
  font-size: 12px;
}

/* ==================== RESPONSIVE: PORTRAIT & NARROW SCREENS ==================== */
@media (max-width: 760px) {
  .title-screen {
    padding: max(54px, calc(env(safe-area-inset-top) + 46px)) 18px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    gap: 16px;
  }
  .topbar-meta span:not(#title-quality-badge) { display: none; }
  .brand-sub { display: none; }
  .hero-title { font-size: clamp(34px, 10.5vw, 52px); }
  .hero-cn { font-size: 15px; margin-top: 10px; }
  .hero-desc { font-size: 13px; line-height: 1.55; margin-top: 10px; }
  .hero-actions { margin-top: 18px; }
  .primary-btn, .secondary-btn { padding: 12px 18px; }
  .controls-strip { display: none; }
  .title-footer { flex-direction: column; gap: 4px; font-size: 9px; }

  .hud-objective {
    top: max(48px, calc(env(safe-area-inset-top) + 46px));
    left: max(10px, env(safe-area-inset-left));
    min-width: 0;
    max-width: 56vw;
    padding: 7px 10px;
  }
  .obj-title { font-size: 12px; }
  .obj-detail { font-size: 10px; }

  .hud-telemetry {
    top: max(48px, calc(env(safe-area-inset-top) + 46px));
    right: max(10px, env(safe-area-inset-right));
    padding: 4px 6px 4px 9px;
    font-size: 10px;
  }

  .hud-toast {
    top: 22%;
    max-width: 88vw;
    padding: 7px 14px;
    font-size: 11px;
    text-align: center;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-card { padding: 20px 18px; }
  .modal-card h2 { font-size: 20px; }

  /* Desktop narrow (non-touch) fallback */
  body:not(.is-touch) .hud-vitals,
  body:not(.is-touch) .hud-weapon { bottom: 14px; padding: 8px 10px; }
  body:not(.is-touch) .hud-vitals { left: 12px; width: 175px; }
  body:not(.is-touch) .hud-weapon { right: 12px; }
  body:not(.is-touch) .ammo-mag { font-size: 28px; }

  /* Portrait touch: lift joystick & right cluster neatly ABOVE centered status bar, weapon switcher cleanly above left stick */
  body.is-touch .touch-weapon-bar {
    bottom: max(206px, calc(env(safe-area-inset-bottom) + 200px));
    left: max(10px, env(safe-area-inset-left));
    transform: none;
    gap: 5px;
  }
  body.is-touch .t-weapon {
    min-width: 48px;
    height: 30px;
    padding: 0 8px;
    font-size: 10px;
  }
  body.is-touch .touch-stick-zone {
    bottom: max(68px, calc(env(safe-area-inset-bottom) + 62px));
    left: 10px;
    width: 126px;
    height: 126px;
  }
  body.is-touch .touch-stick {
    width: 102px;
    height: 102px;
  }
  body.is-touch .touch-right-cluster {
    bottom: max(68px, calc(env(safe-area-inset-bottom) + 62px));
    right: 10px;
  }
  body.is-touch .t-fire { width: 68px; height: 68px; font-size: 13px; }
  body.is-touch .t-round { width: 48px; height: 48px; font-size: 11px; }
  body.is-touch .t-mini { min-width: 44px; height: 34px; font-size: 10px; }
  body.is-touch .t-use { bottom: max(206px, calc(env(safe-area-inset-bottom) + 200px)); }
}

@media (max-width: 680px) and (orientation: portrait) {
  body.is-touch .portrait-tip {
    display: block;
  }
}

/* ==================== RESPONSIVE: MOBILE LANDSCAPE (SHORT HEIGHT!) ==================== */
@media (max-height: 520px) {
  .title-screen {
    padding: max(12px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    gap: 10px;
  }
  .topbar-meta span:not(#title-quality-badge) { display: none; }
  .hero-kicker { margin-bottom: 6px; font-size: 10px; }
  .hero-title { font-size: clamp(28px, 6.2vh, 42px); }
  .hero-cn { font-size: 13px; margin-top: 6px; }
  .hero-desc { font-size: 12px; line-height: 1.45; margin-top: 6px; max-width: 520px; }
  .hero-actions { margin-top: 12px; gap: 8px; }
  .primary-btn, .secondary-btn { padding: 9px 16px; font-size: 12px; }
  .controls-strip, .title-footer { display: none; }
  .touch-hint-strip { margin-top: 10px; padding-top: 8px; font-size: 10px; }

  .hud-objective {
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    min-width: 0;
    max-width: 34vw;
    padding: 6px 10px;
  }
  .obj-tag { font-size: 9px; }
  .obj-title { font-size: 12px; margin-top: 2px; }
  .obj-detail { font-size: 10px; margin-top: 1px; }

  .hud-telemetry {
    top: max(10px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 4px 6px 4px 9px;
    font-size: 10px;
  }

  .hud-toast {
    top: 16%;
    padding: 6px 14px;
    font-size: 11px;
  }

  /* Landscape touch: joystick & fire arc stay LOW on left/right corners, vitals+ammo & weapon bar centered cleanly between them! */
  body.is-touch .touch-weapon-bar {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 54px));
    left: 50%;
    transform: translateX(-50%);
    gap: 5px;
  }
  body.is-touch .t-weapon {
    min-width: 52px;
    height: 28px;
    padding: 0 9px;
    font-size: 10px;
  }
  body.is-touch .touch-stick-zone {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(14px, env(safe-area-inset-left));
    width: 124px;
    height: 124px;
  }
  body.is-touch .touch-stick {
    width: 98px;
    height: 98px;
  }
  body.is-touch .touch-right-cluster {
    bottom: max(10px, env(safe-area-inset-bottom));
    right: max(14px, env(safe-area-inset-right));
    gap: 6px;
  }
  body.is-touch .t-fire { width: 66px; height: 66px; font-size: 12px; }
  body.is-touch .t-round { width: 46px; height: 46px; font-size: 11px; }
  body.is-touch .t-mini { min-width: 44px; height: 32px; font-size: 10px; }
  body.is-touch .t-use { bottom: max(142px, calc(env(safe-area-inset-bottom) + 136px)); }

  .modal-card { padding: 16px 20px; }
  .modal-head { margin-bottom: 12px; }
  .modal-card h2 { font-size: 18px; }
  .settings-grid { gap: 10px; padding: 12px 0; }
  .modal-actions { margin-top: 12px; }
  .photo-bar { bottom: max(8px, env(safe-area-inset-bottom)); padding: 6px 12px; font-size: 10px; }
}
