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

:root {
  --magenta: #ff00ff;
  --cyan: #00ffff;
  --yellow: #ffff00;
  --red: #ff3300;
  --green: #00ff41;
  --bg: #0a0a0a;
  --panel-bg: #111111;
  --text: #cccccc;
  --text-dim: #888888;
  --border: #222222;
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1.15rem;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== CRT OVERLAY ===== */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0,
    rgba(0, 0, 0, 0.15) 2px,
    transparent 2px,
    transparent 4px
  );
  animation: flicker 0.15s infinite;
}

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

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.hero-logo {
  max-width: 500px;
  width: 90%;
  height: auto;
  image-rendering: pixelated;
  margin-bottom: 0.75rem;
}

/* ===== SOCIAL LINKS ===== */
.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}

.social-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.35rem;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.3em 0.6em;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}

.social-link:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

.social-links-login {
  margin-bottom: 1.5rem;
}

.social-links-login .social-link {
  font-size: 0.3rem;
  padding: 0.2em 0.4em;
}

.hero-subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: var(--cyan);
  text-shadow: 0 0 2px var(--cyan);
  letter-spacing: 0.1em;
}

/* ===== GLITCH ===== */
.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
}

.glitch::before {
  color: var(--magenta);
  text-shadow: -2px 0 var(--magenta);
  animation: glitch-before 2s infinite linear alternate-reverse;
}

.glitch::after {
  color: var(--cyan);
  text-shadow: 2px 0 var(--cyan);
  animation: glitch-after 3s infinite linear alternate-reverse;
}

@keyframes glitch-before {
  0%, 80%, 100% { clip-path: inset(0 0 80% 0); }
  20% { clip-path: inset(20% 0 60% 0); }
  40% { clip-path: inset(60% 0 20% 0); }
  60% { clip-path: inset(40% 0 40% 0); }
}

@keyframes glitch-after {
  0%, 80%, 100% { clip-path: inset(80% 0 0 0); }
  20% { clip-path: inset(60% 0 20% 0); }
  40% { clip-path: inset(20% 0 60% 0); }
  60% { clip-path: inset(40% 0 40% 0); }
}

/* ===== DASHBOARD ===== */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

/* ===== STAT CARDS ===== */
.stats-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.stat-card {
  flex: 1 1 180px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
  position: relative;
}

.stat-card:hover {
  border-color: var(--magenta);
}

.stat-value {
  display: block;
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--cyan);
  text-shadow: 0 0 3px var(--cyan);
  line-height: 1.1;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  font-family: 'Press Start 2P', monospace;
  color: var(--text-dim);
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

/* ===== PANELS ===== */
.panel {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.panel-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: var(--magenta);
  text-shadow: 0 0 2px var(--magenta);
  margin-bottom: 1rem;
  letter-spacing: 0.08em;
}

/* ===== CHART CONTAINERS ===== */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  height: 350px;
}

.chart-container.chart-sm {
  max-width: 450px;
  height: 350px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== SCRUBBER ===== */
.scrubber {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
}

.scrubber input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.scrubber input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--magenta);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.scrubber input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--magenta);
  cursor: pointer;
  border: 2px solid var(--bg);
}

#scrubber-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--cyan);
  min-width: 100px;
  text-align: right;
}

/* ===== GRID CARDS ===== */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* ===== FILM CARD (FLIP) ===== */
.film-card {
  perspective: 800px;
  height: 180px;
}

.film-card.mentioned-card {
  height: 300px;
}

.film-card.mentioned-card .film-card-front {
  padding: 0.5rem;
}

.film-card.mentioned-card .film-card-back {
  padding: 0.75rem;
}

/* ===== FILM POSTER ===== */
.film-poster {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--border);
  margin-bottom: 0.3rem;
}

.film-poster.poster-fail {
  display: block;
  background: linear-gradient(135deg, var(--border), var(--panel-bg));
  position: relative;
}

.film-poster.poster-fail::after {
  content: "NO POSTER";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.4rem;
  color: var(--text-dim);
}

/* ===== PODIUM ===== */
.podium .film-card-front,
.podium .film-card-back {
  border-width: 2px;
}

.podium-0 .film-card-front,
.podium-0 .film-card-back {
  border-color: #ffd700;
}

.podium-1 .film-card-front,
.podium-1 .film-card-back {
  border-color: #c0c0c0;
}

.podium-2 .film-card-front,
.podium-2 .film-card-back {
  border-color: #cd7f32;
}

.podium-label {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 5;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  padding: 0.2em 0.5em;
  border-radius: 3px;
  color: #000;
}

.podium-0 .podium-label {
  background: #ffd700;
}

.podium-1 .podium-label {
  background: #c0c0c0;
}

.podium-2 .podium-label {
  background: #cd7f32;
}

.film-card-front,
.film-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: transform 0.5s, border-color 0.3s, box-shadow 0.3s;
}

.film-card-front {
  z-index: 2;
}

.film-card-back {
  transform: rotateY(180deg);
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.film-card:hover .film-card-front {
  transform: rotateY(180deg);
}

.film-card:hover .film-card-back {
  transform: rotateY(0deg);
}

.film-card:hover .film-card-front,
.film-card:hover .film-card-back {
  border-color: var(--magenta);
}

.film-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text);
  line-height: 1.2;
}

.film-year {
  font-size: 0.9rem;
  color: var(--cyan);
}

.film-stars {
  font-size: 0.85rem;
  color: var(--yellow);
}

.film-info {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.film-ep-count {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--magenta);
}

/* ===== FILM ROWS (EPISODE DETAIL) ===== */
.film-list-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--cyan);
  padding: 0.5rem 0;
}

.film-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.film-row-title {
  color: var(--cyan);
  text-decoration: none;
  font-size: 1.05rem;
}

.film-row-title:hover {
  color: var(--magenta);
}

.film-row-year {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.film-row-rating {
  color: var(--yellow);
  font-size: 0.85rem;
}

.film-row-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  width: 100%;
}

/* ===== SCROLLABLE FILM LIST ===== */
.film-list {
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--magenta) var(--border);
}

.film-list::-webkit-scrollbar {
  width: 6px;
}

.film-list::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 3px;
}

.film-list::-webkit-scrollbar-thumb {
  background: var(--magenta);
  border-radius: 3px;
}

/* ===== BUTTONS ===== */
.btn-neon {
  display: inline-block;
  padding: 0.6em 1.5em;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--cyan);
  background: transparent;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  letter-spacing: 0.08em;
}

.btn-neon:hover {
  background: var(--cyan);
  color: var(--bg);
  transform: scale(1.05);
}

.btn-neon:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 0.4em 0.8em;
  font-size: 0.5rem;
}

/* ===== SLOT MACHINE ===== */
#slot-machine {
  text-align: center;
}

.slot-display {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5rem;
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow), 0 0 30px var(--yellow);
  padding: 1.5rem;
  background: var(--bg);
  border: 2px dashed var(--yellow);
  border-radius: 6px;
  margin-bottom: 1rem;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}

#slot-result {
  margin-top: 1rem;
  position: relative;
  height: 220px;
}

#slot-result .film-card {
  max-width: 300px;
  margin: 0 auto;
}

/* ===== SEARCH ===== */
.search-box {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1.2rem;
  color: var(--cyan);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 4px;
  outline: none;
  margin-bottom: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.search-box::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.search-box:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.no-results {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem;
  font-size: 1.1rem;
}

/* ===== HIDDEN ===== */
.hidden {
  display: none;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.last-update {
  margin-top: 0.5rem;
  color: var(--cyan);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  body {
    font-size: 1.3rem;
  }

  .hero-subtitle {
    font-size: 0.6rem;
  }

  .stat-card {
    flex: 1 1 130px;
    padding: 0.75rem 0.5rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .grid-cards {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 250px;
  }

  .chart-container.chart-sm {
    max-width: 100%;
    height: 280px;
  }

  .panel-title {
    font-size: 0.65rem;
  }

  .film-card.mentioned-card {
    height: 270px;
  }

  .film-poster {
    height: 120px;
  }

  .film-title {
    font-size: 1.4rem;
  }

  .film-year {
    font-size: 1.1rem;
  }

  .film-stars {
    font-size: 1rem;
  }

  .film-ep-count {
    font-size: 0.55rem;
  }

  .social-link {
    font-size: 0.5rem;
  }

  .scrubber {
    flex-direction: column;
    align-items: stretch;
  }

  #scrubber-label {
    text-align: center;
  }

  .login-title {
    font-size: 0.9rem;
  }

  .login-subtitle {
    font-size: 0.55rem;
  }

  .login-input {
    font-size: 1.6rem;
  }
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-logo {
  max-width: 300px;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  margin-bottom: 1.5rem;
}

.login-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  color: var(--magenta);
  text-shadow: 0 0 2px var(--magenta);
  margin-bottom: 0.5rem;
}

.login-subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  letter-spacing: 0.05em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 1.4rem;
  color: var(--cyan);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 4px;
  outline: none;
  text-align: center;
  letter-spacing: 0.3em;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.login-input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.3em;
  font-size: 0.8rem;
}

.login-input:focus {
  border-color: var(--cyan);
}

.login-btn {
  width: 100%;
  padding: 0.8em;
  font-size: 0.8rem;
}

.login-error {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--red);
  animation: glitch-before 0.3s linear;
}
