:root {
  --bg: #08090b;
  --panel: #121417;
  --line: #262b30;
  --ink: #e8e4da;
  --muted: #8b9198;
  --muted-dim: #5d6469;
  --teal: #55b8ac;
  --teal-dim: #2f5b56;
  --crimson: #b3453a;
  --crimson-dim: #5c2620;
  --amber: #d9a13d;
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button {
  font-family: var(--font-mono);
  cursor: pointer;
}

/* ---------- Screens ---------- */
.screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.screen[hidden] { display: none; }

.start-card {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: 0.03em;
  margin: 0 0 6px;
  color: var(--teal);
}

.game-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 24px;
}

.blurb {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 28px;
}

.blurb em { color: var(--ink); font-style: normal; }

.btn-primary {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 14px 32px;
  background: var(--teal);
  color: #06100f;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary:hover { background: #6fcabd; }

.btn-quiet {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 11px 18px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.btn-quiet:hover { border-color: var(--teal); color: var(--ink); }
.btn-quiet[aria-pressed="true"] { border-color: var(--crimson); color: var(--crimson); }

/* ---------- Leaderboard ---------- */
.leaderboard { margin-top: 36px; text-align: left; }
.leaderboard h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin: 0 0 12px;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #1c2025;
  color: var(--muted);
}

.leaderboard-list li:first-child { color: var(--amber); }
.leaderboard-list .leaderboard-empty { color: var(--muted-dim); justify-content: center; }
.leaderboard-list .l-name { color: var(--ink); }

/* ---------- HUD ---------- */
.hud {
  display: flex;
  gap: 28px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.hud-block { display: flex; align-items: center; gap: 10px; }
.hud-label { font-size: 0.7rem; color: var(--muted-dim); text-transform: uppercase; }
.hud-value { font-family: var(--font-display); font-weight: 600; color: var(--ink); }

.power-block { flex: 1; max-width: 260px; }
.power-bar {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.power-fill {
  height: 100%;
  width: 100%;
  background: var(--teal);
  transition: width 0.3s ease, background 0.3s ease;
}
.power-fill.low { background: var(--crimson); }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto auto;
  gap: 16px;
  padding: 20px;
}

.viewport {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  aspect-ratio: 16/10;
  background: #030405;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.grain-canvas {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0.35;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.viewport-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 120px 40px rgba(0,0,0,0.85);
}

.cam-scene {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  filter: sepia(0.35) hue-rotate(130deg) saturate(1.4) brightness(0.9);
}

.cam-scene.is-active { display: flex; }

.scene-label {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 6;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: rgba(85,184,172,0.8);
  text-shadow: 0 0 6px rgba(85,184,172,0.4);
}

.office-door {
  width: 70%;
  height: 60%;
  border: 3px solid #223;
  border-radius: 4px;
  background: linear-gradient(180deg, #0d1012, #05070a);
}

.hall-art {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, #10151a 0px, #10151a 2px, #0a0d10 2px, #0a0d10 40px),
    linear-gradient(180deg, #0a0d10, #05070a);
}

.vent-art {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(0deg, #10151a 0px, #10151a 2px, #080b0d 2px, #080b0d 18px),
    linear-gradient(180deg, #0a0d10, #05070a);
}

.entity {
  position: absolute;
  width: 60px;
  height: 110px;
  bottom: 8%;
  border-radius: 40% 40% 10% 10%;
  background: #000;
  opacity: 0;
  transition: opacity 0.25s ease, transform 1.2s ease, left 1.2s ease;
  box-shadow: 0 0 30px 6px rgba(0,0,0,0.6);
}

.entity.visible { opacity: 0.92; }

.entity.null-variant { background: #1a0605; box-shadow: 0 0 30px 8px rgba(179,69,58,0.35); }

.static-flash {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.static-flash.hit {
  animation: flash-hit 0.35s steps(3, end);
}

@keyframes flash-hit {
  0% { opacity: 0.9; background: var(--crimson); }
  50% { opacity: 0.5; background: #fff; }
  100% { opacity: 0; }
}

/* ---------- Camera select ---------- */
.cam-select {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  gap: 10px;
}

.cam-btn {
  flex: 1;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 4px;
  font-size: 0.8rem;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.cam-btn.active { border-color: var(--teal); color: var(--teal); }

/* ---------- Side panel ---------- */
.panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}

.panel-block h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  margin: 0 0 10px;
  color: var(--ink);
}

.reading {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 12px;
  min-height: 2.4em;
}

.panel-actions { display: flex; flex-direction: column; gap: 8px; }
.panel-actions button { width: 100%; }

.log-block { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.72rem;
  color: var(--muted-dim);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
}

.log-list li { line-height: 1.4; }
.log-list li.warn { color: var(--crimson); }
.log-list li.good { color: var(--teal); }

/* ---------- Score form ---------- */
.score-form {
  display: flex;
  gap: 10px;
  margin: 24px 0 8px;
}

.score-form input[type="text"]:not(.hp-field) {
  flex: 1;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-mono);
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.submit-note {
  font-size: 0.75rem;
  color: var(--muted-dim);
  min-height: 1.2em;
  margin: 0 0 20px;
}

/* ---------- Footer ---------- */
.credit {
  text-align: center;
  padding: 14px;
  font-size: 0.7rem;
  color: var(--muted-dim);
  border-top: 1px solid var(--line);
}
.credit a { color: var(--teal); text-decoration: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .cam-select { grid-column: 1; grid-row: 2; }
  .panel { grid-column: 1; grid-row: 3; }
  .hud { flex-wrap: wrap; gap: 14px; }
}
