/* Floodwall Mission 1 — The Night Shift
   Layout: fixed HUD + room canvas + findings rail + Wendy panel.
   No stacked text-on-text. */

:root {
  --bg: #0b1219;
  --panel: #121c27;
  --panel-2: #182433;
  --border: #2a3d52;
  --text: #e6eef6;
  --muted: #8fa3b8;
  --accent: #3db8a8;
  --accent-dim: #1f6f66;
  --warn: #e0a24a;
  --crit: #e05a5a;
  --high: #e08a3a;
  --med: #c9b44a;
  --bonus: #9b7bde;
  --ok: #4caf7a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

button, input {
  font: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 20%, #14303a 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, #1a2038 0%, transparent 50%),
    var(--bg);
}

.card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

.card h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.card .mission-tag {
  margin: 0 0 18px;
  color: var(--warn);
  font-size: 0.95rem;
  font-weight: 600;
}

.card p {
  margin: 0 0 12px;
  line-height: 1.5;
  color: var(--muted);
}

.card label {
  display: block;
  margin: 18px 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.card input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  outline: none;
}

.card input[type="text"]:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  padding: 12px 22px;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  background: linear-gradient(180deg, #2a8f82, #1f6f66);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Game shell ---------- */
#game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 132px;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-areas:
    "hud hud"
    "room findings"
    "wendy wendy";
  background: var(--bg);
}

#hud {
  grid-area: hud;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.9rem;
  z-index: 5;
}

#hud .brand {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
}

#hud .sep { color: var(--border); }

#hud .progress {
  margin-left: auto;
  color: var(--muted);
}

#hud .progress strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#hud .clock {
  font-family: var(--mono);
  color: var(--warn);
  font-size: 0.85rem;
}

#room-wrap {
  grid-area: room;
  position: relative;
  min-height: 0;
  background: #05080c;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

#phaser-room {
  width: 100%;
  height: 100%;
}

#room-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(11,18,25,.78);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  pointer-events: none;
}

#findings-panel {
  grid-area: findings;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid transparent;
}

#findings-panel header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#findings-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 12px;
  list-style: none;
  margin: 0;
}

#findings-list li {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.35;
}

#findings-list li .sev {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sev-CRITICAL { background: rgba(224,90,90,.2); color: var(--crit); }
.sev-HIGH { background: rgba(224,138,58,.2); color: var(--high); }
.sev-MEDIUM { background: rgba(201,180,74,.2); color: var(--med); }
.sev-BONUS { background: rgba(155,123,222,.2); color: var(--bonus); }

#findings-list .empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 12px 8px;
  border: none;
  background: transparent;
}

#findings-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

#wendy-panel {
  grid-area: wendy;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  z-index: 5;
}

#wendy-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  background:
    radial-gradient(circle at 35% 30%, #5ecfc0, #1f6f66 60%, #0f3d38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #dffaf5;
  letter-spacing: 0.02em;
}

#wendy-body { min-width: 0; }

#wendy-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}

#wendy-line {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
  max-height: 4.4em;
  overflow-y: auto;
}

/* ---------- Detail modal ---------- */
#detail-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5,8,12,.72);
}

#detail-modal .modal-card {
  width: min(720px, 100%);
  max-height: min(86vh, 640px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

#detail-modal .modal-art {
  background: #05080c;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}

#detail-modal .modal-art img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

#detail-modal .modal-body {
  padding: 18px 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#detail-modal h2 {
  margin: 0;
  font-size: 1.15rem;
}

#detail-modal .meta {
  font-size: 0.78rem;
  color: var(--muted);
}

#detail-modal .desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

#detail-modal .fix-note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(61,184,168,.08);
  border: 1px solid var(--accent-dim);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- Toast / coffee banner ---------- */
#toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--bonus);
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: min(520px, 92vw);
  text-align: center;
}

#complete-screen .summary {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

#complete-screen .summary li {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

#complete-screen .chain {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  #game-shell {
    grid-template-rows: 48px minmax(220px, 1fr) 160px 120px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "hud"
      "room"
      "findings"
      "wendy";
  }
  #room-wrap { border-right: none; border-bottom: 1px solid var(--border); }
  #findings-panel { max-height: 160px; }
  #detail-modal .modal-card {
    grid-template-columns: 1fr;
    max-height: 90vh;
  }
  #detail-modal .modal-art {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
  }
}

@media (max-width: 640px) {
  .card { padding: 20px; }
  #wendy-panel { grid-template-columns: 48px minmax(0, 1fr) auto; }
  #wendy-avatar { width: 42px; height: 42px; font-size: 0.75rem; }
}


/* ---------- Hotspots (DOM room) ---------- */
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}
.hotspot-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #7fe8d8;
  box-shadow: 0 0 0 2px rgba(61,184,168,.85), 0 0 12px rgba(61,184,168,.55);
}
.hotspot-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgba(61,184,168,.16);
  animation: hotspotPulse 1.6s ease-out infinite;
}
.hotspot-label {
  position: absolute;
  left: 50%;
  top: calc(100% - 4px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  color: #cfe8e4;
  background: rgba(11,18,25,.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  pointer-events: none;
}
.hotspot:hover .hotspot-core { background: #b7fff4; }
.hotspot.found .hotspot-core {
  background: #8fdfb0;
  box-shadow: 0 0 0 2px rgba(76,175,122,.9), 0 0 10px rgba(76,175,122,.45);
}
.hotspot.found .hotspot-pulse { background: rgba(76,175,122,.14); }
.hotspot-bonus .hotspot-core {
  background: #c5a8ff;
  box-shadow: 0 0 0 2px rgba(155,123,222,.9), 0 0 12px rgba(155,123,222,.5);
}
.hotspot-bonus .hotspot-pulse { background: rgba(155,123,222,.16); }
@keyframes hotspotPulse {
  0% { transform: scale(0.75); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0.05; }
}


/* Colossal Cave homage */
#complete-screen .adventure-egg {
  margin: 1.25rem 0 0.5rem;
  text-align: center;
}
#complete-screen .adventure-egg img {
  max-width: min(100%, 420px);
  width: 100%;
  height: auto;
  border: 1px solid #334155;
  border-radius: 6px;
  display: block;
  margin: 0 auto 0.65rem;
}
#complete-screen .egg-caption {
  font-size: 0.82rem;
  color: #94a3b8;
  font-style: italic;
  margin: 0;
}

.fix-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent, #3d8);
  background: rgba(61, 136, 136, 0.12);
  color: var(--muted, #9ab);
  font-size: 0.92rem;
  line-height: 1.45;
}
.fix-hint strong { color: var(--text, #e8f0f0); font-weight: 600; }

#findings-panel .subhead {
  margin-top: 14px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #8aa);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 10px;
}
.story-chain {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.story-chain li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--muted, #8aa);
  font-size: 0.88rem;
  line-height: 1.35;
}
.story-chain li .n {
  flex: 0 0 1.4rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  color: var(--muted, #8aa);
}
.story-chain li.locked .label { opacity: 0.55; }
.story-chain li.next {
  border-color: rgba(90, 200, 160, 0.55);
  box-shadow: 0 0 0 1px rgba(90, 200, 160, 0.2);
  color: var(--text, #e8f0f0);
}
.story-chain li.next .n {
  background: rgba(90, 200, 160, 0.25);
  color: #b6f5d4;
}
.story-chain li.done {
  border-color: rgba(90, 200, 160, 0.35);
  color: var(--text, #e8f0f0);
}
.story-chain li.done .n {
  background: #2a8f6a;
  color: #fff;
}
.story-chain li.done .label::after {
  content: "";
}
.fix-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent, #3d8);
  background: rgba(61, 136, 136, 0.12);
  color: var(--muted, #9ab);
  font-size: 0.92rem;
  line-height: 1.45;
}
.fix-hint strong { color: var(--text, #e8f0f0); font-weight: 600; }

.hotspot.hotspot-next {
  z-index: 5;
  filter: drop-shadow(0 0 10px rgba(90, 220, 160, 0.95));
}
.hotspot.hotspot-next .hotspot-pulse {
  animation-duration: 1.1s;
  border-color: rgba(90, 220, 160, 0.9);
}
.hotspot.hotspot-next .hotspot-core {
  background: #5adca0;
  box-shadow: 0 0 14px #5adca0;
}
.hotspot.hotspot-next .hotspot-label {
  opacity: 1;
  color: #b6f5d4;
  font-weight: 700;
}

/* Opened but not yet logged */
.hotspot.visited .hotspot-core {
  background: #7a9bb8;
  box-shadow: 0 0 10px rgba(122, 155, 184, 0.7);
}
.hotspot.visited .hotspot-pulse {
  border-color: rgba(122, 155, 184, 0.55);
  animation: none;
  opacity: 0.45;
}
.hotspot.visited .hotspot-label {
  color: #a8c0d4;
  opacity: 0.9;
}
/* Logged in notes — clearly done */
.hotspot.found .hotspot-core {
  background: #3d5c4a;
  box-shadow: none;
}
.hotspot.found .hotspot-pulse {
  animation: none;
  opacity: 0.25;
  border-color: rgba(76, 175, 122, 0.25);
}
.hotspot.found .hotspot-label {
  opacity: 0.55;
  color: #8aa;
}

.card-intro {
  max-width: min(560px, 94vw);
}
.intro-art {
  margin: 0 0 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, #243040);
  background: #05080c;
}
.intro-art img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  object-position: center;
}
.intro-art figcaption {
  margin: 0;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted, #9ab);
  background: rgba(0,0,0,0.35);
  border-top: 1px solid var(--border, #243040);
}

.interest-card {
  margin: 18px 0 8px;
  padding: 16px 16px 14px;
  border-radius: 12px;
  border: 1px solid rgba(90, 220, 160, 0.35);
  background: linear-gradient(180deg, rgba(90, 220, 160, 0.08), rgba(0,0,0,0.2));
}
.interest-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--text, #e8f0f0);
}
.interest-copy {
  margin: 0 0 12px;
  color: var(--muted, #9ab);
  font-size: 0.92rem;
  line-height: 1.45;
}
#interest-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#interest-email {
  flex: 1 1 220px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #243040);
  background: #0b1219;
  color: var(--text, #e8f0f0);
  font-size: 1rem;
}
#interest-email:focus {
  outline: 2px solid rgba(90, 220, 160, 0.55);
  outline-offset: 1px;
}
.interest-status {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: #b6f5d4;
}
.interest-status.err { color: #f0a8a8; }
.interest-card.is-done {
  border-color: rgba(90, 220, 160, 0.55);
}
.hp {
  position: absolute;
  left: -10000px;
  opacity: 0;
  height: 0;
  width: 0;
  overflow: hidden;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.btn-mute {
  align-self: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mute[aria-pressed="true"] {
  color: #f0a8a8;
  border-color: rgba(240,168,168,0.45);
}
.btn-mute:hover { color: var(--text); }
