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

:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #eee;
  --text-secondary: #aaa;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --header-height: 56px;
  --footer-height: 60px;
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100%;
}

/* Views */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn, .menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.back-btn:hover, .menu-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* Home View - Webtoon Grid */
.webtoon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-area-inset-bottom));
}

@media (min-width: 600px) {
  .webtoon-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    padding: 24px;
  }
}

.webtoon-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
}

.webtoon-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.webtoon-card:active {
  transform: scale(0.98);
}

.webtoon-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--bg-secondary);
}

/* Shimmer loading placeholder for images */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.webtoon-card img.loading, .character-card img.loading, .segment img.loading {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.webtoon-card-info {
  padding: 12px;
}

.webtoon-card-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.webtoon-card-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Webtoon Detail View - Console-style Hero */
.hero-section {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 60px 16px 32px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(30px) brightness(0.35);
  transform: scale(1.1);
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 900px;
  width: 100%;
  text-align: center;
}

@media (min-width: 768px) {
  .hero-content {
    flex-direction: row;
    text-align: left;
    gap: 48px;
  }
}

.hero-cover {
  width: 200px;
  height: auto;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .hero-cover {
    width: 280px;
  }
}

.hero-info {
  flex: 1;
  max-width: 500px;
}

.genre-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.hero-info h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .hero-info h1 {
    font-size: 2.5rem;
  }
}

.hero-logline {
  font-size: 1rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.6;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .hero-logline {
    font-size: 1.1rem;
  }
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 28px;
  justify-content: center;
}

@media (min-width: 768px) {
  .hero-stats {
    justify-content: flex-start;
  }
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.start-reading-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  padding: 14px 32px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-reading-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(233, 69, 96, 0.5);
}

.start-reading-btn:active {
  transform: translateY(0);
}

.hero-back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 20;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.hero-back-btn:hover {
  background: rgba(0,0,0,0.7);
}

/* Content sections below hero */
.webtoon-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.content-section {
  margin-bottom: 32px;
}

.content-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-family: Georgia, 'Times New Roman', serif;
}

/* Card grid for characters and locations */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
  }
}

/* Character and Location cards - unified style */
.entity-card {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.entity-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.entity-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: top;
  background: var(--bg-secondary);
}

.entity-card .card-body {
  padding: 14px;
}

.entity-card .card-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-card .card-body .role-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.entity-card .card-body .type-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.entity-card .card-body p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* Chapter list items */

.chapter-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.chapter-item:hover {
  background: var(--bg-secondary);
}

.chapter-item:active {
  transform: scale(0.98);
}

.chapter-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 40px;
}

.chapter-info h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.chapter-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Reader View */
#reader-view {
  background: #000;
}

.reader-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, transparent 100%);
  transition: opacity 0.3s, transform 0.3s;
}

.reader-header.hidden {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

.reader-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.reader-title span {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reader-title span:first-child {
  font-weight: 600;
}

.reader-title span:last-child {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.reader-content {
  min-height: 100vh;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--footer-height) + var(--safe-area-inset-bottom));
}

.reader-content img {
  display: block;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-secondary);
}

.reader-content .segment {
  position: relative;
}

.reader-content .segment-placeholder {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  aspect-ratio: 800/600;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.placeholder-icon {
  font-size: 3rem;
  opacity: 0.6;
}

/* Work in Progress message */
.wip-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.wip-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

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

.wip-message h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.wip-message p {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 300px;
}

.reader-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--footer-height) + var(--safe-area-inset-bottom));
  padding: 0 16px;
  padding-bottom: var(--safe-area-inset-bottom);
  background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, transparent 100%);
  transition: opacity 0.3s, transform 0.3s;
}

.reader-footer.hidden {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

.nav-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.nav-btn:hover {
  background: var(--accent-hover);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chapter-indicator {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-secondary);
}

/* Error */
.error-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.error-message h2 {
  color: var(--accent);
  margin-bottom: 12px;
}

/* Scroll behavior */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Hide scrollbar for cleaner mobile experience */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* End of Chapter Card */
.chapter-end-card {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.chapter-end-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chapter-end-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.chapter-end-nav {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.chapter-end-btn {
  padding: 16px 32px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, background 0.2s;
}

.chapter-end-btn:active {
  transform: scale(0.95);
}

.chapter-end-btn.primary {
  background: var(--accent);
  color: white;
}

.chapter-end-btn.primary:hover {
  background: var(--accent-hover);
}

.chapter-end-btn.secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.2);
}

.chapter-end-btn.secondary:hover {
  background: var(--bg-secondary);
}

.chapter-end-complete {
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--accent);
}

/* Text Overlays - webtoon style */
.text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  pointer-events: none;
  gap: 8px;
  z-index: 5;
}

.text-overlay > * {
  pointer-events: auto;
}

/* SFX needs to be positioned relative to panel-frame */
.panel-frame .sfx {
  position: absolute;
  top: 50%;
  left: 50%;
}

/* Narration box - Korean webtoon style, overlaps into next panel */
.narration-box {
  background: #fff;
  color: #222;
  padding: 16px 20px;
  font-size: 0.9rem;
  line-height: 1.7;
  text-align: left;
  max-width: 320px;
  /* Clean bordered rectangle */
  border: 2.5px solid #000;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.12);
  /* Position to overlap into next panel */
  position: relative;
  margin: -20px auto 0 20px;
  z-index: 20;
  /* Animation - starts hidden */
  opacity: 0;
  transform: translateY(-10px);
}

/* Narration animation when visible */
.segment.visible .narration-box {
  animation: narrationAppear 0.5s ease-out 0.2s forwards;
}

@keyframes narrationAppear {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Speech bubbles container - bottom of panel */
.speech-bubbles-area {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.speech-bubble {
  background: #fff;
  color: #1a1a1a;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  max-width: 65%;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  align-self: flex-start;
  border: 1.5px solid #333;
  /* Animation - starts hidden, animates when segment visible */
  opacity: 0;
  transform: translateY(15px);
}

/* Speech bubble animation when visible */
.segment.visible .speech-bubble {
  animation: bubbleAppear 0.4s ease-out forwards;
}

.segment.visible .speech-bubble:nth-child(2) { animation-delay: 0.2s; }
.segment.visible .speech-bubble:nth-child(3) { animation-delay: 0.4s; }
.segment.visible .speech-bubble:nth-child(4) { animation-delay: 0.6s; }
.segment.visible .speech-bubble:nth-child(5) { animation-delay: 0.8s; }

@keyframes bubbleAppear {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.speech-bubble:first-of-type {
  margin-top: auto;
}

.speech-bubble.right {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
}

/* Speech bubble tail - small notch */
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 8px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #333;
}

.speech-bubble.right::after {
  left: auto;
  right: 8px;
}

.speech-bubble.right::before {
  left: auto;
  right: 7px;
}

.speech-bubble .speaker {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.speech-bubble .text {
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Thought bubble - cloud style */
.speech-bubble.thought {
  background: #f0f4ff;
  border: 1.5px dashed #8899bb;
  border-radius: 20px;
  font-style: italic;
}

.speech-bubble.thought::before,
.speech-bubble.thought::after {
  display: none;
}

.speech-bubble.thought .text {
  color: #556;
}

/* SFX - manga style centered text with dramatic effects */
.sfx {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-5deg);
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  background: none;
  padding: 0;
  letter-spacing: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: 'Impact', 'Arial Black', sans-serif;
  /* Manga-style outline and glow */
  text-shadow:
    /* Black outline */
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000,
    /* White inner glow */
    0 0 10px rgba(255,255,255,0.8),
    0 0 20px rgba(255,255,255,0.5),
    /* Colored outer glow */
    0 0 30px rgba(255,100,100,0.6),
    0 0 40px rgba(255,100,100,0.4);
  -webkit-text-stroke: 1px #000;
  /* Animation - starts hidden */
  opacity: 0;
}

/* SFX animation when visible */
.segment.visible .sfx {
  animation: sfxPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.15s forwards;
}

@keyframes sfxPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-5deg) scale(0.5);
  }
  70% {
    transform: translate(-50%, -50%) rotate(-5deg) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-5deg) scale(1);
  }
}

/* Ensure segment is positioning context */
.reader-content .segment {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  /* Dynamic spacing between panels */
  margin-bottom: 12px;
}

/* Panel frame - provides the border/frame effect */
.panel-frame {
  position: relative;
  background: #fff;
  /* Manga-style black border */
  border: 3px solid #000;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
  overflow: hidden;
}

.panel-frame img {
  display: block;
  width: 100%;
}

/* Move text-overlay inside panel-frame */
.panel-frame .text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* === PANEL VARIATIONS === */

/* Tilt left - slight rotation for dynamic feel, stays centered */
.segment.tilt-left {
  transform: rotate(-1.2deg);
}

.segment.tilt-left .panel-frame {
  box-shadow: 5px 4px 0 rgba(0,0,0,0.4);
}

/* Tilt right - opposite rotation, stays centered */
.segment.tilt-right {
  transform: rotate(1.2deg);
}

.segment.tilt-right .panel-frame {
  box-shadow: -1px 4px 0 rgba(0,0,0,0.4);
}

/* Overlap next - negative margin to overlap following panel */
.segment.overlap-next {
  margin-bottom: -25px;
  z-index: 10;
}

.segment.overlap-next .panel-frame {
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Varied spacing between panels */
.segment:nth-child(3n) {
  margin-bottom: 20px;
}

.segment:nth-child(5n) {
  margin-bottom: 8px;
}

.segment:nth-child(7n) {
  margin-bottom: 25px;
}

/* Action panels - thicker border */
.segment:nth-child(4n) .panel-frame {
  border-width: 4px;
}

/* Dramatic panel corners */
.segment:nth-child(6n) .panel-frame {
  border-radius: 0 12px 0 12px;
}

/* Speed lines effect for action panels */
.segment:nth-child(8n)::before {
  content: '';
  position: absolute;
  top: 0;
  left: -20px;
  right: -20px;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 15px,
    rgba(0,0,0,0.03) 15px,
    rgba(0,0,0,0.03) 16px
  );
  pointer-events: none;
  z-index: -1;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .text-overlay {
    padding: 10px;
  }

  .narration-box {
    font-size: 0.8rem;
    padding: 12px 16px;
    max-width: 260px;
    margin-left: 12px;
    margin-top: -15px;
  }

  .speech-bubble {
    padding: 10px 12px;
    max-width: 80%;
  }

  .speech-bubble .text {
    font-size: 0.75rem;
  }

  .sfx {
    font-size: 1.5rem;
  }

  /* Reduce panel variations intensity on mobile */
  .segment.tilt-left {
    transform: rotate(-0.8deg);
  }

  .segment.tilt-right {
    transform: rotate(0.8deg);
  }

  .segment.overlap-next {
    margin-bottom: -15px;
  }

  .panel-frame {
    border-width: 2px;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  }

  .scene-title {
    max-width: 300px;
    padding: 12px 16px;
    font-size: 0.85rem;
    margin-bottom: -18px;
  }

  .chapter-end-btn {
    padding: 12px 24px;
    font-size: 0.9rem;
    width: 100%;
  }

  .chapter-end-nav {
    flex-direction: column;
    width: 100%;
    padding: 0 16px;
  }
}

/* Very small screens (iPhone SE, etc) */
@media (max-width: 375px) {
  .app-header h1 {
    font-size: 1rem;
  }

  .webtoon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
  }

  #webtoon-cover {
    width: 140px;
    height: 187px;
  }

  .speech-bubble {
    max-width: 85%;
  }

  .sfx {
    font-size: 1.5rem;
    -webkit-text-stroke: 1.5px #000;
  }

  .nav-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
}

/* Character Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideIn 0.3s ease;
}

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

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Character Modal - Console-style layout */
.character-modal-content {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}

.character-modal-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

@media (min-width: 600px) {
  .character-modal-layout {
    flex-direction: row;
  }
}

.character-modal-portrait {
  flex-shrink: 0;
}

.character-modal-portrait img {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: top;
  border-radius: 12px;
  background: var(--bg-card);
  margin: 0 auto;
  display: block;
}

@media (min-width: 600px) {
  .character-modal-portrait img {
    width: 200px;
  }
}

.character-modal-info {
  flex: 1;
  min-width: 0;
}

.character-modal-header {
  margin-bottom: 20px;
}

.character-modal-header .role-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.character-modal-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-family: Georgia, 'Times New Roman', serif;
}

.character-age {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.character-modal-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.character-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.character-section p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.7;
  margin: 0;
}

/* Character Outfits section */
.character-modal-outfits {
  padding: 0 24px 24px;
  display: none;
}

.character-modal-outfits.visible {
  display: block;
}

.character-modal-outfits > h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 16px;
}

.outfit-item {
  margin-bottom: 20px;
}

.outfit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.outfit-name {
  font-weight: 600;
  color: var(--text-primary);
}

.view-full-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.view-full-link:hover {
  color: var(--accent-hover);
}

.view-full-link svg {
  stroke: currentColor;
}

.outfit-item img {
  width: 100%;
  max-width: 600px;
  border-radius: 12px;
  background: var(--bg-card);
}

.outfits-loading {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 20px 0;
}

/* Legacy modal body styles */
.modal-body {
  padding: 20px;
}

.modal-body h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-body p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.trait-item {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.trait-item strong {
  color: var(--text-primary);
}

.trait-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.character-card {
  cursor: pointer;
}

/* Scene title - Cute manga style with wavy border */
.scene-title {
  max-width: 400px;
  margin: 0 auto;
  padding: 16px 26px;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.7;
  color: #333;
  background: #fffefa;
  text-align: center;
  /* Lighter wavy/rounded border */
  border: 2px solid #555;
  border-radius: 20px 8px 20px 8px;
  /* Soft shadow */
  box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  /* Gentle tilt */
  transform: rotate(-0.8deg);
  /* Overlap with next panel */
  position: relative;
  z-index: 25;
  margin-bottom: -25px;
  /* Cute rounded font */
  font-family: 'Comic Sans MS', 'Chalkboard', 'Comic Neue', cursive;
  letter-spacing: 0.2px;
}

/* More chapters notice */
.more-chapters-notice {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-secondary);
  font-style: italic;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 8px;
}

/* Upcoming Beats Section */
.upcoming-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--text-secondary);
}

.beats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.beat-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.15);
  transition: background 0.2s, border-color 0.2s;
}

.beat-card:hover {
  background: var(--bg-secondary);
  border-color: rgba(255,255,255,0.25);
}

.beat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 40px;
  opacity: 0.5;
}

.beat-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.beat-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Load more button */
.btn-load-more {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-load-more:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.btn-load-more:active {
  transform: scale(0.95);
}
