:root {
  /* Color Palette */
  --bg-black: #000000;
  --text-primary: #ffffff;
  --text-muted: #888888;
  --accent-gold: #b8b880;
  --system-red: #ff3e3e;
  --border-dim: rgba(255, 255, 255, 0.1);

  /* Centralized Responsive Scale */
  /* Syntax: clamp(min, preferred, max) */
  --fs-xs: clamp(0.65rem, 1vw, 0.75rem);
  --fs-base: clamp(0.9rem, 2vw, 1.05rem);
  --fs-h2: clamp(1.8rem, 8vw, 3.5rem);
  --gutter: clamp(1.5rem, 5vw, 4rem);

  /* Spacing & Transitions */
  --spacing-md: 2rem;
  --transition-fluid: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-black);
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
}

/* --- Z-INDEX ARCHITECTURE (Unified) --- */
.ui-layer {
  position: relative;
  z-index: 10;
}

/* --- RESPONSIVE WAIT ROOM / TERMINAL LAYOUT --- */
.wait-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--gutter);
}

.status-grid {
  display: grid;
  /* Multi-platform Safeguard: Switches to 1 col on mobile automatically */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 15px;
  margin-top: 40px;
  font-family: "Courier New", monospace;
  width: 100%;
  max-width: 800px;
}

.status-card {
  border: 1px solid var(--border-dim);
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-card.full-width {
  grid-column: 1 / -1; /* Spans all columns regardless of count */
  padding: clamp(25px, 5vw, 45px);
}

.terminal-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--text-primary);
  color: var(--text-primary);
  width: 100%;
  padding: 12px;
  text-align: center;
  font-family: monospace;
  font-size: var(--fs-base);
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.3s ease;
}

.terminal-input:focus {
  border-bottom-color: var(--accent-gold);
}

/* --- VISUAL ENGINES --- */
#matrixCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #000;
  pointer-events: none;
  opacity: 0.3;
}

#scanline-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
    linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.02),
      rgba(0, 255, 0, 0.01),
      rgba(0, 0, 255, 0.02)
    );
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
}

/* --- THE STORY TRACK (Handheld Optimized) --- */
.story-step {
  min-height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2000px;
  padding: var(--gutter);
}

.step-content {
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-dim);
  border-left: 3px solid var(--accent-gold);
  padding: clamp(30px, 8vw, 60px);
  max-width: 650px;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--transition-fluid);
}

.story-step.active .step-content {
  opacity: 1;
  transform: translateY(0);
}

/* --- ACTION TRIGGER (Touch Friendly) --- */
.system-btn {
  margin-top: var(--spacing-md);
  background: transparent;
  border: 1px solid #fff;
  color: #fff;
  padding: 1rem 2rem;
  width: clamp(200px, 100%, 400px); /* Scales on mobile */
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition-fluid);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.system-btn:hover {
  background: #fff;
  color: #000;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
}

/* --- MOBILE SPECIFIC OVERRIDES --- */
@media (max-width: 600px) {
  .step-content {
    border-left: none;
    border-top: 3px solid var(--accent-gold);
    text-align: left; /* Better for reading long text on small screens */
  }

  .status-grid {
    gap: 10px;
  }
}

/* --- TBS NOTIFICATION UI --- */
.tbs-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 15px 30px;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 2px;
  z-index: 100;
  backdrop-filter: blur(10px);
  animation: slideUp 0.4s ease-out forwards;
}

.tbs-notification.error {
  border-color: var(--system-red);
  color: var(--system-red);
}

.tbs-notification.fade-out {
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: all 0.6s ease-in;
}

.tbs-notification.success {
  border-color: #44ff44;
  color: #44ff44;
  box-shadow: 0 0 15px rgba(68, 255, 68, 0.2);
}

.transmission-module {
  background: linear-gradient(45deg, rgba(184, 184, 128, 0.05), transparent);
  border-left: 4px solid var(--accent-gold) !important;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 40px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
