:root {
  --bg: #fff;
  --fg: #000;
  --accent: #000;
  --muted: #6b6b6b;
  --success: #2e9b57;
  --warn: #bf3b3b;
  --card-bg: #ffffff;
  --max-width: 1100px;
}

/* Reset & Base */
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a {
  color: inherit;
  text-decoration: none;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--accent);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  gap: 16px;
}
.brand {
  font-size: 1.5rem;
  font-weight: 500;
}
.tabs {
  display: flex;
  gap: 6px;
}
.tab {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid transparent;
  background: none;
  transition: background 0.2s, border-color 0.2s;
}
.tab[aria-selected="true"] {
  border-color: var(--accent);
  background: #f4f4f4;
}

/* Socials Desktop */
.socials {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
  min-width: 0;
  max-width: 88px;
}
.social-icon {
  width: 25px;
  height: 25px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 4px;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.85;
}
.social-icon:hover {
  opacity: 1;
  transform: scale(1.13);
}

/* Mobile-only socials */
.mobile-socials {
  display: none;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 0 0;
  padding: 0;
}

/* Layouts */
main {
  max-width: var(--max-width);
  margin: 28px auto;
  padding: 18px;
}
.home-layout {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-top: 20px;
}
.balan-container {
  flex: 0 1 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(420px, 85vw);
  text-align: center;
  /* nudge left a little to make room for highlights */
  transform: translateX(-12px);
}
.balan-image {
  width: 100%;
  max-width: 275px;
  border-radius: 8px;
  cursor: pointer;
  image-rendering: auto;
  -webkit-user-drag: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.15s cubic-bezier(.4,0,.2,1), box-shadow 0.15s;
}
.balan-image:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.balan-label {
  margin-top: 10px;
  font-weight: 700;
}
#reset-clicks,
#mute-btn {
  margin-top: 10px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 6px;
  transition: background 0.2s;
}
#reset-clicks:hover,
#mute-btn:hover {
  background: #eee;
}
.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comic-title {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.open-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}
.open-btn:hover {
  background: #f5f5f5;
}
.reader {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.reader-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}
.btn:hover {
  background: #f5f5f5;
}
.page {
  max-width: min(900px, 92vw);
  border: 2px solid var(--accent);
  border-radius: 6px;
  display: block;
  height: auto;
}
/* ===== HIGHLIGHTS PANEL ===== */
.highlights-panel {
  width: 320px;
  max-width: 30%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  text-align: center;
}
.highlights-panel h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}
.highlights-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--accent);
  border-radius: 10px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.highlight-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
}
.highlight-slide.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}
.highlight-slide img,
.highlight-slide picture {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}
.highlight-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
/* Expanded state for clearer preview */
.highlights-panel.expanded {
  /* make sure the panel can grow and overlay nicely */
  position: relative;
  z-index: 1000;
}
/* default (desktop) expanded size — reduced compared to previous */
.highlights-panel.expanded .highlights-stage {
  height: min(60vh, 520px);
}

/* ===== SHOP ===== */
.shop {
  width: 220px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}
.shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px;
}
.shop-image {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
.shop-image img {
  width: 100%;
  max-width: 160px;
  height: auto;
  border-radius: 10px;
  object-fit: contain;
  cursor: pointer;
}
.shop-unlocked-img {
  cursor: pointer;
}
/* ===== SHOP BUTTON ===== */
.buy-btn {
  padding: 5px 10px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: #FFFFFF;
  font-weight: bold;
  transition: background 0.2s;
}
.buy-btn:hover {
  background: #D3D3D3;
}
/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.modal-content {
  position: relative;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 90vw;
  max-height: 90vh;
}
#modal-img {
  max-width: 80vw;
  max-height: 70vh;
  border-radius: 8px;
  margin-top: 24px;
}

/* ===== MAIN QUESTS / CHAPTERS LAYOUT ===== */
.section-header h2 {
  margin: 0 0 6px 0;
  font-size: 1.25rem;
}
.section-sub {
  margin: 0 0 12px 0;
  color: var(--muted);
}

/* Coming soon banner */
.coming-soon {
  border: 1px dashed #e4b4b4;
  background: linear-gradient(90deg, rgba(255,250,240,0.9), rgba(255,250,240,0.6));
  color: var(--warn);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Chapters grid: responsive and easy to edit */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}

/* Chapter card */
.chapter-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 10px;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.chapter-thumbnail {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}
.chapter-thumbnail img,
.chapter-thumbnail picture,
.chapter-thumbnail svg {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}
.chapter-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chapter-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
}
.chapter-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 2.5em; /* keep cards visually consistent */
}

/* Actions row */
.chapter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.status-badge {
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: none;
}
.status-coming-soon { background: #fff0f0; color: var(--warn); border: 1px solid #f0c4c4; }
.status-ongoing { background: #e8f8ef; color: var(--success); border: 1px solid #bfe8c7; }
.status-complete { background: #f0f7ff; color: #0b63d6; border: 1px solid #cfe1ff; }
.status-preview { background: #fff7e6; color: #b36b00; border: 1px solid #f0d9b0; }

.chapter-link {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--fg);
  font-weight: 700;
}
.chapter-link.disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* small editor note - hidden visually but present in DOM */
.editor-note {
  display: none;
}

/* default (desktop) expanded size — reduced compared to previous */
.highlights-panel.expanded .highlights-stage {
  height: min(60vh, 520px);
}

/* Voice credit small text and secret button */
.voice-credit {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 8px;
  line-height: 1.2;
}

/* Secret button styling (appears when clicks >= 10000) */
.secret-btn {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  background: white;
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: background 0.2s;
}
.secret-btn:hover {
  background: #f0f0f0;
}

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .home-layout {
    flex-direction: column;
    align-items: center;
  }
  .shop {
    width: 100%;
    max-width: 300px;
  }
  .shop-grid {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .shop-item {
    max-width: 140px;
  }
  .shop-image img {
    max-width: 120px;
  }

  /* Keep highlights functioning like desktop on mobile:
     - Only one slide visible at a time (positioned absolutely).
     - Adjust stage size for mobile but keep overflow:hidden so slides don't stack vertically.
  */
  .highlights-panel {
    width: 100%;
    max-width: 920px;
  }
  .highlights-stage {
    height: 56vw;
    min-height: 160px;
    padding: 12px;
  }
  .highlight-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 600ms ease;
  }
  .highlight-slide.active {
    opacity: 1;
    pointer-events: auto;
  }
  .highlight-slide img,
  .highlight-slide picture {
    max-height: 56vw;
    max-width: 100%;
  }

  /* Keep the expanded mobile preview large (original mobile expansion) */
  .highlights-panel.expanded .highlights-stage {
    height: min(80vh, 90vw);
  }
}
@media (max-width: 700px) {
  .socials {
    display: none !important;
  }
  .mobile-socials {
    display: flex !important;
  }

  /* Slight adjustments for small screens */
  .chapter-desc { font-size: 0.9rem; }
  .chapter-actions { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* Ensure hidden sections stay hidden */
[data-section][hidden] {
  display: none !important;
}
.modal[hidden] {
  display: none !important;
}