:root {
  color-scheme: dark;
  font-family: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  background: #050607;
  --safe-top: max(10px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(10px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
  --blood: #e01925;
  --teal: #62d4d4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #050607;
}

body .lbfab {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

body { min-height: 100dvh; }

button,
input { font: inherit; }

button,
.button-link {
  min-width: 44px;
  min-height: 44px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  padding: .75rem 1.1rem;
  border: 1px solid #738182;
  color: #e8f2ef;
  background: #192022;
  font-weight: 900;
  letter-spacing: .06em;
  cursor: pointer;
}

button:focus-visible {
  border-color: var(--teal);
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
button.primary { border-color: #ef4b46; background: linear-gradient(#9a1c20, #540d13); }

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .75rem 1.1rem;
  border: 1px solid #738182;
  color: #e8f2ef;
  background: #192022;
  font-weight: 900;
  letter-spacing: .06em;
  text-decoration: none;
}

.button-link:focus-visible {
  border-color: var(--teal);
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  button:hover,
  .button-link:hover { border-color: var(--teal); }
}

button:disabled {
  cursor: progress;
  opacity: .72;
  filter: saturate(.72);
}

.game-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
  background: #050607;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #050607;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + .28rem);
  left: calc(var(--safe-left) + .28rem);
  right: calc(var(--safe-right) + .28rem);
  display: grid;
  grid-template-columns: minmax(15rem, 1.18fr) minmax(13rem, 1fr) auto;
  gap: .32rem;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px #000);
}

.hud__block,
.hud__progress {
  position: relative;
  border: 1px solid rgb(128 171 168 / 58%);
  background:
    linear-gradient(115deg, rgb(10 17 18 / 94%), rgb(2 6 7 / 76%)),
    repeating-linear-gradient(90deg, transparent 0 12px, rgb(130 190 184 / 8%) 12px 13px);
  box-shadow: inset 0 1px 0 rgb(220 255 245 / 9%), inset 0 -2px 0 rgb(0 0 0 / 68%);
  backdrop-filter: blur(4px);
  clip-path: polygon(0 0, calc(100% - .48rem) 0, 100% .48rem, 100% 100%, .48rem 100%, 0 calc(100% - .48rem));
}

.hud__block::after {
  content: "";
  position: absolute;
  left: .3rem;
  right: .3rem;
  bottom: 2px;
  height: 1px;
  background: linear-gradient(90deg, #d72f37, transparent 68%);
}

.hud__block {
  display: grid;
  min-width: 0;
  align-items: center;
  gap: .28rem .42rem;
  min-height: 2.9rem;
  padding: .3rem .58rem;
}

.hud__block--vitals { grid-template-columns: 1.55rem auto minmax(3.2rem, 1fr) auto minmax(3.2rem, .82fr); }
.hud__block--weapon { grid-template-columns: 1.55rem minmax(5.6rem, 1fr) auto minmax(3rem, .65fr); color: #a3efea; }
.hud__block--score { display: flex; min-width: 6.2rem; align-items: baseline; justify-content: flex-end; justify-self: end; }
.hud__block strong { color: #f7fffc; font-size: clamp(1rem, 2.6vw, 1.45rem); font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 0 8px currentColor; }
.hud__block--vitals #health { color: #ff5a58; }
.hud__block--vitals #armour { color: #64d9e1; }
.hud__label { display: block; color: #8ba09e; font-size: .54rem; font-weight: 900; letter-spacing: .16em; line-height: 1; }
.hud__metric { display: grid; min-width: 0; gap: .18rem; }
.hud__metric--weapon #weapon { overflow: hidden; font-size: .7rem; font-weight: 900; letter-spacing: .06em; text-overflow: ellipsis; white-space: nowrap; }
.hud__metric--ammo { text-align: right; }

.hud__icon {
  position: relative;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid rgb(182 225 219 / 48%);
  background: radial-gradient(circle, rgb(214 255 246 / 12%) 0 30%, rgb(1 5 6 / 78%) 32%);
  box-shadow: inset 0 0 0 2px #081011, 0 0 8px rgb(72 200 200 / 18%);
  transform: rotate(45deg);
}
.hud__icon::before,
.hud__icon::after { content: ""; position: absolute; inset: 50% auto auto 50%; background: #e43b42; transform: translate(-50%, -50%) rotate(-45deg); }
.hud__icon--vitals::before { width: .72rem; height: .2rem; }
.hud__icon--vitals::after { width: .2rem; height: .72rem; }
.hud__icon--weapon::before { width: .78rem; height: .18rem; background: #58d6dc; transform: translate(-50%, -50%) rotate(-45deg) skewX(-22deg); }
.hud__icon--weapon::after { width: .2rem; height: .44rem; background: #58d6dc; transform: translate(-10%, -8%) rotate(-45deg); }

.hud__meter {
  position: relative;
  display: block;
  min-width: 2.7rem;
  height: .42rem;
  overflow: hidden;
  border: 1px solid #263536;
  background: repeating-linear-gradient(90deg, #071011 0 8px, #142021 8px 9px);
  box-shadow: inset 0 1px 3px #000;
}
.hud__meter > span {
  display: block;
  width: var(--hud-fill, 0%);
  height: 100%;
  background: repeating-linear-gradient(90deg, currentColor 0 7px, rgb(0 0 0 / 35%) 7px 9px);
  box-shadow: 0 0 8px currentColor;
  transition: width .12s linear;
}
.hud__meter--health { color: #e53b43; }
.hud__meter--armour { color: #45c2cf; }
.hud__meter--ammo { color: #e39a39; }
.hud__progress { grid-column: 1 / -1; justify-self: start; padding: .22rem .48rem; color: #c4d2cf; font-size: .66rem; letter-spacing: .04em; }
.hud__progress-label { margin-right: .4rem; color: #e43b42; font-size: .52rem; font-weight: 900; letter-spacing: .14em; }

.crosshair {
  position: absolute;
  z-index: 11;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgb(235 255 246 / 82%);
  box-shadow: 0 0 3px #000;
}
.crosshair::before { left: 8px; top: 1px; width: 2px; height: 16px; }
.crosshair::after { left: 1px; top: 8px; width: 16px; height: 2px; }

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 24%;
  min-width: min(80vw, 22rem);
  max-width: 88vw;
  padding: .65rem .9rem;
  transform: translate(-50%, -12px);
  opacity: 0;
  text-align: center;
  color: #fff;
  border: 1px solid #b42830;
  background: rgb(41 4 8 / 84%);
  font-weight: 900;
  letter-spacing: .08em;
  pointer-events: none;
  transition: opacity .16s linear, transform .16s linear;
}
.toast--visible { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  padding: calc(var(--safe-top) + 1rem) calc(var(--safe-right) + 1rem) calc(var(--safe-bottom) + 1rem) calc(var(--safe-left) + 1rem);
  overflow: auto;
  background: radial-gradient(circle at 50% 35%, rgb(35 58 57 / 76%), rgb(2 4 5 / 95%) 66%);
  touch-action: pan-y;
}
.overlay--visible { display: grid; }

/* Safari-specific control surfaces must never hand a gesture to page zoom. */
.fps-touch-controls,
.fps-touch-stick,
.fps-touch-look,
.fps-touch-button {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.campaign-overlay-open .gg-open,
body.status-overlay-open .gg-open { display: none !important; }

@media (pointer: coarse), (any-pointer: coarse) {
  body.fps-playing .lbfab { display: none !important; }
}

#start-overlay {
  place-items: center start;
  background-image:
    linear-gradient(90deg, rgb(2 4 5 / 96%) 0%, rgb(2 4 5 / 86%) 38%, rgb(2 4 5 / 28%) 72%, rgb(2 4 5 / 62%) 100%),
    linear-gradient(0deg, rgb(2 4 5 / 84%), transparent 40%),
    url("./assets/marketing/red-shift-relay-key-art-web-v1.webp");
  background-position: center;
  background-size: cover;
}

#start-overlay .panel--hero {
  width: min(56rem, 100%);
  background: linear-gradient(135deg, rgb(13 18 19 / 94%), rgb(5 7 8 / 88%));
  backdrop-filter: blur(5px);
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(17rem, .92fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: end;
}

.hero-copy,
.hero-setup { min-width: 0; }

.panel {
  width: min(42rem, 100%);
  padding: clamp(1rem, 4vw, 2.2rem);
  border: 1px solid #43585a;
  border-left: 4px solid var(--blood);
  background: linear-gradient(135deg, rgb(20 28 29 / 96%), rgb(8 10 11 / 97%));
  box-shadow: 0 1.2rem 4rem rgb(0 0 0 / 65%);
}

.eyebrow { margin: 0 0 .5rem; color: #e34d52; font-size: .7rem; font-weight: 900; letter-spacing: .18em; }
h1, h2 { margin: 0; color: #eef5f2; font-stretch: condensed; line-height: .92; text-transform: uppercase; }
h1 { font-size: clamp(2.5rem, 11vw, 6rem); letter-spacing: -.05em; }
h2 { font-size: clamp(2rem, 8vw, 4rem); }
.advisory-badge { display: inline-block; margin: .55rem 0 0; padding: .28rem .45rem; border: 1px solid #984148; color: #f0c1c1; background: rgb(96 10 16 / 36%); font-size: .66rem; font-weight: 900; letter-spacing: .1em; }
.lede { color: #d0dbd8; font-size: clamp(1rem, 2.4vw, 1.2rem); line-height: 1.48; }
.content-warning { padding: .75rem; border-left: 3px solid #d52a32; background: rgb(121 13 20 / 20%); color: #e8c7c5; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin: 1rem 0; }
.hero-actions { margin-bottom: 0; }
details { color: #bdc9c7; }
summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  touch-action: manipulation;
  cursor: pointer;
  color: #7cdad6;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
}
.settings-grid { display: grid; gap: .65rem; padding-top: .5rem; }
.settings-grid p { margin: 0; line-height: 1.4; }
.settings-grid label { display: flex; align-items: center; gap: .65rem; min-height: 44px; }
.settings-grid input[type="checkbox"] { width: 1.35rem; height: 1.35rem; accent-color: var(--blood); }
.settings-grid input[type="range"] { flex: 1; accent-color: var(--teal); }

.character-picker,
.difficulty-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.character-picker legend,
.difficulty-picker legend {
  margin-bottom: .5rem;
  color: #9de8e2;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.character-picker { margin-bottom: .8rem; }
.character-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }

.character-option {
  display: grid;
  grid-template-columns: auto 3.25rem minmax(0, 1fr);
  align-items: center;
  gap: .48rem;
  min-height: 62px;
  touch-action: manipulation;
  padding: .35rem .48rem;
  border: 1px solid #445153;
  background: rgb(4 8 9 / 78%);
  cursor: pointer;
}

.character-option:has(input:checked) {
  border-color: #e34d52;
  background: linear-gradient(100deg, rgb(119 16 23 / 52%), rgb(6 11 12 / 78%));
  box-shadow: inset 0 0 0 1px rgb(255 100 106 / 24%);
}

.character-option:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
.character-option input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--blood); }
.character-option img { width: 3.25rem; height: 3.25rem; border: 1px solid #617174; object-fit: cover; image-rendering: pixelated; }
.character-option span { display: grid; gap: .08rem; min-width: 0; }
.character-option strong { color: #f0f6f4; font-size: .76rem; letter-spacing: .045em; text-transform: uppercase; }
.character-option small { color: #aebcba; font-size: .64rem; line-height: 1.22; }

.difficulty-options { display: grid; gap: .42rem; }

.difficulty-option {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 52px;
  touch-action: manipulation;
  padding: .5rem .65rem;
  border: 1px solid #445153;
  background: rgb(4 8 9 / 72%);
  cursor: pointer;
}

.difficulty-option:has(input:checked) {
  border-color: #e34d52;
  background: linear-gradient(90deg, rgb(119 16 23 / 46%), rgb(6 11 12 / 74%));
}

.difficulty-option:focus-within {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.difficulty-option input {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
  accent-color: var(--blood);
}

.difficulty-option span { display: grid; gap: .08rem; }
.difficulty-option strong { color: #f0f6f4; text-transform: uppercase; letter-spacing: .07em; }
.difficulty-option small { color: #aebcba; line-height: 1.3; }

.panel--campaign { width: min(48rem, 100%); min-width: 0; }

.mission-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: .8rem;
}

.mission-header .eyebrow { margin-bottom: .25rem; }
.mission-position { margin: 0; color: #aebcba; font-size: .78rem; font-weight: 800; letter-spacing: .06em; }
.difficulty-badge { margin: 0; padding: .35rem .55rem; border: 1px solid #8f3035; color: #f4c6c6; background: rgb(91 11 17 / 42%); font-size: .68rem; font-weight: 900; letter-spacing: .12em; }

.mission-briefing {
  margin: 1rem 0;
  color: #d4dedb;
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  line-height: 1.5;
}

.mission-objective {
  padding: .72rem .8rem;
  border-left: 3px solid var(--teal);
  background: rgb(25 61 61 / 28%);
}

.mission-objective span,
.mission-results h3 {
  color: #82dfda;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.mission-objective p { margin: .25rem 0 0; color: #edf5f2; line-height: 1.4; }
.mission-results { margin-top: 1rem; }
.mission-results h3 { margin: 0 0 .45rem; }
.mission-results dl { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; margin: 0; }
.mission-results dl div { min-width: 0; padding: .5rem; border: 1px solid #394748; background: rgb(2 5 6 / 54%); }
.mission-results dt { color: #94a6a3; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mission-results dd { overflow: hidden; margin: .18rem 0 0; color: #fff; font-size: clamp(.92rem, 3vw, 1.25rem); font-weight: 900; text-overflow: ellipsis; }
.mission-next { margin: .75rem 0 0; color: #c6d3d0; line-height: 1.4; }
.mission-actions { margin-bottom: 0; }

@media (pointer: coarse), (any-pointer: coarse) {
  #view { cursor: none; }
  .hud { grid-template-columns: minmax(12rem, 1.15fr) minmax(10rem, 1fr) auto; }
  .hud__progress {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    padding: .18rem .38rem;
    font-size: .54rem;
    line-height: 1.22;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .hud__progress-label { display: none; }
}

@media (orientation: portrait) and (max-width: 600px) {
  .hud { grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); }
  .hud__block { min-height: 2.5rem; padding: .24rem .36rem; }
  .hud__block--vitals { grid-template-columns: auto minmax(2rem, 1fr) auto minmax(2rem, .8fr); }
  .hud__block--weapon { grid-template-columns: minmax(3.8rem, 1fr) auto; }
  .hud__block--score, .hud__icon, .hud__meter { display: none; }
  .hud__label { font-size: .48rem; }
  .hud__metric--weapon #weapon { font-size: .58rem; }
  .panel { margin: auto 0; }
  #start-overlay {
    place-items: end center;
    background-position: 44% center;
  }
  #start-overlay .panel--hero { background: linear-gradient(180deg, rgb(9 12 13 / 86%), rgb(5 7 8 / 97%)); }
  .hero-layout { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  .mission-results dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .overlay {
    place-items: center;
    padding: calc(var(--safe-top) + .35rem) calc(var(--safe-right) + .35rem) calc(var(--safe-bottom) + .35rem) calc(var(--safe-left) + .35rem);
  }

  #start-overlay { place-items: center start; }
  #start-overlay .panel--hero,
  .panel--campaign {
    width: min(48rem, 100%);
    padding: .65rem .8rem;
  }

  .hero-layout { grid-template-columns: minmax(0, 1fr) minmax(19rem, 1.12fr); gap: .8rem; align-items: start; }
  .panel--hero > .eyebrow { margin-bottom: .15rem; font-size: .58rem; }
  h1 { font-size: clamp(2rem, 7vw, 2.8rem); }
  h2 { font-size: clamp(1.7rem, 6vw, 2.6rem); }
  .advisory-badge { margin-top: .18rem; padding: .18rem .3rem; font-size: .55rem; }
  .lede { margin: .35rem 0; font-size: .78rem; line-height: 1.28; }
  .content-warning { margin: .35rem 0 0; padding: .38rem .48rem; font-size: .67rem; line-height: 1.25; }
  .character-picker { margin-bottom: .35rem; }
  .character-picker legend,
  .difficulty-picker legend { margin-bottom: .25rem; font-size: .62rem; }
  .character-options { gap: .3rem; }
  .character-option { grid-template-columns: auto 2.45rem minmax(0, 1fr); min-height: 44px; gap: .3rem; padding: .24rem .32rem; }
  .character-option input { width: 1rem; height: 1rem; }
  .character-option img { width: 2.45rem; height: 2.45rem; }
  .character-option strong { font-size: .66rem; }
  .character-option small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .difficulty-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem; }
  .difficulty-option { min-height: 44px; padding: .35rem .4rem; gap: .35rem; }
  .difficulty-option input { width: 1rem; height: 1rem; }
  .difficulty-option strong { font-size: .7rem; letter-spacing: .03em; }
  .difficulty-option small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .35rem;
    margin: .4rem 0 0;
  }
  .hero-actions > *,
  .mission-actions > * {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: .45rem .55rem;
    font-size: .7rem;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
  }
  .hero-actions:has(#continue[hidden]) #play { grid-column: 1 / -1; }
  .panel--hero > details { margin-top: .2rem; }
  .panel--hero > details summary { min-height: 44px; font-size: .7rem; }

  .mission-header { margin-bottom: .35rem; }
  .mission-position { font-size: .65rem; }
  .difficulty-badge { padding: .25rem .4rem; font-size: .58rem; }
  .mission-briefing { margin: .45rem 0; font-size: .78rem; line-height: 1.3; }
  .mission-objective { padding: .42rem .55rem; }
  .mission-objective span,
  .mission-results h3 { font-size: .58rem; }
  .mission-objective p { margin-top: .1rem; font-size: .75rem; line-height: 1.25; }
  .mission-results { margin-top: .45rem; }
  .mission-results h3 { margin-bottom: .25rem; }
  .mission-results dl { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .25rem; }
  .mission-results dl div { padding: .3rem .4rem; }
  .mission-results dt { font-size: .54rem; }
  .mission-results dd { margin-top: .05rem; font-size: .8rem; }
  .mission-next { margin: .35rem 0 0; font-size: .7rem; line-height: 1.25; }
  .mission-actions { flex-wrap: nowrap; gap: .4rem; margin: .5rem 0 0; }
  .mission-actions > * { flex: 1 1 0; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) and (max-width: 700px) {
  .hero-actions > * {
    padding-inline: .35rem;
    font-size: .65rem;
    letter-spacing: .035em;
  }
  .mission-actions > * {
    padding-inline: .35rem;
    font-size: .65rem;
    letter-spacing: .035em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
