/* Memory quiz, theme-specific chests, and approved story-coin reward flow. */
.memory-sheet{position:relative;padding:20px 16px 24px;border:1px solid #ead9ae65;border-radius:24px;background:linear-gradient(145deg,#172435e8,#111c2aeF);box-shadow:0 16px 38px #06101c88;backdrop-filter:blur(6px)}
.memory-top{display:flex;justify-content:space-between;align-items:center;color:#f0dcae;font-size:12px;letter-spacing:.12em;margin-bottom:17px}
.memory-top .coin-total{display:flex;align-items:center;gap:5px;color:#ffe6a1;font-weight:800;letter-spacing:0}
.memory-top .coin-icon{width:24px;height:24px}
.memory-sheet>h1{font:25px/1.25 var(--serif);color:#fff2d1;margin:0 0 7px}
.memory-intro{font-size:11px;line-height:1.7;color:#d5c9ae;margin:0 0 16px}
#memoryQuestions{display:grid;gap:11px}
.memory-question{padding:13px 12px;border:1px solid #ead8aa44;border-radius:15px;background:#f5ecd8;color:#344233;animation:memory-card-in .35s ease both;animation-delay:var(--answer-delay,0ms)}
.memory-question h3{font:600 13px/1.5 var(--serif);color:#364a37;margin:0 0 8px}
.memory-options{display:grid;gap:6px}
.memory-option{width:100%;padding:9px 10px;border:1px solid #bdb495;border-radius:10px;background:#fffaf0;color:#465143;text-align:left;font-size:12px;line-height:1.45}
.memory-option.chosen{border-color:#779365;background:#edf2e4;box-shadow:0 0 0 2px #7b986b25}
.memory-option.correct-answer{border-color:#63834e;background:#e5efd9;color:#365535}
.memory-option.wrong-answer{border-color:#b87661;background:#f7e6db;color:#734638}
.memory-explanation{margin:9px 1px 0;color:#596a53;font-size:11px;line-height:1.55}
.memory-actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.65fr) minmax(0,1fr);gap:9px;margin-top:14px}
.memory-actions button{min-height:43px;border:1px solid #f4d48e;border-radius:14px;background:linear-gradient(140deg,#f4d995,#e7b968);color:#28372c;font-weight:700;font-size:12px}
.memory-actions button:last-child{background:#152131;color:#f2e3c1;border-color:#e8d3a377}
.memory-actions #memoryHint{padding:7px 5px;font-size:clamp(9px,2.6vw,12px);line-height:1.3}
.memory-actions #memoryHint:disabled{filter:grayscale(1);opacity:.48;cursor:default}
.memory-extra-actions{display:grid;gap:8px;margin-top:8px}
.memory-extra-actions button{min-height:35px;padding:7px 10px;border:1px solid #e8d3a377;border-radius:10px;background:#152131;color:#f2e3c1;font-size:11px}
.memory-extra-actions [hidden]{display:none!important}
.memory-question.hint-locked .memory-option{opacity:.62;cursor:default}
.memory-question.hint-locked .memory-option.hint-correct{opacity:1;border:3px solid #f2c846;background:#fff2b9;color:#49370a;box-shadow:0 0 0 2px #f2c84655,inset 0 0 0 1px #fff9d7;font-weight:800}
#memoryResult{min-height:1px;margin:9px 2px;color:#f6e8c7;font-size:11px;line-height:1.5}
#memoryResult[data-state="success"]{color:#f8dfa0}
#memoryResult[data-state="incomplete"]{color:#ffd2a6}
.memory-modal-backdrop{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;padding:14px;background:#080d15c9;backdrop-filter:blur(5px)}
.memory-modal-backdrop[hidden],.memory-reward-splash[hidden]{display:none!important}
.memory-modal{position:relative;width:min(100%,430px);max-height:calc(100dvh - 28px);overflow:auto;padding:24px 18px 18px;border:1px solid #e2c982;border-radius:23px;background:linear-gradient(145deg,#fff6df,#f0e3c4);color:#344235;text-align:center;box-shadow:0 24px 85px #03070ca8;animation:memory-card-in .28s cubic-bezier(.2,.8,.2,1)}
.memory-modal h2{margin:0 28px 5px;color:#364736;font:600 23px/1.25 var(--serif)}
.memory-modal>p{margin:0 0 13px;color:#69725e;font-size:12px;line-height:1.55}
.treasure-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:16px 0 2px}
.treasure-chest{position:relative;min-width:0;min-height:158px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 3px 8px;overflow:hidden;border:1px solid #aa9158;border-radius:15px;background:linear-gradient(160deg,#fff9e8,#eadbb7);color:#5b4b2d;touch-action:manipulation;transition:transform .2s,box-shadow .2s}
.treasure-chest:enabled:active{transform:scale(.97)}
.treasure-chest:disabled{cursor:default;opacity:.8}
.chest-prompt{font-size:10px;font-weight:700;color:#87662e}
.chest-art{position:relative;display:block;flex:none;width:86px;height:76px;filter:drop-shadow(0 4px 4px #342b1d4d)}
.chest-base{position:absolute;z-index:2;left:8px;top:34px;width:70px;height:38px;border:2px solid #765635;border-radius:4px 4px 10px 10px;background:linear-gradient(90deg,#986737,#c18a4d 50%,#986438);box-shadow:inset 0 4px 5px #fbe2a477}
.chest-lid{position:absolute;z-index:1;left:8px;top:9px;width:70px;height:30px;border:2px solid #765635;border-radius:19px 19px 5px 5px;background:linear-gradient(180deg,#d6aa68,#a76d3b);box-shadow:inset 0 4px 5px #ffe7aa85;transform-origin:50% 100%;transition:transform .38s ease}
.chest-band{position:absolute;z-index:4;left:38px;top:30px;width:10px;height:42px;border-left:1px solid #fff0aa;border-right:1px solid #856127;background:#d4b45f99}
.chest-lock{position:absolute;z-index:5;left:32px;top:41px;width:22px;height:19px;display:grid;place-items:center;border:1px solid #f9e39b;border-radius:5px;background:#986c31;color:#fff0b6;font-size:12px}
.chest-ornament{position:absolute;z-index:5;right:7px;top:16px;color:#fff1b9;font-size:12px;text-shadow:0 1px #63451e}
.chest-art.forest-mushroom .chest-base{border-color:#86704c;border-radius:5px 5px 10px 10px;background:linear-gradient(90deg,#d2bd8e,#f1e5c7 50%,#d2bd8e);box-shadow:inset 0 4px 5px #fff9df}
.chest-art.forest-mushroom .chest-lid{left:3px;width:80px;height:32px;border-color:#944f3b;border-radius:38px 38px 7px 7px;background:radial-gradient(circle at 25% 38%,#fff0d4 0 3px,transparent 3.5px),radial-gradient(circle at 70% 30%,#fff0d4 0 3.5px,transparent 4px),radial-gradient(circle at 52% 65%,#fff0d4 0 2px,transparent 2.5px),linear-gradient(180deg,#df8060,#b64e43);box-shadow:inset 0 4px 5px #ffd4ae}
.chest-art.forest-mushroom .chest-band{border-color:#9a6738;background:#c99656}
.chest-art.forest-mushroom .chest-lock{border-color:#f0d28d;background:#a66e3e;color:#fff1cf}
.chest-art.forest-mushroom .chest-ornament{color:#fff0d0}
.chest-art.night-star .chest-base{border-color:#b29a60;background:linear-gradient(90deg,#111d34,#2d3c56 50%,#141f35);box-shadow:inset 0 3px 5px #c4b77b47}
.chest-art.night-star .chest-lid{border-color:#c8ad6c;background:linear-gradient(180deg,#455675,#1b2943);box-shadow:inset 0 4px 5px #e9d79b62}
.chest-art.night-star .chest-band{border-color:#ffe7a1;background:#d4b45f99}
.chest-art.night-star .chest-lock{border-color:#f8df9c;background:#8e6b32;color:#fff0b6}
.chest-art.opening .chest-lid,.treasure-chest.opening .chest-lid{transform:perspective(140px) rotateX(-74deg) translateY(6px) scaleY(.8);opacity:.72}
.coin-flight{position:absolute;z-index:9;left:50%;top:9px;opacity:0;transform:translate(-50%,12px) scale(.65);pointer-events:none}
.coin-launched .coin-flight{animation:memory-coin-up .68s cubic-bezier(.18,.74,.26,1) forwards}
.coin-flight .reward-amount{display:inline-flex}
.coin-flight .reward-amount>span{display:none}
.coin-flight .reward-amount .coin-icon{width:44px;height:44px}
.reward-amount{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:#714719;font-weight:800;font-size:12px;white-space:nowrap}
.reward-amount .coin-icon{width:26px;height:26px}
.coin-icon .coin-disc{fill:url(#storyCoinGold);stroke:#855716;stroke-width:1.5;filter:drop-shadow(0 2px 1px #65420d)}
.coin-icon .coin-rim{fill:none;stroke:#fff3b0;stroke-width:1.2}
.coin-icon .coin-book{fill:none;stroke:#76501b;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.treasure-finish{width:100%;min-height:44px;margin-top:12px;border:1px solid #80936c;border-radius:22px;background:linear-gradient(135deg,#43634b,#2f513d);color:#fff6dc;font-size:12px;font-weight:700}
.memory-modal-backdrop .treasure-finish[hidden]{display:none}
.oops-modal{width:min(100%,360px);padding:29px 23px 22px}
.oops-mark{display:grid;place-items:center;width:49px;height:49px;margin:0 auto 10px;border:1px solid #d1a968;border-radius:50%;background:#f3dfb7;color:#906242;font-size:25px}
.oops-modal h2{color:#654438;font:700 23px/1.3 var(--sans)}
.oops-modal p{margin:8px 0 20px;color:#71665b}
.oops-retry{width:100%;min-height:45px;border:1px solid #aa8156;border-radius:23px;background:linear-gradient(135deg,#c38d56,#a66e45);color:#fff7e7;font-size:12px;font-weight:700}
.memory-reward-splash{position:fixed;inset:0;z-index:70;display:grid;place-items:center;overflow:hidden;cursor:pointer;background:radial-gradient(circle at 50% 43%,#332313ed 0,#111722f4 56%,#060910fa 100%);opacity:0;visibility:hidden;transition:opacity .22s,visibility .22s}
.memory-reward-splash.show{opacity:1;visibility:visible}
.reward-splash-content{position:relative;z-index:1;padding:28px;text-align:center;animation:reward-content-in .55s cubic-bezier(.16,.8,.24,1) both}
.reward-splash-coin{display:block;width:104px;height:104px;margin:0 auto 14px;filter:drop-shadow(0 0 22px #ffdb69);transform-origin:center}
.memory-reward-splash.show .reward-splash-coin{animation:reward-coin-zoom .68s cubic-bezier(.16,.8,.25,1) both}
.reward-splash-title{display:block;color:#ffe69c;font:900 clamp(38px,10vw,64px)/1.2 var(--sans);font-style:normal;letter-spacing:.025em;-webkit-text-fill-color:#fff0b0;-webkit-text-stroke:1.5px #d69b25;text-shadow:0 0 7px #ffdc73,0 2px 0 #a76c19,0 4px 0 #57300e,0 0 22px #ffc83d99,0 8px 24px #000;white-space:nowrap}
.reward-splash-hint{display:block;margin-top:19px;color:#e8d8b5;font-size:11px;letter-spacing:.04em}
.memory-fireworks{position:absolute;inset:0;z-index:0;pointer-events:none;opacity:0;visibility:hidden}
.memory-fireworks.active{opacity:1;visibility:visible}
.memory-fireworks i{position:absolute;left:var(--x);top:var(--y);width:9px;height:9px;border-radius:50%;background:#fffbd5;box-shadow:0 0 18px 8px #ffe46b,0 -30px 0 -1px #fffbd5,21px -21px 0 -1px #ffbd36,30px 0 0 -1px #fff9d1,21px 21px 0 -1px #ff8c38,0 30px 0 -1px #fff3a2,-21px 21px 0 -1px #ffbd36,-30px 0 0 -1px #fff9d1,-21px -21px 0 -1px #ff8c38,0 -46px 0 -2px #fff7c3,32px -32px 0 -2px #ffd75b,46px 0 0 -2px #fff7c3,32px 32px 0 -2px #ffbd48,0 46px 0 -2px #fff7c3,-32px 32px 0 -2px #ffd75b,-46px 0 0 -2px #fff7c3,-32px -32px 0 -2px #ffbd48;opacity:0}
.memory-fireworks.active i{animation:memory-firework 1.45s cubic-bezier(.16,.7,.23,1) both}
.memory-fireworks i:nth-child(1){--x:17%;--y:25%;animation-delay:0s}.memory-fireworks i:nth-child(2){--x:81%;--y:22%;animation-delay:.12s}.memory-fireworks i:nth-child(3){--x:72%;--y:70%;animation-delay:.22s}.memory-fireworks i:nth-child(4){--x:21%;--y:74%;animation-delay:.08s}.memory-fireworks i:nth-child(5){--x:51%;--y:14%;animation-delay:.28s}.memory-fireworks i:nth-child(6){--x:91%;--y:52%;animation-delay:.35s}.memory-fireworks i:nth-child(7){--x:8%;--y:57%;animation-delay:.18s}.memory-fireworks i:nth-child(8){--x:48%;--y:86%;animation-delay:.4s}
@keyframes memory-card-in{from{opacity:.45;transform:translateY(9px) scale(.98)}to{opacity:1;transform:none}}
@keyframes memory-coin-up{0%{opacity:0;transform:translate(-50%,12px) scale(.65) rotate(-12deg)}65%{opacity:1;transform:translate(-50%,-13px) scale(1) rotate(0)}100%{opacity:1;transform:translate(-50%,-13px) scale(1) rotate(0)}}
@keyframes reward-coin-zoom{0%{opacity:.45;transform:scale(.38) rotate(-8deg)}70%{opacity:1;transform:scale(1.2) rotate(3deg)}100%{opacity:1;transform:scale(1) rotate(0)}}
@keyframes reward-content-in{from{opacity:0;transform:translateY(14px) scale(.86)}to{opacity:1;transform:none}}
@keyframes memory-firework{0%{opacity:0;transform:scale(.08) rotate(-12deg)}12%{opacity:1}100%{opacity:0;transform:scale(1.9) rotate(14deg)}}
body[data-theme="warm"] .memory-sheet{background:linear-gradient(145deg,#f7f0dded,#e7ead8ed);border-color:#83916c;color:#394b39;box-shadow:0 15px 35px #51624633}
body[data-theme="warm"] .memory-top{color:#78904f}
body[data-theme="warm"] .memory-top .coin-total{color:#90621e}
body[data-theme="warm"] .memory-sheet>h1{color:#3d573e}
body[data-theme="warm"] .memory-intro{color:#61725b}
body[data-theme="warm"] #memoryResult{color:#476447}
@media(max-width:370px){.memory-modal{padding:22px 12px 14px}.treasure-grid{gap:5px}.treasure-chest{min-height:148px;padding-inline:1px}.chest-art{transform:scale(.9)}.reward-splash-title{font-size:36px}}
