/* HARDLINE — HUD and overlays. The CRT look itself lives in js/post.js now. */

:root {
  --green: #00ff66;
  --green-dim: #00aa44;
  --green-soft: #7dffaa;
  --panel: rgba(0, 20, 10, 0.82);
  --red: #ff3b4e;
  --ink: #030804;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--green);
  font-family: "Courier New", Courier, "Lucida Console", monospace;
  font-size: 14px;
  overscroll-behavior: none;
  touch-action: none;
}

.hidden { display: none !important; }

#canvas-container, #fade {
  position: fixed;
  inset: 0;
}
#canvas-container { z-index: 1; }
#canvas-container canvas { display: block; width: 100%; height: 100%; }
#fade { z-index: 5; background: #fff; opacity: 0; pointer-events: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.7);
}
body.hud-off #hud { display: none; }

.hud-top {
  display: flex;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--green-dim);
  border-left: 4px solid var(--green);
  padding: 8px 14px;
  font-size: 13px;
  letter-spacing: 1px;
}
.hud-box { display: flex; gap: 8px; white-space: nowrap; }
.hud-objective { margin-left: auto; min-width: 0; }
.hud-objective .hud-value { overflow: hidden; text-overflow: ellipsis; }
.hud-label { color: var(--green-dim); font-size: 11px; letter-spacing: 2px; }
.hud-value { color: var(--green); font-weight: bold; }
#hud-trace { color: var(--red); text-shadow: 0 0 8px rgba(255, 59, 78, 0.7); min-width: 9ch; }
#hud-trace.critical { animation: blink 0.5s steps(2) infinite; }

#crosshair-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -6px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
#crosshair { width: 12px; height: 12px; position: relative; }
.ch-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
#interaction-prompt {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 25, 12, 0.9);
  border: 1px solid var(--green);
  padding: 6px 12px;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.35);
}
.key-badge {
  background: var(--green);
  color: var(--ink);
  font-weight: bold;
  padding: 1px 7px;
  font-size: 12px;
  text-shadow: none;
}
#prompt-text { font-size: 13px; font-weight: bold; letter-spacing: 1px; }

#vision-indicator {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 0, 8, 0.8);
  border: 1px solid var(--red);
  color: #ff8a96;
  padding: 5px 16px;
  font-weight: bold;
  letter-spacing: 2px;
  animation: blink 1s infinite;
}

#overclock-meter {
  position: absolute;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--green-dim);
  padding: 5px 12px;
}
#overclock-meter .meter { width: 160px; height: 8px; border: 1px solid var(--green-dim); }
#overclock-fill { height: 100%; width: 100%; background: #5fd0ff; box-shadow: 0 0 8px #5fd0ff; }
#overclock-meter.active { border-color: #5fd0ff; }
#overclock-meter.depleted #overclock-fill { background: var(--red); box-shadow: none; }

#toasts {
  position: absolute;
  top: 64px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--green);
  padding: 5px 12px;
  font-weight: bold;
  letter-spacing: 1px;
  animation: toastIn 2.6s ease forwards;
}
.toast.bad { border-color: var(--red); color: #ff8a96; }
.toast.good { border-color: #5fd0ff; color: #aee8ff; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(20px); }
  10%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}

#dialogue-box {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 24px));
  background: rgba(1, 18, 8, 0.94);
  border: 1px solid var(--green);
  box-shadow: 0 0 22px rgba(0, 255, 102, 0.3);
  padding: 12px 18px;
  pointer-events: auto;
  cursor: pointer;
}
.dialogue-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed rgba(0, 255, 102, 0.35);
}
#dialogue-sender { color: #aaffbb; font-weight: bold; letter-spacing: 2px; }
.dialogue-skip { color: var(--green-dim); }
#dialogue-text {
  font-size: 15px;
  line-height: 1.55;
  color: #fff;
  min-height: 46px;
  white-space: pre-wrap;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--green-dim);
  padding: 7px 14px;
  font-size: 12px;
}
.hud-quick-controls { display: flex; flex-wrap: wrap; gap: 12px; }
kbd {
  display: inline-block;
  border: 1px solid var(--green);
  padding: 0 5px;
  margin-right: 3px;
  font-size: 11px;
  font-family: inherit;
}
.hud-status-indicators { display: flex; gap: 8px; pointer-events: auto; }
.hud-btn {
  background: rgba(0, 30, 15, 0.9);
  color: var(--green-dim);
  border: 1px solid var(--green-dim);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.hud-btn:hover { color: var(--green); border-color: var(--green); }
.hud-btn.active {
  background: rgba(0, 255, 102, 0.22);
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}
.hud-btn.locked { opacity: 0.4; }

#loading {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 40px);
  z-index: 70;
  color: #0a3a1a;
  font-weight: bold;
  letter-spacing: 3px;
}

/* ---------- RED PILL REVEAL ---------- */
#source-reveal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 6, 2, 0.88);
  overflow: hidden;
  pointer-events: none;
}
#source-reveal-path {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 2;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--green);
  padding: 6px 10px;
  font-weight: bold;
  letter-spacing: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#source-reveal-code {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 100%;
  font-size: 12px;
  line-height: 1.35;
  color: var(--green);
  white-space: pre;
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.8);
}
@keyframes sourceScroll {
  from { transform: translateY(0); }
  to { transform: translateY(calc(-100% - 100vh)); }
}

/* ---------- MODALS / END ---------- */
#project-modal, #end-screen, #blocker {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
#project-modal { z-index: 90; background: rgba(0, 8, 3, 0.7); }
#end-screen { z-index: 95; background: rgba(0, 8, 3, 0.55); }
#end-screen[data-kind="won"], #end-screen[data-kind="woke"] { background: rgba(255, 255, 255, 0.4); }
body.ended #hud, body.ended #touch-ui { display: none; }
#blocker { z-index: 100; background: rgba(1, 10, 4, 0.9); cursor: pointer; }
#blocker[data-mode="paused"] { background: rgba(1, 10, 4, 0.72); }

/* Back to the site. Top-left corner, well away from the resume target, so a stray click
   on the pause screen resumes rather than throwing the run away. */
.site-link {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 2;
  padding: 6px 11px;
  color: var(--green-dim);
  background: rgba(0, 20, 10, 0.7);
  border: 1px solid rgba(0, 170, 68, 0.45);
  font-size: 12px;
  letter-spacing: 2px;
  text-decoration: none;
  cursor: pointer;
}
.site-link:hover, .site-link:focus-visible { color: var(--green); border-color: var(--green); outline: none; }

.panel, .modal-card, .end-card {
  width: 100%;
  max-width: 620px;
  max-height: 100%;
  overflow: auto;
  background: rgba(0, 22, 11, 0.96);
  border: 2px solid var(--green);
  box-shadow: 0 0 35px rgba(0, 255, 102, 0.35);
  padding: 28px 30px;
  text-align: center;
}
#end-screen[data-kind="won"] .end-card, #end-screen[data-kind="woke"] .end-card { color: #053016; background: rgba(245, 255, 248, 0.96); border-color: #0a7a33; box-shadow: 0 0 40px rgba(0, 120, 50, 0.25); }
#end-screen[data-kind="lost"] .end-card { border-color: var(--red); box-shadow: 0 0 40px rgba(255, 40, 60, 0.35); }

.title, #end-title, #project-title {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--green);
  text-shadow: 0 0 20px var(--green), 0 0 40px var(--green-dim);
}
.title.small { font-size: 32px; }
#end-title { font-size: 36px; letter-spacing: 6px; }
#end-screen[data-kind="won"] #end-title, #end-screen[data-kind="woke"] #end-title { color: #07501f; text-shadow: none; }
#end-screen[data-kind="lost"] #end-title { color: var(--red); text-shadow: 0 0 18px var(--red); }
#project-title { font-size: 30px; letter-spacing: 5px; margin: 10px 0; }
.subtitle { color: var(--green-dim); letter-spacing: 3px; font-size: 12px; margin: 6px 0 18px; }

.terminal-intro {
  text-align: left;
  background: rgba(0, 10, 5, 0.85);
  border-left: 3px solid var(--green);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  line-height: 1.6;
}
.ok { color: var(--green-soft); font-weight: bold; }
.bad { color: var(--red); font-weight: bold; }
.pitch { color: #cfeedd; line-height: 1.5; margin-bottom: 16px; }
.click-to-enter {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #fff;
  background: rgba(0, 255, 102, 0.18);
  border: 1px dashed var(--green);
  padding: 12px;
  margin-bottom: 18px;
  animation: blink 1.4s infinite;
}
.control-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  text-align: left;
  font-size: 12px;
  color: #a0d8b0;
}
.control-list strong { color: var(--green); }
#touch-hint { margin-top: 14px; color: #a0d8b0; font-size: 12px; line-height: 1.5; }

#end-body, #project-blurb { margin: 14px 0; line-height: 1.5; font-size: 15px; }
#end-stats {
  display: grid;
  gap: 4px;
  margin: 12px auto 18px;
  max-width: 340px;
  text-align: left;
}
#end-stats div { display: flex; justify-content: space-between; border-bottom: 1px dotted currentColor; padding: 2px 0; }
#end-countdown { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.modal-actions .hud-btn { font-size: 14px; padding: 10px 16px; }
#end-screen[data-kind="won"] .hud-btn, #end-screen[data-kind="woke"] .hud-btn { color: #07501f; border-color: #0a7a33; background: rgba(10, 122, 51, 0.08); box-shadow: none; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- TOUCH ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#look-zone { position: absolute; top: 0; right: 0; bottom: 0; left: 40%; pointer-events: auto; }
#joy-zone { position: absolute; left: 0; bottom: 0; width: 40%; height: 55%; pointer-events: auto; }
#joy-base {
  position: absolute;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(34px, env(safe-area-inset-bottom));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(0, 255, 102, 0.5);
  background: rgba(0, 30, 12, 0.35);
}
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 255, 102, 0.35);
  border: 2px solid var(--green);
  transform: translate(-50%, -50%);
}
#touch-buttons {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 10px;
  pointer-events: auto;
}
.t-btn {
  width: 64px;
  height: 48px;
  background: rgba(0, 25, 10, 0.7);
  color: var(--green);
  border: 1px solid var(--green-dim);
  font-family: inherit;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 1px;
}
.t-btn.active { background: rgba(0, 255, 102, 0.3); border-color: var(--green); }
.t-big { grid-column: span 2; width: 138px; height: 64px; font-size: 18px; }
#t-act.ready { background: rgba(0, 255, 102, 0.4); border-color: var(--green); box-shadow: 0 0 16px rgba(0, 255, 102, 0.6); }
#t-pause { position: absolute; top: max(96px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 48px; height: 40px; pointer-events: auto; }

body.touch-mode .hud-bottom { display: none; }
body.touch-mode #toasts { top: 160px; left: 12px; right: auto; align-items: flex-start; }
body.touch-mode #dialogue-box { bottom: 190px; }
body.touch-mode #overclock-meter { bottom: 200px; }

@media (max-width: 700px) {
  .hud-top { flex-wrap: wrap; gap: 4px 12px; font-size: 11px; padding: 6px 10px; }
  .hud-objective { margin-left: 0; width: 100%; }
  .hud-objective .hud-value { white-space: normal; }
  .hud-box { white-space: normal; }
  #vision-indicator { top: 110px; }
  #toasts { top: 110px; right: 12px; }
  .title { font-size: 32px; letter-spacing: 6px; }
  .panel, .modal-card, .end-card { padding: 20px 16px; }
  .control-list { grid-template-columns: 1fr; }
  #dialogue-text { font-size: 13px; }
  #t-pause { top: 160px; }
}
