:root {
  color-scheme: dark;
  --ink: #050706;
  --ink-raised: rgba(9, 13, 11, 0.92);
  --bone: #d6d0bc;
  --bone-muted: #8e8d81;
  --mold: #879a72;
  --mold-bright: #b1ca8d;
  --rust: #9b4237;
  --blood: #6e171a;
  --line: rgba(177, 202, 141, 0.28);
  --shadow: rgba(0, 0, 0, 0.72);
  --safe-top: max(1rem, env(safe-area-inset-top));
  --safe-right: max(1rem, env(safe-area-inset-right));
  --safe-bottom: max(1rem, env(safe-area-inset-bottom));
  --safe-left: max(1rem, env(safe-area-inset-left));
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 20rem;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--bone);
  text-rendering: geometricPrecision;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(74, 91, 64, 0.14), transparent 38%),
    #030504;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #030504;
  cursor: crosshair;
  outline: 0;
}

#gameCanvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--mold-bright);
}

.atmosphere,
.vignette,
.scanlines,
.film-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.atmosphere {
  z-index: 2;
  overflow: hidden;
}

.vignette {
  background:
    radial-gradient(ellipse at center, transparent 36%, rgba(1, 3, 2, 0.28) 62%, rgba(0, 0, 0, 0.9) 100%),
    linear-gradient(90deg, rgba(23, 40, 24, 0.08), transparent 28%, transparent 72%, rgba(63, 12, 12, 0.08));
}

.scanlines {
  opacity: 0.18;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.34) 4px,
    rgba(0, 0, 0, 0.34) 5px
  );
}

.film-grain {
  inset: -35%;
  width: 170%;
  height: 170%;
  opacity: 0.075;
  background-image:
    repeating-radial-gradient(circle at 12% 18%, #b8c5a6 0 0.7px, transparent 0.8px 4px),
    repeating-radial-gradient(circle at 83% 71%, #000 0 1px, transparent 1.2px 5px);
  animation: grain-shift 180ms steps(2, end) infinite;
}

@keyframes grain-shift {
  0% { transform: translate3d(-2%, 1%, 0); }
  25% { transform: translate3d(2%, -1%, 0); }
  50% { transform: translate3d(1%, 2%, 0); }
  75% { transform: translate3d(-1%, -2%, 0); }
  100% { transform: translate3d(2%, 1%, 0); }
}

.hud {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 0.8rem rgba(0, 0, 0, 0.75));
}

.hud-card {
  position: absolute;
  top: var(--safe-top);
  left: var(--safe-left);
  min-width: min(14rem, 58vw);
  padding: 0.65rem 0.9rem 0.7rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--mold);
  background: linear-gradient(105deg, rgba(4, 8, 6, 0.92), rgba(4, 8, 6, 0.48));
  clip-path: polygon(0 0, calc(100% - 0.65rem) 0, 100% 0.65rem, 100% 100%, 0 100%);
}

.hud-label,
.eyebrow,
.controls-card h2 {
  display: block;
  color: var(--mold-bright);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.hud-value {
  display: block;
  margin-top: 0.15rem;
  color: var(--bone);
  font-size: clamp(1.45rem, 3.5vw, 2.1rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
}

#collectibleCount {
  color: var(--mold-bright);
  text-shadow: 0 0 0.65rem rgba(177, 202, 141, 0.48);
}

.objective {
  position: absolute;
  top: var(--safe-top);
  left: 50%;
  max-width: min(30rem, 48vw);
  margin: 0.5rem 0 0;
  padding: 0.35rem 0.75rem;
  transform: translateX(-50%);
  color: rgba(214, 208, 188, 0.8);
  font-size: clamp(0.68rem, 1.6vw, 0.82rem);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.125rem;
  height: 1.125rem;
  transform: translate(-50%, -50%);
  opacity: 0.74;
}

.reticle::before,
.reticle::after,
.reticle span::before,
.reticle span::after {
  position: absolute;
  background: var(--bone);
  box-shadow: 0 0 4px #000;
  content: "";
}

.reticle::before,
.reticle::after {
  top: calc(50% - 1px);
  width: 0.3rem;
  height: 2px;
}

.reticle::before { left: 0; }
.reticle::after { right: 0; }

.reticle span::before,
.reticle span::after {
  left: calc(50% - 1px);
  width: 2px;
  height: 0.3rem;
}

.reticle span::before { top: 0; }
.reticle span::after { bottom: 0; }

.interaction-prompt {
  position: absolute;
  top: calc(50% + 1.75rem);
  left: 50%;
  margin: 0;
  padding: 0.42rem 0.65rem;
  transform: translateX(-50%);
  border: 1px solid rgba(214, 208, 188, 0.2);
  background: rgba(2, 4, 3, 0.7);
  color: var(--bone);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pause-control {
  position: absolute;
  top: var(--safe-top);
  right: var(--safe-right);
  pointer-events: auto;
}

.icon-button,
.touch-button {
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 1px solid rgba(214, 208, 188, 0.28);
  background: rgba(3, 6, 4, 0.72);
  color: var(--bone);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--mold-bright);
  color: var(--mold-bright);
}

.game-message {
  position: absolute;
  z-index: 6;
  bottom: calc(var(--safe-bottom) + 9vh);
  left: 50%;
  max-width: min(34rem, calc(100vw - 2rem));
  margin: 0;
  padding: 0.65rem 1rem;
  transform: translate(-50%, 0.5rem);
  border-left: 2px solid var(--rust);
  background: rgba(3, 5, 4, 0.83);
  color: var(--bone);
  font-size: clamp(0.76rem, 2vw, 0.9rem);
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.game-message:empty {
  display: none;
}

.game-message.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background:
    linear-gradient(rgba(1, 3, 2, 0.7), rgba(1, 3, 2, 0.9)),
    repeating-linear-gradient(90deg, rgba(97, 120, 86, 0.035) 0 1px, transparent 1px 7px);
  backdrop-filter: blur(2px);
}

.screen--start {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(85, 104, 72, 0.22), transparent 38%),
    linear-gradient(105deg, rgba(0, 0, 0, 0.96), rgba(5, 9, 7, 0.84) 52%, rgba(0, 0, 0, 0.96));
}

.screen--danger {
  background: radial-gradient(circle at center, rgba(89, 10, 12, 0.26), rgba(0, 0, 0, 0.96) 72%);
}

.screen--victory {
  background: radial-gradient(circle at 50% 32%, rgba(132, 147, 96, 0.23), rgba(1, 4, 2, 0.95) 72%);
}

.screen-panel {
  position: relative;
  width: min(44rem, calc(100vw - 2rem));
  padding: clamp(1.3rem, 4vw, 3rem);
  border: 1px solid rgba(177, 202, 141, 0.23);
  border-top-color: rgba(177, 202, 141, 0.5);
  background:
    linear-gradient(135deg, rgba(12, 17, 13, 0.95), rgba(5, 7, 6, 0.94)),
    var(--ink-raised);
  box-shadow:
    0 1.5rem 6rem rgba(0, 0, 0, 0.8),
    inset 0 0 2.5rem rgba(128, 151, 105, 0.035);
  text-align: center;
}

.screen-panel::before,
.screen-panel::after {
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  content: "";
}

.screen-panel::before {
  top: -1px;
  left: -1px;
  border-top: 3px solid var(--mold);
  border-left: 3px solid var(--mold);
}

.screen-panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 3px solid var(--rust);
  border-bottom: 3px solid var(--rust);
}

.title-panel {
  margin-block: auto;
}

.compact-panel {
  width: min(30rem, calc(100vw - 2rem));
}

.eyebrow {
  margin: 0 0 0.7rem;
}

.game-title,
.screen h2 {
  margin: 0;
  color: var(--bone);
  font-size: clamp(2rem, 9vw, 5.2rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: clamp(0.05em, 1vw, 0.13em);
  text-transform: uppercase;
  text-shadow:
    3px 0 0 rgba(110, 23, 26, 0.7),
    -2px 2px 0 rgba(45, 68, 41, 0.8),
    0 0 1.6rem rgba(0, 0, 0, 0.95);
}

.screen h2 {
  font-size: clamp(2rem, 7vw, 3.8rem);
  letter-spacing: 0.08em;
}

.tagline {
  max-width: 34rem;
  margin: 1.1rem auto 1.5rem;
  color: var(--bone-muted);
  font-size: clamp(0.82rem, 2vw, 1rem);
  line-height: 1.55;
}

.mission {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.9rem;
  max-width: 31rem;
  margin: 0 auto 1.35rem;
  padding: 0.7rem;
  border: 1px solid rgba(214, 208, 188, 0.13);
  background: rgba(0, 0, 0, 0.26);
  text-align: left;
}

.mission p {
  margin: 0;
  color: rgba(214, 208, 188, 0.86);
  font-size: 0.78rem;
  line-height: 1.45;
}

.mission em {
  color: #ba5b4e;
  font-style: normal;
}

.mission-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--mold);
  color: var(--mold-bright);
  font-size: 1.05rem;
  font-weight: 700;
}

.button {
  position: relative;
  min-width: min(17rem, 100%);
  min-height: 3rem;
  padding: 0.78rem 1.3rem;
  border: 1px solid transparent;
  color: var(--bone);
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 100ms ease, background-color 100ms ease, border-color 100ms ease;
}

.button--primary {
  border-color: var(--mold);
  background: #273422;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35), 0 0 1.5rem rgba(105, 132, 82, 0.08);
}

.button--primary:hover {
  border-color: var(--mold-bright);
  background: #33442b;
}

.button--secondary {
  border-color: rgba(214, 208, 188, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: var(--bone-muted);
}

.button--secondary:hover {
  border-color: var(--rust);
  color: var(--bone);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(1px);
}

.button:focus-visible,
.icon-button:focus-visible,
.touch-button:focus-visible,
#gameCanvas:focus-visible {
  outline: 3px solid var(--mold-bright);
  outline-offset: 3px;
}

.button-stack {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  margin-top: 1.75rem;
}

.controls-card {
  max-width: 31rem;
  margin: 1.35rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(214, 208, 188, 0.12);
}

.controls-card h2 {
  margin: 0 0 0.7rem;
}

.controls-card dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin: 0;
}

.controls-card dl div {
  min-width: 0;
}

.controls-card dt {
  min-height: 1.75rem;
  color: var(--bone);
  font-weight: 700;
}

.controls-card dd {
  margin: 0.25rem 0 0;
  color: var(--bone-muted);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

kbd {
  display: inline-block;
  min-width: 1.55rem;
  padding: 0.18rem 0.35rem;
  border: 1px solid rgba(214, 208, 188, 0.38);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: #101411;
  color: var(--bone);
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  text-align: center;
}

.mouse-icon {
  position: relative;
  display: inline-block;
  width: 1.05rem;
  height: 1.6rem;
  border: 1px solid rgba(214, 208, 188, 0.55);
  border-radius: 0.55rem 0.55rem 0.4rem 0.4rem;
}

.mouse-icon::before {
  position: absolute;
  top: 0.23rem;
  left: 50%;
  width: 2px;
  height: 0.38rem;
  background: var(--mold-bright);
  transform: translateX(-50%);
  content: "";
}

.start-note,
.screen-hint {
  margin: 0.95rem 0 0;
  color: #676b63;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-copy {
  margin: 1rem auto 1.5rem;
  color: var(--bone-muted);
  line-height: 1.5;
}

.mobile-controls {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
  touch-action: none;
}

.joystick,
.look-pad,
.touch-button {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

.joystick {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 0.6rem);
  left: var(--safe-left);
  width: 7.5rem;
  height: 7.5rem;
  border: 1px solid rgba(214, 208, 188, 0.25);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(112, 132, 94, 0.09) 0 35%, rgba(0, 0, 0, 0.32) 36%);
}

.joystick::before,
.joystick::after {
  position: absolute;
  top: 50%;
  left: 50%;
  background: rgba(214, 208, 188, 0.11);
  transform: translate(-50%, -50%);
  content: "";
}

.joystick::before { width: 70%; height: 1px; }
.joystick::after { width: 1px; height: 70%; }

.joystick-knob {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid rgba(177, 202, 141, 0.48);
  border-radius: 50%;
  background: rgba(31, 44, 27, 0.78);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 1rem rgba(0, 0, 0, 0.55);
}

.look-pad {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 55%;
  height: 70%;
  color: rgba(214, 208, 188, 0.24);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.look-pad span {
  position: absolute;
  right: var(--safe-right);
  bottom: calc(var(--safe-bottom) + 0.55rem);
}

.action-button {
  position: absolute;
  right: var(--safe-right);
  bottom: calc(var(--safe-bottom) + 2.35rem);
  width: 4rem;
  height: 4rem;
  border-color: rgba(177, 202, 141, 0.5);
  border-radius: 50%;
  background: rgba(31, 44, 27, 0.75);
  color: var(--bone);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-pause {
  position: absolute;
  top: var(--safe-top);
  right: var(--safe-right);
}

.noscript-message {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: #050706;
  color: var(--bone);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 42rem), (max-height: 42rem) {
  .screen-panel {
    padding: 1.25rem;
  }

  .title-panel {
    width: min(36rem, calc(100vw - 1rem));
  }

  .tagline {
    margin-block: 0.75rem 0.9rem;
  }

  .mission {
    margin-bottom: 0.9rem;
  }

  .controls-card {
    margin-top: 0.9rem;
    padding-top: 0.75rem;
  }

  .start-note {
    margin-top: 0.6rem;
  }

  .objective {
    top: auto;
    bottom: var(--safe-bottom);
    max-width: calc(100vw - 4rem);
  }
}

@media (max-width: 31rem) {
  .controls-card dl {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 0.8rem;
  }

  .mission {
    display: none;
  }

  .hud-card {
    min-width: 10.5rem;
  }
}

@media (pointer: coarse) {
  .pause-control {
    display: none;
  }

  .mobile-controls:not([hidden]) {
    display: block;
  }
}

@media (pointer: fine) {
  .mobile-controls {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --bone: #fffbe9;
    --bone-muted: #cfcebf;
    --mold-bright: #d1f6a2;
    --line: rgba(209, 246, 162, 0.7);
  }

  .screen-panel,
  .hud-card,
  .button,
  .icon-button,
  .touch-button {
    border-width: 2px;
  }

  .scanlines,
  .film-grain {
    display: none;
  }
}
