/* ===== La commande de Liang (js/liang.js, liangShow dans game.js) =====
   Couches : ciel et soleil, lanternes (canvas), Liang (canvas), rouleau et carte, rouleau volant, étincelles (canvas), bulle, cri,
   bouton « Passer ». Carte crème unie, arrondie, sans contour. */
dialog#liang-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: none; color: #3a2412; overflow: hidden; cursor: default; }
dialog#liang-dialog::backdrop { background: rgba(14, 3, 4, .6); }
#liang-dialog.lg-load > :not(.lg-sky) { visibility: hidden; }
#liang-dialog canvas { position: fixed; left: 0; top: 0; pointer-events: none; }
.lg-sky { position: fixed; inset: 0; opacity: 0; pointer-events: none;
  background:
    radial-gradient(circle at var(--sun-x, 80%) var(--sun-y, 45%), #ffdf8e 0, #ff9a3e calc(var(--sun-r, 300px) * .5), #e0412a calc(var(--sun-r, 300px) * .74), rgba(214, 48, 34, .5) calc(var(--sun-r, 300px) * .76), transparent calc(var(--sun-r, 300px) * 1.5)),
    radial-gradient(ellipse 80% 46% at 50% 112%, rgba(255, 150, 60, .5), transparent 72%),
    linear-gradient(180deg, #24070f 0%, #551119 48%, #8c2a1a 100%); }
.lg-sky::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 55% 45%, transparent 52%, rgba(10, 0, 4, .6) 100%); }
#liang-dialog .lg-back { z-index: 1; }
#liang-dialog .lg-liang { z-index: 2; opacity: 0; will-change: transform; filter: drop-shadow(0 0 22px rgba(60, 4, 6, .75)); }
#liang-dialog .lg-front { z-index: 7; }

.lg-stage { position: fixed; z-index: 3; left: 0; top: 0; bottom: 0; width: var(--stage-w, 60vw); box-sizing: border-box; padding: 24px 28px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 22px; pointer-events: none; }
.lg-plan { position: relative; z-index: 0; width: min(820px, 100% - 24px); flex: none; visibility: hidden; }
.lg-plan.on { visibility: visible; }
.lg-rays { position: absolute; left: 50%; top: 50%; width: 900px; height: 900px; margin: -450px 0 0 -450px; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 205, 110, .34) 0deg 7deg, transparent 7deg 20deg);
  -webkit-mask: radial-gradient(closest-side, #000 18%, transparent 100%); mask: radial-gradient(closest-side, #000 18%, transparent 100%);
  animation: lgSpin 26s linear infinite; }
@keyframes lgSpin { to { transform: rotate(360deg); } }
.lg-sheet { position: relative; z-index: 1; box-sizing: border-box; padding: 16px 22px 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px;
  background: linear-gradient(#a3201c, #a3201c) top / 100% 7px no-repeat, linear-gradient(#a3201c, #a3201c) bottom / 100% 7px no-repeat,
    radial-gradient(ellipse at 50% 45%, #fdf3d8, #ebd2a0 100%);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .55), inset 0 0 34px rgba(150, 90, 40, .3); }
.lg-cell { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.lg-cell img { width: 100%; height: clamp(62px, 14.5vh, 180px); object-fit: contain; }
.lg-cell b { margin-top: 4px; font: normal 16px/1.15 var(--font-title); color: #4a1512; opacity: 0; transition: opacity .25s; }
.lg-cell small { font-size: 14px; line-height: 1.2; color: #6b4a2c; opacity: 0; transition: opacity .25s; }
.lg-cell.on b, .lg-cell.on small { opacity: 1; }
.lg-rod { position: absolute; z-index: 2; top: -9px; bottom: -9px; width: 18px; border-radius: 9px;
  background: linear-gradient(#c9992f, #c9992f) top / 100% 9px no-repeat, linear-gradient(#c9992f, #c9992f) bottom / 100% 9px no-repeat, linear-gradient(90deg, #4d0f10, #b2302a 40%, #8a1c1a 66%, #420b0c);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .45); }
.lg-rod-l { left: -9px; } .lg-rod-r { right: -9px; }
.lg-seal { position: absolute; z-index: 3; right: -20px; bottom: -22px; width: 72px; height: 72px; opacity: 0; transform: rotate(10deg) scale(2.6);
  transition: opacity .15s, transform .35s cubic-bezier(.2, 1.4, .4, 1); filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .5)); }
.lg-seal.on { opacity: 1; transform: rotate(10deg) scale(1); }

.lg-card { position: relative; z-index: 1; width: min(620px, 100%); flex: none; box-sizing: border-box; padding: 16px 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); }
.lg-card.on { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.lg-card h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font: normal 25px/1.15 var(--font-title); color: #8c1d1a; }
.lg-face { width: 50px; height: 50px; object-fit: contain; flex: none; }
.lg-body p { margin: 0 0 6px; }
.lg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.lg-roll { position: fixed; z-index: 5; left: 0; top: 0; width: 30px; border-radius: 15px; opacity: 0; pointer-events: none; will-change: transform;
  background: linear-gradient(#d8a838, #d8a838) center / 100% 12px no-repeat, linear-gradient(90deg, #4d0f10, #b2302a 40%, #8a1c1a 66%, #420b0c);
  box-shadow: 0 10px 18px rgba(0, 0, 0, .5), 0 0 24px rgba(255, 200, 110, .6); }
.lg-bubble { position: fixed; z-index: 8; left: -999px; top: 0; width: min(400px, 32vw); box-sizing: border-box; padding: 16px 22px; border-radius: 18px;
  background: #fdf3d6; color: #3a1412; font: normal 23px/1.3 var(--font-title); pointer-events: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .5), inset 0 -3px 0 rgba(150, 70, 50, .3);
  opacity: 0; transform: scale(.5); transform-origin: 100% var(--ty, 50%); transition: opacity .18s, transform .32s cubic-bezier(.2, .9, .3, 1.5); }
.lg-bubble.on { opacity: 1; transform: none; }
.lg-bubble::after { content: ""; position: absolute; right: -13px; top: var(--ty, 50%); margin-top: -10px; border: 10px solid transparent; border-right: 0; border-left: 14px solid #fdf3d6; }
.lg-hidden { color: transparent; }
.lg-cry { position: fixed; z-index: 9; left: 50%; top: 44%; white-space: nowrap; pointer-events: none; opacity: 0; will-change: transform;
  font: normal clamp(64px, 9vw, 168px)/1 var(--font-title); text-transform: uppercase; color: #ffd25e; paint-order: stroke fill;
  -webkit-text-stroke: 14px #7c1014; text-shadow: 0 8px 0 #3c0508, 0 0 46px rgba(255, 120, 40, .9); }
.lg-skip { position: fixed; z-index: 10; right: 24px; top: 20px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.lg-skip[hidden] { display: none; }

/* Sans animation (fenêtre étroite, images absentes) : le rouleau et la carte seuls, au centre */
#liang-dialog.lg-still canvas, #liang-dialog.lg-still .lg-roll, #liang-dialog.lg-still .lg-bubble, #liang-dialog.lg-still .lg-cry { display: none; }
#liang-dialog.lg-still .lg-sky { opacity: 1; }
#liang-dialog.lg-still .lg-stage { width: 100%; padding: 24px 28px; overflow-y: auto; pointer-events: auto; }
#liang-dialog.lg-still .lg-rays { display: none; }
#liang-dialog.lg-still .lg-card, #liang-dialog.lg-still .lg-seal { transition: none; }
@media (max-height: 760px) {
  .lg-stage { gap: 24px; padding: 14px 28px 12px; }
  .lg-sheet { padding: 13px 22px 11px; gap: 5px 12px; }
  .lg-cell img { height: clamp(54px, 11.5vh, 88px); }
  .lg-card { padding: 12px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  #liang-dialog .lg-bubble, #liang-dialog .lg-card, #liang-dialog .lg-seal { transition: none !important; }
  #liang-dialog .lg-rays { animation: none; }
}
html.dark-win #liang-dialog .lg-card { background: var(--dw-bg); color: var(--dw-ink); color-scheme: dark; }
html.dark-win #liang-dialog .lg-card h2 { color: #f0a08c; }
html.dark-win #liang-dialog .lg-bubble { background: var(--dw-bg); color: var(--dw-ink); }
html.dark-win #liang-dialog .lg-bubble::after { border-left-color: var(--dw-bg); }
