:root {
  --charcoal: #1a1a2e;
  --amber: #e6a817;
  --orange: #d4631d;
  --cream: #f5e6ca;
  --crt-green: #33ff33;
  --deep-brown: #2a1f14;
  --warm-brown: #3d2b1f;
}

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

body {
  background: var(--deep-brown);
  color: var(--cream);
  font-family: 'Crimson Pro', serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scanline overlay on the whole page */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Static noise animation */
@keyframes staticNoise {
  0% { background-position: 0 0; }
  10% { background-position: -5% -10%; }
  20% { background-position: -15% 5%; }
  30% { background-position: 7% -25%; }
  40% { background-position: -5% 25%; }
  50% { background-position: -15% 10%; }
  60% { background-position: 15% 0%; }
  70% { background-position: 0% 15%; }
  80% { background-position: 3% 35%; }
  90% { background-position: -10% 10%; }
  100% { background-position: 0 0; }
}

.static-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.4'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: staticNoise 0.5s steps(10) infinite;
  opacity: 0.06;
  pointer-events: none;
  z-index: 1;
}

/* CRT Screen */
.crt-screen {
  position: relative;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.6),
    0 0 20px rgba(230, 168, 23, 0.15),
    0 0 60px rgba(230, 168, 23, 0.05);
}

.crt-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  pointer-events: none;
  z-index: 2;
}

.crt-screen::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 3;
}

/* TV Frame */
.tv-frame {
  background: linear-gradient(145deg, #5a4a3a 0%, #3d2b1f 40%, #2a1f14 100%);
  border-radius: 32px;
  padding: 20px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 2px 4px rgba(255,255,255,0.1),
    inset 0 -2px 4px rgba(0,0,0,0.3);
  position: relative;
}

.tv-frame::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  border-radius: 32px 32px 0 0;
}

/* Tuning animation */
@keyframes tuningBars {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

.tuning-bars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation: tuningBars 0.3s linear infinite;
  z-index: 5;
}

/* Retro button */
.retro-btn {
  background: linear-gradient(180deg, #e6a817 0%, #d4631d 100%);
  border: 3px solid #f5e6ca;
  border-radius: 12px;
  color: var(--charcoal);
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  padding: 14px 28px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow:
    0 4px 0 #8a4010,
    0 6px 12px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(255,255,255,0.3);
  transition: all 0.15s ease;
  position: relative;
  top: 0;
  min-height: 48px;
  touch-action: manipulation;
}

.retro-btn:hover {
  background: linear-gradient(180deg, #f0b820 0%, #e07030 100%);
  box-shadow:
    0 4px 0 #8a4010,
    0 6px 20px rgba(230, 168, 23, 0.4),
    inset 0 1px 2px rgba(255,255,255,0.3);
  transform: scale(1.03);
}

.retro-btn:active {
  top: 3px;
  box-shadow:
    0 1px 0 #8a4010,
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(255,255,255,0.3);
}

.retro-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.share-btn {
  font-size: 10px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #3d2b1f, #2a1f14);
  color: #e6a817;
  border: 2px solid #e6a817;
}

.share-btn:hover {
  background: linear-gradient(180deg, #4d3b2f, #3a2f24);
}

.clear-btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  color: rgba(255,255,255,0.4);
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  min-height: 32px;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.clear-btn:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.4);
}

/* Input styling */
.retro-input {
  background: #0d0d1a;
  border: 3px solid #e6a817;
  border-radius: 8px;
  color: #33ff33;
  font-family: 'Crimson Pro', serif;
  font-size: 18px;
  font-weight: 600;
  padding: 14px 16px;
  width: 100%;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
  text-shadow: 0 0 8px rgba(51, 255, 51, 0.4);
  min-height: 52px;
  -webkit-appearance: none;
  appearance: none;
}

.retro-input::placeholder {
  color: rgba(51, 255, 51, 0.35);
  font-style: italic;
  text-shadow: none;
  font-size: 16px;
}

.retro-input:focus {
  border-color: #f0b820;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.5),
    0 0 12px rgba(230, 168, 23, 0.3);
}

/* Rarity badge/card */
.rarity-card {
  position: relative;
  border-radius: 16px;
  padding: 24px 16px;
  overflow: hidden;
}

.rarity-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255,255,255,0.1) 60deg,
    transparent 120deg
  );
  animation: holoRotate 4s linear infinite;
  z-index: 0;
}

@keyframes holoRotate {
  100% { transform: rotate(360deg); }
}

.rarity-card-inner {
  position: relative;
  z-index: 1;
}

/* Holographic effect for rare+ cards */
.holo-effect::before {
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255,255,255,0.25) 30deg,
    rgba(255,200,100,0.15) 60deg,
    transparent 90deg,
    rgba(100,200,255,0.15) 150deg,
    transparent 180deg,
    rgba(255,100,200,0.2) 240deg,
    transparent 300deg,
    rgba(100,255,200,0.15) 340deg,
    transparent 360deg
  );
}

/* Rarity meter */
.rarity-meter {
  height: 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
  position: relative;
}

.rarity-meter-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 1.5s ease-out;
}

/* Pulse for legendary+ */
@keyframes legendaryPulse {
  0%, 100% { text-shadow: 0 0 10px currentColor, 0 0 20px currentColor; }
  50% { text-shadow: 0 0 20px currentColor, 0 0 40px currentColor, 0 0 60px currentColor; }
}

.legendary-pulse {
  animation: legendaryPulse 2s ease-in-out infinite;
}

/* Rainbow text */
@keyframes rainbowShift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

.rainbow-text {
  background: linear-gradient(90deg, #ff0000, #ff7700, #ffff00, #00ff00, #0077ff, #8800ff, #ff0088);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rainbowShift 3s linear infinite;
}

/* Glowing white for impossibly rare */
@keyframes impossibleGlow {
  0%, 100% {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 40px #fff;
    opacity: 1;
  }
  50% {
    text-shadow: 0 0 20px #fff, 0 0 40px #fff, 0 0 80px #fff, 0 0 120px rgba(255,255,255,0.5);
    opacity: 0.95;
  }
}

.impossible-glow {
  animation: impossibleGlow 2s ease-in-out infinite;
  color: #ffffff;
}

/* Reveal animation */
@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reveal-up {
  animation: revealUp 0.6s ease-out forwards;
}

.reveal-delay-1 { animation-delay: 0.1s; opacity: 0; }
.reveal-delay-2 { animation-delay: 0.3s; opacity: 0; }
.reveal-delay-3 { animation-delay: 0.5s; opacity: 0; }
.reveal-delay-4 { animation-delay: 0.7s; opacity: 0; }

/* History item */
.history-item {
  transition: all 0.2s ease;
}

.history-item:hover {
  transform: translateX(4px);
  background: rgba(255,255,255,0.08) !important;
}

.history-item:active {
  transform: translateX(2px);
}

/* Antenna */
@keyframes antennaWiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.antenna-wiggle {
  animation: antennaWiggle 4s ease-in-out infinite;
  transform-origin: bottom center;
}

/* Copied toast */
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast-in {
  animation: toastIn 0.3s ease-out forwards;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: var(--amber);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--orange);
}

/* Mobile-specific adjustments */
@media (max-width: 480px) {
  .tv-frame {
    border-radius: 24px;
    padding: 16px;
  }

  .crt-screen {
    border-radius: 18px;
  }

  .rarity-card {
    padding: 20px 12px;
  }

  .retro-btn {
    font-size: 11px;
    padding: 12px 20px;
    width: 100%;
  }

  .share-btn {
    font-size: 9px;
    padding: 10px 16px;
    width: auto;
  }
}