/* RECURSION - 6-Act Genre-Shifting Browser Platformer Stylesheet */

:root {
  --bg-dark: #020617;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-border: rgba(56, 189, 248, 0.25);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --act1-accent: #38bdf8;
  --act1-glow: rgba(56, 189, 248, 0.4);
  
  --act2-accent: #38bdf8;
  --act2-glow: rgba(56, 189, 248, 0.4);

  --act3-accent: #10b981;
  --act3-glow: rgba(16, 185, 129, 0.4);

  --act4-accent: #c084fc;
  --act4-glow: rgba(192, 132, 252, 0.4);

  --act5-accent: #fbbf24;
  --act5-glow: rgba(251, 191, 36, 0.45);
  
  --act6-accent: #f43f5e;
  --act6-glow: rgba(244, 63, 94, 0.5);

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

.hidden {
  display: none !important;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-display);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1040px;
  padding: 12px;
  position: relative;
}

/* ---------------- Top HUD Bar ---------------- */
#game-hud {
  width: 100%;
  max-width: 960px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 13px;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-center {
  display: flex;
  align-items: center;
}

.hud-coords {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.act-badge {
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.act-1 {
  background: rgba(56, 189, 248, 0.15);
  color: var(--act1-accent);
  border: 1px solid var(--act1-accent);
  box-shadow: 0 0 10px var(--act1-glow);
}

.act-2 {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid #38bdf8;
  box-shadow: 0 0 10px var(--act1-glow);
}

.act-3 {
  background: rgba(16, 185, 129, 0.15);
  color: var(--act3-accent);
  border: 1px solid var(--act3-accent);
  box-shadow: 0 0 10px var(--act3-glow);
}

.act-4 {
  background: rgba(192, 132, 252, 0.15);
  color: var(--act4-accent);
  border: 1px solid var(--act4-accent);
  box-shadow: 0 0 10px var(--act4-glow);
}

.act-5 {
  background: rgba(251, 191, 36, 0.15);
  color: var(--act5-accent);
  border: 1px solid var(--act5-accent);
  box-shadow: 0 0 12px var(--act5-glow);
}

.act-6 {
  background: rgba(244, 63, 94, 0.2);
  color: var(--act6-accent);
  border: 1px solid var(--act6-accent);
  box-shadow: 0 0 12px var(--act6-glow);
  animation: pulse-danger 1s infinite alternate;
}

@keyframes pulse-danger {
  from { opacity: 0.8; transform: scale(1); }
  to { opacity: 1; transform: scale(1.04); }
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
}

.hud-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}

.hp-bar {
  display: flex;
  gap: 4px;
}

.hp-pip {
  font-size: 14px;
  line-height: 1;
}

.hp-pip.filled {
  color: #38bdf8;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

.hp-pip.empty {
  color: #334155;
}

/* Boss Health Bar HUD */
.hud-boss {
  display: flex;
  align-items: center;
  gap: 6px;
}

.boss-hp-track {
  width: 110px;
  height: 10px;
  background: #1e1b4b;
  border: 1px solid #fbbf24;
  border-radius: 2px;
  overflow: hidden;
}

.boss-hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
  transition: width 0.15s ease;
}

.hud-timer .hud-val {
  color: #f43f5e;
  font-size: 14px;
  text-shadow: 0 0 8px rgba(244, 63, 94, 0.7);
}

.hud-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.hud-btn.level-btn {
  border-color: #c084fc;
  color: #e879f9;
}

.hud-btn.level-btn:hover {
  background: rgba(192, 132, 252, 0.2);
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.hud-btn.terminal-btn {
  border-color: #10b981;
  color: #34d399;
}

.hud-btn.terminal-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 10px var(--act3-glow);
}

.hud-btn.muted {
  opacity: 0.6;
}

/* ---------------- Main Canvas Container ---------------- */
#canvas-container {
  position: relative;
  width: 960px;
  height: 540px;
  background: #000;
  border: 1px solid var(--panel-border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.crt-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.22) 50%
  );
  background-size: 100% 4px;
  z-index: 10;
}

/* ---------------- Real-Time Task / Mission Tracker HUD ---------------- */
.tasks-tracker-widget {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  z-index: 25;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  max-width: 290px;
  transition: all 0.2s ease;
}

.tasks-tracker-widget.collapsed .tasks-list {
  display: none;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tasks-title {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.8px;
}

.tasks-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 0 4px;
}

.tasks-toggle-btn:hover {
  color: #fff;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  line-height: 1.35;
  transition: all 0.2s ease;
}

.task-item.task-pending {
  color: #cbd5e1;
}

.task-item.task-done {
  color: #34d399;
  text-decoration: line-through;
  opacity: 0.85;
}

.task-check {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #38bdf8;
}

.task-item.task-done .task-check {
  color: #10b981;
  text-decoration: none;
}

/* Toast Notification Popup */
.task-toast-popup {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 50;
  animation: toast-slidein 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes toast-slidein {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.task-toast-popup.toast-fadeout {
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.35s ease;
}

.toast-icon {
  font-size: 20px;
}

.toast-body {
  display: flex;
  flex-direction: column;
}

.toast-title {
  font-size: 11px;
  font-weight: 800;
  color: #34d399;
  letter-spacing: 0.8px;
}

.toast-desc {
  font-size: 12px;
  color: #f8fafc;
}

/* ---------------- Retro Debug Terminal Overlay ---------------- */
.terminal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.terminal-window {
  width: 100%;
  max-width: 820px;
  height: 420px;
  background: #03140c;
  border: 2px solid #10b981;
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-header {
  background: #062617;
  border-bottom: 1px solid rgba(16, 185, 129, 0.4);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #34d399;
}

.term-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}

.term-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.term-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.term-btn-close {
  background: transparent;
  border: none;
  color: #34d399;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
}

.term-btn-close:hover {
  color: #fff;
}

.terminal-logs {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: #a7f3d0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line.log-err { color: #f43f5e; }
.log-line.log-ok { color: #34d399; }
.log-line.log-sys { color: #38bdf8; font-weight: 600; }
.log-line.log-info { color: #e2e8f0; }

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: #020c07;
  border-top: 1px solid rgba(16, 185, 129, 0.25);
  gap: 8px;
}

.term-prompt {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #10b981;
  font-weight: 700;
}

.term-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

.term-submit-btn {
  background: #10b981;
  border: none;
  color: #020c07;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.term-submit-btn:hover {
  background: #34d399;
}

.terminal-quick-bar {
  padding: 6px 14px;
  background: #010604;
  border-top: 1px solid rgba(16, 185, 129, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #6ee7b7;
  flex-wrap: wrap;
}

.terminal-quick-bar code {
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ---------------- Modals ---------------- */
.game-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(8px);
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-levelselect {
  z-index: 45 !important;
}

.modal-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 28px;
  max-width: 600px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card.modal-lg {
  max-width: 890px;
}

.brand-badge {
  align-self: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid #38bdf8;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}

.brand-badge.brand-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: #10b981;
}

.game-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  line-height: 1;
}

.glitch-glow {
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.6);
}

.game-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Acts Preview Cards (6 items) */
.menu-acts-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 6px 0;
}

.act-preview-card {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 10px 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-display);
  display: block;
}

.act-preview-card:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.act-preview-card:active {
  transform: translateY(0);
}

.act-preview-card h4 {
  font-size: 11px;
  margin: 2px 0;
  color: #fff;
  font-weight: 800;
}

.act-preview-card p {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

.preview-num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
}

/* Level Select Grid */
.level-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.level-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-card:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
}

.level-card.special-card {
  background: rgba(45, 15, 38, 0.7);
  border-color: rgba(236, 72, 153, 0.4);
}

.level-card.special-card:hover {
  background: rgba(70, 20, 58, 0.9);
  border-color: #ec4899;
  box-shadow: 0 6px 16px rgba(236, 72, 153, 0.3);
}

.lvl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.lvl-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
}

.lvl-diff {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
}

.act-2-badge { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid #38bdf8; }
.act-3-badge { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.act-4-badge { background: rgba(192, 132, 252, 0.2); color: #c084fc; border: 1px solid #c084fc; }
.act-5-badge { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid #fbbf24; }
.act-6-badge { background: rgba(244, 63, 94, 0.2); color: #f43f5e; border: 1px solid #f43f5e; }
.act-horde-badge { background: rgba(236, 72, 153, 0.25); color: #f472b6; border: 1px solid #ec4899; }
.act-trial-badge { background: rgba(14, 165, 233, 0.25); color: #38bdf8; border: 1px solid #0284c7; }

.level-card h3 {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.level-card p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Modal Actions & Buttons */
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.modal-actions.vertical {
  flex-direction: column;
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background: #38bdf8;
  color: #020617;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  background: #7dd3fc;
  transform: translateY(-1px);
}

.btn-accent {
  background: #c084fc;
  color: #020617;
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.4);
}

.btn-accent:hover {
  background: #e879f9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Instructions Layout */
.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  margin: 8px 0;
}

.instruction-box {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 12px;
}

.instruction-box.full-width {
  grid-column: 1 / -1;
}

.instruction-box h3 {
  font-size: 13px;
  color: #38bdf8;
  margin-bottom: 8px;
}

.instruction-box ul {
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.instruction-box kbd {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
}

.cmd-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.cmd-row {
  display: flex;
  gap: 12px;
  font-size: 11px;
  align-items: center;
}

.cmd-row code {
  font-family: var(--font-mono);
  background: #03140c;
  color: #34d399;
  border: 1px solid #10b981;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 170px;
}

.cmd-row span {
  color: var(--text-muted);
}

/* Stats Summary */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.stat-box {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: #38bdf8;
}

.title-danger { color: #f43f5e; }
.text-danger { color: #fda4af; }
.title-success { color: #34d399; }

/* ---------------- Bottom Footer ---------------- */
#game-footer {
  width: 100%;
  max-width: 960px;
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}
