/* ── I Love Lucy Visual Novel ── */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Special+Elite&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --cream: #f5f0e8;
  --warm-white: #ede7d9;
  --sepia: #8b7355;
  --sepia-light: #c4a882;
  --sepia-dark: #5c4a32;
  --charcoal: #2a2520;
  --dark-brown: #1a1510;
  --heart-red: #c0392b;
  --heart-glow: rgba(192, 57, 43, 0.3);
  --soft-black: #333028;
  --highlight: #d4a960;
  --tv-body: #8b7355;
  --tv-dark: #5c4a32;
}

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

body {
  background: #2c2416;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Lora', Georgia, serif;
  overflow: hidden;
}

/* ── TV Frame ── */
#tv-frame {
  width: 100%;
  max-width: 800px;
  margin: 10px;
}

#tv-screen {
  position: relative;
  background: var(--charcoal);
  border: 12px solid var(--tv-body);
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.5),
    0 4px 20px rgba(0, 0, 0, 0.6);
}

/* ── Scanlines ── */
#scanlines {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  pointer-events: none;
  z-index: 50;
}

/* Slight vignette */
#tv-screen::after {
  content: '';
  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: 49;
}

/* ── TV Base ── */
.tv-base {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 30px;
  background: linear-gradient(to bottom, var(--tv-body), var(--tv-dark));
  border-radius: 0 0 12px 12px;
}

.tv-knob {
  width: 24px;
  height: 24px;
  background: radial-gradient(circle, #a08060, #6b5540);
  border-radius: 50%;
  border: 2px solid #4a3828;
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.2);
}

.tv-label {
  font-family: 'Special Elite', monospace;
  color: var(--cream);
  font-size: 0.75rem;
  letter-spacing: 6px;
  opacity: 0.7;
}

/* ── App Container ── */
#app {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 51;
  overflow-y: auto;
}

/* ── Screen Management ── */
.screen {
  display: none;
  width: 100%;
  min-height: 100%;
  animation: fadeIn 0.6s ease;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen-game.active {
  align-items: stretch;
}

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

/* ── Title Screen ── */
.title-card {
  text-align: center;
  padding: 20px;
  width: 100%;
}

.heart-container {
  margin-bottom: 4px;
}

.heart {
  font-size: 3.5rem;
  color: var(--heart-red);
  text-shadow: 0 0 20px var(--heart-glow), 0 0 40px var(--heart-glow);
  animation: heartBeat 1.5s ease-in-out infinite;
  line-height: 1;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
}

.show-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3rem;
  font-weight: 900;
  font-style: italic;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--sepia-dark);
  margin-bottom: 2px;
  line-height: 1.1;
}

.show-subtitle {
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  color: var(--sepia-light);
  letter-spacing: 4px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.show-tagline {
  font-family: 'Lora', serif;
  font-style: italic;
  color: var(--sepia);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.credits {
  font-size: 0.65rem;
  color: var(--sepia);
  margin-top: 16px;
  font-style: italic;
  opacity: 0.6;
}

/* ── Buttons ── */
.retro-btn {
  font-family: 'Special Elite', monospace;
  font-size: 0.9rem;
  padding: 10px 32px;
  border: 2px solid var(--cream);
  background: var(--cream);
  color: var(--charcoal);
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  text-transform: uppercase;
  min-width: 200px;
}

.retro-btn:hover {
  background: var(--highlight);
  border-color: var(--highlight);
  transform: scale(1.02);
}

.retro-btn:active {
  transform: scale(0.98);
}

.retro-btn.outline {
  background: transparent;
  color: var(--cream);
}

.retro-btn.outline:hover {
  background: rgba(245, 240, 232, 0.1);
  border-color: var(--highlight);
  color: var(--highlight);
}

/* ── About Screen ── */
.about-card {
  padding: 24px 32px;
  max-height: 100%;
  overflow-y: auto;
}

.about-card h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  color: var(--cream);
  margin-bottom: 16px;
  text-align: center;
}

.about-text {
  color: var(--sepia-light);
  font-size: 0.8rem;
  line-height: 1.7;
  margin-bottom: 20px;
}

.about-text p {
  margin-bottom: 10px;
}

.about-text strong {
  color: var(--cream);
}

/* ── Episode Select ── */
.episode-card {
  padding: 20px 24px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.episode-card h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  color: var(--cream);
  margin-bottom: 16px;
  text-align: center;
}

.episode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.episode-item {
  background: rgba(245, 240, 232, 0.05);
  border: 1px solid rgba(245, 240, 232, 0.15);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.episode-item:hover {
  background: rgba(245, 240, 232, 0.1);
  border-color: var(--highlight);
}

.episode-number {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--heart-red);
  min-width: 30px;
}

.episode-info {
  flex: 1;
}

.episode-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.95rem;
  color: var(--cream);
  margin-bottom: 2px;
}

.episode-premise {
  font-size: 0.7rem;
  color: var(--sepia);
  font-style: italic;
}

/* ── Game Screen ── */
.game-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.scene-header {
  padding: 6px 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(245, 240, 232, 0.1);
}

.scene-location {
  font-family: 'Special Elite', monospace;
  font-size: 0.7rem;
  color: var(--sepia-light);
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ── Stage ── */
.stage {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 20px;
  position: relative;
  min-height: 0;
  background: linear-gradient(to bottom, var(--charcoal) 0%, #2f2a22 100%);
}

.character-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transition: all 0.4s ease;
  flex: 0 0 auto;
  padding: 0 8px;
}

.character-slot.hidden {
  opacity: 0;
  transform: translateY(10px);
}

.character-sprite {
  width: 80px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s;
}

.character-sprite.speaking {
  transform: scale(1.05);
}

/* Character bust portraits using CSS */
.char-portrait {
  width: 72px;
  height: 100px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  position: relative;
  border: 2px solid rgba(245, 240, 232, 0.2);
  border-bottom: none;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.char-portrait.lucy {
  background: linear-gradient(135deg, #8b4557 0%, #6b3040 100%);
}

.char-portrait.ricky {
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

.char-portrait.ethel {
  background: linear-gradient(135deg, #6b5b4e 0%, #4a3f35 100%);
}

.char-portrait.fred {
  background: linear-gradient(135deg, #5a6652 0%, #3d4638 100%);
}

.char-portrait.narrator {
  background: linear-gradient(135deg, #4a4540 0%, #2d2a25 100%);
}

.char-nameplate {
  font-family: 'Special Elite', monospace;
  font-size: 0.55rem;
  color: var(--cream);
  letter-spacing: 2px;
  text-align: center;
  padding: 3px 10px;
  background: rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
  width: 76px;
  border: 1px solid rgba(245, 240, 232, 0.15);
  border-top: none;
}

/* ── Dialogue Box ── */
.dialogue-box {
  background: rgba(15, 12, 8, 0.92);
  border-top: 2px solid var(--sepia);
  padding: 14px 20px;
  min-height: 120px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.speaker-name {
  font-family: 'Special Elite', monospace;
  font-size: 0.8rem;
  color: var(--highlight);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 6px;
  min-height: 1em;
}

.speaker-name.lucy { color: #e88ca0; }
.speaker-name.ricky { color: #a0b4cc; }
.speaker-name.ethel { color: #c4a882; }
.speaker-name.fred { color: #9aab8e; }
.speaker-name.narrator { color: var(--sepia); }

.dialogue-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: var(--cream);
  line-height: 1.6;
  flex: 1;
}

.dialogue-text em {
  color: var(--sepia-light);
}

.continue-prompt {
  font-family: 'Special Elite', monospace;
  font-size: 0.6rem;
  color: var(--sepia);
  text-align: right;
  margin-top: 6px;
  animation: blink 1.2s ease-in-out infinite;
}

.continue-prompt.hidden {
  display: none;
}

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

/* ── Choices ── */
.dialogue-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.choice-btn {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  padding: 8px 16px;
  background: rgba(245, 240, 232, 0.06);
  border: 1px solid var(--sepia);
  color: var(--cream);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  line-height: 1.3;
}

.choice-btn:hover {
  background: rgba(212, 169, 96, 0.15);
  border-color: var(--highlight);
  color: var(--highlight);
  padding-left: 22px;
}

.choice-btn:active {
  transform: scale(0.99);
}

/* ── Ending Screen ── */
.ending-card {
  text-align: center;
  padding: 24px 32px;
  width: 100%;
}

.ending-banner {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 900;
  font-style: italic;
  color: var(--cream);
  margin-bottom: 12px;
  text-shadow: 2px 2px 0 var(--sepia-dark);
}

.ending-card h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.2rem;
  color: var(--highlight);
  margin-bottom: 8px;
}

.ending-desc {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  color: var(--sepia-light);
  line-height: 1.6;
  margin-bottom: 16px;
  font-style: italic;
}

.ending-stats {
  font-family: 'Special Elite', monospace;
  font-size: 0.7rem;
  color: var(--sepia);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.ending-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Typewriter effect ── */
.typewriter-cursor {
  display: inline;
  animation: blink 0.7s step-end infinite;
}

/* ── Screen transitions ── */
.screen-iris {
  animation: irisIn 0.8s ease forwards;
}

@keyframes irisIn {
  from {
    clip-path: circle(0% at center);
    opacity: 0;
  }
  to {
    clip-path: circle(100% at center);
    opacity: 1;
  }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
  }

  #tv-frame {
    margin: 0;
  }

  #tv-screen {
    border-width: 6px;
    border-radius: 10px;
    aspect-ratio: auto;
    height: calc(100vh - 40px);
    min-height: 500px;
  }

  .tv-base {
    padding: 6px 20px;
    border-radius: 0 0 8px 8px;
  }

  .show-title {
    font-size: 2rem;
  }

  .heart {
    font-size: 2.5rem;
  }

  .char-portrait {
    width: 56px;
    height: 78px;
    font-size: 2rem;
  }

  .char-nameplate {
    width: 60px;
    font-size: 0.45rem;
  }

  .dialogue-box {
    padding: 10px 14px;
    min-height: 100px;
  }

  .dialogue-text {
    font-size: 0.78rem;
  }

  .retro-btn {
    min-width: 160px;
    font-size: 0.8rem;
    padding: 8px 24px;
  }

  .episode-item {
    padding: 10px 12px;
  }
}

@media (max-height: 600px) {
  #tv-screen {
    aspect-ratio: auto;
    height: calc(100vh - 50px);
  }
}
