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

:root {
  --retro-bg-deep: #030303;
  --retro-bg-mid: #090909;
  --retro-bg-slate: #111111;
  --retro-bg-haze: rgba(180, 180, 180, 0.08);
  --retro-cyan: #8be9fd;
  --retro-cyan-dim: rgba(139, 233, 253, 0.2);
}

body {
  background:
    radial-gradient(
      130% 85% at 52% 0%,
      var(--retro-bg-haze) 0%,
      rgba(24, 24, 24, 0.5) 35%,
      rgba(8, 8, 8, 0.96) 72%,
      rgba(3, 3, 3, 1) 100%
    ),
    linear-gradient(
      155deg,
      var(--retro-bg-slate) 0%,
      var(--retro-bg-mid) 48%,
      var(--retro-bg-deep) 100%
    );
  font-family:
    "JetBrains Mono", "Fira Code", "Source Code Pro", "Consolas", monospace;
  overflow: hidden;
  min-height: 100vh;
  position: relative;
  color: #e8f7ff;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(180, 238, 255, 0.025) 2px,
    rgba(180, 238, 255, 0.025) 3px
  );
  mix-blend-mode: soft-light;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 14% 22%, rgba(115, 115, 115, 0.12) 0%, transparent 42%),
    radial-gradient(circle at 88% 14%, rgba(90, 90, 90, 0.11) 0%, transparent 38%),
    radial-gradient(circle at 52% 100%, rgba(52, 52, 52, 0.19) 0%, transparent 44%);
  pointer-events: none;
  z-index: 2;
}

.scene-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  background:
    radial-gradient(
      75% 55% at 54% 8%,
      rgba(146, 146, 146, 0.11) 0%,
      rgba(35, 35, 35, 0.2) 42%,
      rgba(8, 8, 8, 0.9) 100%
    ),
    linear-gradient(150deg, #161616 0%, #0c0c0c 56%, #050505 100%);
  opacity: 0;
  visibility: hidden;
  animation: scene-appear 1s ease-out forwards;
  animation-play-state: paused;
}

@keyframes scene-appear {
  0% {
    opacity: 0;
    visibility: hidden;
  }
  1% {
    visibility: visible;
  }
  100% {
    opacity: 1;
    visibility: visible;
  }
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
  font-family: "JetBrains Mono", monospace;
}

.overlay.visible {
  opacity: 1;
}

.top-bar {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.portfolio-title {
  color: #888888;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
}

.portfolio-title:hover {
  color: #8be9fd;
  text-shadow: 0 0 8px rgba(139, 233, 253, 0.4);
}

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

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

.instructions {
  position: absolute;
  bottom: 24px;
  left: 24px;
  color: #777777;
  font-size: 11px;
  pointer-events: none;
  opacity: 0.8;
  letter-spacing: 0.3px;
  text-shadow: 0 0 1px rgba(119, 119, 119, 0.5);
}

/* Guide - minimal bottom-right checklist */
.guide-checklist {
  position: absolute;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-align: left;
  max-width: min(380px, 40vw);
}

.guide-checklist:not(.hidden) {
  opacity: 1;
}

.guide-checklist.hidden {
  display: none;
}

.guide-checklist.guide-fade-out {
  opacity: 0;
}

.guide-task {
  color: #888888;
  font-size: 12px;
  letter-spacing: 0.2px;
  line-height: 1.5;
  transition: color 0.3s ease, opacity 0.3s ease;
}

.guide-task.done {
  color: #556655;
  opacity: 0.55;
}

.guide-task.done .guide-check-mark {
  color: #5a9a6a;
}

.guide-check-mark {
  color: #888888;
}

.guide-hint {
  color: #cc9955;
  font-size: 13px;
  letter-spacing: 0.2px;
  margin-top: 6px;
  opacity: 0;
  animation: guide-hint-in 0.8s ease forwards;
  text-shadow: 0 0 4px rgba(204, 153, 85, 0.25);
}

@keyframes guide-hint-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.guide-chapter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 7px;
  margin-bottom: 3px;
  border-bottom: 1px solid rgba(136, 136, 136, 0.25);
}

.guide-chapter-title {
  color: #aaaaaa;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.guide-progress {
  color: #777777;
  font-size: 12px;
  letter-spacing: 0.3px;
}

/* Guide - bottom-center fun fact with typing effect */
.guide-funfact {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: #bbbbbb;
  font-size: 13px;
  letter-spacing: 0.3px;
  line-height: 1.5;
  max-width: min(560px, 48vw);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  text-shadow: 0 0 6px rgba(187, 187, 187, 0.35);
}

.guide-funfact.visible {
  opacity: 0.8;
}

.guide-funfact.hidden {
  display: none;
}

.guide-funfact.guide-fade-out {
  opacity: 0;
}

.audio-btn {
  border: none;
  color: #888888;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 2px;
  transition: all 0.3s ease;
  font-family: inherit;
  letter-spacing: 0.5px;
  background: transparent;
}

.audio-btn:hover {
  color: #ffffff;
}

.audio-btn.muted {
  color: #ff6464;
  text-decoration: line-through;
}

.audio-btn.muted:hover {
  color: #ffffff;
}

@media (max-width: 768px) {
  .top-bar {
    top: 16px;
    left: 16px;
    gap: 12px;
  }

  .portfolio-title {
    font-size: 12px;
  }

  .instructions {
    bottom: 16px;
    left: 16px;
    font-size: 10px;
  }

  .audio-btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .guide-checklist {
    bottom: 16px;
    right: 16px;
  }

  .guide-funfact {
    max-width: min(400px, 70vw);
    font-size: 9px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .instructions {
    font-size: 9px;
  }

  .portfolio-title {
    font-size: 11px;
  }

  .audio-btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  .guide-checklist {
    bottom: 12px;
    right: 12px;
  }

  .guide-task {
    font-size: 11px;
  }

  .guide-funfact {
    max-width: 80vw;
    font-size: 9px;
  }
}

.loading:not(.hidden) ~ * .overlay {
  opacity: 0;
  pointer-events: none;
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(230, 230, 230, 0.02) 2px,
      rgba(230, 230, 230, 0.02) 4px
    ),
    linear-gradient(140deg, #1a1a1a 0%, #0f0f0f 48%, #070707 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: #ffffff;
  font-family: "JetBrains Mono", monospace;
  transition: opacity 0.5s ease-out;
  backdrop-filter: blur(10px);
}

.loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.03) 2px,
    rgba(255, 255, 255, 0.03) 4px
  );
  animation: loading-scanlines 0.1s linear infinite;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(190, 190, 190, 0.04) 18%,
    rgba(22, 22, 22, 0.48) 62%,
    rgba(7, 7, 7, 0.7) 100%
  );
  animation: loading-flicker 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes loading-scanlines {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(4px);
  }
}

@keyframes loading-flicker {
  0%,
  96%,
  100% {
    opacity: 1;
  }
  97% {
    opacity: 0.92;
  }
  98% {
    opacity: 0.98;
  }
  99% {
    opacity: 0.94;
  }
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-size: 24px;
  text-shadow:
    0 0 5px rgba(255, 255, 255, 0.8),
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 15px rgba(255, 255, 255, 0.4);
  animation:
    text-glow 2s infinite ease-in-out,
    text-flicker 0.15s infinite linear;
  margin-bottom: 1rem;
  position: relative;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.loading-text::before {
  content: "> ";
  color: #cccccc;
  animation: text-cursor-blink 1s infinite;
}

.loading-text::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  animation: text-scan 3s infinite;
}

.desktop-notice {
  font-size: 12px;
  color: #888888;
  text-align: center;
  margin-bottom: 2rem;
  opacity: 0.8;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.3);
  letter-spacing: 1px;
}

.desktop-notice::before {
  content: "⚠ ";
  color: #ffffff;
}

@keyframes notice-fade-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 0.8;
    transform: translateY(0);
  }
}

@keyframes text-glow {
  0%,
  100% {
    text-shadow:
      0 0 5px rgba(255, 255, 255, 0.8),
      0 0 10px rgba(255, 255, 255, 0.6),
      0 0 15px rgba(255, 255, 255, 0.4);
    filter: brightness(1);
  }
  50% {
    text-shadow:
      0 0 10px rgba(255, 255, 255, 1),
      0 0 20px rgba(255, 255, 255, 0.8),
      0 0 30px rgba(255, 255, 255, 0.6);
    filter: brightness(1.2);
  }
}

@keyframes text-flicker {
  0%,
  98%,
  100% {
    opacity: 1;
  }
  99% {
    opacity: 0.8;
  }
}

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

@keyframes text-scan {
  0%,
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
  50% {
    transform: translateX(100%);
    opacity: 0.3;
  }
}

.loading-bar {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #ffffff;
  border-radius: 0;
  overflow: hidden;
  width: 400px;
  height: 20px;
  margin-top: 20px;
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.8);
  position: relative;
  font-family: inherit;
}

.loading-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 1px,
    rgba(255, 255, 255, 0.05) 1px,
    rgba(255, 255, 255, 0.05) 2px
  );
  animation: bar-scanlines 0.1s linear infinite;
  z-index: 1;
}

.loading-bar::after {
  content: attr(data-text);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #ffffff;
  letter-spacing: 1px;
  z-index: 3;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  mix-blend-mode: difference;
  font-weight: bold;
}

@keyframes bar-scanlines {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(2px);
  }
}

.loading-progress {
  background: linear-gradient(90deg, #ffffff 0%, #f0f0f0 50%, #ffffff 100%);
  height: 100%;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 0 10px rgba(255, 255, 255, 0.8),
    inset 0 0 10px rgba(255, 255, 255, 0.2);
  animation:
    progress-flicker 0.2s infinite linear,
    progress-glow 2s infinite ease-in-out;
  position: relative;
  z-index: 2;
}

.loading-progress::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.2) 2px,
    rgba(255, 255, 255, 0.2) 4px
  );
  animation: progress-pattern 1s linear infinite;
}

@keyframes progress-flicker {
  0%,
  95%,
  100% {
    opacity: 1;
  }
  96% {
    opacity: 0.85;
  }
  97% {
    opacity: 0.95;
  }
  98% {
    opacity: 0.9;
  }
  99% {
    opacity: 0.98;
  }
}

@keyframes progress-glow {
  0%,
  100% {
    box-shadow:
      0 0 10px rgba(255, 255, 255, 0.8),
      inset 0 0 10px rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow:
      0 0 20px rgba(255, 255, 255, 1),
      inset 0 0 15px rgba(255, 255, 255, 0.3);
  }
}

@keyframes progress-pattern {
  0% {
    transform: translateX(-8px);
  }
  100% {
    transform: translateX(8px);
  }
}

.start-button {
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
  border: 2px solid #ffffff;
  color: #ffffff;
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 15px 40px;
  margin-top: 30px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.8);
  text-shadow:
    0 0 5px rgba(255, 255, 255, 0.8),
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 15px rgba(255, 255, 255, 0.4);
  animation: button-glow 2s infinite ease-in-out;
  z-index: 2;
}

.start-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 1px,
    rgba(255, 255, 255, 0.05) 1px,
    rgba(255, 255, 255, 0.05) 2px
  );
  animation: button-scanlines 0.1s linear infinite;
}

.start-button::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  transition: left 0.5s ease;
}

.start-button:hover {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  transform: scale(1.05);
  box-shadow:
    0 0 30px rgba(255, 255, 255, 0.5),
    inset 0 0 30px rgba(0, 0, 0, 0.6);
  text-shadow:
    0 0 10px rgba(255, 255, 255, 1),
    0 0 20px rgba(255, 255, 255, 0.8),
    0 0 30px rgba(255, 255, 255, 0.6);
}

.start-button:hover::after {
  left: 100%;
}

.start-button:active {
  transform: scale(0.98);
  background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
}

.start-button.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.start-button.visible {
  opacity: 1;
  transform: translateY(0);
  animation: button-appear 1s ease-out forwards;
}

@keyframes button-glow {
  0%,
  100% {
    box-shadow:
      0 0 20px rgba(255, 255, 255, 0.3),
      inset 0 0 20px rgba(0, 0, 0, 0.8);
  }
  50% {
    box-shadow:
      0 0 30px rgba(255, 255, 255, 0.5),
      inset 0 0 30px rgba(0, 0, 0, 0.6);
  }
}

@keyframes button-scanlines {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(2px);
  }
}

@keyframes button-appear {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    filter: blur(5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

.terminal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  visibility: hidden;
  background: #000000;
  box-shadow:
    0 0 20px rgba(139, 233, 253, 0.3),
    0 0 40px rgba(139, 233, 253, 0.2),
    0 0 60px rgba(139, 233, 253, 0.1);
  display: none;
  border-radius: 6px;
  outline: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation: terminal-appear 1.5s ease-out forwards;
  animation-play-state: paused;
}

@keyframes terminal-appear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    filter: blur(5px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0px);
  }
}

.terminal:focus {
  box-shadow:
    0 0 30px rgba(139, 233, 253, 0.7),
    0 0 60px rgba(139, 233, 253, 0.5),
    0 0 90px rgba(139, 233, 253, 0.3),
    0 0 120px rgba(139, 233, 253, 0.1);
  transform: translate(-50%, -50%) scale(1.02);
  animation: terminal-pulse 2s infinite ease-in-out;
}

@keyframes terminal-pulse {
  0%,
  100% {
    box-shadow:
      0 0 30px rgba(139, 233, 253, 0.7),
      0 0 60px rgba(139, 233, 253, 0.5),
      0 0 90px rgba(139, 233, 253, 0.3);
  }
  50% {
    box-shadow:
      0 0 35px rgba(139, 233, 253, 0.8),
      0 0 70px rgba(139, 233, 253, 0.6),
      0 0 105px rgba(139, 233, 253, 0.4);
  }
}

.terminal:hover {
  box-shadow:
    0 0 35px rgba(139, 233, 253, 0.5),
    0 0 70px rgba(139, 233, 253, 0.4),
    0 0 105px rgba(139, 233, 253, 0.2);
  transform: translate(-50%, -50%) scale(1.01);
}

.terminal.texture-mode {
  visibility: hidden;
  position: fixed;
  top: -9999px;
  left: -9999px;
  z-index: -1;
  opacity: 1;
}

.scene-container canvas {
  cursor: default;
  transition: cursor 0.3s ease;
}

.scene-container canvas:hover {
  cursor: grab;
}

.scene-container canvas:active {
  cursor: grabbing;
}

.scene-container canvas.screen-hover {
  cursor: pointer !important;
}

.camera-transitioning {
  pointer-events: none;
}

.camera-focused .terminal {
  box-shadow:
    0 0 40px rgba(139, 233, 253, 0.8),
    0 0 80px rgba(139, 233, 253, 0.6),
    0 0 120px rgba(139, 233, 253, 0.4) !important;
  animation: terminal-focused-glow 1.5s infinite ease-in-out;
}

@keyframes terminal-focused-glow {
  0%,
  100% {
    filter: brightness(1) contrast(1);
  }
  50% {
    filter: brightness(1.1) contrast(1.05);
  }
}

.hidden-input {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1024px) {
  .terminal {
    width: 90vw;
    height: 70vh;
    max-width: 800px;
    max-height: 600px;
  }
  .loading-bar {
    width: 300px;
  }
  .start-button {
    padding: 12px 30px;
    font-size: 14px;
  }
  .loading-text {
    font-size: 20px;
  }
  .desktop-notice {
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  .terminal {
    width: 95vw;
    height: 75vh;
    font-size: 14px;
  }
  .loading-bar {
    width: 250px;
    height: 16px;
  }
  .start-button {
    padding: 10px 25px;
    font-size: 12px;
    margin-top: 25px;
  }
  .loading-text {
    font-size: 18px;
    margin-bottom: 0.8rem;
  }
  .desktop-notice {
    font-size: 10px;
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 480px) {
  .loading-text {
    font-size: 16px;
  }
  .loading-bar {
    width: 200px;
    height: 14px;
  }
  .start-button {
    padding: 8px 20px;
    font-size: 11px;
    margin-top: 20px;
  }
  .desktop-notice {
    font-size: 9px;
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .terminal {
    image-rendering: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-text,
  .loading-progress,
  .start-button,
  .terminal,
  .scene-container,
  .overlay {
    animation: none !important;
    transition: opacity 0.3s ease !important;
  }
  .loading {
    transition: opacity 0.5s ease !important;
  }
}

.scene-container,
.terminal,
.loading,
.start-button {
  will-change: transform, opacity;
}

*:focus-visible {
  outline: 2px solid #8be9fd;
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: rgba(139, 233, 253, 0.4);
  color: #ffffff;
  text-shadow: 0 0 5px rgba(139, 233, 253, 0.5);
}

::-moz-selection {
  background: rgba(139, 233, 253, 0.4);
  color: #ffffff;
  text-shadow: 0 0 5px rgba(139, 233, 253, 0.5);
}



body.editor-active {
  cursor: text !important;
}
