/* Comic player (js/game/comic.js): a full-screen reader with thick cartoon panel frames, live-text bubbles and an
   end card. Panel sizes are set from JS so a page always fits the screen in portrait and landscape. */
.comic {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; overflow: hidden;
  color: #2a211d; font-family: system-ui, sans-serif; outline: none; user-select: none; -webkit-user-select: none;
  background-color: #3b2f3f;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1.5px, transparent 1.6px);
  background-size: 14px 14px;
  touch-action: manipulation; cursor: pointer;
}
.comic-top {
  flex: none; display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 12px 4px;
}
.comic-title {
  flex: 1; min-width: 0; margin: 0; color: #fff3e6; font-weight: 800; font-size: 1rem; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.comic-btn {
  flex: none; min-width: 44px; min-height: 44px; padding: 6px 16px; border-radius: 999px; font: inherit; font-weight: 800;
  font-size: 0.95rem; color: #2a211d; background: #fff3e6; border: 3px solid #2a211d; box-shadow: 0 3px 0 #2a211d;
  cursor: pointer;
}
.comic-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a211d; }
.comic-btn:focus-visible { outline: 3px solid #5eead4; outline-offset: 2px; }
.comic-btn--main { background: #5eead4; }
.comic-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 12px;
}
.comic-page { display: flex; gap: 10px; align-items: center; justify-content: center; }
.comic-page--column { flex-direction: column; }
.comic-panel {
  position: relative; flex: none; overflow: hidden; border: 3px solid #2a211d; border-radius: 8px; background: #fffdf6;
  box-shadow: 5px 6px 0 rgba(20, 12, 18, 0.55); visibility: hidden; box-sizing: border-box;
}
.comic-panel.is-on { visibility: visible; }
.comic-panel.is-new { animation: comic-in 280ms cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
/* Upright phone, wide panel: bubbles in bands above and below the art, tails reaching into it. */
.comic-panel--out { border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
.comic-artbox {
  position: relative; overflow: hidden; border: 3px solid #2a211d; border-radius: 8px; background: #fffdf6;
  box-shadow: 5px 6px 0 rgba(20, 12, 18, 0.55); box-sizing: border-box; margin: 0 auto;
}
.comic-band { position: relative; z-index: 2; }
.comic-band .comic-text { position: relative; display: block; left: auto; top: auto; }
.comic-panel--out .comic-balloons { z-index: 1; }
.comic-art, .comic-balloons { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.comic-cam { transform-origin: 0 0; transform-box: view-box; }
.comic-texts { position: absolute; inset: 0; }
.comic-text {
  position: absolute; left: 0; top: 0; box-sizing: border-box; padding: 0.45em 0.8em; line-height: 1.2; font-weight: 700;
  text-align: center; overflow-wrap: break-word; width: max-content; opacity: 0;
}
.comic-text--caption { padding: 0.4em 0.7em; text-align: left; font-style: italic; font-weight: 800; }
.comic-text--shout { font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em; }
.comic-text--think { font-weight: 600; font-style: italic; }
.comic-text--whisper { font-weight: 500; font-style: italic; }
.comic-bub { opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; }
.comic-bub.is-on, .comic-text.is-on { opacity: 1; }
.comic-text.is-on { transform-origin: 50% 60%; }
.is-pop { animation: comic-pop 240ms cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.is-pop-late { animation: comic-pop 240ms cubic-bezier(0.3, 1.6, 0.5, 1) 320ms both; }
.comic-hint {
  flex: none; margin: 0; padding: 4px 12px max(8px, env(safe-area-inset-bottom)); text-align: center;
  color: rgba(255, 243, 230, 0.7); font-size: 0.85rem;
}
.comic-end {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(30, 22, 32, 0.72); cursor: default;
}
.comic-end[hidden] { display: none; }
.comic-end__text {
  margin: 0; padding: 10px 22px; color: #2a211d; background: #ffe08a; border: 3px solid #2a211d; border-radius: 10px;
  font-size: 1.4rem; font-weight: 900; transform: rotate(-2deg); box-shadow: 5px 6px 0 rgba(20, 12, 18, 0.55);
}
.comic-end__row { display: flex; gap: 12px; }
.comic-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes comic-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes comic-pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }
@media (max-height: 420px) {
  .comic-top { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 0; }
  .comic-btn { min-height: 40px; padding: 4px 14px; }
  .comic-hint { padding-top: 0; padding-bottom: max(4px, env(safe-area-inset-bottom)); font-size: 0.78rem; }
}
.comic--still .is-pop, .comic--still .is-pop-late, .comic--still .is-new { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .comic .is-pop, .comic .is-pop-late, .comic .is-new { animation: none; }
}
