/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --yellow: #FFD600;
  --orange: #FF6B00;
  --purple: #6A0DAD;
  --purple-light: #9B4DCA;
  --sky: #87CEEB;
  --ink: #1a1a1a;
  --panel-bg: #FFFDF0;
  --border: 3px solid var(--ink);
  --border-fat: 5px solid var(--ink);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  background: var(--yellow);
  background-image:
    radial-gradient(circle, rgba(0,0,0,.08) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--ink);
  min-height: 100vh;
}

/* ===== HEADER ===== */
header {
  background: var(--purple);
  border-bottom: var(--border-fat);
  box-shadow: 0 6px 0 var(--ink);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-wrap { display: flex; align-items: center; gap: 14px; }

.sun-icon {
  font-size: 2.8rem;
  animation: spin 8s linear infinite;
  filter: drop-shadow(0 0 12px #FFD600);
  line-height: 1;
}

@keyframes spin { to { transform: rotate(360deg); } }

.site-title {
  font-family: 'Bangers', 'Impact', sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  color: var(--yellow);
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink);
  line-height: 1;
}

.site-sub {
  color: rgba(255,255,255,.75);
  font-size: .8rem;
  margin-top: 3px;
}

.char-btn {
  background: var(--yellow);
  border: var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'Bangers', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
  white-space: nowrap;
}
.char-btn:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.char-btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--ink); }

/* ===== CHARACTER CARD ===== */
.char-card {
  display: none;
  background: white;
  border-bottom: var(--border-fat);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.1);
}

.char-card.open { display: block; }

.char-card-inner {
  max-width: 900px;
  margin: auto;
  padding: 28px 20px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.char-portrait {
  width: 180px;
  height: 240px;
  object-fit: cover;
  border: var(--border-fat);
  border-radius: 12px;
  box-shadow: 6px 6px 0 var(--ink);
  flex-shrink: 0;
  background: #e8e0ff;
}

.char-name {
  font-family: 'Bangers', sans-serif;
  font-size: 2rem;
  letter-spacing: 2px;
  color: var(--purple);
  text-shadow: 2px 2px 0 var(--ink);
}

.char-tagline {
  font-style: italic;
  color: var(--orange);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 6px 0 14px;
  border-left: 4px solid var(--orange);
  padding-left: 10px;
}

.char-traits {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.char-traits li { font-size: .95rem; }

.char-origin {
  font-size: .9rem;
  color: #444;
  line-height: 1.6;
  max-width: 540px;
}

/* ===== MAIN ===== */
main {
  max-width: 960px;
  margin: 30px auto;
  padding: 0 16px;
}

/* ===== DATE NAV ===== */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.nav-btn {
  background: var(--purple);
  color: white;
  border: var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'Bangers', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
  flex-shrink: 0;
}
.nav-btn:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink); }
.nav-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.nav-btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: 4px 4px 0 var(--ink); }

.date-display {
  text-align: center;
  background: white;
  border: var(--border-fat);
  border-radius: 12px;
  padding: 10px 24px;
  box-shadow: 4px 4px 0 var(--ink);
  flex: 1;
  max-width: 320px;
  margin: 0 auto;
}

.episode-label {
  font-family: 'Bangers', sans-serif;
  font-size: .8rem;
  letter-spacing: 3px;
  color: #888;
}

.episode-num {
  font-family: 'Bangers', sans-serif;
  font-size: 2rem;
  color: var(--purple);
  line-height: 1;
}

.date-label {
  font-size: .85rem;
  color: #555;
  margin-top: 2px;
}

/* ===== COMIC TITLE ===== */
.comic-title-wrap {
  text-align: center;
  margin-bottom: 24px;
  background: var(--orange);
  border: var(--border-fat);
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 6px 6px 0 var(--ink);
  position: relative;
  overflow: hidden;
}

.comic-title-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.15) 1px, transparent 1px);
  background-size: 12px 12px;
  pointer-events: none;
}

.comic-title {
  font-family: 'Bangers', sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: white;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 var(--ink);
  position: relative;
}

.comic-setting {
  font-size: .95rem;
  color: rgba(255,255,255,.85);
  margin-top: 6px;
  font-style: italic;
  position: relative;
}

/* ===== PANELS GRID ===== */
.panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 580px) {
  .panels-grid { grid-template-columns: 1fr; }
}

/* ===== PANEL ===== */
.panel {
  background: var(--panel-bg);
  border: var(--border-fat);
  border-radius: 10px;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275) both;
  position: relative;
}

.panel:nth-child(1) { animation-delay: .05s; }
.panel:nth-child(2) { animation-delay: .1s; }
.panel:nth-child(3) { animation-delay: .15s; }
.panel:nth-child(4) { animation-delay: .2s; }

@keyframes popIn {
  from { opacity: 0; transform: scale(.85) rotate(-2deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.panel-num {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--ink);
  color: white;
  font-family: 'Bangers', sans-serif;
  font-size: .9rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  letter-spacing: 0;
}

.panel-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #e8e0ff 0%, #fff9e6 100%);
  overflow: hidden;
  flex-shrink: 0;
}

.panel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .5s;
}

.panel-img.loading { opacity: 0; }
.panel-img.loaded  { opacity: 1; }

.panel-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #e8e0ff 0%, #fff9e6 100%);
  transition: opacity .4s;
  z-index: 1;
}

.panel-loader.hidden { opacity: 0; pointer-events: none; }

.loader-sun {
  font-size: 2.5rem;
  animation: spinBounce 1.2s ease-in-out infinite;
}

@keyframes spinBounce {
  0%,100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.2) rotate(180deg); }
}

.loader-text {
  font-family: 'Comic Neue', cursive;
  font-size: .8rem;
  color: #777;
}

/* ===== SPEECH BUBBLE ===== */
.speech-bubble {
  position: absolute;
  bottom: 10px;
  right: 10px;
  max-width: 60%;
  background: white;
  border: 2.5px solid var(--ink);
  border-radius: 14px 14px 4px 14px;
  padding: 6px 10px;
  font-size: clamp(.65rem, 1.5vw, .8rem);
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 2px 2px 0 var(--ink);
  z-index: 3;
}

.speech-bubble.zara {
  border-color: var(--purple);
  background: #f5eeff;
  border-radius: 14px 14px 14px 4px;
  left: 10px;
  right: auto;
}

.bubble-speaker {
  font-size: .6rem;
  color: var(--purple);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  display: block;
  margin-bottom: 2px;
}

/* ===== PANEL CAPTION ===== */
.panel-caption {
  padding: 10px 12px;
  font-size: clamp(.75rem, 1.8vw, .9rem);
  font-style: italic;
  color: #333;
  border-top: 2px solid var(--ink);
  background: var(--panel-bg);
  line-height: 1.4;
  flex: 1;
}

/* ===== SHARING BAR ===== */
.sharing-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px;
  background: white;
  border: var(--border-fat);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 700;
  font-size: .9rem;
}

.share-btn {
  background: var(--purple);
  color: white;
  border: var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-family: 'Comic Neue', cursive;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
  font-size: .9rem;
}
.share-btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }

.kael-link-btn {
  background: #0EA5E9;
  color: white;
  border: var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: 'Bangers', sans-serif;
  font-size: 1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.kael-link-btn:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }

.kael-universe-btn {
  background: #0EA5E9;
  color: white;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 24px 16px;
  background: var(--ink);
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  margin-top: 40px;
  border-top: var(--border-fat);
}

footer a { color: var(--yellow); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
