/* ============================================================
   XRFXRC MAZE — STYLES v3.0
   Monochrome UI. Color lives inside the canvas only.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  user-select: none; -webkit-user-select: none;
}

/* ─── TOKENS ─────────────────────────────────────────────────── */
:root {
  --bg:         #040404;
  --surface:    #080808;
  --border:     #111111;
  --border-mid: #1c1c1c;
  --border-hi:  #2e2e2e;
  --text-mute:  #2c2c2c;
  --text-dim:   #484848;
  --text:       #787878;
  --text-hi:    #aaaaaa;
  --warn:       #7a3030;
  --success:    #2e7a2e;
  --glow-green: rgba(20,70,20,0.12);
  --font:       'Share Tech Mono', 'Courier New', monospace;
}

/* ─── BODY ───────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

/* ─── CRT SCANLINES ──────────────────────────────────────────── */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(0,0,0,0.18) 2px, rgba(0,0,0,0.18) 4px
  );
  opacity: 0.6;
}

/* ─── SCREEN FLICKER ─────────────────────────────────────────── */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 10000;
  pointer-events: none;
  animation: screenFlicker 9s infinite;
}

@keyframes screenFlicker {
  0%,100% { opacity:0; }
  1.5%    { opacity:1; background:rgba(5,15,5,0.018); }
  3%      { opacity:0; }
  50.5%   { opacity:1; background:rgba(0,0,0,0.012); }
  51%     { opacity:0; }
}

/* ─── OUTER CONTAINER ────────────────────────────────────────── */
#terminal-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: 100vw;
}

/* ─── HUD ────────────────────────────────────────────────────── */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  white-space: nowrap;
  letter-spacing: 0.12em;
}

#hud span {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 10px;
}

#hud #status-display {
  flex: 1;
  text-align: center;
  color: var(--text);
  font-size: 10px;
}

#timer-display.warning {
  color: var(--warn) !important;
  animation: timerPulse 0.8s ease-in-out infinite;
}

@keyframes timerPulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.5; }
}

/* ─── LEVEL PROGRESS ─────────────────────────────────────────── */
#level-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
}

.lvl-dot {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0;
  transition: color 0.3s;
}
.lvl-dot.done   { color: var(--text-dim); }
.lvl-dot.active { color: var(--text-hi); }

/* ─── CANVAS WRAP ────────────────────────────────────────────── */
#canvas-wrap {
  position: relative;
  line-height: 0;
  transition: transform 0.07s ease;
  border: 1px solid var(--border);
}

canvas#mazeCanvas {
  display: block;
  background: #000;
  cursor: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow:
    0 0 0 1px #090909,
    0 0 40px var(--glow-green),
    inset 0 0 80px rgba(0,0,0,0.98);
  max-width: 100vw;
  max-height: calc(100vh - 140px);
}

/* ─── OVERLAY ────────────────────────────────────────────────── */
#overlay-msg {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0,0,0,0.91);
  z-index: 20;
  pointer-events: none;
  font-size: 14px;
  letter-spacing: 0.32em;
  color: #3a8a3a;
  text-shadow: 0 0 22px rgba(58,138,58,0.30);
}

#overlay-msg.show { display: flex; }

#overlay-msg .sub {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: #255a25;
  text-shadow: none;
}

#overlay-msg .score-line {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #3a7a3a;
}

/* ─── CONTROLS BAR ───────────────────────────────────────────── */
#controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
}

#controls-left {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 9px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.seed-label { color: var(--text-mute); }

#controls-center {
  display: flex;
  gap: 4px;
  align-items: center;
}

#controls-right {
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  flex-shrink: 0;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
button {
  background: none;
  border: 1px solid var(--border-mid);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  min-height: 28px;
}

button:hover {
  border-color: var(--border-hi);
  color: var(--text);
}

button:active { transform: scale(0.97); }

button.active {
  border-color: #1a3a1a;
  color: #3a7a3a;
}

/* ─── STATUS CLASSES ─────────────────────────────────────────── */
.warning { color: var(--warn) !important; }
.success { color: var(--success) !important; }

/* ─── DEBUG PANEL ────────────────────────────────────────────── */
#debug-panel {
  position: fixed;
  bottom: 28px; left: 10px;
  background: rgba(0,0,0,0.96);
  border: 1px solid #1a3a1a;
  padding: 10px 16px;
  font-size: 10px;
  color: #3a7a3a;
  line-height: 2;
  display: none;
  z-index: 9998;
  letter-spacing: 0.1em;
  pointer-events: none;
}

/* ─── HELP STRIP ─────────────────────────────────────────────── */
#help-strip {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.85);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  padding: 5px 0;
  pointer-events: none;
  z-index: 100;
}

/* ─── SHAKE ANIMATION ────────────────────────────────────────── */
.canvas-shake {
  animation: shakeIt 0.12s ease;
}
@keyframes shakeIt {
  0%  { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  100%{ transform: translateX(0); }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 680px) {
  #hud { gap: 8px; padding: 6px 10px; font-size: 9px; }
  #hud #score-display,
  #hud #shape-display { display: none; }
  #controls-right { display: none; }
  #help-strip { font-size: 7px; letter-spacing: 0.1em; }
}

@media (max-width: 420px) {
  #hud #timer-display { display: none; }
  #controls-left .seed-label { display: none; }
  button { padding: 5px 8px; font-size: 8px; }
}