/* ═══════════════════════════════════════════════════════════
   THE GREAT VIDEO GAME QUEST - Retro Pixel UI
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Dark cosmic palette */
  --bg-primary: #0f0a1e;
  --bg-secondary: #1a1333;
  --bg-card: #231c3d;
  
  /* Neon accent colors */
  --neon-cyan: #00f5ff;
  --neon-magenta: #ff00ff;
  --neon-yellow: #fff000;
  --neon-green: #39ff14;
  --neon-orange: #ff6b35;
  
  /* Text colors */
  --text-primary: #ffffff;
  --text-secondary: #b8b5c4;
  --text-muted: #6b6880;
  
  /* Pixel border effect */
  --pixel-size: 4px;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Press Start 2P', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.8;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scanline overlay effect */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
}

/* Main container */
.game-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(0, 245, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 0, 255, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   LEVEL SCREEN
   ═══════════════════════════════════════════════════════════ */

.level-screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: fadeIn 0.5s ease-out;
}

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

/* Progress bar */
.progress-section {
  text-align: center;
}

.progress-label {
  font-size: 0.625rem;
  color: var(--neon-cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--neon-cyan);
  margin-bottom: var(--space-xs);
}

.progress-bar {
  height: 8px;
  background: var(--bg-card);
  border: 2px solid var(--neon-cyan);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  transition: width 0.5s ease-out;
  box-shadow: 0 0 10px var(--neon-cyan);
}

/* Level image */
.level-image-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto var(--space-md);
  border: 4px solid var(--neon-cyan);
  box-shadow: 
    0 0 10px var(--neon-cyan),
    inset 0 0 30px rgba(0, 245, 255, 0.1);
  overflow: hidden;
  background: var(--bg-card);
}

.level-image-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 2;
}

.level-image-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 0, 255, 0.03) 0%,
    transparent 50%,
    rgba(0, 255, 255, 0.03) 100%
  );
  pointer-events: none;
  z-index: 3;
  animation: colorShift 3s ease-in-out infinite;
}

@keyframes colorShift {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.level-image {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.1) saturate(1.2);
  animation: imageGlitch 8s ease-in-out infinite;
}

@keyframes imageGlitch {
  0%, 94%, 100% {
    transform: translate(0);
    filter: contrast(1.1) saturate(1.2);
  }
  95% {
    transform: translate(-2px, 1px);
    filter: contrast(1.1) saturate(1.2) hue-rotate(5deg);
  }
  96% {
    transform: translate(2px, -1px);
    filter: contrast(1.2) saturate(1.3) hue-rotate(-5deg);
  }
  97% {
    transform: translate(-1px, 2px);
    filter: contrast(1.1) saturate(1.2);
  }
}

/* Glitch line effect */
.level-image-container .glitch-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(0, 245, 255, 0.8);
  z-index: 4;
  opacity: 0;
  animation: glitchLine 4s linear infinite;
}

@keyframes glitchLine {
  0%, 100% {
    top: 0%;
    opacity: 0;
  }
  10% {
    opacity: 0;
  }
  11% {
    opacity: 1;
  }
  50% {
    top: 100%;
    opacity: 1;
  }
  51% {
    opacity: 0;
  }
}

/* CRT corner vignette */
.level-image-container .crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
  pointer-events: none;
  z-index: 5;
}

/* Image loading state */
.level-image-container.loading {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-image-container.loading::before {
  content: 'LOADING...';
  font-family: 'Press Start 2P', monospace;
  font-size: 0.625rem;
  color: var(--neon-cyan);
  animation: blink 1s steps(2) infinite;
}

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

/* Level header */
.level-header {
  text-align: center;
  padding: var(--space-md) 0;
}

.level-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.level-title {
  font-size: 1.25rem;
  color: var(--neon-yellow);
  text-shadow: 
    /* Dark outline for readability */
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8),
    /* Glow effect */
    0 0 10px var(--neon-yellow),
    0 0 20px rgba(255, 240, 0, 0.5);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.level-subtitle {
  font-size: 0.625rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
}

/* Flavor text */
.flavor-text {
  text-align: center;
  font-size: 0.625rem;
  color: var(--neon-green);
  padding: var(--space-sm);
  border-left: 4px solid var(--neon-green);
  background: rgba(57, 255, 20, 0.1);
  text-shadow: 0 0 5px var(--neon-green);
}

/* Quest card (riddle) */
.quest-card {
  background: var(--bg-card);
  border: 4px solid var(--neon-magenta);
  padding: var(--space-md);
  position: relative;
}

.quest-card::before {
  content: '📜 YOUR QUEST';
  position: absolute;
  top: -12px;
  left: var(--space-sm);
  background: var(--bg-card);
  padding: 0 var(--space-xs);
  font-size: 0.5rem;
  color: var(--neon-magenta);
  letter-spacing: 2px;
}

.riddle-text {
  font-size: 0.75rem;
  line-height: 2;
  color: var(--text-primary);
}

/* Hints section */
.hints-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.hint-button {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.625rem;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 3px solid var(--text-muted);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hint-button:hover:not(:disabled) {
  border-color: var(--neon-orange);
  color: var(--neon-orange);
  box-shadow: 0 0 10px var(--neon-orange);
}

.hint-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint-button.revealed {
  border-color: var(--neon-orange);
  background: rgba(255, 107, 53, 0.2);
  color: var(--neon-orange);
}

.hint-content {
  display: none;
  padding: var(--space-sm);
  background: rgba(255, 107, 53, 0.1);
  border-left: 4px solid var(--neon-orange);
  font-size: 0.625rem;
  line-height: 1.8;
  color: var(--text-primary);
  animation: slideDown 0.3s ease-out;
}

.hint-content.visible {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   VICTORY SCREEN
   ═══════════════════════════════════════════════════════════ */

.victory-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: var(--space-lg);
  animation: fadeIn 0.5s ease-out;
}

.victory-trophy {
  font-size: 5rem;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.victory-title {
  font-size: 1.5rem;
  color: var(--neon-yellow);
  text-shadow: 
    /* Dark outline for readability */
    -2px -2px 0 rgba(0, 0, 0, 0.9),
    2px -2px 0 rgba(0, 0, 0, 0.9),
    -2px 2px 0 rgba(0, 0, 0, 0.9),
    2px 2px 0 rgba(0, 0, 0, 0.9),
    0 -2px 0 rgba(0, 0, 0, 0.9),
    0 2px 0 rgba(0, 0, 0, 0.9),
    -2px 0 0 rgba(0, 0, 0, 0.9),
    2px 0 0 rgba(0, 0, 0, 0.9),
    /* Glow effect */
    0 0 15px var(--neon-yellow),
    0 0 30px rgba(255, 240, 0, 0.4);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.victory-message {
  font-size: 0.75rem;
  color: var(--text-primary);
  line-height: 2;
  max-width: 300px;
  text-shadow: 
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8);
}

.victory-stars {
  display: flex;
  gap: var(--space-sm);
  font-size: 2rem;
}

.victory-stars span {
  animation: starPop 0.5s ease-out backwards;
}

.victory-stars span:nth-child(1) { animation-delay: 0.2s; }
.victory-stars span:nth-child(2) { animation-delay: 0.4s; }
.victory-stars span:nth-child(3) { animation-delay: 0.6s; }

@keyframes starPop {
  from {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ═══════════════════════════════════════════════════════════
   START SCREEN
   ═══════════════════════════════════════════════════════════ */

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: var(--space-lg);
  animation: fadeIn 0.5s ease-out;
}

.start-logo {
  font-size: 4rem;
  animation: pulse 2s ease-in-out infinite;
}

.start-title {
  font-size: 1rem;
  color: var(--neon-cyan);
  text-shadow: 
    0 0 10px var(--neon-cyan),
    0 0 20px var(--neon-cyan);
  line-height: 1.6;
}

.start-subtitle {
  font-size: 0.625rem;
  color: var(--text-secondary);
  line-height: 2;
}

.start-button {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.875rem;
  padding: var(--space-md) var(--space-xl);
  background: var(--neon-yellow);
  border: none;
  color: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  animation: glow 2s ease-in-out infinite;
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 
    0 0 20px var(--neon-yellow),
    0 0 40px var(--neon-yellow);
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 10px var(--neon-yellow);
  }
  50% {
    box-shadow: 
      0 0 20px var(--neon-yellow),
      0 0 30px var(--neon-orange);
  }
}

/* ═══════════════════════════════════════════════════════════
   FINAL BOSS SPECIAL STYLING
   ═══════════════════════════════════════════════════════════ */

.level-screen.final-boss .level-title {
  color: #ff0044;
  text-shadow: 
    /* Dark outline for readability */
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8),
    /* Glow effect */
    0 0 10px #ff0044,
    0 0 20px rgba(255, 0, 68, 0.5);
  animation: bossFlicker 0.5s ease-in-out infinite;
}

.level-screen.final-boss .level-image-container {
  border-color: #ff0044;
  box-shadow: 
    0 0 10px #ff0044,
    0 0 20px rgba(255, 0, 68, 0.5),
    inset 0 0 30px rgba(255, 0, 68, 0.1);
}

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

.level-screen.final-boss .quest-card {
  border-color: #ff0044;
}

.level-screen.final-boss .quest-card::before {
  content: '⚔️ FINAL QUEST';
  color: #ff0044;
}

/* ═══════════════════════════════════════════════════════════
   ERROR SCREEN
   ═══════════════════════════════════════════════════════════ */

.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: var(--space-md);
}

.error-icon {
  font-size: 4rem;
}

.error-title {
  font-size: 1rem;
  color: #ff0044;
}

.error-message {
  font-size: 0.625rem;
  color: var(--text-secondary);
  line-height: 2;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  html {
    font-size: 18px;
  }
  
  #app {
    padding: var(--space-xl);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

