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

body {
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', 'Noto Sans KR', sans-serif;
  color: #fff;
  cursor: default;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Overlays */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  cursor: default;
}

.menu-content {
  text-align: center;
  max-width: 500px;
}

.title {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  margin-bottom: 0.5em;
  text-transform: uppercase;
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.subtitle {
  font-size: 1rem;
  opacity: 0.6;
  margin-bottom: 2em;
  font-style: italic;
}

.menu-content button {
  display: block;
  margin: 0.8em auto;
  padding: 0.8em 2.5em;
  font-size: 1.1rem;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
  letter-spacing: 0.1em;
}

.menu-content button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.6);
}

.lang-select {
  margin-top: 2em;
  display: flex;
  justify-content: center;
  gap: 1em;
}

.btn-reset {
  margin-top: 2.5em !important;
  padding: 0.4em 1.2em !important;
  font-size: 0.7rem !important;
  opacity: 0.25;
  border-color: rgba(255, 255, 255, 0.15) !important;
  transition: opacity 0.3s, border-color 0.3s;
}

.btn-reset:hover {
  opacity: 0.6;
  border-color: rgba(255, 100, 100, 0.5) !important;
  color: #ff8888;
}

.lang-btn {
  padding: 0.4em 1em !important;
  font-size: 0.9rem !important;
  opacity: 0.5;
  transition: opacity 0.3s;
}

.lang-btn.active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.8) !important;
}

/* Ending Tracker (Pause Menu) */
.ending-tracker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em;
  margin: 1.2em 0;
  max-width: 420px;
}

.ending-tracker .ending-chip {
  padding: 0.3em 0.7em;
  font-size: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  letter-spacing: 0.05em;
  transition: all 0.3s;
}

.ending-tracker .ending-chip.locked {
  color: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.06);
}

.ending-tracker .ending-chip.unlocked {
  color: rgba(180, 220, 255, 0.9);
  border-color: rgba(180, 220, 255, 0.35);
  text-shadow: 0 0 6px rgba(140, 180, 255, 0.3);
}

/* Lore Tracker (Pause Menu) */
.lore-tracker {
  text-align: center;
  margin: 0.6em 0 1em;
  font-size: 0.8rem;
  color: rgba(220, 190, 100, 0.85);
  letter-spacing: 0.08em;
  text-shadow: 0 0 6px rgba(200, 170, 60, 0.2);
}

.lore-tracker.lore-complete {
  color: rgba(255, 215, 80, 1);
  text-shadow: 0 0 10px rgba(255, 200, 40, 0.4);
}

.controls-hint {
  font-size: 0.85rem;
  opacity: 0.4;
  margin-top: 1em;
}

/* Narrator Chat Log */
#narrator-log {
  position: fixed;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 700px;
  width: 90%;
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.narrator-line {
  font-size: 1.05rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow:
    0 0 8px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 0, 0, 0.8),
    0 1px 3px rgba(0, 0, 0, 1),
    0 0 30px rgba(0, 0, 0, 0.5);
  padding: 0.2em 0;
  opacity: 1;
  transition: opacity 1.5s ease-out;
  animation: lineAppear 0.4s ease-out;
}

.narrator-line.narrator-old {
  opacity: 0.3;
}

.narrator-line.narrator-gone {
  opacity: 0;
  transition: opacity 0.8s ease-out;
}

@keyframes lineAppear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Narrator mode styles */
.narrator-line.mode-inner {
  font-style: italic;
  opacity: 0.85;
  padding-left: 1em;
  color: rgba(200, 210, 230, 0.85);
}

.narrator-line.mode-inner_uneasy {
  font-style: italic;
  opacity: 0.85;
  padding-left: 1em;
  color: rgba(190, 200, 225, 0.88);
  text-shadow: 0 0 8px rgba(100, 120, 180, 0.15);
}

.narrator-line.mode-questioning {
  font-style: italic;
  opacity: 0.9;
  padding-left: 0.8em;
  color: rgba(180, 195, 230, 0.92);
  animation: lineAppear 0.4s ease-out, questionPulse 4s ease-in-out infinite;
}

@keyframes questionPulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.78; }
}

.narrator-line.mode-cracking {
  animation: lineAppear 0.4s ease-out, crackingShake 3s ease-in-out infinite;
}

@keyframes crackingShake {
  0%, 92%, 100% { transform: translateX(0); }
  94% { transform: translateX(2px); }
  96% { transform: translateX(-1px); }
  98% { transform: translateX(1px); }
}

.narrator-line.mode-revealed {
  /* Slightly bolder presence */
  letter-spacing: 0.04em;
}

.narrator-line.mode-dialogue {
  letter-spacing: 0.03em;
}

/* Narrator mood text colors */
.narrator-line.mood-calm { color: rgba(200, 215, 255, 0.95); }
.narrator-line.mood-surprised { color: rgba(255, 230, 150, 0.95); }
.narrator-line.mood-annoyed { color: rgba(255, 185, 110, 0.95); }
.narrator-line.mood-frustrated { color: rgba(255, 110, 110, 0.95); }

.narrator-line.mood-desperate {
  color: rgba(255, 70, 70, 0.95);
  animation: lineAppear 0.4s ease-out, desperateLinePulse 1.5s ease-in-out infinite;
}

@keyframes desperateLinePulse {
  0%, 100% { color: rgba(255, 70, 70, 0.95); }
  50% { color: rgba(255, 140, 70, 0.7); }
}

/* Inner voice mood (Era 1 — player's own thoughts) */
.narrator-line.mood-inner {
  color: rgba(180, 195, 220, 0.8);
  font-style: italic;
}

.narrator-line.mood-amused { color: rgba(200, 220, 160, 0.95); }

/* Extended mood colors */
.narrator-line.mood-pleased { color: rgba(180, 230, 180, 0.95); }
.narrator-line.mood-patronizing { color: rgba(200, 200, 140, 0.95); }
.narrator-line.mood-curious { color: rgba(150, 200, 255, 0.95); }
.narrator-line.mood-respectful { color: rgba(180, 160, 255, 0.95); }
.narrator-line.mood-regretful {
  color: rgba(200, 150, 200, 0.95);
  animation: lineAppear 0.4s ease-out;
}

.narrator-line.mood-broken {
  color: rgba(255, 50, 50, 0.95);
  animation: lineAppear 0.4s ease-out, glitchLine 0.1s infinite;
}

@keyframes glitchLine {
  0% { transform: translateX(0); }
  25% { transform: translateX(2px); }
  50% { transform: translateX(-1px); }
  75% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

/* Crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  opacity: 0.5;
  z-index: 40;
  pointer-events: none;
  font-weight: 100;
}

/* Interaction Prompt */
#interact-prompt {
  position: fixed;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5em 1.2em;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  z-index: 45;
  pointer-events: none;
  animation: promptPulse 2s ease-in-out infinite;
}

@keyframes promptPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Ending Screen */
.ending-content {
  text-align: center;
  max-width: 600px;
}

.ending-content h2 {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  margin-bottom: 1em;
}

#ending-body {
  font-size: 1rem;
  line-height: 1.8;
  opacity: 0.8;
  margin-bottom: 2em;
}

#ending-body .stat-line {
  font-family: 'Courier New', monospace;
  margin: 0.3em 0;
  font-size: 0.9rem;
  opacity: 0.7;
}

#ending-body .ending-subtitle {
  font-size: 0.85rem;
  opacity: 0.5;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.5em;
}


/* Glitch overlay for rebellion ending */
.glitch-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 90;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1) 0px,
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 3px
  );
  animation: scanlines 0.05s linear infinite;
  mix-blend-mode: overlay;
}

@keyframes scanlines {
  0% { background-position: 0 0; }
  100% { background-position: 0 3px; }
}

/* Room transition vignette */
.room-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.5) 100%);
  opacity: 0;
  animation: vignetteFlash 1.2s ease-out forwards;
}

@keyframes vignetteFlash {
  0% { opacity: 0.7; }
  100% { opacity: 0; }
}

/* Code Input Overlay (Security Checkpoint puzzle) */
#code-input-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 80;
  cursor: default;
}

.code-input-content {
  text-align: center;
  position: relative;
}

.code-input-content p {
  margin-bottom: 1em;
  font-size: 1.1rem;
  opacity: 0.8;
}

#code-input-field {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  letter-spacing: 0.5em;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.5em 1em;
  text-align: center;
  width: 200px;
  outline: none;
}

#code-input-field:focus {
  border-color: rgba(255, 255, 255, 0.6);
}

.code-input-content .code-hint {
  margin-top: 1em;
  font-size: 0.8rem;
  opacity: 0.4;
}

/* Mobile code display (replaces input) */
#code-display {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  letter-spacing: 0.5em;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5em 1em;
  text-align: center;
  width: 200px;
  min-height: 1.2em;
  margin: 0 auto 0.8em;
}

/* Numpad grid */
#code-numpad {
  margin: 0 auto;
  max-width: 240px;
}

.numpad-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.numpad-btn {
  width: 64px;
  height: 54px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 1.4rem;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.12s;
}

.numpad-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.numpad-del {
  font-size: 1.2rem;
  opacity: 0.7;
}

.numpad-ok {
  background: rgba(80, 200, 120, 0.15);
  border-color: rgba(80, 200, 120, 0.3);
}

.numpad-ok:active {
  background: rgba(80, 200, 120, 0.35);
}

/* Close button for mobile */
#code-close-btn {
  position: absolute;
  top: -50px;
  right: -10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.2rem;
  cursor: pointer;
  touch-action: manipulation;
}

#code-close-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Inventory notification */
.inventory-popup {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6em 1.5em;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(200, 180, 100, 0.4);
  color: rgba(255, 220, 150, 0.9);
  font-size: 0.9rem;
  z-index: 55;
  pointer-events: none;
  animation: popupShow 3s ease-out forwards;
}

@keyframes popupShow {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* Fade transitions */
.fade-in {
  animation: fadeIn 1s ease-in;
}

.fade-out {
  animation: fadeOut 1s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════
   CCTV Overlay (Era 6-7)
   ═══════════════════════════════════════════════════════ */

#cctv-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  pointer-events: none;
}

.cctv-header {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 20px;
  align-items: center;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.cctv-cam-id {
  letter-spacing: 0.1em;
}

.cctv-rec {
  color: #ff3333;
  animation: recBlink 1s ease-in-out infinite;
}

@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.cctv-footer {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 20px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

.cctv-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.05) 0px,
    rgba(0, 0, 0, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════
   Terminal (Era 10)
   ═══════════════════════════════════════════════════════ */

#terminal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200;
  cursor: text;
}

.terminal-container {
  width: 80%;
  max-width: 800px;
  height: 70vh;
  background: #0a0a0a;
  border: 1px solid #1a3a1a;
  border-radius: 4px;
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 20px rgba(0, 255, 0, 0.05),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  /* CRT curve effect */
  position: relative;
  overflow: hidden;
}

.terminal-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #33ff33;
  line-height: 1.6;
  text-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
  scrollbar-width: none;
}

.terminal-output::-webkit-scrollbar {
  display: none;
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #33ff33;
  text-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
  line-height: 1.6;
}

.terminal-prompt {
  white-space: pre;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #33ff33;
  text-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
  caret-color: #33ff33;
  padding: 0;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════
   Era 10 Ending — Dual Monitor + ChatML
   ═══════════════════════════════════════════════════════ */

#era10-ending {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 2s;
  cursor: default;
}

#era10-ending.era10-fade-black {
  background: rgba(0, 0, 0, 1);
}

/* Title Screen */
.era10-title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 2s;
}

/* Title — 48px : subtitle 14px = 3.4:1 ratio, cinematic weight */
.era10-title {
  font-size: 48px;
  font-weight: 100;
  letter-spacing: 14px;
  text-indent: 14px;          /* balance letter-spacing visually */
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 0;
  opacity: 0;
  transition: opacity 3s ease;
}

.era10-subtitle {
  font-size: 14px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.32);
  letter-spacing: 5px;
  text-indent: 5px;
  margin-top: 18px;
  opacity: 0;
  transition: opacity 2s ease;
  font-style: italic;
}

.era10-replay-btn,
.era10-restart-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-family: inherit;
  font-weight: 300;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  opacity: 0;
  transition: opacity 2s ease, color 0.3s ease;
  background: none;
  border: none;
}

.era10-replay-btn { bottom: 36%; }
.era10-restart-btn { bottom: 30%; }

.era10-replay-btn:hover,
.era10-restart-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.era10-credit {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 8%;
  font-size: 11px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 2s ease, color 0.3s ease;
  letter-spacing: 3px;
  text-indent: 3px;
  text-transform: uppercase;
}

.era10-credit:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* ═══════════════════════════════════════════════════════
   Mobile (portrait) — touch controls
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) and (orientation: portrait) {
  #narrator-log { bottom: 22%; font-size: 0.85em; }
  #interact-prompt { bottom: 35%; }
}
