:root {
  color-scheme: dark;
  --bg: #070a0d;
  --panel: rgba(12, 17, 22, 0.82);
  --panel-strong: rgba(9, 13, 17, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --text: #edf3ea;
  --muted: #9dad9a;
  --green: #86d378;
  --red: #ef6565;
  --yellow: #f0d06b;
  --blue: #8cc8ff;
  --orange: #ff9f55;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  overscroll-behavior: none;
}

button,
select,
input { font: inherit; }

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.32);
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.04));
}

button.primary {
  border-color: rgba(134,211,120,.48);
  color: #051008;
  font-weight: 800;
  background: linear-gradient(180deg, #b9f29d, #6ec06a);
}

canvas#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #111714;
  cursor: crosshair;
  touch-action: none;
}

.hidden { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 22% 12%, rgba(75,107,80,.34), transparent 38%),
    radial-gradient(circle at 80% 70%, rgba(94,70,39,.28), transparent 42%),
    linear-gradient(135deg, rgba(8,12,11,.95), rgba(4,6,8,.92));
  backdrop-filter: blur(6px);
}

.menu-panel {
  width: min(1180px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(14,20,18,.95), rgba(8,11,13,.96));
  box-shadow: var(--shadow);
}

.kicker {
  color: var(--green);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(42px, 7vw, 84px);
  line-height: .92;
  letter-spacing: -.07em;
}

h2 { margin: 0 0 12px; }

.lead {
  max-width: 930px;
  color: #c7d2c3;
  font-size: 17px;
  line-height: 1.75;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 18px;
}

.drawer {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.04);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px 22px;
}

.settings-grid label {
  display: grid;
  gap: 8px;
  color: #dbe5d5;
  font-weight: 650;
}

.settings-grid select,
.settings-grid input[type="range"] { width: 100%; }

.settings-grid select {
  appearance: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(0,0,0,.34);
}

.settings-grid span,
.subtle {
  color: var(--muted);
  font-size: 13px;
}

.weapon-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 12px;
}

.weapon-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(0,0,0,.2);
}

.weapon-card h3 { margin: 0 0 6px; }
.weapon-card p {
  margin: 0 0 10px;
  color: #c5d1c1;
  line-height: 1.55;
}

.weapon-stat {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 9px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
}

.stat-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #799b6e, #d7d26c);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.help-grid div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(0,0,0,.18);
}

.help-grid b { color: var(--yellow); }

.end-message {
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid rgba(240,208,107,.45);
  border-radius: 16px;
  color: #fff4c8;
  background: rgba(99,79,20,.28);
}

.hud {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
  padding: 16px;
}

.hud-card {
  position: absolute;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  padding: 12px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(0,0,0,.2);
  backdrop-filter: blur(8px);
}

.hud-title {
  margin-bottom: 8px;
  color: #cdd9ca;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.vitals { left: 16px; top: 16px; width: 330px; }
.weapon-panel { left: 16px; bottom: 16px; width: 320px; }
.time-panel { top: 16px; right: 16px; width: 245px; }
.faction-panel { top: 132px; right: 16px; width: 245px; }
.tasks-panel { right: 16px; bottom: 230px; width: 360px; max-height: 340px; overflow: hidden; }
.inventory-panel { right: 16px; bottom: 16px; width: 360px; }
.minimap-panel { left: 50%; bottom: 16px; transform: translateX(-50%); text-align: center; }
.minimap-panel.large { transform: translateX(-50%) scale(1.45); transform-origin: bottom center; }

#miniMap {
  display: block;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(0,0,0,.32);
}

.bar-row {
  display: grid;
  grid-template-columns: 54px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 13px;
}

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

.bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b43131, #f46f6f);
  transition: width .12s ease;
}

.bar.hunger i { background: linear-gradient(90deg, #806226, #f0d06b); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
  margin-top: 8px;
}

.chip {
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: #ffefcf;
  background: rgba(128,65,26,.42);
  font-size: 12px;
}

.chip.good {
  color: #c9f7c1;
  background: rgba(38,89,47,.44);
}

.weapon-name { font-size: 20px; font-weight: 900; }
.ammo {
  margin-top: 4px;
  color: #fff3c5;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.time-text { font-size: 21px; font-weight: 850; }
.tasks-panel ol { display: grid; gap: 8px; margin: 0; padding-left: 20px; }
.tasks-panel li { color: #ccd8c8; font-size: 13px; line-height: 1.35; }
.tasks-panel li.done { color: #9ce78c; text-decoration: line-through; }
.progress-line { color: var(--muted); font-size: 12px; }

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 8px;
}

.inv-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(0,0,0,.2);
  color: #d8e2d3;
  font-size: 12px;
}

.keys { line-height: 1.5; }

.center-prompt {
  position: fixed;
  left: 50%;
  top: 58%;
  z-index: 12;
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #f5f0d0;
  background: rgba(0,0,0,.62);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.toast-log {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 40;
  display: grid;
  gap: 8px;
  width: min(560px, 92vw);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(8,10,12,.82);
  color: #eef4e9;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  transition: opacity .4s ease, transform .4s ease;
}
.toast.good { border-color: rgba(134,211,120,.42); color: #d9ffd3; }
.toast.warn { border-color: rgba(240,208,107,.48); color: #fff4c7; }
.toast.danger { border-color: rgba(239,101,101,.55); color: #ffd4d4; }

#crosshairOverlay {
  --spread: 16px;
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 11;
  width: 1px;
  height: 1px;
  pointer-events: none;
  transform: translate(-.5px, -.5px);
}

#crosshairOverlay i,
#crosshairOverlay b {
  position: absolute;
  display: block;
  background: rgba(255,245,200,.84);
  box-shadow: 0 0 8px rgba(0,0,0,.8);
}

#crosshairOverlay.aiming i,
#crosshairOverlay.aiming b { background: rgba(210,245,190,.95); }
#crosshairOverlay i:nth-child(1) { width: 10px; height: 2px; left: calc(-18px - var(--spread)); top: -1px; }
#crosshairOverlay i:nth-child(2) { width: 10px; height: 2px; left: calc(8px + var(--spread)); top: -1px; }
#crosshairOverlay i:nth-child(3) { width: 2px; height: 10px; left: -1px; top: calc(-18px - var(--spread)); }
#crosshairOverlay i:nth-child(4) { width: 2px; height: 10px; left: -1px; top: calc(8px + var(--spread)); }
#crosshairOverlay b { width: 4px; height: 4px; left: -2px; top: -2px; border-radius: 50%; }

@media (max-width: 980px) {
  .tasks-panel,
  .inventory-panel,
  .faction-panel { display: none; }
  .minimap-panel { right: 16px; left: auto; transform: none; }
  .weapon-panel { width: 290px; }
}

@media (max-width: 720px) {
  .overlay { padding: 12px; }
  .menu-panel { padding: 22px; }
  .settings-grid { grid-template-columns: 1fr; }
  .vitals,
  .weapon-panel,
  .time-panel { width: calc(100vw - 32px); left: 16px; right: 16px; }
  .time-panel { top: 128px; }
  .weapon-panel { bottom: 16px; }
  .minimap-panel { display: none; }
}
