/* ===== Les plans de Kokuro (js/kokuro.js, kokuroShow dans game.js) =====
   Couches : décor (ciel, lune, démon, torii, brume, lanternes, cerisiers), image à l'encre, Kokuro (WebGL), pétales (canvas),
   rouleau et carte, bulle, éclair, bouton « Passer ». Carte crème unie, arrondie, sans contour. */
dialog#kokuro-dialog { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; box-sizing: border-box;
  border: 0; background: #05071a; color: #3a2412; overflow: hidden; cursor: default; }
dialog#kokuro-dialog::backdrop { background: rgba(4, 5, 18, .8); }
#kokuro-dialog.kk-load > * { visibility: hidden; }
#kokuro-dialog canvas { pointer-events: none; }
.kk-scene { position: absolute; inset: 0; opacity: 0; overflow: hidden; }
.kk-world { position: absolute; inset: 0; will-change: transform; }
.kk-sky, .kk-far, .kk-fx, .kk-kok, .kk-ink { position: absolute; left: 0; top: 0; }
.kk-oni { position: absolute; -webkit-mask: radial-gradient(closest-side, #000 84%, transparent 100%); mask: radial-gradient(closest-side, #000 84%, transparent 100%); will-change: transform; transform-origin: 50% 70%; }
.kk-moon { position: absolute; will-change: transform; }
.kk-moon i { position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 34%, rgba(150, 130, 130, .26) 0 5%, transparent 13%), radial-gradient(circle at 62% 26%, rgba(150, 130, 130, .2) 0 3%, transparent 9%), radial-gradient(circle at 66% 62%, rgba(150, 130, 130, .22) 0 8%, transparent 19%), radial-gradient(circle at 36% 70%, rgba(150, 130, 130, .16) 0 3%, transparent 12%),
    radial-gradient(circle at 42% 40%, #fffdf2, #ffefc4 62%, #f3cf95 100%);
  box-shadow: 0 0 60px rgba(255, 236, 190, .75), 0 0 170px 40px rgba(255, 215, 170, .32); }
.kk-moon .kk-moon-red { opacity: 0;
  background: radial-gradient(circle at 30% 34%, rgba(70, 0, 8, .4) 0 5%, transparent 13%), radial-gradient(circle at 62% 26%, rgba(70, 0, 8, .3) 0 3%, transparent 9%), radial-gradient(circle at 66% 62%, rgba(70, 0, 8, .34) 0 8%, transparent 19%), radial-gradient(circle at 36% 70%, rgba(70, 0, 8, .26) 0 3%, transparent 12%),
    radial-gradient(circle at 42% 40%, #ff7a5c, #e02f26 55%, #9c1018 100%);
  box-shadow: 0 0 60px rgba(255, 60, 40, .8), 0 0 190px 60px rgba(210, 20, 30, .42); }
.kk-night { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: radial-gradient(ellipse at 40% 45%, rgba(70, 4, 24, .25) 0, rgba(5, 2, 20, .95) 85%); }
.kk-night2 { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: radial-gradient(ellipse 60% 75% at 42% 50%, transparent 35%, rgba(8, 2, 26, .95) 100%); }
.kk-mist { position: absolute; left: 0; right: 0; background-repeat: repeat-x; background-size: 900px 100%; opacity: 0; pointer-events: none; }
.kk-tree { position: absolute; will-change: transform; }
.kk-tree-l { transform-origin: 0 100%; }
.kk-tree-r { transform-origin: 100% 0; }
.kk-lamp { position: absolute; width: 60px; height: 96px; transform-origin: 50% 0; will-change: transform; }
.kk-lamp canvas { position: absolute; left: 0; top: 0; }
.kk-lamp i { position: absolute; left: -70px; top: -54px; width: 200px; height: 200px; border-radius: 50%; pointer-events: none; background: radial-gradient(closest-side, rgba(255, 170, 80, .75), transparent); }
.kk-lamp i + i { background: radial-gradient(closest-side, rgba(70, 150, 255, .85), transparent); opacity: 0; }
.kk-kshade { position: absolute; right: 0; bottom: 0; width: 52vw; height: 100%; opacity: 0; pointer-events: none; background: radial-gradient(ellipse 70% 78% at 70% 78%, rgba(4, 4, 24, .8), transparent 72%); }
.kk-portrait .kk-kshade { width: 100%; }
.kk-inkbox { position: absolute; inset: 0; visibility: hidden; overflow: hidden; z-index: 2; }
.kk-stroke { position: absolute; transform-origin: 50% 50%; }
.kk-kok { z-index: 3; opacity: 0; will-change: transform; transform-origin: 50% 0; }
.kk-fx { z-index: 4; }

.kk-stage { position: absolute; z-index: 5; left: 0; top: 0; bottom: 0; width: var(--kk-stage, 62vw); box-sizing: border-box; padding: 24px 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 24px; pointer-events: none; }
.kk-plan { position: relative; width: min(var(--plan-w, clamp(520px, 41vw, 820px)), 100% - 32px); flex: none; opacity: 0; will-change: opacity; }
.kk-plan[data-n="3"] { --plan-w: clamp(600px, 45vw, 940px); }
.kk-plan[data-n="4"], .kk-plan[data-n="5"], .kk-plan[data-n="6"], .kk-plan[data-n="7"] { --plan-w: clamp(660px, 50vw, 1040px); }
.kk-plan::before { content: ""; position: absolute; inset: 0; opacity: 0; box-shadow: 0 18px 34px rgba(0, 0, 0, .65); transition: opacity .4s .5s; }
.kk-plan.on::before { opacity: 1; }
.kk-sheet { position: relative; will-change: clip-path; box-sizing: border-box; padding: 34px 34px 30px; display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px 18px;
  background:
    repeating-linear-gradient(90deg, #d9a441 0 2px, transparent 2px 14px) top / 100% 16px no-repeat, repeating-linear-gradient(90deg, #d9a441 0 2px, transparent 2px 14px) bottom / 100% 16px no-repeat,
    linear-gradient(#3a1a4c, #24103a) top / 100% 16px no-repeat, linear-gradient(#24103a, #3a1a4c) bottom / 100% 16px no-repeat,
    radial-gradient(circle at 88% 12%, rgba(236, 130, 165, .28), transparent 34%), radial-gradient(circle at 8% 92%, rgba(236, 130, 165, .24), transparent 38%),
    linear-gradient(100deg, #f1e4c6, #fbf4e2 45%, #efe0bd); }
/* 7 plans : 4 au-dessus (oni), 3 centrés au-dessous (cerisier) */
.kk-plan[data-n="7"] .kk-sheet { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.kk-plan[data-n="7"] .kk-cell { grid-column: span 2; }
.kk-plan[data-n="7"] .kk-cell:nth-child(5) { grid-column: 2 / span 2; }
.kk-cell { min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.kk-pic { position: relative; width: 100%; height: clamp(120px, 28vh, 330px); display: flex; align-items: center; justify-content: center; }
.kk-plan[data-n="5"] .kk-pic, .kk-plan[data-n="6"] .kk-pic, .kk-plan[data-n="7"] .kk-pic { height: clamp(84px, 16vh, 170px); }
.kk-pic canvas { position: absolute; left: 50%; top: 50%; height: 100%; width: auto; aspect-ratio: 1; transform: translate(-50%, -50%); }
.kk-pic img { position: relative; width: 88%; height: 88%; object-fit: contain; opacity: 0; filter: drop-shadow(0 5px 6px rgba(60, 20, 30, .4)); }
.kk-cell b { margin-top: 8px; font: normal 20px/1.15 var(--font-title); color: #4a1024; opacity: 0; transition: opacity .3s; }
.kk-cell small { margin-top: 2px; font-size: 16px; line-height: 1.25; color: #6b4a2c; opacity: 0; transition: opacity .3s; }
.kk-cell.on b, .kk-cell.on small { opacity: 1; }
.kk-rod { position: absolute; z-index: 2; top: -12px; bottom: -12px; width: 22px; border-radius: 9px;
  background: linear-gradient(#e0b04a, #8a5a1c) top / 100% 14px no-repeat, linear-gradient(#8a5a1c, #e0b04a) bottom / 100% 14px no-repeat, linear-gradient(90deg, #160a0c, #5e2a22 38%, #7d3c2c 50%, #2a1010); }
.kk-rod-l { left: -11px; } .kk-rod-r { right: -11px; }
.kk-seal { position: absolute; z-index: 3; right: 20px; bottom: -26px; opacity: 0; transform: rotate(6deg) scale(2.4); transition: opacity .12s, transform .3s cubic-bezier(.2, 1.4, .4, 1); }
.kk-seal.on { opacity: 1; transform: rotate(6deg) scale(1); }
.kk-card { width: min(620px, 100%); flex: none; box-sizing: border-box; padding: 18px 24px; border-radius: 20px; background: #fbf0d8; box-shadow: 0 18px 40px rgba(0, 0, 0, .6); font-size: 16px; line-height: 1.4;
  opacity: 0; visibility: hidden; transform: translateY(18px); transition: opacity .35s, transform .45s cubic-bezier(.2, .9, .3, 1.2); }
.kk-card.on { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.kk-card h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font: normal 25px/1.15 var(--font-title); color: #8c1d3a; }
.kk-face { height: 52px; width: auto; object-fit: contain; flex: none; }
.kk-body p { margin: 0 0 6px; }
.kk-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.kk-bubble { position: absolute; z-index: 6; left: -999px; top: 0; width: max-content; max-width: min(400px, 34vw); box-sizing: border-box; padding: 16px 22px; border-radius: 18px; background: #fdf3e6; color: #2a1020; font: normal 23px/1.3 var(--font-title); pointer-events: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .55), inset 0 -3px 0 rgba(150, 60, 100, .28); opacity: 0; transform: scale(.5); transform-origin: 100% 50%; transition: opacity .18s, transform .32s cubic-bezier(.2, .9, .3, 1.5); }
.kk-bubble.on { opacity: 1; transform: none; }
.kk-bubble::after { content: ""; position: absolute; right: -13px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right: 0; border-left: 14px solid #fdf3e6; }
.kk-portrait .kk-bubble { max-width: calc(100vw - 24px); font-size: 20px; transform-origin: 50% 100%; }
.kk-portrait .kk-bubble::after { right: auto; left: var(--tx, 50%); top: -13px; margin: 0 0 0 -10px; border: 10px solid transparent; border-top: 0; border-bottom: 14px solid #fdf3e6; }
.kk-portrait .kk-seal { right: -8px; bottom: -34px; zoom: .75; }
.kk-hidden { color: transparent; }
.kk-flash { position: absolute; inset: 0; z-index: 7; background: #fff; opacity: 0; pointer-events: none; }
.kk-skip { position: absolute; z-index: 8; right: 24px; top: 20px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.kk-skip[hidden] { display: none; }

/* Téléphone et fenêtres hautes : Kokuro en buste en haut, rouleau et carte en bas */
.kk-portrait .kk-stage { width: 100%; justify-content: safe flex-end; padding: 16px 16px 18px; gap: 22px; }
.kk-portrait .kk-sheet { padding: 28px 22px 24px; gap: 8px 10px; }
.kk-portrait .kk-pic { height: clamp(84px, 17vh, 190px); }
.kk-portrait .kk-cell b { font-size: 17px; }
.kk-portrait .kk-plan[data-n="7"] .kk-sheet { padding: 26px 16px 22px; gap: 8px 4px; }
.kk-portrait .kk-plan[data-n="7"] .kk-cell b { font-size: 16px; line-height: 1.05; }
.kk-portrait .kk-skip { right: 12px; top: 12px; }
.kk-portrait .kk-card { padding: 14px 16px; }
.kk-portrait .kk-card h2 { font-size: 22px; }
.kk-portrait .kk-face { display: none; }
.kk-portrait .kk-foot .btn { flex: 1 1 auto; }
.kk-portrait .kk-plan[data-n="4"] .kk-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kk-portrait .kk-plan[data-n="4"] .kk-pic, .kk-portrait .kk-plan[data-n="5"] .kk-pic, .kk-portrait .kk-plan[data-n="6"] .kk-pic, .kk-portrait .kk-plan[data-n="7"] .kk-pic { height: clamp(56px, 9.5vh, 120px); }
#kokuro-dialog.kk-done .kk-stage { overflow-y: auto; pointer-events: auto; }

/* Sans animation (WebGL ou images absents) : le rouleau et la carte seuls */
#kokuro-dialog.kk-still { background: radial-gradient(circle at 50% 20%, #3b3f7d, #14204f 45%, #060a24); }
#kokuro-dialog.kk-still > :not(.kk-stage) { display: none; }
#kokuro-dialog.kk-still .kk-stage { width: 100%; justify-content: safe center; }
#kokuro-dialog.kk-still .kk-plan, #kokuro-dialog.kk-still .kk-pic img { opacity: 1; }
@media (max-height: 860px) {
  .kk-stage { gap: 20px; padding-top: 14px; padding-bottom: 14px; }
  .kk-plan[data-n="7"] .kk-sheet { padding: 24px 26px 22px; gap: 4px 12px; }
  .kk-plan[data-n="7"] .kk-cell b { margin-top: 4px; font-size: 17px; line-height: 1.08; }
  .kk-plan[data-n="7"] .kk-pic { height: 14vh; }
  .kk-plan[data-n="7"] ~ .kk-card { padding: 12px 20px; }
  .kk-plan[data-n="7"] ~ .kk-card .kk-face { height: 40px; }
  .kk-plan[data-n="7"] ~ .kk-card h2, .kk-plan[data-n="7"] ~ .kk-card p { margin-bottom: 4px; }
  .kk-portrait .kk-plan[data-n="7"] .kk-pic { height: 9.5vh; }
}
@media (max-height: 760px) {
  .kk-stage { gap: 22px; padding: 14px 28px; }
  .kk-sheet { padding: 28px 30px 24px; }
  .kk-card { padding: 13px 20px; }
}
@media (prefers-reduced-motion: reduce) { #kokuro-dialog .kk-bubble, #kokuro-dialog .kk-card, #kokuro-dialog .kk-seal, #kokuro-dialog .kk-cell b, #kokuro-dialog .kk-cell small { transition: none !important; } }
html.dark-win #kokuro-dialog .kk-card { background: var(--dw-bg); color: var(--dw-ink); color-scheme: dark; }
html.dark-win #kokuro-dialog .kk-card h2 { color: #f0a0bc; }
html.dark-win #kokuro-dialog .kk-bubble { background: var(--dw-bg); color: var(--dw-ink); }
html.dark-win #kokuro-dialog .kk-bubble::after { border-left-color: var(--dw-bg); }
html.dark-win .kk-portrait .kk-bubble::after { border-left-color: transparent; border-bottom-color: var(--dw-bg); }
