:root {
  --ink: #050708;
  --concrete: #2b3338;
  --steel: #7d8b93;
  --paper: #d9cfae;
  --amber: #ff7a29;
  --amber-dim: #a8501a;
  --blood: #b3181f;
  --clean: #cfd8dc;
  --mono: "Cascadia Mono", ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  --sans: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--ink);
  color: var(--clean);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  text-rendering: optimizeLegibility;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#viewport { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------------- screen effects ---------------- */
#fx-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 42%, rgba(0,0,0,0.55) 82%, rgba(0,0,0,0.85) 100%),
    linear-gradient(180deg, rgba(4,8,10,0.35), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 76%, rgba(4,8,10,0.42));
}
#fx-damage {
  position: absolute; inset: 0; pointer-events: none; z-index: 6; opacity: 0;
  transition: opacity .18s ease-out;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(120,0,0,0) 40%, rgba(122,4,10,0.62) 100%),
    linear-gradient(0deg, rgba(88,2,6,0.5), rgba(0,0,0,0) 45%);
  mix-blend-mode: multiply;
}
#fx-flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 7; opacity: 0;
  background: radial-gradient(circle at 50% 60%, rgba(255,214,150,0.5), rgba(255,150,60,0.08) 55%, rgba(0,0,0,0) 78%);
}
#fx-flash.on { opacity: 1; transition: none; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute; inset: 0; z-index: 10; pointer-events: none;
  font-family: var(--mono);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

.hud-vitals { position: absolute; left: 26px; bottom: 26px; width: min(300px, 30vw); }
.vitals-row { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.vitals-label { font-size: 10px; letter-spacing: .22em; color: #8fa0a8; width: 30px; }
.vitals-num { font-size: 12px; color: var(--paper); width: 34px; text-align: right; letter-spacing: .04em; }
.bar { flex: 1; height: 9px; background: rgba(8,12,14,0.82); border: 1px solid rgba(160,180,190,0.24); position: relative; overflow: hidden; }
.bar > i { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(1); transition: transform .12s linear; }
.bar.health > i { background: linear-gradient(90deg, #7d1218, #c31f27 60%, #e2453a); }
.bar.health > i.low { background: linear-gradient(90deg, #6b0a0e, #e01018); animation: hpPulse .9s ease-in-out infinite; }
@keyframes hpPulse { 0%,100% { opacity: .68; } 50% { opacity: 1; } }
.bar.stamina { height: 4px; }
.bar.stamina > i { background: linear-gradient(90deg, #4a6c74, #86b3bd); }
.vitals-row.small { opacity: .85; }

.compass {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  width: min(520px, 62vw); height: 30px; overflow: hidden;
  background: linear-gradient(180deg, rgba(8,12,14,0.72), rgba(8,12,14,0.28));
  border-top: 1px solid rgba(200,150,90,0.28);
  border-bottom: 1px solid rgba(120,140,150,0.18);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.compass-strip { position: absolute; inset: 0; }
.compass-needle {
  position: absolute; left: 50%; top: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, var(--amber), rgba(255,122,41,0.05));
}
.compass-mark {
  position: absolute; top: 0; height: 100%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.compass-mark .tick { width: 1px; height: 5px; background: rgba(190,205,212,0.6); }
.compass-mark .lbl { font-size: 9px; letter-spacing: .1em; color: #a8b8bf; white-space: nowrap; }
.compass-mark.key .lbl { color: var(--paper); font-size: 10px; }
.compass-mark.key .tick { height: 8px; background: var(--amber); }
.compass-mark.obj .lbl { color: var(--amber); font-size: 10px; font-weight: 700; }
.compass-mark.obj .glyph { font-size: 11px; color: var(--amber); }

.objectives {
  position: absolute; right: 24px; top: 22px; width: min(268px, 32vw);
  background: linear-gradient(180deg, rgba(10,14,16,0.82), rgba(10,14,16,0.5));
  border-left: 2px solid var(--amber-dim);
  padding: 10px 12px 11px;
  backdrop-filter: blur(2px);
}
.panel-title {
  font-size: 9px; letter-spacing: .2em; color: #8b9aa1; margin-bottom: 7px;
  border-bottom: 1px dashed rgba(140,160,170,0.2); padding-bottom: 6px;
}
#objective-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
#objective-list li {
  font-size: 11.5px; line-height: 1.35; color: #b9c6cc; display: flex; gap: 7px; align-items: flex-start;
  font-family: var(--sans); letter-spacing: .02em;
}
#objective-list li .mark { font-family: var(--mono); font-size: 10px; color: #6c7c84; width: 12px; flex: 0 0 12px; margin-top: 1px; }
#objective-list li.active { color: #f0e7cd; }
#objective-list li.active .mark { color: var(--amber); }
#objective-list li.done { color: #5f6f76; text-decoration: line-through; text-decoration-color: rgba(120,140,150,0.4); }
#objective-list li.done .mark { color: #4f8a5e; }
#objective-list li .dist { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: #7d8d94; padding-left: 6px; }

.weapon-hud {
  position: absolute; right: 26px; bottom: 24px; text-align: right; min-width: 190px;
}
.weapon-name { font-size: 11px; letter-spacing: .16em; color: #9fb0b7; margin-bottom: 2px; }
.weapon-ammo { font-size: 38px; line-height: 1; letter-spacing: .02em; color: var(--paper); font-weight: 600; }
.weapon-ammo .slash { font-size: 18px; color: #66757c; margin: 0 4px; }
#ammo-reserve { font-size: 17px; color: #93a3aa; }
.weapon-ammo.empty #ammo-mag { color: #d8383f; }
.weapon-slots { display: flex; gap: 5px; justify-content: flex-end; margin-top: 7px; }
.slot {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: #6f7f86;
  border: 1px solid rgba(130,150,160,0.2); padding: 2px 6px;
}
.slot.on { color: var(--paper); border-color: var(--amber-dim); background: rgba(255,122,41,0.1); }
.slot.locked { opacity: .32; }
.reload-hint { margin-top: 6px; font-size: 10px; letter-spacing: .12em; color: var(--amber); opacity: 0; transition: opacity .2s; }
.reload-hint.on { opacity: 1; }
.reload-hint.reloading { color: #9fb0b7; }

.crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.crosshair .ch-dot {
  position: absolute; left: -1.5px; top: -1.5px; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(240,235,215,0.9); box-shadow: 0 0 4px rgba(0,0,0,0.8);
}
.crosshair .ch-line {
  position: absolute; background: rgba(235,232,215,0.82); box-shadow: 0 0 3px rgba(0,0,0,0.9);
  transition: transform .07s linear;
}
.crosshair .ch-line.top, .crosshair .ch-line.bottom { width: 1.5px; height: 8px; left: -0.75px; }
.crosshair .ch-line.left, .crosshair .ch-line.right { height: 1.5px; width: 8px; top: -0.75px; }
.crosshair .ch-line.top { transform: translateY(-11px); }
.crosshair .ch-line.bottom { transform: translateY(3px); }
.crosshair .ch-line.left { transform: translateX(-11px); }
.crosshair .ch-line.right { transform: translateX(3px); }
.crosshair.hidden-cross .ch-line { opacity: .25; }
.hitmarker {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; opacity: 0;
  background:
    linear-gradient(45deg, transparent 44%, #fff 44%, #fff 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, #fff 44%, #fff 56%, transparent 56%);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  transform: scale(.6);
}
.hitmarker.show { animation: hit .22s ease-out; }
.hitmarker.kill { filter: drop-shadow(0 0 4px #ff3b30) brightness(1.1); }
@keyframes hit { 0% { opacity: 1; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.15); } 100% { opacity: 0; transform: scale(1.3); } }

.prompt {
  position: absolute; left: 50%; bottom: 21%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  background: rgba(8,12,14,0.78); border: 1px solid rgba(200,170,110,0.35);
  padding: 7px 14px; font-size: 12px; letter-spacing: .08em; color: var(--paper);
  font-family: var(--sans);
}
.prompt kbd {
  font-family: var(--mono); font-size: 11px; border: 1px solid rgba(226,200,140,0.6);
  padding: 1px 6px; color: var(--amber); background: rgba(255,122,41,0.08);
}

.toasts { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  font-family: var(--sans); font-size: 12px; letter-spacing: .04em; color: #e7e0ca;
  background: linear-gradient(90deg, rgba(10,14,16,0), rgba(10,14,16,0.86) 12%, rgba(10,14,16,0.86) 88%, rgba(10,14,16,0));
  border-top: 1px solid rgba(200,160,90,0.35);
  border-bottom: 1px solid rgba(200,160,90,0.35);
  padding: 5px 22px; opacity: 0; animation: toastIn 3.2s ease forwards;
}
.toast.warn { color: #ffb27a; border-color: rgba(255,122,41,0.5); }
.toast.alarm { color: #ff8a70; font-weight: 700; letter-spacing: .1em; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(-6px); }
  10% { opacity: 1; transform: translateY(0); }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

.alarm-banner {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--blood) 0 26px, rgba(179,24,31,0.15) 26px 52px);
  animation: alarmSlide 1.1s linear infinite;
  box-shadow: 0 0 18px rgba(255,40,40,0.5);
}
@keyframes alarmSlide { to { background-position: 52px 0; } }

/* ---------------- screens ---------------- */
.screen {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

#loading { background: radial-gradient(ellipse at 50% 45%, #131a1e, #050708 70%); flex-direction: column; }
.loading-inner { width: min(520px, 82vw); text-align: center; }
.loading-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: .28em; color: #6f8088; margin-bottom: 14px; }
.loading-title { font-size: clamp(21px, 3.4vw, 34px); letter-spacing: .18em; color: var(--paper); margin-bottom: 30px; font-weight: 600; }
.loading-bar { height: 2px; background: rgba(140,160,170,0.18); overflow: hidden; }
.loading-bar > i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); transition: width .25s ease; }
.loading-step { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: #7d8d94; margin-top: 12px; }

#title-screen { background: transparent; justify-content: flex-start; padding-left: min(8vw, 110px); }
.title-photo {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(64%, 980px);
  pointer-events: none;
  background-size: cover;
  background-position: 58% 42%;
  opacity: 0;
  transition: opacity 1s ease;
  filter: saturate(0.92) contrast(1.05) brightness(0.92);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 100%);
}
.title-photo.on { opacity: 1; }
.title-photo.on + .title-art { background: linear-gradient(90deg, rgba(4,6,8,0.9) 0%, rgba(4,6,8,0.7) 34%, rgba(4,7,9,0.1) 62%, rgba(4,7,9,0.05) 100%), linear-gradient(180deg, rgba(0,0,0,0.5), transparent 26%, transparent 70%, rgba(0,0,0,0.7)), repeating-linear-gradient(0deg, rgba(0,0,0,0.14) 0 1px, transparent 1px 4px); }
.title-art {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4,6,8,0.93) 0%, rgba(4,6,8,0.8) 34%, rgba(4,7,9,0.28) 62%, rgba(4,7,9,0.06) 100%),
    radial-gradient(ellipse at 78% 45%, rgba(255,86,20,0.16), rgba(0,0,0,0) 58%),
    linear-gradient(180deg, rgba(0,0,0,0.55), transparent 28%, transparent 66%, rgba(0,0,0,0.78)),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 1px, transparent 1px 4px);
}
.title-art::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 42% 58%, rgba(0,0,0,0) 46%, rgba(0,0,0,0.42) 100%);
}
.title-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .3;
  background-image: repeating-conic-gradient(rgba(255,255,255,0.03) 0% 25%, transparent 0% 50%);
  background-size: 3px 3px; mix-blend-mode: overlay;
}
.title-panel { position: relative; z-index: 2; max-width: 560px; }
.title-kicker { font-family: var(--mono); font-size: 9.5px; letter-spacing: .24em; color: #8a6a4e; margin-bottom: 16px; }
#title-screen h1 {
  font-size: clamp(34px, 5.6vw, 64px); line-height: 1.06; letter-spacing: .04em;
  color: #efe6cd; font-weight: 700; text-shadow: 0 6px 30px rgba(0,0,0,0.85);
}
#title-screen h1 .colon { color: var(--amber); }
.title-sub { margin-top: 18px; font-size: 14px; line-height: 1.85; color: #9dabb1; letter-spacing: .04em; }
.title-actions { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.title-record { margin-top: 18px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: #7b6a52; min-height: 14px; }
.title-controls {
  position: absolute; left: min(8vw, 110px); bottom: 30px; right: 30px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: 10px; color: #6d7c83;
  letter-spacing: .06em;
}
.title-controls b { color: #b4c1c7; font-weight: 600; margin-right: 3px; }
.title-controls span { white-space: nowrap; }
#title-controls:not(.open) { display: none; }

.btn {
  font-family: var(--sans); font-size: 13px; letter-spacing: .1em; color: #c6d1d6;
  background: rgba(14,19,22,0.72); border: 1px solid rgba(150,170,180,0.28);
  padding: 11px 22px; cursor: pointer; transition: all .16s ease; text-align: left;
  display: inline-flex; flex-direction: column; gap: 2px; line-height: 1.3;
}
.btn small { font-family: var(--mono); font-size: 9px; letter-spacing: .12em; color: #7f8f96; }
.btn:hover { color: #fff; border-color: rgba(255,150,80,0.6); background: rgba(28,20,14,0.8); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, #b0480f, #7d2d08); border-color: #d9732b; color: #fff5e6; }
.btn.primary small { color: #ffd7b0; }
.btn.primary:hover { background: linear-gradient(180deg, #cf5820, #943507); border-color: #ff9b52; }

.modal {
  position: relative; z-index: 2; width: min(560px, 88vw); padding: 34px 34px 30px;
  background: linear-gradient(180deg, rgba(11,16,19,0.95), rgba(7,10,12,0.96));
  border: 1px solid rgba(150,170,180,0.2); border-left: 3px solid var(--amber-dim);
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
#pause-screen { background: rgba(4,7,9,0.78); backdrop-filter: blur(3px); }
.modal-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; color: #8a6a4e; margin-bottom: 10px; }
.modal h2 { font-size: clamp(21px, 3vw, 30px); letter-spacing: .04em; color: var(--paper); font-weight: 600; line-height: 1.3; }
.modal-sub { margin-top: 10px; font-size: 12.5px; line-height: 1.8; color: #93a1a8; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 22px; background: rgba(140,160,170,0.16); }
.stats > div { background: #0a0e11; padding: 11px 13px; }
.stats .k { font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: #7c8c93; }
.stats .v { font-family: var(--mono); font-size: 19px; color: var(--paper); margin-top: 3px; }
#death-screen { background: radial-gradient(ellipse at 50% 50%, rgba(52,4,6,0.9), rgba(3,3,4,0.97) 72%); }
#death-screen .modal { border-left-color: var(--blood); }
#win-screen { background: radial-gradient(ellipse at 50% 45%, rgba(70,42,12,0.88), rgba(4,5,6,0.97) 70%); }

#pointer-hint {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%); z-index: 12;
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: rgba(230,220,195,0.75);
  border: 1px solid rgba(220,190,130,0.3); padding: 6px 14px; background: rgba(6,9,11,0.7);
  animation: hintPulse 2s ease-in-out infinite; pointer-events: none;
}
@keyframes hintPulse { 0%,100% { opacity: .5; } 50% { opacity: .95; } }

@media (max-width: 760px) {
  .hud-vitals { left: 14px; bottom: 14px; width: 42vw; }
  .weapon-hud { right: 14px; bottom: 12px; min-width: 140px; }
  .weapon-ammo { font-size: 28px; }
  .objectives { right: 10px; top: 54px; width: 46vw; padding: 8px 9px; }
  #objective-list li { font-size: 10px; }
  .compass { width: 82vw; }
  #title-screen { padding-left: 22px; justify-content: center; }
  .title-controls { left: 22px; bottom: 18px; font-size: 9px; gap: 4px 10px; }
  .title-panel { padding-bottom: 60px; }
  .title-sub { font-size: 12.5px; }
}
