/* Real object sprites share stable, keyboard-accessible casting areas. */
.memorial-page .ritual-tools { max-width: 860px; gap: 24px; }
.ritual-tool[open] { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.ritual-tool[open] summary { border-bottom: 1px solid var(--line); }
.ritual-game { display: grid; grid-template-rows: 48px 210px 32px minmax(32px, auto); padding: 18px 20px 16px; text-align: center; }
.ritual-instruction { min-height: 24px; margin: 0; color: var(--muted); font: 13px/1.8 var(--sans); }
.ritual-stage { display: block; position: relative; width: 100%; height: 210px; margin: 0; padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ritual-stage:disabled { cursor: wait; }
.ritual-stage:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.ritual-cast-label { position: absolute; bottom: 8px; left: 0; width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; font: 500 13px/1.5 var(--sans); }
.ritual-cast-label i { font-size: 11px; }
.is-casting .ritual-cast-label { opacity: .45; }
.moon-pieces { position: absolute; inset: 40px 0 44px; display: flex; justify-content: center; align-items: center; gap: 22px; perspective: 650px; }
.moon-piece { --landing-angle: -14deg; --flight-x: -18px; --spin: 360deg; position: relative; display: block; width: min(39%, 132px); aspect-ratio: 1.76; transform: rotate(var(--landing-angle)); transform-style: preserve-3d; }
.moon-piece:nth-child(2) { --landing-angle: 14deg; --flight-x: 18px; --spin: -360deg; }
.moon-model { position: absolute; inset: 0; display: block; transform: rotateX(var(--face-angle)); transform-style: preserve-3d; }
.moon-face { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; backface-visibility: hidden; -webkit-backface-visibility: hidden; filter: drop-shadow(0 9px 5px #39291b30); user-select: none; pointer-events: none; }
.moon-face-convex { transform: rotateX(180deg); }
.moon-face-labels { display: flex; justify-content: center; gap: 22px; margin: 0 0 12px; }
.moon-face-labels span { width: min(39%, 132px); color: var(--muted); font: 12px/1.7 var(--sans); }
.is-casting .moon-face-labels { visibility: hidden; }
.ritual-result { min-height: 32px; margin: 0; color: var(--muted); font: 500 14px/2 var(--sans); letter-spacing: .03em; }
.has-result .ritual-result { color: var(--ink); }
.dice-model { position: absolute; top: 25px; left: calc(50% - 65px); display: block; width: 130px; height: 150px; transform-style: preserve-3d; filter: drop-shadow(0 8px 6px #30281b35); }
.dice-model img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; pointer-events: none; }
.dice-value { position: absolute; top: 43%; left: 0; width: 100%; color: #fff6d9; font: 700 29px/1 Georgia, serif; text-shadow: 0 1px 2px #172517; font-variant-numeric: tabular-nums; }
.ritual-range { margin: 0 0 12px; color: var(--muted); font: 12px/1.7 var(--sans); }
.is-casting .moon-piece { animation: memorial-moon-flight 1.68s both; }
.is-casting .moon-piece:nth-child(2) { animation-delay: .06s; animation-duration: 1.62s; }
.is-casting .moon-model { animation: memorial-moon-flip 1.15s .08s both; }
.is-casting .dice-model { animation: memorial-dice-roll 1.6s both; }
.has-result .ritual-result { animation: memorial-result-in .22s ease-out both; }
@keyframes memorial-moon-flight {
    0% { transform: translate(0, 0) rotate(var(--landing-angle)); }
    9% { transform: translate(0, 6px) rotate(var(--landing-angle)); animation-timing-function: cubic-bezier(.15,.6,.4,1); }
    34% { transform: translate(var(--flight-x), -48px) rotate(calc(var(--spin) * .45)); animation-timing-function: cubic-bezier(.6,0,.85,.5); }
    59% { transform: translate(calc(var(--flight-x) * .5), 6px) rotate(calc(var(--spin) * .9)); animation-timing-function: ease-out; }
    73% { transform: translate(calc(var(--flight-x) * .25), -15px) rotate(calc(var(--spin) + var(--landing-angle) + 10deg)); animation-timing-function: ease-in; }
    84% { transform: translate(0, 2px) rotate(calc(var(--spin) + var(--landing-angle) - 5deg)); }
    92% { transform: translate(0, -3px) rotate(calc(var(--spin) + var(--landing-angle) + 3deg)); }
    100% { transform: translate(0, 0) rotate(calc(var(--spin) + var(--landing-angle))); }
}
@keyframes memorial-moon-flip {
    0% { transform: rotateX(var(--from-face)); }
    100% { transform: rotateX(var(--to-face)); }
}
@keyframes memorial-dice-roll {
    0% { transform: translate(0,0) rotate(0); }
    8% { transform: translate(-4px,5px) rotate(-12deg); animation-timing-function: cubic-bezier(.15,.6,.4,1); }
    30% { transform: translate(18px,-35px) rotate(170deg) rotateY(42deg) rotateX(-18deg); animation-timing-function: cubic-bezier(.6,0,.85,.5); }
    52% { transform: translate(-13px,6px) rotate(345deg) rotateY(-24deg); animation-timing-function: ease-out; }
    67% { transform: translate(7px,-16px) rotate(550deg) rotateY(32deg); animation-timing-function: ease-in; }
    79% { transform: translate(-3px,2px) rotate(690deg) rotateY(-12deg); }
    89% { transform: translate(0,-4px) rotate(731deg); }
    96% { transform: translate(0,0) rotate(716deg); }
    100% { transform: translate(0,0) rotate(720deg); }
}
@keyframes memorial-result-in { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .ritual-stage:not(:disabled):hover .ritual-cast-label { text-decoration: underline; text-underline-offset: 5px; }
}
@media (max-width: 560px) {
    .memorial-page .ritual-tools { gap: 16px; }
    .ritual-game { padding: 16px 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .ritual-game *, .ritual-game *::before, .ritual-game *::after { animation: none !important; transition: none !important; }
}

.memorial-page .ritual-tools:has(.fortune-game) { max-width: 1120px; }
.fortune-draw { display: flex; flex-direction: column; align-items: center; justify-content: center; grid-row: 1 / 4; gap: 6px; width: 100%; margin: 0; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--accent); cursor: pointer; }
.fortune-draw:disabled { cursor: wait; }
.fortune-source, .fortune-canvas { display: block; flex: 0 0 auto; width: min(100%, 260px); height: auto; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 3px; object-fit: contain; }
.fortune-button-label { display: flex; align-items: center; justify-content: center; min-height: 24px; font: 500 13px/1.5 var(--sans); }
.fortune-draw:hover:not(:disabled) .fortune-button-label { text-decoration: underline; text-underline-offset: 4px; }
.fortune-game.has-result .fortune-canvas { border-color: var(--accent); }
.fortune-game .ritual-result { grid-row: 4; font-size: 15px; }
@media (max-width: 800px) {
    .memorial-page .ritual-tools:has(.fortune-game) { flex-direction: column; max-width: 560px; }
    .ritual-tools:has(.fortune-game) .ritual-tool { width: 100%; }
}

/* Japanese garapon: the drum turns around its axle; the ball drops into the tray. */
.lucky-wheel-game { grid-template-rows: auto 260px auto minmax(42px,auto); gap: 10px; }
.lucky-wheel-draw { height: 260px; }
.lucky-wheel-art { display:block; width:min(100%,300px); height:230px; margin:0 auto; overflow:visible; filter:drop-shadow(0 6px 5px #30241f20); }
.lucky-drum,.lucky-handle { transform-origin:149px 107px; }
.lucky-ball,.lucky-ball-glint { opacity:0; }
.lucky-ball-shadow { visibility:hidden; }
.has-result .lucky-ball-shadow { visibility:visible; }
.has-result .lucky-ball,.has-result .lucky-ball-glint { opacity:1; }
.is-drawing .lucky-drum { animation:lucky-wheel-turn 2.1s cubic-bezier(.35,.05,.2,1) both; }
.is-drawing .lucky-handle { animation:lucky-wheel-turn 2.1s cubic-bezier(.35,.05,.2,1) both; }
.is-drawing .lucky-ball,.is-drawing .lucky-ball-glint { animation:lucky-ball-drop .65s 1.9s both; }
.is-drawing .ritual-cast-label { opacity:.45; }
@keyframes lucky-wheel-turn { 0%{transform:rotate(0)} 12%{transform:rotate(-20deg)} 100%{transform:rotate(1080deg)} }
@keyframes lucky-ball-drop { 0%{opacity:0;transform:translate(-22px,-46px)} 10%{opacity:1} 45%{transform:translate(-13px,0)} 65%{transform:translate(-7px,-13px)} 82%{transform:translate(-3px,0)} 92%{transform:translate(-1px,-3px)} 100%{opacity:1;transform:translate(0,0)} }
@media(prefers-reduced-motion:reduce) { .is-drawing .lucky-drum,.is-drawing .lucky-handle,.is-drawing .lucky-ball,.is-drawing .lucky-ball-glint { animation:none; } }
