/* ==========================================================================
   THE INFERENCE CHRONICLES: Stylesheet
   Design Paradigm: Cyberpunk D&D Comic Book / Matrix Neon Glow
   ========================================================================== */

:root {
  --bg-deep: #05050f;
  --bg-card: rgba(13, 15, 33, 0.85);
  --border-color: #1f223d;
  --border-neon-cyan: #00ffcc;
  --border-neon-magenta: #ff007f;
  --border-neon-purple: #9d4edd;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --neon-cyan: #00ffcc;
  --neon-magenta: #ff007f;
  --neon-yellow: #ffd166;
  --neon-green: #39ff14;
  --neon-red: #ff3838;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
  height: 100vh;
  width: 100vw;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

/* SCREEN LAYOUTS */
.screen-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* TITLE SCREEN */
#title-screen {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0f1026 0%, #05050f 100%);
  padding: 20px;
}

.matrix-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 1;
}

.title-content-card {
  z-index: 2;
  background: var(--bg-card);
  border: 4px solid var(--border-neon-purple);
  box-shadow: 0 0 30px rgba(157, 78, 221, 0.25), inset 0 0 15px rgba(157, 78, 221, 0.1);
  border-radius: 12px;
  width: 100%;
  max-width: 650px;
  padding: 40px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.glitch-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 2px 2px 0px var(--neon-magenta), -2px -2px 0px var(--neon-cyan);
  position: relative;
  margin-bottom: 5px;
}

.title-subtitle {
  font-family: 'Share Tech Mono', monospace;
  color: var(--neon-cyan);
  font-size: 1.2rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 30px;
}

.terminal-box {
  background: #020208;
  border: 1px solid var(--border-color);
  padding: 15px;
  border-radius: 6px;
  font-family: 'Share Tech Mono', monospace;
  color: var(--neon-green);
  text-align: left;
  min-height: 90px;
  margin-bottom: 30px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.manual-tips {
  margin-top: 25px;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
}

.manual-tips p {
  margin-bottom: 6px;
}

/* GAME DASHBOARD */
#game-screen {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-deep);
}

/* TOP STATS BAR */
.stats-bar {
  background: rgba(10, 10, 25, 0.9);
  border-bottom: 3px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 30px;
  z-index: 10;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item.full-width {
  flex-grow: 1;
}

.stat-item .label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  margin-bottom: 2px;
}

.stat-item .val {
  font-family: 'Share Tech Mono', monospace;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.stat-item .val.highlight {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.warning-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

.status-good {
  color: var(--neon-green);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
}

.status-warning {
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid var(--neon-yellow);
  color: var(--neon-yellow);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: 'Share Tech Mono', monospace;
}

.reset-icon-btn {
  background: transparent;
  border: 1px solid var(--neon-red);
  color: var(--neon-red);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.reset-icon-btn:hover {
  background: var(--neon-red);
  color: white;
  box-shadow: 0 0 10px rgba(255, 56, 56, 0.4);
}

/* MAIN BOARD */
.game-board {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-rows: 1fr;
  flex-grow: 1;
  min-height: 0;
  margin-top: 12px;
  border-top: 3px solid var(--border-color);
}

@media (max-width: 1024px) {
  .game-board {
    grid-template-columns: 1fr;
    grid-template-rows: 1.1fr 0.9fr;
    overflow-y: auto;
  }
}

/* LEFT STAGE PANEL */
.stage-panel {
  display: flex;
  flex-direction: column;
  border-right: 3px solid var(--border-color);
  background: #020208;
  height: 100%;
  min-height: 0;
}

.stage-container {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  background: #03030b;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* SPEECH BUBBLES */
.speech-bubble {
  position: absolute;
  background: rgba(13, 15, 33, 0.92);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 12px 18px;
  font-family: 'Kalam', cursive;
  font-size: 1.1rem;
  line-height: 1.4;
  max-width: 280px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 5;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speech-bubble .bubble-header {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: bold;
}

.player-bubble {
  border: 3px solid var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 204, 0.2);
  left: 80px;
  top: 40px;
}

.player-bubble::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 40px;
  border-width: 15px 15px 0;
  border-style: solid;
  border-color: var(--neon-cyan) transparent;
  display: block;
  width: 0;
}

.demon-bubble {
  border: 3px solid var(--neon-magenta);
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.2);
  right: 80px;
  top: 60px;
}

.demon-bubble::after {
  content: '';
  position: absolute;
  bottom: -15px;
  right: 40px;
  border-width: 15px 15px 0;
  border-style: solid;
  border-color: var(--neon-magenta) transparent;
  display: block;
  width: 0;
}

/* Overlays */
.gate-overlay {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  background: rgba(5, 5, 15, 0.8);
  border: 1px solid var(--border-color);
  padding: 6px 20px;
  border-radius: 6px;
  backdrop-filter: blur(5px);
  z-index: 4;
}

.gate-overlay h2 {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.1rem;
  color: var(--neon-cyan);
  letter-spacing: 1.5px;
}

#current-gate-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* PROGRESS MAP PIPELINE */
.map-container {
  background: rgba(10, 10, 20, 0.95);
  border-top: 3px solid var(--border-color);
  padding: 15px 20px;
}

.map-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-align: center;
}

.pipeline-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.pipeline-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
}

.pipeline-node .node-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #111322;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Share Tech Mono', monospace;
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.pipeline-node .node-name {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 6px;
  white-space: nowrap;
  transition: all 0.3s ease;
}

/* Node States */
.pipeline-node.completed .node-icon {
  border-color: var(--neon-green);
  background: rgba(57, 255, 20, 0.1);
  color: var(--neon-green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}
.pipeline-node.completed .node-name {
  color: var(--neon-green);
}

.pipeline-node.active .node-icon {
  border-color: var(--neon-cyan);
  background: rgba(0, 255, 204, 0.15);
  color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 204, 0.6);
  animation: pulse-node 2s infinite;
}
.pipeline-node.active .node-name {
  color: var(--neon-cyan);
  font-weight: bold;
}

.pipeline-node.locked {
  opacity: 0.4;
}

/* Connection Lines */
.pipeline-line {
  flex-grow: 1;
  height: 3px;
  background: var(--border-color);
  position: relative;
  z-index: 1;
  margin: 0 -10px;
}

.pipeline-line.completed {
  background: var(--neon-green);
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
}

@keyframes pulse-node {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(0, 255, 204, 0.8); }
  100% { transform: scale(1); }
}

/* RIGHT STORY & RESPONSE PANEL */
.story-panel {
  display: flex;
  flex-direction: column;
  background: rgba(7, 7, 20, 0.95);
  height: 100%;
  min-height: 0;
}

.narration-box {
  flex-grow: 1;
  border-bottom: 3px solid var(--border-color);
  position: relative;
  padding: 30px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.panel-tag {
  position: absolute;
  top: 0;
  left: 20px;
  transform: translateY(-50%);
  background: var(--neon-magenta);
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 2px;
  padding: 3px 12px;
  clip-path: polygon(0 0, 100% 0, 90% 100%, 0% 100%);
  font-weight: bold;
}

.narration-content {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-primary);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  flex-grow: 1;
  overflow-y: auto;
}

/* Action Box */
.action-box {
  padding: 30px;
  background: #020208;
  position: relative;
  min-height: 220px;
}

.action-box .panel-tag {
  background: var(--neon-cyan);
  color: #000;
}

.options-flex {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

/* COMIC BUTTONS */
.comic-btn {
  background: #111326;
  border: 3px solid var(--border-color);
  color: var(--text-primary);
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.05rem;
  padding: 12px 20px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.comic-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--neon-cyan);
  transition: all 0.2s;
}

.comic-btn:hover {
  transform: scale(1.02) translateX(4px);
  background: #191b35;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 204, 0.3);
}

.comic-btn.choice-btn:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 204, 0.3);
}

.comic-btn.primary-glow {
  border-color: var(--border-neon-purple);
  box-shadow: 0 0 15px rgba(157, 78, 221, 0.3);
  text-align: center;
  font-size: 1.2rem;
  background: rgba(157, 78, 221, 0.1);
}

.comic-btn.primary-glow::before {
  background: var(--neon-magenta);
}

.comic-btn.primary-glow:hover {
  border-color: var(--neon-magenta);
  background: rgba(255, 0, 127, 0.15);
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.5);
  transform: scale(1.03);
}

.choice-tag {
  color: var(--neon-cyan);
  margin-right: 8px;
}

.comic-btn.retry-btn {
  border-color: var(--neon-red);
  background: rgba(255, 56, 56, 0.15);
  color: #fff;
  text-align: center;
}

.comic-btn.retry-btn::before {
  background: var(--neon-red);
}

.comic-btn.retry-btn:hover {
  background: rgba(255, 56, 56, 0.3);
  box-shadow: 0 0 20px rgba(255, 56, 56, 0.6);
  border-color: var(--neon-red);
}

/* RESULTS & VICTORY */
.victory-results {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 15px 20px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.victory-results h3 {
  font-family: 'Share Tech Mono', monospace;
  color: var(--neon-cyan);
  margin-bottom: 10px;
}

.assessment-table {
  width: 100%;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1rem;
}

.assessment-table td {
  padding: 4px 0;
}

.assessment-table td.val {
  text-align: right;
  font-weight: bold;
}
