/* style.css */
@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #080d13;
  --surface: rgba(10, 18, 27, .88);
  --cream: #f4dfc0;
  --muted: #9aa5ae;
  --dim: #65717b;
  --orange: #ff8950;
  --orange-bright: #ffb06b;
  --cyan: #79e5e5;
  --red: #ff5b50;
  --line: rgba(244, 223, 192, .18);
  --line-bright: rgba(244, 223, 192, .34);
  --mono: "Space Mono", ui-monospace, monospace;
  --display: "Chakra Petch", "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #dfd2bf;
  --surface: rgba(250, 243, 229, .92);
  --cream: #241d19;
  --muted: #675d55;
  --dim: #85786d;
  --line: rgba(36, 29, 25, .19);
  --line-bright: rgba(36, 29, 25, .36);
}

* { box-sizing: border-box; }

html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--display);
  letter-spacing: .045em;
}

button {
  font: inherit;
  touch-action: manipulation;
}

#app {
  position: relative;
  isolation: isolate;
  background: var(--bg);
}

#viewport {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .13;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 3px,
    rgba(255,255,255,.055) 4px
  );
  mix-blend-mode: screen;
}

#hud {
  position: absolute;
  z-index: 4;
  inset: 0 0 auto;
  min-height: 112px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 58px);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 8, 13, .9), rgba(4, 8, 13, .25), transparent);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--orange);
  border: 1px solid var(--orange);
  font-weight: 700;
  font-size: 21px;
  transform: skew(-8deg);
  box-shadow: inset 0 0 18px rgba(255, 137, 80, .13);
}

.brand {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .18em;
}

.brand-sub {
  margin-top: 5px;
  color: var(--orange);
  font: 9px var(--mono);
  letter-spacing: .1em;
}

.objective {
  position: absolute;
  top: 83px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  color: var(--cyan);
  white-space: nowrap;
  text-transform: uppercase;
  font: 9px var(--mono);
  letter-spacing: .14em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 11px var(--cyan);
  animation: pulse 1.4s infinite;
}

.stats {
  display: flex;
  gap: clamp(14px, 3vw, 38px);
  text-align: right;
}

.stat {
  display: grid;
  gap: 3px;
  min-width: 48px;
}

.stat small,
.record span,
.report-grid small {
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: .16em;
}

.stat strong {
  font-size: 22px;
  line-height: 1;
  font-weight: 600;
}

.armor-stat { min-width: 72px; }

.armor-bar,
.meter-track {
  width: 72px;
  height: 3px;
  overflow: hidden;
  background: rgba(255,255,255,.13);
}

.armor-bar i,
.meter-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  transition: width .25s ease;
}

#waveMeter {
  position: absolute;
  z-index: 4;
  top: 126px;
  left: clamp(18px, 4vw, 58px);
  width: 150px;
  pointer-events: none;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font: 8px var(--mono);
  letter-spacing: .1em;
}

.meter-label b {
  color: var(--orange-bright);
  font-weight: 400;
}

.meter-track {
  width: 100%;
  height: 4px;
}

.meter-track i {
  width: 0;
  background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
}

#compass {
  position: absolute;
  z-index: 3;
  top: 20px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 17px;
  color: rgba(244,223,192,.45);
  transform: translateX(-50%);
  font: 9px var(--mono);
  pointer-events: none;
}

#compass span:first-child { color: var(--orange); }

#compass i {
  width: 1px;
  height: 7px;
  background: currentColor;
}

.panel {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  width: min(500px, calc(100% - 34px));
  transform: translate(-50%, -46%);
  padding: clamp(28px, 5vw, 52px);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(255,137,80,.045), transparent 38%),
    var(--surface);
  border: 1px solid var(--line-bright);
  box-shadow:
    0 30px 90px rgba(0,0,0,.48),
    inset 0 0 70px rgba(255,126,69,.035);
  backdrop-filter: blur(18px);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.panel::before {
  inset: 9px;
  border: 1px solid rgba(255,137,80,.16);
}

.panel::after {
  top: -1px;
  left: 24px;
  width: 74px;
  height: 2px;
  background: var(--orange);
  box-shadow: 0 0 14px var(--orange);
}

.panel-topline {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--cyan);
  font: 8px var(--mono);
  letter-spacing: .12em;
}

.panel-topline b {
  color: var(--muted);
  font-weight: 400;
}

.title-kicker {
  margin-top: 28px;
  color: var(--orange);
  font: 10px var(--mono);
  letter-spacing: .25em;
}

h1, h2 {
  margin: 13px 0 19px;
  font-size: clamp(46px, 11vw, 82px);
  line-height: .82;
  font-weight: 700;
  letter-spacing: -.055em;
}

h1 span,
h2 span {
  color: var(--orange);
}

h2 { font-size: clamp(43px, 10vw, 70px); }

.lead {
  max-width: 360px;
  margin: 0 auto 27px;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0;
}

.primary-button {
  position: relative;
  min-height: 52px;
  min-width: 210px;
  padding: 0 28px;
  color: #1a1110;
  background: var(--orange);
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  transition: transform .18s, filter .18s, box-shadow .18s;
  box-shadow: 0 8px 28px rgba(255,137,80,.18);
}

.primary-button i {
  position: absolute;
  right: 13px;
  bottom: 9px;
  width: 18px;
  height: 1px;
  background: #1a1110;
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.13);
  transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(255,137,80,.3);
}

.briefing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 31px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.briefing > div {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.brief-icon {
  color: var(--orange);
  font: 10px var(--mono);
}

.briefing b {
  font-size: 10px;
  letter-spacing: .12em;
}

.briefing small {
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  font-size: 10px;
  letter-spacing: 0;
}

.record {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  margin-top: 27px;
  color: var(--muted);
}

.record strong {
  color: var(--cyan);
  font: 700 18px var(--mono);
}

.record small {
  color: var(--dim);
  font: 9px var(--mono);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 26px 0;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.report-grid div {
  display: grid;
  gap: 8px;
}

.report-grid strong {
  color: var(--cyan);
  font: 700 17px var(--mono);
}

.hidden { display: none; }

#reticle {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: .9;
}

#reticle i,
#reticle b,
#reticle em,
#reticle strong {
  position: absolute;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

#reticle i,
#reticle b {
  left: 25px;
  width: 2px;
  height: 13px;
}

#reticle i { top: 0; }
#reticle b { bottom: 0; }

#reticle em,
#reticle strong {
  top: 25px;
  width: 13px;
  height: 2px;
}

#reticle em { left: 0; }
#reticle strong { right: 0; }

#reticle span {
  position: absolute;
  inset: 22px;
  border: 1px solid var(--orange);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255,137,80,.7);
}

#hitFlash,
#damageVignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
}

#hitFlash { background: rgba(255,142,82,.18); }
#hitFlash.flash { animation: flash .12s ease-out; }

#damageVignette {
  box-shadow: inset 0 0 120px 36px rgba(255,45,39,.55);
}

#damageVignette.damage { animation: damage .35s ease-out; }

#eventLog {
  position: absolute;
  z-index: 4;
  right: clamp(18px, 4vw, 58px);
  bottom: 25px;
  width: 210px;
  pointer-events: none;
  text-align: right;
}

.event {
  margin-top: 6px;
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: .08em;
  animation: eventIn .25s ease-out;
}

.event.good { color: var(--cyan); }
.event.warn { color: var(--orange-bright); }
.event.danger { color: var(--red); }
.event.fade { opacity: 0; transition: opacity .6s; }

.utility-button {
  position: absolute;
  z-index: 5;
  right: 18px;
  bottom: 18px;
  min-height: 38px;
  padding: 0 14px;
  color: var(--cream);
  background: rgba(8,14,21,.68);
  border: 1px solid var(--line);
  cursor: pointer;
  font: 9px var(--mono);
  letter-spacing: .1em;
}

#mobileControls { display: none; }

@keyframes pulse {
  50% { opacity: .35; transform: scale(.72); }
}

@keyframes flash {
  50% { opacity: 1; }
}

@keyframes damage {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes eventIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 700px) {
  #hud {
    min-height: 96px;
    padding: 16px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
    font-size: 17px;
  }

  .brand { font-size: 15px; }
  .brand-sub { font-size: 7px; }
  .stats { gap: 12px; }
  .stat small { font-size: 8px; }
  .stat strong { font-size: 17px; }
  .armor-stat { min-width: 55px; }
  .armor-bar { width: 55px; }

  .objective {
    top: 72px;
    font-size: 8px;
  }

  #waveMeter {
    top: 111px;
    left: 16px;
    width: 125px;
  }

  #compass { display: none; }

  .panel {
    width: calc(100% - 28px);
    padding: 26px 20px;
    transform: translate(-50%, -48%);
  }

  .panel-topline { font-size: 7px; }
  .title-kicker { margin-top: 23px; }
  h1 { margin-top: 11px; }
  .lead { font-size: 13px; margin-bottom: 22px; }

  .briefing {
    gap: 5px;
    margin-top: 24px;
    padding-top: 16px;
  }

  .briefing small {
    max-width: 75px;
    font-size: 9px;
  }

  #eventLog {
    right: 16px;
    bottom: 157px;
    width: 185px;
  }

  #mobileControls {
    display: block;
    position: absolute;
    z-index: 5;
    inset: auto 0 17px;
    height: 122px;
    pointer-events: none;
  }

  #joystick {
    position: absolute;
    left: 18px;
    bottom: 0;
    width: 108px;
    height: 108px;
    border: 1px solid rgba(245,223,188,.3);
    border-radius: 50%;
    background: rgba(8,17,25,.42);
    pointer-events: auto;
    touch-action: none;
  }

  #joystick::after {
    content: "";
    position: absolute;
    inset: 27px;
    border: 1px solid rgba(245,223,188,.26);
    border-radius: 50%;
  }

  #joystick span {
    position: absolute;
    z-index: 1;
    top: 39px;
    left: 39px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 16px rgba(255,135,78,.5);
    transition: transform .05s linear;
  }

  #fireButton {
    position: absolute;
    right: 18px;
    bottom: 10px;
    width: 88px;
    height: 88px;
    min-height: 0;
    padding: 0;
    color: #1a1110;
    background: var(--orange);
    border: 2px solid rgba(255,255,255,.22);
    border-radius: 50%;
    box-shadow: inset 0 0 0 8px rgba(255,255,255,.08);
    pointer-events: auto;
    font-size: 11px;
  }

  .utility-button {
    right: 16px;
    bottom: 155px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .panel {
    max-height: calc(100% - 24px);
    overflow-y: auto;
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .title-kicker { margin-top: 15px; }
  h1 { font-size: 48px; margin-bottom: 12px; }
  .lead { margin-bottom: 14px; }
  .briefing,
  .record { margin-top: 15px; }
}
