:root {
  color-scheme: dark;
  --ink: #f4eee1;
  --muted: #b8aa95;
  --panel: rgba(22, 18, 16, 0.78);
  --panel-strong: rgba(14, 12, 10, 0.92);
  --line: rgba(255, 240, 210, 0.2);
  --amber: #f8b233;
  --amber-strong: #ffcf56;
  --red: #d64336;
  --blue: #5cb6d8;
  --green: #74c55a;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080706;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 235, 190, 0.28);
  border-radius: 6px;
  background: rgba(24, 21, 19, 0.82);
  color: var(--ink);
  font: 800 0.82rem/1 "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--shadow);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(214, 67, 54, 0.24), transparent 34%),
    linear-gradient(135deg, #080706 0%, #211711 52%, #0d0a08 100%);
  transition:
    opacity 260ms ease,
    visibility 260ms ease;
}

.preloader-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(360px, 78vw);
  padding: 28px 24px;
  border: 1px solid rgba(255, 235, 190, 0.2);
  border-radius: 8px;
  background: rgba(14, 12, 10, 0.9);
  box-shadow: 0 22px 60px var(--shadow);
  text-align: center;
}

.preloader-logo {
  width: min(180px, 42vw);
  height: min(180px, 42vw);
  object-fit: contain;
}

.preloader p {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
}

.preloader span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

body.preload-done .preloader {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

button:hover,
button:focus-visible,
a.mode-card:hover,
a.mode-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 210, 100, 0.82);
  outline: none;
}

button:disabled {
  cursor: default;
  opacity: 0.48;
  transform: none;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  background: #0b0908;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
  touch-action: none;
}

#gameCanvas:focus-visible {
  outline: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.hud button,
.overlay button {
  pointer-events: auto;
}

.hud-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr minmax(210px, 330px);
  gap: 12px;
  align-items: center;
}

.brand,
.status-pill,
.gate-wrap,
.objective-card,
.ammo-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px var(--shadow);
  backdrop-filter: blur(8px);
}

.brand {
  padding: 10px 12px;
  text-transform: uppercase;
  font-weight: 900;
  line-height: 1;
}

.brand span {
  color: var(--red);
  display: block;
  font-size: clamp(0.92rem, 1.5vw, 1.18rem);
}

.brand strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.02rem, 1.8vw, 1.35rem);
}

.hud-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.status-pill {
  min-width: 96px;
  padding: 8px 12px;
  text-align: center;
}

.status-pill span,
.gate-wrap span,
.objective-card span,
.ammo-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill strong {
  display: block;
  margin-top: 3px;
  font-size: 1.15rem;
}

.gate-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.gate-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.gate-meter i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  transform-origin: left center;
}

.objective-card {
  position: absolute;
  top: 92px;
  right: 16px;
  width: min(370px, calc(100vw - 32px));
  padding: 12px 14px;
}

.objective-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.reload-badge {
  position: absolute;
  left: 50%;
  bottom: 30%;
  min-width: 138px;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border: 1px solid rgba(255, 210, 100, 0.4);
  border-radius: 8px;
  background: rgba(14, 12, 10, 0.84);
  color: var(--amber-strong);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.reload-badge.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hit-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

.hit-marker::before,
.hit-marker::after {
  content: "";
  position: absolute;
  inset: 15px 0 auto 0;
  height: 4px;
  border-radius: 999px;
  background: var(--amber-strong);
  box-shadow: 0 0 14px rgba(255, 205, 80, 0.9);
}

.hit-marker::after {
  transform: rotate(90deg);
}

.hit-marker.active {
  animation: hitMark 170ms ease-out;
}

@keyframes hitMark {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
}

.hud-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.ammo-panel {
  width: 168px;
  padding: 10px 12px;
}

.ammo-panel strong {
  display: block;
  margin-top: 3px;
  font-size: 1.35rem;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 94px));
  gap: 8px;
}

.control-row button {
  width: 100%;
  min-width: 0;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(5, 4, 4, 0.1), rgba(5, 4, 4, 0.62)),
    rgba(0, 0, 0, 0.36);
}

.overlay.active {
  display: grid;
}

.overlay-panel {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid rgba(255, 230, 180, 0.24);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
  padding: clamp(18px, 3vw, 30px);
}

.menu-panel {
  width: min(720px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber-strong);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  font-size: clamp(3rem, 10vw, 6.5rem);
}

h2 {
  font-size: clamp(2.1rem, 7vw, 4rem);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.mode-card {
  display: block;
  min-height: 170px;
  border: 1px solid rgba(255, 235, 190, 0.28);
  border-radius: 6px;
  padding: 18px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  background:
    linear-gradient(145deg, rgba(45, 36, 26, 0.95), rgba(16, 15, 15, 0.96));
  box-shadow: 0 8px 24px var(--shadow);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.mode-card.primary,
.primary-action {
  border-color: rgba(255, 202, 74, 0.72);
  background:
    linear-gradient(145deg, rgba(177, 63, 47, 0.92), rgba(38, 26, 21, 0.96));
}

.mode-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.mode-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.4rem, 3.8vw, 2.2rem);
}

.reward-panel {
  width: min(700px, 100%);
}

.reward-lines {
  display: grid;
  gap: 8px;
  margin: 22px 0;
}

.reward-lines div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.reward-lines strong {
  color: var(--ink);
}

.reward-lines .total {
  color: var(--amber-strong);
  font-size: 1.1rem;
}

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

.upgrade-item {
  min-height: 86px;
  padding: 12px;
  text-align: left;
}

.upgrade-item span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.upgrade-item strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.upgrade-item em {
  display: block;
  margin-top: 8px;
  color: var(--amber-strong);
  font-style: normal;
  font-size: 0.84rem;
}

.overlay-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 22px;
}

.overlay-actions button {
  width: 120px;
}

@media (max-width: 800px) {
  .hud-top {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .brand {
    display: none;
  }

  .hud-group {
    justify-content: stretch;
  }

  .status-pill {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
  }

  .gate-wrap {
    grid-template-columns: auto 1fr auto;
  }

  .objective-card {
    top: 148px;
    right: 10px;
    width: min(310px, calc(100vw - 20px));
  }

  .hud-bottom {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .control-row {
    grid-template-columns: repeat(2, minmax(0, 78px));
  }

  .control-row button {
    width: 100%;
    min-height: 40px;
    font-size: 0.72rem;
  }

  .ammo-panel {
    width: 128px;
  }

  .mode-grid,
  .upgrade-list {
    grid-template-columns: 1fr;
  }

  .mode-card {
    min-height: 120px;
  }
}

@media (max-height: 560px) {
  .objective-card {
    display: none;
  }

  .overlay-panel {
    max-height: calc(100vh - 24px);
  }
}
