:root {
  --ink: #e8dcc0;
  --amber: #ffb45e;
  --dim: #8a7f6a;
  --panel: rgba(14, 16, 18, 0.72);
  --line: rgba(232, 220, 192, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #07080a;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, Consolas, monospace;
  overflow: hidden;
  -webkit-font-smoothing: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #07080a;
}

#view {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.corner { position: absolute; padding: 12px 14px; }
.tl { top: 0; left: 0; }
.tr { top: 0; right: 0; text-align: right; }

.label { color: var(--dim); font-size: 9px; }
.big {
  font-size: 20px;
  letter-spacing: 0.22em;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255, 180, 94, 0.35);
}

.stat { display: flex; gap: 10px; justify-content: flex-end; line-height: 1.7; }
.stat span { color: var(--dim); font-size: 9px; }
.stat b { color: var(--ink); font-weight: 700; }
.stat.dim b { color: var(--dim); }

#prompt {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.16em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s linear;
}
#prompt.on { opacity: 1; }

#cross {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1px 0 0 -1px;
  background: rgba(232, 220, 192, 0.7);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
}

#toast {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.2em;
  opacity: 0;
  transition: opacity 0.25s linear;
}
#toast.on { opacity: 1; }

/* ---------- панель орудия ---------- */

.gun {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 168px;
  padding: 8px 10px 9px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.gun .row { display: flex; justify-content: space-between; align-items: baseline; line-height: 1.5; }
.gun .row span { color: var(--dim); font-size: 8px; letter-spacing: 0.14em; }
.gun .row b { color: var(--amber); font-size: 10px; letter-spacing: 0.12em; }
.gun .bar {
  height: 3px;
  margin: 4px 0 3px;
  background: rgba(232, 220, 192, 0.14);
}
.gun .bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 180, 94, 0.5);
}

/* ---------- подводная тьма ---------- */

#deep {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(16, 58, 68, 0.10), rgba(0, 7, 11, 0.88) 70%),
    linear-gradient(180deg, rgba(3, 30, 40, 0.55), rgba(0, 2, 5, 0.96));
}
#deep.on { opacity: 1; }
#deep::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 70%, rgba(130, 210, 220, 0.05) 0 3px, transparent 4px),
    radial-gradient(circle at 66% 40%, rgba(130, 210, 220, 0.04) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 80%, rgba(130, 210, 220, 0.035) 0 5px, transparent 6px);
  background-size: 220px 220px, 160px 160px, 260px 260px;
  animation: deep-drift 18s linear infinite;
}
@keyframes deep-drift {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 0 -220px, 0 -160px, 0 -260px; }
}

/* ---------- заставка затопления ---------- */

#death {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(18, 62, 82, 0.45), rgba(2, 8, 14, 0.94) 68%),
    linear-gradient(180deg, rgba(2, 18, 30, 0.82), rgba(0, 0, 0, 0.97));
}
#death::before,
#death::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 78%, rgba(120, 200, 220, 0.05) 0 6px, transparent 7px),
    radial-gradient(circle at 74% 62%, rgba(120, 200, 220, 0.045) 0 4px, transparent 5px),
    radial-gradient(circle at 48% 88%, rgba(120, 200, 220, 0.04) 0 8px, transparent 9px);
  background-size: 180px 180px, 140px 140px, 220px 220px;
  animation: death-drift 14s linear infinite;
}
#death::after { animation-duration: 22s; animation-direction: reverse; opacity: 0.7; }
#death.on { opacity: 1; }

@keyframes death-drift {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 0 -180px, 0 -140px, 0 -220px; }
}

.death-inner {
  position: relative;
  z-index: 1;
  max-width: min(760px, 90vw);
  padding: 26px 30px;
  text-align: center;
  transform: translateY(5vh);
}
.death-kicker {
  color: #7fbecb;
  font-size: 10px;
  letter-spacing: 0.5em;
  margin-bottom: 16px;
}
#death h2 {
  margin: 0 0 18px;
  font-size: clamp(22px, 4.4vw, 48px);
  line-height: 1.22;
  letter-spacing: 0.12em;
  color: #c3e9f1;
  text-shadow: 0 0 26px rgba(90, 180, 200, 0.5), 4px 4px 0 rgba(0, 0, 0, 0.65);
}
#death p {
  margin: 0;
  color: #7c9aa2;
  font-size: 11px;
  line-height: 1.8;
  letter-spacing: 0.12em;
}

/* ---------- overlay ---------- */

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(30, 26, 22, 0.55), rgba(5, 6, 8, 0.94) 70%),
    #050608;
  z-index: 10;
}

.card {
  width: min(560px, 88vw);
  padding: 30px 32px 26px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 30px 80px rgba(0, 0, 0, 0.7);
}

.kicker { color: var(--dim); font-size: 9px; letter-spacing: 0.28em; }

h1 {
  margin: 6px 0 4px;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
}

.sub { margin: 10px 0 20px; color: var(--dim); font-size: 11px; line-height: 1.6; max-width: 42ch; }

.keys { display: grid; gap: 6px; margin-bottom: 22px; font-size: 11px; color: var(--dim); }
.keys div { display: flex; gap: 10px; align-items: center; }
kbd {
  display: inline-block;
  min-width: 76px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-align: center;
}

.link { display: flex; gap: 8px; margin-bottom: 14px; }
#share {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--dim);
  font: inherit;
  font-size: 10px;
}

.btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}
.btn:hover { background: rgba(255, 180, 94, 0.1); color: var(--amber); }
.btn.primary {
  width: 100%;
  padding: 13px;
  margin-top: 4px;
  border-color: rgba(255, 180, 94, 0.5);
  color: var(--amber);
  font-size: 12px;
}
.btn.small { margin-top: 8px; padding: 5px 8px; font-size: 8px; }

.conn { margin-top: 12px; color: var(--dim); font-size: 9px; letter-spacing: 0.14em; text-align: center; }
.conn.ok { color: #8fbf8a; }
.conn.bad { color: #c9553f; }
