/* 2026-10-17 total-quality layer. Load last.
 * Type treatment, dialogue portraits (original art crops), typewriter, sweeps, game feel and the
 * chapter-clear medal. Layout of the story screens lives in adventure-20261016.css ("ものがたりの画面")
 * and campaign-games-20261017.css; this file does not size or place them. */

/* ---------- type system ----------
 * Titles: Dela Gothic One with the logo's ink-and-sun treatment (white rim on art, sun shadow on paper).
 * Body: Zen Maru Gothic Medium (the 400 face) for steady small-screen reading; emphasis: Zen Maru Bold.
 * All faces are full-coverage subsets of the original OFL fonts (制作メモ/フォント_20261017). */
:root { --font-title: "UMK Dela", "UMK Zen Maru", "UMK Sym", "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Meiryo", sans-serif;
  --pl-ink: #173d59; --pl-sun: #ffd84a; --pl-rim: #fffdf5; }
body { font-kerning: normal; text-rendering: optimizeLegibility; }
.cg-top h3, .cg-complete h4, .cp-reward h3, .adv-map__heading, .adv-panel h3, .adv-screen__main h3,
.pl-banner strong, .pl-pop, .an-title {
  font-family: var(--font-title); font-weight: 400; font-synthesis: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.adv-panel h3 rt { font-family: var(--font-body); }
/* On paper: ink letters lifted by a thin rim and a sunny offset shadow. */
.cg-complete h4, .cp-reward h3, .adv-panel h3, .adv-screen__main h3 {
  color: var(--pl-ink); text-shadow: 0 2px 0 var(--pl-rim), 0 3px 0 var(--pl-sun); }
.cp-reward__title strong { color: var(--pl-ink); letter-spacing: .06em; }
.an-title { letter-spacing: .05em; }
/* Name plates and counters. */
.adv-dialogue__name, .cp-dialogue__name { font-family: var(--font-body); font-weight: 700; }
.cp-hub__count, .cg-stamp, .cp-medal b { font-variant-numeric: tabular-nums; }

/* ---------- dialogue portrait (sized and placed by the dialogue box) ---------- */
.pl-face { position: relative; display: block; flex: none; width: var(--pl-face, 64px); height: var(--pl-face, 64px); overflow: hidden; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fffdf2 0 55%, #fff1c4 100%); border: 3px solid var(--pl-speaker, #2F7FB5);
  box-shadow: 0 3px 0 #173d5933, inset 0 0 0 3px #fff; isolation: isolate; }
.pl-face img { position: absolute; display: block; height: auto; max-width: none!important; max-height: none!important; pointer-events: none; user-select: none; }
[data-motion="full"] .pl-face.is-pop { animation: pl-face-pop 360ms cubic-bezier(.2,.9,.3,1.25) both; }
@keyframes pl-face-pop { 0% { transform: scale(.72) rotate(-6deg); } 60% { transform: scale(1.08) rotate(2deg); } 100% { transform: none; } }

/* ---------- typewriter ---------- */
/* 分かち書き: wrap at the spaces between phrases, never inside a phrase. */
.adv-dialogue__text, .cp-dialogue__text, .cg-status, .adv-hint p, .adv-panel > p, .adv-screen__main p { word-break: keep-all; line-break: strict; overflow-wrap: anywhere; }
.pl-ch { opacity: 0; }
.pl-ch.is-on { opacity: 1; }
[data-motion="full"] .pl-typing .pl-ch.is-on { animation: pl-char 140ms ease-out both; }
@keyframes pl-char { from { opacity: 0; transform: translateY(.18em); } to { opacity: 1; transform: none; } }
span.pl-ch { display: inline; }
ruby.pl-ch { display: ruby; }
.pl-tap-stage { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pl-is-typing .adv-next, .pl-is-typing .cp-next { background: #fff3c4; }
[data-motion="full"] .pl-is-ready .adv-next__arrow, [data-motion="full"] .pl-is-ready .cp-next__arrow { animation: pl-nudge 1.1s ease-in-out infinite; }
@keyframes pl-nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
/* Height probe for the steady dialogue box (polish.js reserve): same text, same cue, never shown. */
.adv-dialogue__text.pl-measure::after, .cp-dialogue__text.pl-measure::after { content: none!important; }
.pl-measure-cue { display: inline-block; margin-left: .35em; font-size: .62em; vertical-align: .15em; }
.pl-is-ready .adv-dialogue__text::after, .pl-is-ready .cp-dialogue__text::after { content: '▼'; display: inline-block; margin-left: .35em; color: var(--pl-speaker, #2F7FB5); font-size: .62em; vertical-align: .15em; }
[data-motion="full"] .pl-is-ready .adv-dialogue__text::after, [data-motion="full"] .pl-is-ready .cp-dialogue__text::after { animation: pl-blink 1s steps(2, start) infinite; }
@keyframes pl-blink { to { visibility: hidden; } }
[data-motion="full"] .adv-person.pl-talk, [data-motion="full"] .cp-person.pl-talk { animation: pl-talk 460ms cubic-bezier(.3,.7,.3,1.2); }
@keyframes pl-talk { 0% { translate: 0 0; } 30% { translate: 0 -9px; } 55% { translate: 0 1px; } 100% { translate: 0 0; } }

/* ---------- sweep transition ---------- */
.pl-sweep { position: absolute; inset: 0; z-index: 40; overflow: hidden; pointer-events: none; }
.pl-sweep i { position: absolute; top: -10%; bottom: -10%; width: 62%; transform: skewX(-14deg); animation: pl-sweep 560ms cubic-bezier(.55,0,.25,1) both; }
.pl-sweep i:nth-child(1) { left: -22%; background: #fff6d6; animation-delay: 0ms; }
.pl-sweep i:nth-child(2) { left: 22%; background: #ffd84a; animation-delay: 40ms; }
.pl-sweep i:nth-child(3) { left: 66%; background: #5fc6ef; animation-delay: 80ms; }
.pl-sweep[data-tone="leaf"] i:nth-child(3) { background: #79c85b; }
.pl-sweep[data-tone="sun"] i:nth-child(3) { background: #f7a51d; }
.pl-sweep[data-tone="festival"] i:nth-child(2) { background: #ff9a91; }
.pl-sweep[data-tone="festival"] i:nth-child(3) { background: #ffd84a; }
.pl-sweep b { position: absolute; left: 50%; top: 50%; margin: -30px 0 0 -30px; width: 60px; height: 60px; display: grid; place-items: center; color: #173d59; font-size: 44px; line-height: 1; animation: pl-sweep-star 520ms ease-out both; }
@keyframes pl-sweep { 0% { transform: skewX(-14deg) translateX(0); } 100% { transform: skewX(-14deg) translateX(190%); } }
@keyframes pl-sweep-star { 0% { opacity: 1; transform: scale(1) rotate(0); } 100% { opacity: 0; transform: scale(2.2) rotate(120deg); } }

/* ---------- celebrations ---------- */
.pl-confetti { position: absolute; inset: 0; z-index: 30; width: 100%; height: 100%; pointer-events: none; }
.pl-pop { position: absolute; z-index: 8; transform: translate(-50%, -50%); padding: 3px 12px; border: 2px solid #173d59; border-radius: 99px; background: #fff; color: #173d59;
  font-size: 15px; line-height: 1.4; letter-spacing: .04em; white-space: nowrap; box-shadow: 0 3px 0 #173d59; pointer-events: none; animation: pl-pop 900ms cubic-bezier(.2,.8,.2,1) both; }
.pl-pop--combo { background: #ffd84a; font-size: 17px; }
@keyframes pl-pop { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.5); } 18% { opacity: 1; transform: translate(-50%, -70%) scale(1.12); } 70% { opacity: 1; transform: translate(-50%, -110%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -150%) scale(.95); } }
.pl-banner { position: absolute; z-index: 9; left: 0; right: 0; top: 38%; display: grid; place-items: center; gap: 2px; padding: 16px 10px; pointer-events: none; color: #173d59; text-align: center; animation: pl-banner 1400ms cubic-bezier(.2,.8,.2,1) both; }
.pl-banner__band { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #ffd84a00, #ffd84a 14%, #ffd84a 86%, #ffd84a00); border-block: 3px solid #173d59; transform: skewY(-3deg); }
.pl-banner strong { font-size: clamp(22px, 5vw, 34px); line-height: 1.3; letter-spacing: .06em; text-shadow: 0 2px 0 #fff; }
@keyframes pl-banner { 0% { opacity: 0; transform: scaleX(.2); } 14% { opacity: 1; transform: scaleX(1.04); } 22% { transform: scaleX(1); } 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(40px); } }

/* ---------- picture games: touch and drag ---------- */
.cg-food, .cg-slot, .cg-btn, .cg-help { -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.cg-pantry .cg-food:not(:disabled) { touch-action: none; cursor: grab; }
.cg-food.is-dragging { opacity: .45; transform: scale(.94); }
.cg-game.is-dragging .cg-slot:not(:disabled) { outline: 2px dashed #ffc927; outline-offset: 3px; }
.cg-slot.is-drop-target { transform: scale(1.06); box-shadow: 0 0 0 4px #ffd84a, 0 6px 0 #c68138; }
.cg-drag-ghost { position: fixed; left: 0; top: 0; z-index: 2147483000; width: 88px; height: 88px; pointer-events: none; filter: drop-shadow(0 10px 8px #173d5944); will-change: transform; }
.cg-drag-ghost img { width: 100%; height: 100%; object-fit: contain; }
.cg-customer[data-speaker="boy"] .pl-face { --pl-speaker: #2F7FB5; }
.cg-customer[data-speaker="girl"] .pl-face { --pl-speaker: #B85578; }
.cg-customer[data-speaker="teacher"] .pl-face { --pl-speaker: #398564; }
[data-motion="full"] .cg-game.is-complete .cg-complete__card { animation: pl-complete 520ms cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes pl-complete { 0% { opacity: 0; transform: translateY(16px) scale(.9); } 100% { opacity: 1; transform: none; } }

/* ---------- chapter clear: the medal with the original cast cheering beside it ---------- */
.cp-reward__hero { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 4px; max-width: 560px; margin: 4px auto 2px; }
.cp-trophy--medal { position: relative; isolation: isolate; width: 168px; height: 168px; margin: 18px 6px 4px; border: 0; background: none; box-shadow: none; font-size: 0; }
.cp-trophy__medal { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 7px 0 #173d5926) drop-shadow(0 14px 18px #173d5933); }
.cp-trophy__rays { position: absolute; z-index: 0; inset: -54px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, #fff3a3 0 9deg, #fff3a300 9deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 28%, #0000 70%); mask: radial-gradient(circle, #000 28%, #0000 70%); }
.cp-trophy__shine { position: absolute; z-index: 2; inset: 9%; border-radius: 50%; overflow: hidden; pointer-events: none; }
.cp-trophy__shine::after { content: ''; position: absolute; inset: -20%; background: linear-gradient(115deg, #fff0 38%, #ffffffcc 48%, #fff0 58%); transform: translateX(-120%); }
.cp-reward__cheer { flex: none; width: auto; height: 150px; object-fit: contain; filter: none; }
[data-motion="full"] .cp-trophy__rays { animation: pl-spin 22s linear infinite; }
[data-motion="full"] .cp-trophy__shine::after { animation: pl-shine 2.8s ease-in-out .9s infinite; }
[data-motion="full"] .cp-reward .cp-trophy--medal { animation: pl-medal-in 760ms cubic-bezier(.2,.9,.25,1.2) both; }
[data-motion="full"] .cp-reward__cheer--left { animation: pl-cheer-in 520ms cubic-bezier(.2,.9,.3,1.3) .25s both, pl-hop 2.4s ease-in-out 1.2s infinite; }
[data-motion="full"] .cp-reward__cheer--right { animation: pl-cheer-in 520ms cubic-bezier(.2,.9,.3,1.3) .38s both, pl-hop 2.4s ease-in-out 1.6s infinite; }
@keyframes pl-spin { to { transform: rotate(360deg); } }
@keyframes pl-shine { 0% { transform: translateX(-120%); } 45%, 100% { transform: translateX(120%); } }
@keyframes pl-medal-in { 0% { opacity: 0; transform: scale(.3) rotateY(160deg); } 70% { opacity: 1; transform: scale(1.08) rotateY(-8deg); } 100% { transform: none; } }
@keyframes pl-cheer-in { 0% { opacity: 0; transform: translateY(40px) scale(.7); } 100% { opacity: 1; transform: none; } }
@keyframes pl-hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-10px); } 90% { transform: translateY(0) scaleY(.97); } }
@media (max-width: 599px), (orientation: landscape) and (max-height: 499px) {
  .cp-trophy--medal { width: 108px; height: 108px; margin: 12px 2px 2px; }
  .cp-trophy__rays { inset: -36px; }
  .cp-reward__cheer { height: 100px; }
}
@media (max-height: 699px) and (orientation: portrait) {
  .cp-trophy--medal { width: 96px; height: 96px; margin-top: 8px; }
  .cp-reward__cheer { height: 88px; }
}

/* ---------- lighter on phones ---------- */
@media (max-width: 599px), (pointer: coarse) {
  /* Static sun rays (a rotating masked layer is costly on small GPUs); the medal shine stays. */
  [data-motion="full"] .cp-trophy__rays { animation: none; }
  .cg-drag-ghost { filter: none; }
  .pl-pop { box-shadow: none; }
}

/* ---------- reduced motion / paused ---------- */
[data-motion="reduced"] .pl-sweep, [data-motion="reduced"] .pl-confetti, [data-motion="reduced"] .pl-pop, [data-motion="reduced"] .pl-banner { display: none!important; }
[data-motion="reduced"] .cp-trophy--medal, [data-motion="reduced"] .cp-trophy__rays, [data-motion="reduced"] .cp-trophy__shine::after, [data-motion="reduced"] .cp-reward__cheer,
[data-motion="reduced"] .pl-face, [data-motion="reduced"] .pl-ch, [data-motion="reduced"] .cp-next__arrow, [data-motion="reduced"] .adv-next__arrow { animation: none!important; }
@media (prefers-reduced-motion: reduce) {
  .pl-sweep, .pl-confetti, .pl-pop, .pl-banner { display: none!important; }
  .pl-face, .pl-ch, .cp-next__arrow, .adv-next__arrow, .adv-dialogue__text::after, .cp-dialogue__text::after { animation: none!important; }
}
html.quality-paused .pl-sweep *, html.quality-paused .pl-banner, html.quality-paused .pl-pop { animation-play-state: paused!important; }
