@charset "UTF-8";
:root{font-family:"Apple SD Gothic Neo","Noto Sans KR","Malgun Gothic",system-ui,sans-serif;color:#064e53;background:#139da3;font-synthesis:none;font-weight:700;--teal:#07565b;--cream:#fff8e8;--shadow:0 3px 0 #d8ccb5,0 5px 8px #174d4c35;color-scheme:light}
*{box-sizing:border-box}
body{display:flex;align-items:center;justify-content:center;margin:0;min-width:320px;min-height:100svh;background:radial-gradient(ellipse at 15% 35%,#a8f1df66,transparent 50%),radial-gradient(ellipse at 85% 70%,#79e6cf66,transparent 48%),linear-gradient(145deg,#0aa2ae,#45c5c4 52%,#129aab);background-attachment:fixed}
button{font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation;color:inherit}
button:disabled{cursor:default;opacity:.45}button:focus-visible{outline:3px solid #022f34;outline-offset:4px}
button,button svg{user-select:none}button svg{pointer-events:none}button:active:not(:disabled){transform:translateY(2px)}
svg{display:block}h1,h2,p{margin:0}
.game-shell{width:min(100vw,580px,54svh);zoom:.7;flex:none;margin:auto;padding:0 10px max(10px,env(safe-area-inset-bottom));min-height:0;display:flex;flex-direction:column;position:relative;container-type:inline-size}
.topbar{height:clamp(63px,13cqw,82px);display:flex;align-items:center;justify-content:space-between;flex:none;margin:0 -10px 10px;padding:8px 15px 11px;background:radial-gradient(ellipse at 50% 0%,#38b7b677,transparent 65%),linear-gradient(165deg,#079ba4,#02747e);border-radius:0 0 23px 23px;border-bottom:1px solid #a7efdf80;box-shadow:0 3px 0 #075f6818}
.topbar h1{color:#fffef2;font-size:clamp(30px,7.3cqw,46px);letter-spacing:-1.5px;font-weight:950;text-shadow:0 2px #086971,0 4px 5px #003b4166}
.icon-button{border:1px solid #fffeeb;background:linear-gradient(145deg,#fffef6,#fff6de 75%,#eee0be);box-shadow:var(--shadow);border-radius:17px;width:clamp(42px,8.2cqw,51px);height:clamp(42px,8.2cqw,51px);display:grid;place-items:center;flex:none}
.ui-icon{width:27px;height:28px}
.hud{display:grid;grid-template-columns:auto minmax(52px,1fr) auto auto;align-items:center;gap:8px;min-height:46px;flex:none;background:linear-gradient(#fffdf5,#f7edd7);border:2px solid #fffbea;padding:6px 8px;border-radius:24px;box-shadow:0 3px 6px #00545c33;margin-bottom:10px}
.stage-pill{border:0;border-radius:16px;background:linear-gradient(#c3e4df,#d9eae2);padding:5px 8px;white-space:nowrap;font-weight:950;font-size:clamp(12px,3.25cqw,19px)}
.progress-area{min-width:0}
.progress-track{height:clamp(24px,5cqw,30px);border-radius:18px;background:#efe6d4;box-shadow:inset 0 2px 3px #95856b55;position:relative;overflow:hidden;border:1.5px solid #b9a98e}
.progress-fill{height:100%;width:0;border-radius:18px;background:linear-gradient(#fff17a,#ffca00 57%,#efac00);box-shadow:inset 0 2px #fff6b5,inset 0 -2px #cf8a04;transition:width .35s}
.progress-label{position:absolute;inset:0;display:grid;place-items:center;font-size:clamp(16px,3.9cqw,23px);font-weight:950;color:#364414;text-shadow:0 1px #fff7}
.progress-count{font-size:clamp(12px,3cqw,19px);font-weight:900;white-space:nowrap;line-height:1.4;letter-spacing:-.3px;padding-right:8px;border-right:1.5px solid #8bbdb9}
.wallet{border:0;background:none;display:flex;align-items:center;gap:4px;padding:0;line-height:1.05;font-size:clamp(16px,3.6cqw,23px);font-weight:950;min-width:0;white-space:nowrap}
.wallet .coin-art{width:clamp(24px,5.4cqw,33px);height:auto;flex:none;filter:drop-shadow(0 2px 1px #94601f40)}
.wallet-copy{text-align:left}.run-coins{display:block;font-size:11px;color:#16827d;margin-top:2px}
.playfield{flex:none;display:flex;flex-direction:column;background:radial-gradient(ellipse at 35% 15%,#fffdf7,#fbf1df 80%);border:2px solid #fffef3;border-radius:26px;padding:8px 12px 14px;box-shadow:0 4px 12px #005b5c20;position:relative}
.board-head{display:grid;grid-template-columns:repeat(3,1fr);height:25px;margin-bottom:12px;justify-items:center;color:#07999e;flex:none;filter:drop-shadow(0 1px #00656c)}
.board-head .ui-icon{width:20px;height:24px}
.board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 16px;align-items:start;justify-items:center;position:relative;margin-bottom:38px}
.column{display:flex;flex-direction:column;gap:12px;align-items:center;width:100%;min-width:0}
.chest{--light:#fff36e;--mid:#ffbf00;--dark:#a96200;display:block;position:relative;width:91%;aspect-ratio:1.13;min-width:0;border:0;padding:0;background:none;perspective:350px;isolation:isolate}
.chest:active:not(:disabled){transform:translateY(1px)}
.chest-body{position:absolute;left:0;right:0;top:30%;bottom:0;border:1.8px solid #aa9370;border-top:none;border-radius:0 0 16% 16%;background:linear-gradient(90deg,#ecd4aa,#fff9e7 9%,#fff7e5 86%,#e8cba0);box-shadow:inset 0 -3px #fff8db,0 2px 0 #826d51,0 5px 4px #5d45253d}
.chest-lid{position:absolute;z-index:3;left:0;right:0;top:0;height:42%;border:1.7px solid var(--dark);border-bottom-width:3px;border-radius:26% 26% 8% 8%/67% 67% 18% 18%;background:radial-gradient(ellipse at 25% 10%,#ffffff99,transparent 42%),linear-gradient(180deg,var(--light),var(--mid) 48%,var(--mid) 78%,color-mix(in srgb,var(--mid),black 14%));box-shadow:inset 0 2px 3px #ffffff70,inset 0 -3px 3px #00000015,0 2px 2px #0003;transform-origin:center 0;transition:transform .23s,opacity .23s}
.chest-lid:after{content:'';position:absolute;inset:5% 7% 49%;border-radius:50% 50% 20% 20%;background:linear-gradient(#ffffff18,#ffffff03);pointer-events:none}
.keyhole{position:absolute;width:13%;height:48%;left:43.5%;top:29%;color:color-mix(in srgb,var(--dark),black 64%);filter:drop-shadow(0 1px #fff6);z-index:1}
.glass{position:absolute;z-index:2;left:8%;right:8%;top:47%;bottom:9%;border:1.8px solid #93aaa7;border-radius:13%;background:linear-gradient(135deg,transparent 0 15%,#f3ffff60 15% 24%,transparent 24% 66%,#f0ffff4a 66% 78%,transparent 78%),linear-gradient(135deg,#c0d4d3,#a9c3c8);box-shadow:0 1px #fff9,inset 0 2px 3px #49676628;display:flex;align-items:center;justify-content:center;overflow:hidden;container-type:size}
.reward-keys{display:flex;align-items:center;justify-content:center;width:100%;height:100%;gap:0}
.reward-keys .key-art{width:47%;height:96%;filter:drop-shadow(0 1px 0 #36595255)}
.reward-keys.single .key-art{width:68%;height:98%}
.reward-keys.triple .key-art{width:32.5%;height:93%}
.key-quantity{font-size:19cqw;font-weight:950;margin-left:-2px;color:#064e53}
.reward-coins{width:96%;height:96%;display:flex;align-items:center;justify-content:center;gap:2%}
.reward-coins .coin-art{width:47%;height:95%;filter:drop-shadow(0 1px 0 #aa6b2855)}
.coin-quantity{font-size:25cqw;font-weight:950;white-space:nowrap;letter-spacing:-.5px;text-shadow:0 1px #f0fff599}
.chest.usable:hover .chest-lid{filter:brightness(1.08)}
.chest.usable:hover:after,.chest.usable:focus-visible:after{content:'';position:absolute;inset:-4px;border:2px solid #0ec1a8;border-radius:26% 26% 18% 18%;box-shadow:0 0 0 2px #fff9;pointer-events:none}
.chest.usable:focus-visible{outline:0}
.chest.master-target{outline:2px solid #f4bc23;outline-offset:5px;border-radius:19px;animation:masterPulse 1s infinite alternate}
.chest.opening .chest-lid{transform:rotateX(100deg) translateY(-10px);opacity:0}
.chest.opening .glass{animation:rewardFly .3s ease-in both}
.chest.opening .chest-body{opacity:0;transition:opacity .22s .1s}
.chest.shake{animation:shake .3s}.chest.arriving{animation:fallIn .32s cubic-bezier(.2,.8,.3,1.05) both}.chest.falling{animation:fallDown .32s cubic-bezier(.2,.8,.3,1.05) both}.board.busy .chest{pointer-events:none}
.inventory{border:3px solid #a4cec7;border-radius:23px;padding:20px 7px 8px;margin-top:0;position:relative;background:#fff8ea;flex:none}
.inventory-title{position:absolute;top:-14px;left:50%;transform:translateX(-50%);white-space:nowrap;background:radial-gradient(ellipse at 35% 0%,#4ac9bfa6,transparent 65%),linear-gradient(#23b5b5,#006c78);color:#fffdf4;font-weight:950;font-size:clamp(14px,3.8cqw,18px);letter-spacing:.2px;padding:3px 16px 4px;border-radius:24px;text-shadow:0 2px #03565a;box-shadow:0 1px #2dc0bc}
.inventory-grid{display:grid;grid-template-columns:repeat(var(--inventory-columns,4),minmax(0,1fr));gap:5px}
.key-stock{display:flex;align-items:center;justify-content:center;min-width:0;background:linear-gradient(#fff9ef,#f5ead7);border:1.5px solid #ded3be;border-radius:10px;padding:4px 2px;min-height:61px;gap:2px;container-type:inline-size}
.key-stock .key-art{width:57%;max-width:75px;aspect-ratio:1;flex:none;filter:drop-shadow(0 1px 1px #7a693544)}
.key-stock strong{font-size:clamp(20px,30cqw,34px);font-weight:950;letter-spacing:-1px;white-space:nowrap}
.key-stock[data-total="4"] .key-art{width:61%}
.key-stock[data-total="4"] strong{font-size:clamp(19px,28cqw,30px)}
.key-stock.empty .key-art{opacity:.45}.key-stock.empty strong{color:#709d96}
.key-stock.changed{animation:stockBump .38s}
.tools{display:flex;justify-content:center;gap:30px;align-items:start;margin-top:9px;flex:none;min-height:76px}
.tool-wrap{text-align:center;min-width:78px}
.tool{position:relative;width:62px;height:60px;border-radius:50%;border:2px solid #fff8e3;background:radial-gradient(ellipse at 35% 20%,#fffef8,#fff9e7 60%,#e9d5af);box-shadow:var(--shadow);display:grid;place-items:center;margin:0 auto 5px}
.tool .ui-icon{width:35px;height:37px}.tool .key-art{width:48px;height:48px}
.tool .tool-count{position:absolute;right:-3px;top:-3px;min-width:22px;height:22px;padding:1px 5px;border:2px solid #fff6df;background:#116e73;color:white;border-radius:14px;font-size:12px;line-height:16px}
.tool-label{color:#f4fffb;font-size:12px;font-weight:800;text-shadow:0 1px #045d62}
.tool.armed{outline:3px solid #ffe68d;background:#ffefb0}.tool.armed .tool-count{background:#ac6c12}
.master-banner{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:7;background:#fff7dd;color:#235c5b;border:2px solid #f3d477;box-shadow:0 6px 25px #003a4055;border-radius:17px;padding:12px 14px;display:flex;align-items:center;gap:12px;font-size:14px;max-width:94vw;white-space:nowrap}
.master-banner button{background:#e5d8b9;border:0;padding:7px 11px;border-radius:10px;font-size:12px}

.modal{border:0;border-radius:28px;padding:0;width:min(90vw,440px);max-height:86svh;background:#fff8e7;color:#164f53;box-shadow:0 20px 70px #00383d66;overflow:auto}.modal::backdrop{background:#003d46a6;backdrop-filter:blur(4px)}.modal-inner{padding:28px 25px 24px}.modal-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:20px}.modal-heading h2{font-size:24px;font-weight:950;letter-spacing:-1px}.modal-close{border:0;background:#eee4cf;border-radius:50%;width:32px;height:32px;padding:6px}.modal-close .ui-icon{width:20px;height:20px}.modal p{font-size:14px;font-weight:550;line-height:1.7;color:#607877;margin-bottom:17px}.modal-actions{display:flex;flex-direction:column;gap:10px}.primary,.secondary{border:0;border-radius:14px;min-height:46px;padding:11px 16px;font-size:16px;font-weight:850}.primary{color:white;background:linear-gradient(#2cb2ad,#087c83);box-shadow:0 3px #04636b}.secondary{background:#e9e2cf;color:#416968}.secondary.danger{color:#9b4540}.stage-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.stage-card{position:relative;min-height:72px;border:1px solid #dcd4be;background:#fffdf3;border-radius:14px;padding:8px 3px}.stage-card strong{display:block;font-size:22px;font-weight:950}.stage-card small{font-size:10px;color:#78908b;letter-spacing:1px}.stage-card.current{border:2px solid #179698;background:#e7f5ec}.stage-card.complete:after{content:'✓';position:absolute;top:3px;right:6px;color:#26998b;font-size:12px}.stage-picker-note{font-size:12px!important;line-height:1.4!important;margin-bottom:16px!important}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:15px;margin:16px 0;font-size:15px}.toggle{width:52px;height:29px;border:0;border-radius:20px;background:#bdc8be;padding:3px;transition:background .15s}.toggle:before{content:'';display:block;width:23px;height:23px;border-radius:50%;background:white;box-shadow:0 2px 3px #0002;transition:transform .15s}.toggle.on{background:#139b94}.toggle.on:before{transform:translateX(23px)}.settings-note{font-size:11px!important;border-top:1px solid #e2d9bf;padding-top:15px;margin-top:20px!important}.result{text-align:center}.result .result-emblem{width:72px;height:72px;display:grid;place-items:center;background:#e4f2d8;border:3px solid #b6dca0;color:#58a34b;border-radius:50%;margin:0 auto 16px}.result-emblem .ui-icon{width:40px;height:42px}.result-emblem.failed{background:#f7e5d0;color:#b37b45;border-color:#e7c59b;font-size:43px;font-weight:950}.result h2{font-size:29px;letter-spacing:-1px;font-weight:950;margin-bottom:9px}.result-meta{font-size:12px;color:#7a8d80;margin:10px 0}.result .coin-gain{display:flex;justify-content:center;align-items:center;gap:4px;font-size:26px;font-weight:950;margin:14px 0 22px;color:#ad7717}.coin-gain .coin-art{width:47px;height:41px}.result .modal-actions{margin-top:22px}.result .dismiss-result{border:0;background:none;text-decoration:underline;font-size:12px;color:#85948a;margin-top:17px}.toast{position:fixed;left:50%;bottom:max(30px,env(safe-area-inset-bottom));transform:translate(-50%,20px);z-index:20;background:#073f47ee;color:#fff;border:1px solid #72b8b5;border-radius:16px;padding:11px 17px;font-size:13px;line-height:1.5;max-width:min(90vw,430px);width:max-content;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;box-shadow:0 8px 20px #003b3f35}.toast.show{opacity:1;transform:translate(-50%,0)}.loading{min-height:80svh;display:grid;place-content:center;text-align:center;color:white;gap:15px}.loading-key{font-size:50px;animation:masterPulse 1s infinite alternate}.loading p{font-size:15px}.app-footer{text-align:center;color:#cdf5eb90;font-size:9px;margin-top:10px;letter-spacing:1px}.reduced-motion *, .reduced-motion *:before{animation-duration:.001ms!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-4px)}75%{transform:translateX(4px)}}@keyframes fallIn{from{transform:translateY(-90%);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes fallDown{from{transform:translateY(-115%)}to{transform:translateY(0)}}@keyframes rewardFly{to{transform:translateY(-45px) scale(.75);opacity:0}}@keyframes stockBump{50%{transform:scale(1.08);background:#fff1b3}}@keyframes masterPulse{to{box-shadow:0 0 16px #ffe27b66}}

@media(max-width:360px){
 .game-shell{padding-left:7px;padding-right:7px}.topbar{margin-left:-7px;margin-right:-7px;padding-left:12px;padding-right:12px}
 .topbar h1{font-size:29px}.hud{gap:5px;padding:5px 6px;min-height:42px}.stage-pill{font-size:11px;padding:5px 6px}.progress-count{padding-right:5px;font-size:11px}.wallet{gap:2px;font-size:15px}.wallet .coin-art{width:22px}.progress-label{font-size:15px}
 .playfield{padding:8px 10px 12px;border-radius:23px}.board{column-gap:10px;margin-bottom:31px}.board-head{height:21px;margin-bottom:9px}.board-head .ui-icon{width:18px;height:21px}.column{gap:10px}.chest{width:94%}
 .inventory{padding:17px 5px 6px;border-radius:19px}.inventory-title{font-size:14px;top:-13px}.key-stock{min-height:51px;gap:0}.key-stock strong{font-size:clamp(18px,29cqw,28px)}.key-stock .key-art{width:56%}
 .tools{margin-top:8px;min-height:71px}.tool{width:57px;height:55px}.tool .key-art{width:44px;height:44px}.tool .ui-icon{width:32px;height:34px}.tool-label{font-size:11px}
}
@media(min-width:760px){.game-shell{box-shadow:0 0 70px #003b4130;border-left:1px solid #77e4d540;border-right:1px solid #77e4d540}}
@media(prefers-reduced-motion:reduce){*:not(.allow-motion){animation-duration:.001ms!important;transition-duration:.001ms!important}}

/* Keep the complete board and dense inventory in view. */
.game-shell[data-colors="5"],.game-shell[data-colors="6"]{width:min(100vw,580px,49svh)}
.game-shell:is([data-colors="5"],[data-colors="6"]) .board{margin-bottom:22px}
.game-shell:is([data-colors="5"],[data-colors="6"]) .column{gap:8px}
.game-shell:is([data-colors="5"],[data-colors="6"]) .inventory{padding:16px 6px 6px}
.game-shell:is([data-colors="5"],[data-colors="6"]) .inventory-grid{row-gap:3px}
.game-shell:is([data-colors="5"],[data-colors="6"]) .key-stock{min-height:48px}

.key-stock[data-total="4"][data-digits="2"] .key-art{width:51%}
.key-stock[data-total="4"][data-digits="2"] strong{font-size:clamp(17px,25cqw,28px)}
@media(max-width:360px){.game-shell:is([data-colors="5"],[data-colors="6"]){width:min(calc(100vw - 8px),49svh)}.game-shell:is([data-colors="5"],[data-colors="6"]) .board{margin-bottom:18px}}

/* Keep slot height steady while the number of owned colors changes. */
.inventory-grid{--inventory-slot-height:clamp(54px,7.5svh,78px);position:relative;z-index:1}
.key-stock{height:var(--inventory-slot-height);min-height:0;will-change:transform}
.key-stock .key-art,.key-stock[data-total] .key-art{width:calc(var(--inventory-slot-height) - 10px);height:calc(var(--inventory-slot-height) - 10px);max-width:61%;max-height:100%;flex:none}
.key-stock.receiving .key-art{opacity:.25}
.key-stock.receiving strong{min-width:1.2em}
.inventory-empty{height:var(--inventory-slot-height);display:grid;place-items:center;color:#71928b;font-size:15px;font-weight:650}
.inventory-title{z-index:2}
.inventory-frame{position:absolute;inset:-3px;border:3px solid #a4cec7;border-radius:inherit;background:#fff8ea;pointer-events:none}
.inventory-morphing{border-color:transparent;background:transparent}
.reward-flight,.inventory-exit{position:fixed;pointer-events:none;z-index:25;transform-origin:center;will-change:transform,opacity;user-select:none}
.reward-flight{filter:drop-shadow(0 2px 3px #284e5145)}
.reward-flight svg{width:100%;height:100%}
.inventory-exit>.key-stock{width:100%;height:100%;min-height:0}
.inventory-exit .key-art{height:90%;width:55%;max-height:75px}
.chest.opening .glass{animation:none}
.chest.opening .chest-lid{transition-duration:.1s}
.key-stock.received .key-art,.wallet.received .coin-art{animation:receiveReward .2s ease-out}
.key-stock.received strong,.wallet.received .wallet-copy{animation:receiveNumber .2s ease-out}
@keyframes receiveReward{0%{transform:scale(.92)}45%{transform:scale(1.2)}100%{transform:scale(1)}}
@keyframes receiveNumber{45%{transform:scale(1.1);color:#109b86}100%{transform:scale(1)}}

/* Only the three introductory lessons show short contextual guidance. */
.game-shell[data-tutorial="true"]{width:min(100vw,580px,49svh)}
.tutorial-strip{display:flex;align-items:center;gap:8px;padding:7px 9px;margin-bottom:9px;border:1px solid #aad3c6;border-radius:12px;background:#e3f1e6;flex:none;color:#256a67}
.tutorial-strip>span{font-size:10px;font-weight:850;white-space:nowrap;color:#337d78}
.tutorial-strip p{font-size:13px;font-weight:750;line-height:1.4;letter-spacing:-.3px}
.chest.tutorial-focus:after{content:'';position:absolute;inset:-4px;border:2px solid #0eb799;border-radius:26% 26% 18% 18%;box-shadow:0 0 0 2px #fff9;pointer-events:none}
.board.busy .chest.tutorial-focus:after{opacity:0}
@media(max-width:360px){.tutorial-strip{padding:6px 7px;gap:6px}.tutorial-strip p{font-size:12px}.game-shell[data-tutorial="true"] .board{margin-bottom:24px}.game-shell[data-tutorial="true"] .column{gap:8px}}

/* Every owned color occupies one slot in the same row. */
.inventory{padding-top:14px}
.game-shell:is([data-colors="5"],[data-colors="6"]) .inventory{padding-top:12px}
.key-stock:is([data-total="5"],[data-total="6"]){flex-direction:column;padding:3px 1px;gap:0}
.key-stock:is([data-total="5"],[data-total="6"]) .key-art{width:calc(var(--inventory-slot-height) * .6);height:calc(var(--inventory-slot-height) * .6);max-width:90%;max-height:60%;flex:none}
.key-stock:is([data-total="5"],[data-total="6"]) strong{font-size:clamp(13px,40cqw,17px);line-height:1.1;letter-spacing:-.5px}
.key-stock:is([data-total="5"],[data-total="6"])[data-digits="2"] strong{font-size:clamp(12px,35cqw,16px)}
.key-stock:is([data-total="5"],[data-total="6"]).receiving strong{min-height:1.1em}
