html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

:root {
  --bone: #e8e0cf;
  --bone-dim: #b8ae99;
  --ochre: #c9a227;
  --ochre-dim: #8a7320;
  --red: #a83226;
  --red-bright: #c8442f;
  --ink: #14100c;
  --panel: rgba(16, 13, 10, 0.82);
}

/* ============ HUD ============ */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--bone);
}

.hud-corner {
  position: absolute;
  top: 18px;
  width: 240px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-left: 3px solid var(--ochre);
  padding: 8px 12px 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.hud-top-left {
  left: 18px;
}

.hud-top-right {
  right: 18px;
  border-left: 1px solid rgba(201, 162, 39, 0.35);
  border-right: 3px solid var(--ochre);
  text-align: right;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 5px;
}

.hud-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--bone-dim);
  letter-spacing: 1px;
}

.bar {
  position: relative;
  height: 12px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(232, 224, 207, 0.25);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.18s ease-out;
}

.bar-health {
  background: linear-gradient(180deg, #b8542e 0%, #8f3a1d 100%);
}

.bar-fort {
  background: linear-gradient(180deg, #c9a227 0%, #8a7320 100%);
}

.bar-fill.bar-low {
  background: linear-gradient(180deg, #c8442f 0%, #7e241a 100%);
  animation: bar-pulse 0.9s ease-in-out infinite;
}

@keyframes bar-pulse {

  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.5);
  }
}

.hud-top-center {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-bottom: 3px solid var(--ochre);
  padding: 6px 26px 8px;
  font-size: 15px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--bone);
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.hud-bottom-right {
  position: absolute;
  right: 22px;
  bottom: 24px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-right: 3px solid var(--ochre);
  padding: 10px 18px;
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--bone);
  text-shadow: 0 1px 2px #000;
}

/* Crosshair: dot + ring */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  transition: opacity 0.18s ease-out;
}

#crosshair.crosshair-hidden {
  opacity: 0;
  pointer-events: none;
}

.ch-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--bone);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 3px #000;
}

.ch-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(232, 224, 207, 0.75);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8), inset 0 0 4px rgba(0, 0, 0, 0.6);
}

/* Hit marker: white X flash at screen center */
#hit-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  opacity: 0;
}

#hit-marker::before,
#hit-marker::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 3px;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}

#hit-marker::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

#hit-marker::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

#hit-marker.hit-flash {
  animation: hit-marker-anim 0.24s ease-out forwards;
}

@keyframes hit-marker-anim {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.25);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
}

/* Contextual cannon prompt */
#cannon-hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-bottom: 3px solid var(--ochre);
  padding: 8px 22px 7px;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--bone);
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

/* Damage vignette */
#damage-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(168, 50, 38, 0) 42%, rgba(168, 50, 38, 0.6) 100%);
}

#damage-vignette.hit-flash {
  animation: damage-flash 0.45s ease-out;
}

@keyframes damage-flash {
  0% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
  }
}

/* ============ Intro toast ============ */

#intro-toast {
  position: fixed;
  top: 148px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-left: 4px solid var(--ochre);
  color: var(--bone);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 10px 22px;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}

#intro-toast.toast-show {
  animation: toast-life 4s ease forwards;
}

@keyframes toast-life {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }

  8% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  78% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ============ Pause overlay ============ */

#pause-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 3, 0.62);
  cursor: pointer;
  z-index: 10;
  user-select: none;
}

.pause-inner {
  font-family: Impact, 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  font-size: 34px;
  letter-spacing: 8px;
  text-transform: uppercase;
  color: var(--bone);
  text-align: center;
  text-shadow: 0 2px 6px #000;
}

.pause-inner span {
  display: block;
  margin-top: 10px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: none;
  color: var(--bone-dim);
}

/* ============ Full-screen screens (menu / victory / defeat) ============ */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--bone);
  background:
    radial-gradient(ellipse at 50% 42%, rgba(60, 38, 18, 0.35) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, #191411 0%, #100d0a 55%, #070605 100%);
}

.menu-inner,
.screen-inner {
  text-align: center;
  max-width: 860px;
  padding: 0 32px;
}

.menu-kicker,
.screen-kicker {
  font-size: 12px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 18px;
}

.screen-kicker-defeat {
  color: var(--red-bright);
}

.menu-title,
.screen-title {
  font-family: Impact, 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  font-weight: 400;
  font-size: clamp(56px, 11vw, 116px);
  line-height: 0.98;
  letter-spacing: 6px;
  text-transform: uppercase;
  margin: 0;
  color: var(--bone);
  text-shadow:
    0 3px 0 #2a1f14,
    0 6px 24px rgba(0, 0, 0, 0.9),
    0 0 80px rgba(201, 162, 39, 0.22);
}

.menu-rule {
  margin: 22px auto 24px;
  width: 320px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--red) 20%, var(--ochre) 50%, var(--red) 80%, transparent);
}

.menu-sub {
  font-size: 16px;
  line-height: 1.65;
  font-style: italic;
  color: var(--bone-dim);
  margin: 0 auto 34px;
  max-width: 620px;
}

.screen-title-victory {
  font-size: clamp(38px, 6.4vw, 72px);
  color: #e6d89a;
  text-shadow:
    0 3px 0 #2a2412,
    0 6px 26px rgba(0, 0, 0, 0.9),
    0 0 90px rgba(201, 162, 39, 0.35);
}

.screen-title-defeat {
  font-size: clamp(56px, 10vw, 104px);
  color: var(--red-bright);
  text-shadow:
    0 3px 0 #2a0f0a,
    0 6px 26px rgba(0, 0, 0, 0.9),
    0 0 90px rgba(168, 50, 38, 0.4);
}

.screen-cause {
  font-size: 17px;
  font-style: italic;
  color: var(--bone-dim);
  margin: 18px 0 34px;
}

/* Stats row (victory) */
.stats-row {
  display: flex;
  gap: 28px;
  justify-content: center;
  margin: 30px 0 38px;
}

.stat {
  min-width: 170px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-top: 3px solid var(--ochre);
  padding: 18px 22px 14px;
}

.stat-value {
  display: block;
  font-family: Impact, 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  font-size: 46px;
  letter-spacing: 2px;
  color: var(--bone);
}

.stat-label {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ochre);
}

/* Buttons */
.btn-primary {
  pointer-events: auto;
  font-family: Impact, 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  font-size: 22px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--ochre);
  background: transparent;
  border: 2px solid var(--ochre);
  padding: 14px 58px 12px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--ochre);
  color: var(--ink);
  box-shadow: 0 0 34px rgba(201, 162, 39, 0.35);
  outline: none;
}

.btn-primary-defeat {
  color: var(--red-bright);
  border-color: var(--red-bright);
}

.btn-primary-defeat:hover,
.btn-primary-defeat:focus-visible {
  background: var(--red-bright);
  color: var(--ink);
  box-shadow: 0 0 34px rgba(200, 68, 47, 0.35);
}

.btn-music,
.btn-voice {
  display: block;
  margin: 14px auto 0;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 10px 24px 9px;
  color: var(--bone-dim);
  border-color: var(--bone-dim);
}

.btn-music:hover,
.btn-music:focus-visible,
.btn-voice:hover,
.btn-voice:focus-visible {
  background: var(--bone-dim);
  color: var(--ink);
  box-shadow: 0 0 24px rgba(232, 224, 207, 0.2);
}

/* Mejoras HUD: score/misión + viñeta daño (sincronizado con rama misiones). */
.hud-bottom-right {
  min-width: 180px;
  text-align: right;
}

.hud-medkit {
  display: block;
  margin-top: 3px;
  color: #8ce0ad;
}

#damage-vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 56%, rgba(200, 68, 47, .55) 100%);
}

#damage-vignette.damage-flash {
  animation: damage-flash-anim .42s ease-out forwards;
}

@keyframes damage-flash-anim {
  0% {
    opacity: .95;
  }

  100% {
    opacity: 0;
  }
}

#heal-vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(46, 204, 113, .45) 100%);
}

#heal-vignette.heal-flash {
  animation: heal-flash-anim .55s ease-out forwards;
}

@keyframes heal-flash-anim {
  0% {
    opacity: .9;
  }

  100% {
    opacity: 0;
  }
}

#hud.hud-low-hp .hud-top-left {
  border-color: rgba(200, 68, 47, .7);
  border-left-color: var(--red-bright);
  animation: hud-pulse .9s ease-in-out infinite;
}

@keyframes hud-pulse {

  0%,
  100% {
    box-shadow: 0 2px 12px rgba(0, 0, 0, .6);
  }

  50% {
    box-shadow: 0 2px 18px rgba(200, 68, 47, .45);
  }
}

.mission-picker {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 0 0 22px;
  flex-wrap: wrap;
}

.mission-btn {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  line-height: 1.35;
  color: var(--bone-dim);
  background: rgba(16, 13, 10, .6);
  border: 1px solid rgba(201, 162, 39, .35);
  padding: 10px 18px;
  cursor: pointer;
  max-width: 280px;
  transition: border-color .18s, color .18s, background .18s;
}

.mission-btn:hover,
.mission-btn:focus-visible {
  border-color: var(--ochre);
  color: var(--bone);
  outline: none;
}

.mission-btn.is-active {
  border-color: var(--ochre);
  color: var(--ochre);
  background: rgba(201, 162, 39, .12);
}

.mission-brief {
  display: block;
  font-size: 11px;
  font-style: italic;
  opacity: .8;
  margin-top: 3px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 18px auto 0;
  max-width: 680px;
  font-size: 12px;
  color: var(--bone-dim);
  text-align: left;
}

.controls-grid b {
  color: var(--ochre);
}

@media (max-width: 640px) {
  .hud-corner {
    width: 168px;
  }

  .hud-bottom-right {
    min-width: 0;
    font-size: 18px;
  }

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


.menu-credits {
  margin-top: 40px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #7a7263;
}

/* ============ Objetivos, rachas y señales ============ */

.hud-objective {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ochre);
  text-transform: uppercase;
  max-width: 215px;
  line-height: 1.35;
}

.hud-signal {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-left: 3px solid var(--ochre);
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--bone);
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.65);
  animation: hud-signal-in 0.3s ease-out;
}

.hud-signal b {
  color: var(--ochre);
}

@keyframes hud-signal-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Radio de la guarnición */
#radio-line {
  position: absolute;
  left: 50%;
  bottom: 94px;
  transform: translateX(-50%);
  max-width: 34vw;
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  color: var(--bone);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  background: rgba(16, 13, 10, 0.55);
  border-left: 2px solid var(--ochre);
  border-right: 2px solid var(--ochre);
  padding: 7px 18px;
}

.radio-speaker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 3px;
}

/* Tarjeta de hecho histórico durante el combate */
#beat-card {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 340px;
  max-width: 42vw;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-left: 3px solid var(--ochre);
  padding: 10px 14px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  animation: beat-in 0.45s ease-out;
}

.beat-tag {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 5px;
}

.beat-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--bone);
}

.beat-source {
  margin-top: 6px;
  font-size: 10.5px;
  font-style: italic;
  color: var(--bone-dim);
}

@keyframes beat-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============ Cinemáticas ============ */

#cinematic {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--bone);
}

#cine-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
      rgba(0, 0, 0, 0) 48%,
      rgba(8, 6, 4, 0.34) 80%,
      rgba(4, 3, 2, 0.72) 100%);
  transition: opacity 0.6s ease;
}

#cinematic.active #cine-vignette {
  opacity: 1;
}

#cine-fade {
  position: absolute;
  inset: 0;
  background: #060504;
  opacity: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity 0.08s linear;
}

.cine-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  background: linear-gradient(180deg, #050403 0%, #0b0907 100%);
  z-index: 10;
  transition: height 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.cine-top {
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(201, 162, 39, 0.18);
  overflow: hidden;
}

.cine-bottom {
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(201, 162, 39, 0.18);
  overflow: hidden;
}

#cinematic.active .cine-bar {
  height: 9.5vh;
}

#cine-top-meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  opacity: 0;
  transition: opacity 0.45s ease 0.2s;
}

#cinematic.active #cine-top-meta {
  opacity: 1;
}

#cine-seq-kicker {
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ochre);
}

#cine-seq-title {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--bone-dim);
}

/* Ephemeral chapter title card shown briefly at sequence start */
#cine-title-card {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 10;
  padding: 26px 56px 28px;
  background: radial-gradient(ellipse 68% 60% at center, rgba(10, 8, 6, 0.70) 0%, rgba(10, 8, 6, 0.24) 48%, rgba(10, 8, 6, 0) 72%);
  opacity: 0;
  transition: opacity 0.65s ease, transform 0.65s ease;
}

#cine-title-card.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.cine-title-kicker {
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ochre);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.cine-title-main {
  margin-top: 8px;
  font-family: Impact, 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  font-size: clamp(28px, 4.2vw, 52px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.95);
}

.cine-title-rule {
  width: 110px;
  height: 2px;
  margin: 12px auto 10px;
  background: linear-gradient(90deg, transparent, var(--ochre), transparent);
}

.cine-title-sub {
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

#cine-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(920px, 92vw);
  opacity: 0;
  transition: opacity 0.35s ease 0.2s;
}

#cinematic.active #cine-hud {
  opacity: 1;
}

#cine-step {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ochre);
  white-space: nowrap;
}

#cine-progress {
  position: relative;
  flex: 1;
  height: 4px;
  background: rgba(201, 162, 39, 0.22);
  overflow: hidden;
  border-radius: 2px;
}

#cine-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--ochre), #f4d678);
  transition: width 0.1s linear;
}

#cine-progress-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cine-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(6, 5, 4, 0.85);
}

.cine-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.cine-ctrl-btn {
  pointer-events: auto;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(24, 20, 15, 0.85);
  border: 1px solid rgba(201, 162, 39, 0.45);
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.cine-ctrl-btn:hover,
.cine-ctrl-btn:focus-visible {
  background: var(--ochre);
  color: var(--ink);
  border-color: var(--ochre);
  outline: none;
}

.cine-ctrl-skip {
  color: var(--bone-dim);
  border-color: rgba(184, 174, 153, 0.35);
}

.cine-ctrl-skip:hover,
.cine-ctrl-skip:focus-visible {
  color: var(--ink);
}

/* Historical caption pinned cleanly top-left under top letterbox bar — zero overlap with subtitles */
#cine-caption {
  position: absolute;
  left: 3.2vw;
  top: 12vh;
  width: min(360px, 32vw);
  background: rgba(11, 9, 7, 0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(201, 162, 39, 0.26);
  border-left: 3px solid var(--ochre);
  padding: 11px 15px 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
  z-index: 10;
  animation: cine-card-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cine-card-in {
  from {
    opacity: 0.85;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.cine-caption-tag {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 5px;
}

.cine-caption-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--bone);
}

.cine-caption-source {
  margin-top: 6px;
  font-size: 10px;
  font-style: italic;
  color: var(--bone-dim);
}

/* Centered dialogue subtitle above bottom letterbox bar with subtle legible backing */
#cine-subtitle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12vh;
  max-width: min(760px, 78vw);
  text-align: center;
  font-size: 17px;
  line-height: 1.48;
  padding: 9px 24px 10px;
  background: linear-gradient(90deg, rgba(8, 6, 5, 0) 0%, rgba(8, 6, 5, 0.72) 12%, rgba(8, 6, 5, 0.72) 88%, rgba(8, 6, 5, 0) 100%);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.98);
  z-index: 10;
  animation: cine-sub-in 0.38s ease-out;
}

@keyframes cine-sub-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.cine-speaker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 4px;
}

/* ============ Briefing ============ */

#briefing-screen {
  overflow-y: auto;
  align-items: flex-start;
}

.brief-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 28px 56px;
  text-align: left;
}

.brief-kicker {
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ochre);
}

.brief-title {
  margin: 8px 0 10px;
  font-size: 42px;
  line-height: 1.05;
  color: var(--bone);
}

.brief-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13px;
  color: var(--bone-dim);
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.25);
}

.brief-body p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--bone);
  max-width: 66ch;
}

.brief-facts {
  margin: 18px 0 26px;
  display: grid;
  gap: 10px;
}

.brief-fact {
  border-left: 2px solid rgba(201, 162, 39, 0.5);
  padding: 2px 0 2px 12px;
}

.brief-fact-tag {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ochre);
}

.brief-fact-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--bone-dim);
}

.brief-fact-source {
  font-size: 10.5px;
  font-style: italic;
  color: rgba(184, 174, 153, 0.7);
}

.btn-link {
  background: none;
  border: none;
  color: var(--bone-dim);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  margin-left: 16px;
  text-decoration: underline;
}

.btn-link:hover,
.btn-link:focus-visible {
  color: var(--bone);
}

.cine-reel {
  margin: 0 0 22px;
  padding: 12px 14px;
  background: rgba(16, 13, 10, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-left: 3px solid var(--ochre);
}

.cine-reel-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 10px;
}

.cine-reel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cine-reel-btn {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12.5px;
  color: var(--bone-dim);
  background: rgba(24, 19, 14, 0.78);
  border: 1px solid rgba(201, 162, 39, 0.42);
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.cine-reel-btn:hover,
.cine-reel-btn:focus-visible {
  background: var(--ochre);
  color: var(--ink);
  border-color: var(--ochre);
  outline: none;
}


/* ============ Tactical HUD v3 ============ */

.hud-top-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#hud-compass {
  position: relative;
  width: 260px;
  height: 22px;
  overflow: hidden;
  background: rgba(16, 13, 10, 0.72);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-bottom: 2px solid var(--ochre);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--bone-dim);
  margin-bottom: 2px;
}

#hud-compass::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 6px;
  background: var(--ochre);
  transform: translateX(-50%);
}

#hud-compass-track {
  position: absolute;
  top: 4px;
  left: 50%;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: transform 0.05s linear;
}

#hud-compass-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.compass-marker {
  position: absolute;
  bottom: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: #e05242;
  box-shadow: 0 0 4px rgba(224, 82, 66, 0.9);
}

.compass-marker.marker-officer {
  background: #f0cf65;
  box-shadow: 0 0 5px rgba(240, 207, 101, 0.95);
}

.hud-enemies {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bone-dim);
  text-shadow: 0 1px 3px #000;
}

#hit-marker.hit-critical::before,
#hit-marker.hit-critical::after {
  background: #f5c842;
  width: 34px;
  height: 4px;
  box-shadow: 0 0 8px rgba(245, 200, 66, 0.95);
}

/* Active reload bar under crosshair */
#reload-bar {
  position: absolute;
  top: calc(50% + 36px);
  left: 50%;
  transform: translateX(-50%);
  width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reload-track {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(16, 13, 10, 0.85);
  border: 1px solid rgba(232, 224, 207, 0.35);
}

.reload-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  width: 16%;
  background: rgba(201, 162, 39, 0.78);
  box-shadow: 0 0 6px rgba(201, 162, 39, 0.7);
}

.reload-cursor {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  left: 0%;
  background: #ffffff;
  box-shadow: 0 0 4px #000;
}

#reload-bar.reload-jammed .reload-zone {
  background: rgba(168, 50, 38, 0.75);
}

.reload-hint {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--bone-dim);
  text-shadow: 0 1px 2px #000;
}

/* Floating combat callout */
#hud-badge {
  position: absolute;
  top: calc(50% + 66px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #f5c842;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
  font-weight: bold;
}

#hud-badge.badge-parry {
  color: #8ad8ff;
}

#hud-badge.badge-jam {
  color: #e25f4e;
}

/* Directional damage arc */
#damage-arc {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 240px;
  height: 240px;
  margin-left: -120px;
  margin-top: -120px;
  border-radius: 50%;
  pointer-events: none;
  border-top: 8px solid rgba(200, 48, 36, 0.9);
  box-shadow: inset 0 14px 20px -12px rgba(200, 48, 36, 0.7);
  opacity: 0;
  transition: opacity 0.12s ease-out;
}

#damage-arc.arc-active {
  opacity: 0.95;
}

/* ============ Menu record, Settings Modal & Battle Stats ============ */

.menu-record {
  display: inline-block;
  margin: 0 auto 14px;
  padding: 5px 14px;
  background: rgba(201, 162, 39, 0.14);
  border: 1px solid rgba(201, 162, 39, 0.45);
  color: var(--ochre);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.record-badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 6px 16px;
  background: rgba(201, 162, 39, 0.2);
  border: 1px solid var(--ochre);
  color: #f0cf65;
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.btn-secondary {
  margin-top: 14px;
  padding: 8px 18px;
  background: rgba(16, 13, 10, 0.85);
  border: 1px solid rgba(201, 162, 39, 0.55);
  color: var(--bone);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--ochre);
  color: var(--ink);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 7, 5, 0.84);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(460px, 92vw);
  background: rgba(20, 16, 12, 0.96);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-top: 3px solid var(--ochre);
  padding: 24px 26px;
  color: var(--bone);
  font-family: Georgia, 'Times New Roman', serif;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85);
}

.modal-title {
  margin: 4px 0 18px;
  font-size: 24px;
  color: var(--bone);
}

.setting-row {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--bone-dim);
}

.setting-row label {
  display: flex;
  justify-content: space-between;
}

.setting-row input[type="range"] {
  accent-color: var(--ochre);
  width: 100%;
}

.setting-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.setting-inline select {
  background: #1a1510;
  color: var(--bone);
  border: 1px solid rgba(201, 162, 39, 0.4);
  padding: 5px 8px;
  font-family: inherit;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.stats-row-compact {
  margin-bottom: 18px;
  gap: 18px;
}

/* ============ v4 Campaign Selector, Difficulty, Codex Dialog & Tactical HUD ============ */

#menu-screen {
  overflow-y: auto;
  align-items: flex-start;
  padding: 20px 0 28px;
}

.menu-inner-v4 {
  max-width: 980px;
  margin: auto;
  padding: 6px 24px 12px;
}

.menu-title-v4 {
  font-size: clamp(42px, 6.2vw, 76px);
  letter-spacing: 5px;
}

.menu-rule-v4 {
  margin: 12px auto 12px;
}

.menu-sub-v4 {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 auto 16px;
  max-width: 720px;
}

.section-mini-label {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 8px;
}

.campaign-section {
  margin: 0 auto 14px;
}

.campaign-selector {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 900px) {
  .campaign-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.campaign-card {
  font-family: Georgia, 'Times New Roman', serif;
  text-align: left;
  background: rgba(18, 14, 10, 0.86);
  border: 1px solid rgba(201, 162, 39, 0.32);
  border-top: 2px solid rgba(201, 162, 39, 0.45);
  color: var(--bone);
  padding: 10px 11px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s ease;
}

.campaign-card:hover,
.campaign-card:focus-visible {
  border-color: var(--ochre);
  background: rgba(34, 26, 17, 0.94);
  transform: translateY(-2px);
  outline: none;
}

.campaign-card.is-active {
  border-color: var(--ochre);
  border-top: 3px solid var(--ochre);
  background: rgba(201, 162, 39, 0.15);
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.22);
}

.campaign-card.is-done {
  border-bottom: 2px solid #59b37a;
}

.cc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.cc-war {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ochre);
}

.cc-war-2 {
  color: #e6825c;
}

.cc-badge {
  font-size: 9.5px;
  color: var(--bone-dim);
  white-space: nowrap;
}

.cc-done {
  color: #8ce0ad;
  font-weight: bold;
}

.cc-title {
  font-size: 13.5px;
  font-weight: bold;
  color: var(--bone);
  line-height: 1.25;
}

.cc-date {
  margin-top: 3px;
  font-size: 10.5px;
  font-style: italic;
  color: var(--bone-dim);
}

.difficulty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 auto 14px;
  flex-wrap: wrap;
}

.difficulty-row .section-mini-label {
  margin-bottom: 0;
}

.difficulty-picker {
  display: inline-flex;
  gap: 8px;
}

.diff-btn {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bone-dim);
  background: rgba(18, 14, 10, 0.78);
  border: 1px solid rgba(201, 162, 39, 0.34);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.diff-btn:hover,
.diff-btn:focus-visible {
  border-color: var(--ochre);
  color: var(--bone);
  outline: none;
}

.diff-btn.is-active {
  background: var(--ochre);
  color: var(--ink);
  border-color: var(--ochre);
  font-weight: bold;
}

.menu-actions-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px auto 10px;
}

.btn-menu-util {
  font-size: 14px;
  letter-spacing: 2.5px;
  padding: 13px 22px 11px;
  color: var(--bone);
  border-color: rgba(201, 162, 39, 0.55);
}

.menu-audio-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.btn-chip {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  background: rgba(16, 13, 10, 0.7);
  border: 1px solid rgba(184, 174, 153, 0.35);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.btn-chip:hover,
.btn-chip:focus-visible {
  background: var(--bone-dim);
  color: var(--ink);
  border-color: var(--bone);
  outline: none;
}

/* Native Modal Dialog: Historical Codex & Medals (modern-web-guidance compliant) */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(6, 5, 4, 0.84);
  backdrop-filter: blur(4px);
}

dialog.codex-dialog {
  width: min(760px, 92vw);
  max-height: 84vh;
  padding: 0;
  background: rgba(18, 14, 10, 0.97);
  border: 1px solid rgba(201, 162, 39, 0.52);
  border-top: 3px solid var(--ochre);
  color: var(--bone);
  font-family: Georgia, 'Times New Roman', serif;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.9);
}

dialog.codex-dialog[open] {
  display: flex;
  flex-direction: column;
}

.codex-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.24);
}

.codex-title {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: normal;
  color: var(--bone);
}

.codex-close-btn {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(34, 26, 18, 0.9);
  border: 1px solid rgba(201, 162, 39, 0.5);
  padding: 7px 14px;
  cursor: pointer;
}

.codex-close-btn:hover,
.codex-close-btn:focus-visible {
  background: var(--ochre);
  color: var(--ink);
  outline: none;
}

.codex-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 22px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.18);
  background: rgba(12, 9, 7, 0.7);
}

.codex-tab {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bone-dim);
  background: transparent;
  border: 1px solid rgba(201, 162, 39, 0.28);
  padding: 6px 14px;
  cursor: pointer;
}

.codex-tab.is-active {
  background: rgba(201, 162, 39, 0.22);
  border-color: var(--ochre);
  color: var(--ochre);
}

.codex-content {
  padding: 16px 22px 22px;
  overflow-y: auto;
  display: grid;
  gap: 12px;
}

.codex-entry {
  background: rgba(26, 20, 15, 0.72);
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-left: 3px solid var(--ochre);
  padding: 12px 14px;
}

.codex-cat {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 4px;
}

.codex-entry-title {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--bone);
}

.codex-entry-body {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--bone-dim);
}

.codex-entry-src {
  font-size: 11px;
  font-style: italic;
  color: rgba(184, 174, 153, 0.72);
}

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

@media (max-width: 640px) {
  .medals-grid {
    grid-template-columns: 1fr;
  }
}

.medal-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(201, 162, 39, 0.25);
  background: rgba(24, 19, 14, 0.78);
}

.medal-card.is-unlocked {
  border-color: var(--ochre);
  background: rgba(201, 162, 39, 0.14);
}

.medal-card.is-locked {
  opacity: 0.62;
}

.medal-icon {
  font-size: 22px;
  min-width: 30px;
  text-align: center;
}

.medal-info {
  flex: 1;
}

.medal-name {
  font-size: 13.5px;
  font-weight: bold;
  color: var(--bone);
}

.medal-desc {
  font-size: 11.5px;
  color: var(--bone-dim);
  margin-top: 2px;
}

.medal-status {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ochre);
}

/* HUD v4: Killfeed, Priority Boss Bar, Tactical Indicators & Medal Toast */
.hud-boss-bar {
  margin-top: 4px;
  width: 240px;
  text-align: center;
}

.hud-boss-label {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #f3cc6a;
  margin-bottom: 3px;
}

.hud-boss-track {
  height: 7px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(201, 162, 39, 0.45);
  overflow: hidden;
}

.hud-boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #a83226 0%, #e0523c 55%, #f0a846 100%);
  transition: width 0.16s ease-out;
}

.hud-killfeed {
  position: absolute;
  top: 104px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  max-width: 320px;
  pointer-events: none;
}

.kf-item {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  background: rgba(16, 13, 10, 0.78);
  border-right: 3px solid var(--ochre);
  color: var(--bone);
  text-shadow: 0 1px 2px #000;
  animation: kf-in 0.2s ease-out;
}

.kf-crit {
  border-right-color: #f5c842;
  color: #fce28b;
}

.kf-ally {
  border-right-color: #6ab7df;
  color: #c8e3f2;
}

.kf-special {
  border-right-color: #e6603c;
  color: #ffcdb8;
}

@keyframes kf-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.hud-tactical {
  color: #e6cf8b;
  letter-spacing: 0.06em;
}

.hud-medal-toast {
  position: absolute;
  top: 196px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  background: rgba(20, 16, 10, 0.94);
  border: 1px solid var(--ochre);
  border-left: 4px solid #f5c842;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.75);
  z-index: 8;
}

.medal-toast-icon {
  font-size: 22px;
}

.medal-toast-body {
  display: flex;
  flex-direction: column;
  text-align: left;
  font-size: 12px;
  color: var(--bone-dim);
}

.medal-toast-body strong {
  color: #f5c842;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.victory-historical-note {
  max-width: 660px;
  margin: 0 auto 14px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.5;
  font-style: italic;
  color: var(--bone-dim);
  background: rgba(16, 13, 10, 0.72);
  border-left: 3px solid var(--ochre);
}

.victory-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}