/* =============================================
   KALSHI EVACUATION SIMULATOR — TERMINAL THEME
   ============================================= */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #0f0f0f;
  --bg-panel: #050505;
  --green-primary: #00ff41;
  --green-secondary: #00cc33;
  --green-dim: #00661a;
  --green-glow: rgba(0, 255, 65, 0.4);
  --green-highlight: #33ff66;
  --red-alert: #ff3333;
  --amber: #ffaa00;
  --font-mono: 'Fira Code', 'Courier New', 'Lucida Console', monospace;
  --glow-sm: 0 0 2px var(--green-glow);
  --glow-md: 0 0 5px var(--green-glow), 0 0 10px rgba(0, 255, 65, 0.2);
  --glow-lg: 0 0 10px var(--green-glow), 0 0 20px rgba(0, 255, 65, 0.15), 0 0 40px rgba(0, 255, 65, 0.05);
  --transition-speed: 0.3s;
}

/* ===================== RESET ===================== */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--green-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  text-shadow: var(--glow-sm);
}

::selection {
  background: var(--green-primary);
  color: var(--bg-primary);
}

/* ===================== CRT OVERLAY ===================== */

#crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  animation: crt-flicker 12s infinite;
}

#crt-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.08;
}

#crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
}

/* ===================== SCREENS ===================== */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.screen.glitch-in {
  animation: glitch-in 0.6s ease-out;
}

.screen-scroll {
  width: 100%;
  max-width: 1100px;
  max-height: 100%;
  overflow-y: auto;
  padding: 1rem 0;
}

.screen-scroll::-webkit-scrollbar {
  width: 6px;
}

.screen-scroll::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.screen-scroll::-webkit-scrollbar-thumb {
  background: var(--green-dim);
  border-radius: 3px;
}

.screen-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--green-secondary);
}

/* ===================== ANIMATIONS ===================== */

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

@keyframes glitch-in {
  0% { clip-path: inset(50% 0 50% 0); opacity: 0; }
  15% { clip-path: inset(30% 0 35% 0); opacity: 0.3; }
  30% { clip-path: inset(20% 0 15% 0); opacity: 0.5; }
  50% { clip-path: inset(8% 0 12% 0); opacity: 0.7; }
  70% { clip-path: inset(3% 0 5% 0); opacity: 0.85; }
  85% { clip-path: inset(1% 0 2% 0); opacity: 0.95; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

@keyframes value-flash {
  0% { color: var(--green-highlight); text-shadow: var(--glow-lg); }
  100% { color: var(--green-primary); text-shadow: var(--glow-sm); }
}

@keyframes pulse {
  0%, 100% { text-shadow: var(--glow-sm); }
  50% { text-shadow: var(--glow-lg); }
}

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  95% { opacity: 0.85; }
  96% { opacity: 1; }
}

@keyframes station-breathe {
  0%, 100% { text-shadow: var(--glow-md); opacity: 0.9; }
  50% { text-shadow: var(--glow-lg); opacity: 1; }
}

@keyframes count-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes rule-reveal {
  0% { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes game-fade-in {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes mission-glow {
  0% { opacity: 0; text-shadow: none; }
  50% { text-shadow: var(--glow-lg); }
  100% { opacity: 1; text-shadow: var(--glow-md); }
}

.cursor.blink {
  animation: blink 1s step-end infinite;
}

.value-changed {
  animation: value-flash 0.4s ease-out;
}

/* ===================== BRIEFING ===================== */

.briefing {
  margin-bottom: 1.5rem;
}

.briefing-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  text-shadow: var(--glow-md);
  margin-bottom: 0.75rem;
}

.briefing-status {
  font-size: 11px;
  color: var(--green-dim);
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
  min-height: 1.4em;
}

.briefing-status .status-cursor {
  color: var(--green-dim);
}

.briefing-rules {
  font-size: 13px;
  line-height: 1.8;
  color: var(--green-secondary);
}

.briefing-rules p {
  padding-left: 1.2em;
  text-indent: -1.2em;
  margin-bottom: 0.15rem;
}

.briefing-rules p::before {
  content: '> ';
  color: var(--green-dim);
}

.briefing-rules p.rule-visible {
  animation: rule-reveal 0.3s ease-out both;
}

.briefing-rules strong {
  color: var(--green-primary);
  font-weight: 600;
}

.briefing-mission {
  margin-top: 0.75rem;
  font-size: 14px;
  font-weight: 600;
  color: var(--green-highlight);
  text-shadow: var(--glow-md);
  letter-spacing: 1px;
}

.briefing-mission.mission-visible {
  animation: mission-glow 0.6s ease-out both;
}

.mission-objectives {
  margin-top: 1.25rem;
  padding: 0.75rem 0;
}

.mission-objectives.objectives-visible {
  animation: mission-glow 0.6s ease-out both;
}

.objectives-header {
  font-size: 12px;
  color: var(--green-dim);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.objective {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-highlight);
  text-shadow: var(--glow-md);
  letter-spacing: 0.5px;
  line-height: 1.8;
  padding-left: 0.5rem;
}

/* ===================== GAME AREA REVEAL ===================== */

.game-area.game-visible {
  animation: game-fade-in 0.5s ease-out both;
}

/* ===================== LOGO ===================== */

.logo-corner {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  opacity: 0.3;
  z-index: 2;
  transition: opacity 0.3s;
}

.logo-corner:hover {
  opacity: 0.6;
}

.kalshi-logo {
  width: 100px;
  height: auto;
}

/* ===================== COMMAND LINE / BUTTONS ===================== */

.command-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.prompt {
  color: var(--green-primary);
  font-weight: 700;
  font-size: 16px;
}

.terminal-btn {
  background: transparent;
  border: 1px solid var(--green-primary);
  color: var(--green-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: var(--glow-sm);
  transition: all var(--transition-speed);
}

.terminal-btn:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 15px var(--green-glow), inset 0 0 15px rgba(0, 255, 65, 0.05);
  text-shadow: var(--glow-md);
}

.terminal-btn:active {
  background: rgba(0, 255, 65, 0.2);
}

.transmit-btn {
  border-width: 2px;
  padding: 0.6rem 2rem;
  animation: pulse 2s infinite;
}

/* ===================== CHALLENGE HEADER ===================== */

.challenge-header {
  margin-bottom: 1rem;
}

.challenge-tag {
  font-size: 12px;
  color: var(--green-dim);
  letter-spacing: 2px;
}

.challenge-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  text-shadow: var(--glow-md);
  margin-top: 0.25rem;
}

/* ===================== NARRATIVE ===================== */

.narrative-block {
  font-size: 13px;
  line-height: 1.7;
  color: var(--green-secondary);
  margin-bottom: 1.5rem;
  min-height: 2.5em;
}

/* ===================== CHALLENGE LAYOUT ===================== */

.challenge-layout {
  display: flex;
  gap: 1.5rem;
  width: 100%;
}

.panel {
  flex: 1;
  min-width: 0;
}


/* ===================== STATS BLOCK ===================== */

.stats-block {
  padding: 0.75rem 1rem;
  font-size: 13px;
  line-height: 1.8;
  background: var(--bg-panel);
  border: 1px solid var(--green-dim);
  margin-top: 0.75rem;
}

.stats-block .divider {
  color: var(--green-dim);
  font-size: 12px;
  line-height: 1.2;
}

.stats-block .highlight {
  color: var(--green-highlight);
  font-weight: 700;
  font-size: 15px;
  text-shadow: var(--glow-md);
}

.stats-block .advance-line {
  color: var(--amber);
}

.val {
  font-weight: 600;
}

/* ===================== TACTICAL MAP ===================== */

.tactical-map {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto auto;
  background: var(--bg-panel);
  border: 1px solid var(--green-dim);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

/* Diagonal X lines behind everything */
.map-x-lines {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.map-x-lines::before,
.map-x-lines::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 141%;
  height: 1px;
  background: var(--green-dim);
  opacity: 0.4;
}

.map-x-lines::before {
  transform: translate(-50%, -50%) rotate(30deg);
}

.map-x-lines::after {
  transform: translate(-50%, -50%) rotate(-30deg);
}

.map-spacer {
  z-index: 1;
}

/* Station in center */
.station-icon {
  grid-column: 2;
  grid-row: 2;
  z-index: 1;
  text-align: center;
  font-size: 24px;
  padding: 0.5rem 1rem;
  animation: station-breathe 4s ease-in-out infinite;
}

.station-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--green-dim);
  margin-top: -0.25rem;
}

/* Pod cards at corners */
.pod {
  z-index: 1;
  border: 1px solid var(--green-dim);
  padding: 0.6rem 0.75rem;
  min-width: 150px;
  transition: all var(--transition-speed);
  background: var(--bg-primary);
}

.pod.nw { grid-column: 1; grid-row: 1; }
.pod.ne { grid-column: 3; grid-row: 1; }
.pod.sw { grid-column: 1; grid-row: 3; }
.pod.se { grid-column: 3; grid-row: 3; }

.pod.deployed {
  border-color: var(--green-primary);
}

.pod.glow-1 { box-shadow: 0 0 6px rgba(0, 255, 65, 0.2); }
.pod.glow-2 { box-shadow: 0 0 10px rgba(0, 255, 65, 0.3); background: rgba(0, 255, 65, 0.02); }
.pod.glow-3 { box-shadow: 0 0 14px rgba(0, 255, 65, 0.4); background: rgba(0, 255, 65, 0.04); }
.pod.glow-4 { box-shadow: 0 0 18px rgba(0, 255, 65, 0.5); background: rgba(0, 255, 65, 0.06); }
.pod.glow-5 { box-shadow: 0 0 24px rgba(0, 255, 65, 0.6), 0 0 40px rgba(0, 255, 65, 0.15); background: rgba(0, 255, 65, 0.08); }

.pod-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}

.pod-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.pod-price {
  font-size: 10px;
  color: var(--green-dim);
}

.pod-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.pod-btn {
  background: transparent;
  border: 1px solid var(--green-dim);
  color: var(--green-dim);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed);
  line-height: 1;
  padding: 0;
}

.pod-btn:hover {
  border-color: var(--green-primary);
  color: var(--green-primary);
  background: rgba(0, 255, 65, 0.1);
  text-shadow: var(--glow-sm);
}

.pod-btn:active {
  background: rgba(0, 255, 65, 0.25);
}

.pod-btn.disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.pod-input {
  background: var(--bg-primary);
  border: 1px solid var(--green-dim);
  color: var(--green-primary);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  width: 50px;
  text-align: center;
  padding: 0.1rem;
  outline: none;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  text-shadow: var(--glow-sm);
  -moz-appearance: textfield;
}

.pod-input::-webkit-outer-spin-button,
.pod-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pod-input:focus {
  border-color: var(--green-primary);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.15);
}

.pod:not(.deployed) .pod-input {
  color: var(--green-dim);
}

.pod-cost {
  font-size: 10px;
  color: var(--green-dim);
  text-align: center;
  margin-top: 0.2rem;
}

.pod.deployed .pod-cost {
  color: var(--green-secondary);
}

/* ===================== SUBMISSION FORM ===================== */

.terminal-form {
  max-width: 700px;
  width: 100%;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 0.4rem;
  color: var(--green-secondary);
}

.form-group textarea,
.form-group input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--green-dim);
  color: var(--green-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0.6rem 0.8rem;
  outline: none;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  text-shadow: var(--glow-sm);
}

.form-group textarea:focus,
.form-group input:focus {
  border-color: var(--green-primary);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.15);
}

.form-group textarea::placeholder,
.form-group input::placeholder {
  color: var(--green-dim);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group.half {
  flex: 1;
}

.form-group .field-error {
  color: var(--red-alert);
  font-size: 11px;
  margin-top: 0.25rem;
  display: none;
}

.form-group.error input,
.form-group.error textarea {
  border-color: var(--red-alert);
}

.form-group.error .field-error {
  display: block;
}

/* ===================== ANALYSIS SECTION ===================== */

.analysis-section {
  margin-top: 1.5rem;
  max-width: 700px;
}

.analysis-section.section-visible {
  animation: game-fade-in 0.5s ease-out both;
}

.form-note {
  font-size: 11px;
  color: var(--green-dim);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.analysis-section.outro-fade {
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

.outro-message {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-shadow: var(--glow-md);
  line-height: 2;
}

.outro-line {
  color: var(--green-secondary);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 1px;
}

/* ===================== UTILITY ===================== */

.hidden {
  display: none !important;
}

.typing-cursor {
  display: inline;
  animation: blink 1s step-end infinite;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 768px) {
  html, body {
    font-size: 12px;
  }

  .screen {
    padding: 1rem;
  }

  .challenge-layout {
    flex-direction: column;
  }

  .challenge-title {
    font-size: 18px;
    letter-spacing: 2px;
  }

  .pod {
    min-width: 110px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

@media (max-width: 480px) {
  .tactical-map {
    padding: 0.5rem;
  }

  .pod {
    min-width: 90px;
    padding: 0.4rem 0.5rem;
  }
}
