:root{font-family:system-ui,-apple-system,"Noto Sans KR","Malgun Gothic",sans-serif;color:#345451;background:#e5f0e9;font-synthesis:none}
*{box-sizing:border-box}html{min-width:310px}body{margin:0;min-height:100dvh;background:radial-gradient(circle at 10% 2%,#fcf3da 0,transparent 40%),#e3ede9}
button,select{font:inherit;color:inherit}button{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button:disabled{opacity:.42;cursor:default}button:focus-visible,select:focus-visible{outline:4px solid #ffb85a;outline-offset:2px}
.shell{width:min(100%,540px);padding:16px 16px 26px;min-height:100dvh;margin:auto;background:linear-gradient(180deg,#fffdf7,#f7f2e7);box-shadow:0 0 35px #39564b30}
.loading,.error{display:grid;place-items:center;min-height:65dvh;text-align:center;padding:20px}
.top{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:15px}
.brand{display:flex;gap:10px;align-items:center}.emblem{width:44px;height:44px;display:grid;place-items:center;font-size:27px;color:#fef7ae;border-radius:14px;background:linear-gradient(145deg,#58baa2,#287f75);box-shadow:0 4px 0 #a3ccba}
.brand small,.brand strong{display:block}.brand small{font-weight:850;font-size:10px;letter-spacing:1.6px;color:#8da59c}.brand strong{font-size:22px;line-height:1.1;font-weight:900;color:#27786d}
.round{width:42px;height:42px;background:#fff;border:2px solid #e9e1d2;border-radius:50%;font-size:21px;box-shadow:0 2px 0 #ddd1bf}
.stage-top{display:flex;align-items:center;gap:11px;justify-content:space-between;margin:0 0 13px}
.stage-chooser{border:0;background:#eda74e;color:white;padding:12px 11px;border-radius:13px;font-weight:850;white-space:nowrap;box-shadow:0 3px 0 #c9863d}
.stage-name{flex:1;min-width:0}.stage-name strong,.stage-name small{display:block}.stage-name strong{font-size:17px;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stage-name small{font-size:12px;color:#82958a;font-weight:700}
.progress-text{font-size:13px;color:#4c9886;font-weight:800;white-space:nowrap}
.meter{height:12px;border-radius:10px;background:#e2eadd;border:2px solid #d6e2d6;overflow:hidden;margin:0 0 11px}.meter span{display:block;height:100%;background:linear-gradient(90deg,#84caba,#37a58e);transition:width .15s}
.board{position:relative;height:clamp(300px,48dvh,470px);border-radius:24px;border:3px solid #cce1d3;background:radial-gradient(circle at 20% 14%,#f1f9ed,#d8ebdf);box-shadow:inset 0 5px 12px #8eb89b22,0 4px 0 #c3d9cc;overflow:hidden}
.board:before{content:"";position:absolute;inset:12px;border-radius:14px;border:2px dashed #ffffff8c;pointer-events:none}
.board .tile{position:absolute;padding:0;border:0;border-radius:12px;background:#e0c7ae;box-shadow:0 4px 0 #ac957f,0 6px 8px #576e5844;display:grid;place-items:center}
.tile-face{position:absolute;inset:0 0 4px;display:grid;place-items:center;border:2px solid white;background:linear-gradient(135deg,#fffefa,#f7eddb);border-radius:11px}.tile-face svg{width:76%;height:76%}
.tile.covered{filter:brightness(.72) saturate(.72)}.tile.ready:hover{transform:translateY(-2px)}
.tile-badge{z-index:4;position:absolute;right:-5px;top:-5px;border:1px solid #e1c8a2;background:#fffbdf;min-width:20px;min-height:20px;padding:1px 2px;display:grid;place-items:center;border-radius:7px;font-size:clamp(10px,3vw,16px)}
.tile-badge.bottom{top:auto;bottom:-4px}.tile-badge.left{right:auto;left:-4px}
.tile-cover{position:absolute;inset:1px 1px 4px;z-index:3;border-radius:10px;display:grid;place-items:center}
.tile-cover.obstacle{background:#c5e6e9e8;border:2px solid #8dbcca;font-size:clamp(18px,5vw,30px)}
.tile-cover.obstacle small{position:absolute;right:3px;bottom:3px;font-size:12px;background:#fff;border-radius:100%;min-width:18px;font-weight:900}
.tile-cover.curtain{background:linear-gradient(90deg,#88b9ad,#bde5d8,#88b9ad);font-size:27px}
.tile-cover.lock{background:#7d8b8682}
.tile.hint{outline:5px solid #ffbf48;outline-offset:1px;filter:brightness(1.08);animation:glow 1s ease-in-out infinite}@keyframes glow{50%{transform:scale(1.08)}}
.board-footer{display:flex;align-items:center;justify-content:space-between;padding:12px 3px 9px;gap:8px;font-size:12px;color:#80958a;font-weight:750}.board-footer span:last-child{color:#49897b}
.tray-panel{background:linear-gradient(150deg,#f3e8d8,#e7d7c3);border:2px solid #e4d0b7;border-bottom:4px solid #d4b89a;border-radius:17px;padding:11px}
.tray-head{display:flex;justify-content:space-between;align-items:center;font-size:13px;font-weight:850;margin-bottom:9px;color:#7f6655}.tray-head b{font-size:15px}
.tray-head .danger{color:#c65d4b}.slots{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px}
.slot{aspect-ratio:1/1.06;border:2px solid #d2bea2;background:#e5d5bf;border-radius:10px;min-width:0;display:grid;place-items:center;box-shadow:inset 0 2px 4px #b39d813d}
.slot.used{background:#fffaf0;border-color:#fff;box-shadow:0 2px 0 #d2b99a}.slot svg{width:87%;height:87%}
.instruction{font-size:13px;line-height:1.65;color:#738f85;text-align:center;margin:4px 2px 10px;min-height:22px}
.footer{display:flex;justify-content:center;gap:12px;flex-wrap:wrap;padding:8px 0}.footer button{border:0;background:transparent;color:#799187;font-size:12px;text-decoration:underline;text-underline-offset:4px;padding:6px}
.fineprint{text-align:center;font-size:10px;color:#9fae9f;line-height:1.5;margin:4px 0}
.backdrop{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:14px;background:#223a37b8}
.dialog{background:#fffdf6;border:3px solid #fff;width:min(460px,100%);border-radius:23px;max-height:85dvh;overflow:auto;padding:18px;box-shadow:0 14px 50px #1127208e}
.dialog-head{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:10px}.dialog-head h2{font-size:20px;margin:0;color:#315f54}.dialog-head button{border:0;background:#f0ebdf;width:36px;height:36px;border-radius:50%;font-size:24px}
.dialog p{font-size:14px;color:#678177;line-height:1.6}.dialog .primary,.dialog .secondary{width:100%;min-height:49px;border:0;border-radius:13px;font-size:15px;font-weight:850;margin-top:10px}
.dialog .primary{background:#288d7b;color:#fff;box-shadow:0 3px 0 #1e7063}.dialog .secondary{background:#eee9df;color:#56736d}
.stage-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:7px;margin:18px 0}
.stage-grid button{padding:8px 2px;min-height:51px;background:#f7f3e8;border:2px solid #e1ddce;border-radius:11px;display:grid;place-items:center}
.stage-grid button.current{background:#d8f1e4;border-color:#4d9e84}.stage-grid button.done{color:#bb914b}
.stage-grid b{font-size:18px}.stage-grid small{font-size:9px}
.win-icon{font-size:65px;text-align:center;color:#e3ac43;margin:8px 0}
#toast{position:fixed;bottom:max(20px,env(safe-area-inset-bottom));left:50%;max-width:90vw;z-index:130;background:#20483fe8;color:#fff;border-radius:18px;padding:12px 15px;font-size:13px;font-weight:700;text-align:center;pointer-events:none;opacity:0;transform:translate(-50%,15px);transition:opacity .2s,transform .2s}
#toast.show{opacity:1;transform:translate(-50%,0)}
@media(min-width:610px){.shell{margin:12px auto;border-radius:23px;min-height:calc(100dvh - 24px)}}
@media(max-width:380px){.shell{padding:12px 11px 23px}.brand strong{font-size:20px}.stage-name strong{font-size:15px}.board{height:clamp(260px,43dvh,385px)}}
@media(max-height:730px){.board{height:clamp(265px,41dvh,400px)}.top{margin-bottom:8px}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

.tools-heading{display:flex;align-items:baseline;justify-content:space-between;gap:9px;margin:14px 2px 8px}
.tools-heading strong{font-size:14px;color:#49786d}.tools-heading span{font-size:11px;color:#92a69c}

.tool{position:relative;min-width:0;min-height:75px;padding:8px 2px 7px;
  border:2px solid #d9e5da;border-radius:15px;background:linear-gradient(#fffefa,#f7f4eb);
  box-shadow:0 3px 0 #c6d8cc;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:3px}
.tool:not(:disabled):active{transform:translateY(2px);box-shadow:0 1px 0 #c6d8cc}
.tool.picked,.tool.recover{border-color:#9ecfbd;background:#ebfaf3}
.tool.picked{outline:3px solid #f4be63}
.tool .tool-icon{font-size:clamp(24px,6vw,29px);font-weight:900;line-height:1.15;color:#2b927e}
.tool .tool-name{font-size:clamp(10px,2.75vw,12px);font-weight:850;color:#4c7468;white-space:nowrap}
.tool .tool-count{position:absolute;top:3px;right:3px;min-width:22px;height:22px;display:grid;place-items:center;
  font-size:11px;font-weight:900;color:#fff;border:2px solid white;background:#309985;border-radius:50%}
.cancel-tool{width:100%;margin:10px 0 0;min-height:44px;border:1px solid #e9bf8a;
  background:#fff2dc;color:#aa772f;border-radius:11px;font-weight:850}.recover-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:17px 0}.recover-grid .tool{min-height:90px}
.recover-grid .tool{min-height:76px}
.tile.pick-target{outline:4px solid #ffbc55;outline-offset:1px;filter:brightness(1.12)}
.tile.pick-target::after{content:"";position:absolute;z-index:6;left:-3px;top:-8px;
  width:24px;height:24px;border-radius:50%;background:#fbe4b3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%23a27525' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M4 10c5-9 16-10 24-4M16 6L6 29'/%3E%3C/svg%3E") center/contain no-repeat;border:1px solid #d59e40;
  display:grid;place-items:center;font-size:16px;pointer-events:none}
.tile-badge.key{padding:1px 3px;display:flex;gap:0;align-items:center;background:#fff6d2;
  min-width:38px;height:25px;font-size:12px}
.tile-badge.key .key-art{width:21px;height:21px;display:grid;place-items:center}
.tile-badge.key svg{width:20px;height:20px}

.slots.expanded{grid-template-columns:repeat(8,minmax(0,1fr));gap:4px}
.slots .extra-slot{border-color:#79c8ac;background:#daefe1}
.instruction{margin-top:9px;min-height:25px}
.footer{padding:7px 0 4px}
.fineprint{padding-bottom:8px}
.shell{padding-bottom:max(26px,env(safe-area-inset-bottom))}
@media(max-width:360px){
  .tool{min-height:71px}
  .tools-row{gap:5px}
  .tool .tool-name{font-size:10px}
  .tool .tool-count{top:2px;right:1px}
}
@media(prefers-reduced-motion:reduce){.tile.hint{animation:none}}

.tool .tool-icon{display:grid;place-items:center;width:37px;height:37px}
.tool .tool-icon svg{width:33px;height:33px;stroke:#318f7c}
.tile-badge svg{width:17px;height:17px;stroke:#6e7054}
.tile-badge.key{min-width:39px}
.tile-badge.key>b{display:grid;place-items:center}
.tile-badge.key>b svg{width:17px;height:17px;stroke:#aa8742}
.tile-badge.bomb-mark{display:flex;gap:1px;align-items:center}
.tile-badge.bomb-mark small{font-size:11px;color:#9d5548;font-weight:900}
.tile-cover.obstacle svg{width:52%;height:52%;stroke:#4a909a;stroke-width:2.3}
.tile-cover.curtain svg{width:55%;height:55%;stroke:#4c9585}

@media(max-width:609px){
 .shell{padding-top:11px}
 .top{margin-bottom:9px}
 .brand .emblem{width:40px;height:40px}
 .stage-top{margin-bottom:8px}
 .stage-chooser{padding:10px 9px}
 .meter{margin-bottom:8px;height:10px}
 .board{height:clamp(270px,36dvh,390px)}
 .board-footer{padding:9px 3px 6px}
 .tray-panel{padding:8px}
 .slot{aspect-ratio:1/1}
 .tools-heading{margin:10px 2px 7px}
 .tool{min-height:69px}
 .instruction{margin:6px 0}
}
@media(max-width:380px) and (max-height:700px){
 .board{height:clamp(245px,35dvh,330px)}
 .tray-panel{padding:7px}
}

.tools-row{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  grid-auto-rows:minmax(69px,auto);
  column-gap:7px;
  row-gap:9px;
}
.tools-row .tool{min-height:69px}
.tools-row .tool .tool-name{
  font-size:clamp(10px,2.85vw,12px);
  white-space:nowrap;
}
@media (max-width:609px){
  .shell{padding-top:12px}
  .top{margin-bottom:11px}
  .stage-top{margin-top:3px}
  .tools-heading{margin-top:12px}
  .board{height:clamp(275px,38dvh,385px)}
  .tools-row{row-gap:8px}
  .tools-row .tool{min-height:70px}
  .instruction{margin-top:8px}
}
@media (max-width:380px) and (max-height:740px){
  .board{height:clamp(245px,35dvh,335px)}
  .tools-row .tool{min-height:64px}
  .tools-row .tool-icon{width:31px;height:31px}
  .tools-row .tool-icon svg{width:29px;height:29px}
}

.stage-jump{display:flex;align-items:center;gap:9px;background:#eff7f2;padding:10px;border-radius:12px;margin-top:10px}
.stage-jump label{font-size:12px;font-weight:850;white-space:nowrap;color:#54887b}
.stage-jump input{flex:1;min-width:60px;height:44px;border:1px solid #b5d4c7;border-radius:9px;
 background:#fff;color:#315f50;text-align:center;font-weight:850;font-size:17px}
.stage-jump button{min-height:44px;min-width:62px}
.dialog .stage-grid{max-height:min(50dvh,410px);overflow-y:auto;overscroll-behavior:contain;
 margin:12px 0;padding:4px;scrollbar-width:thin;align-items:stretch}
.dialog .stage-grid button{width:100%;min-height:55px}

.board{isolation:isolate;z-index:0}

#effects{position:fixed;inset:0;z-index:85;pointer-events:none;overflow:hidden;
  contain:layout style}
#effects:empty{display:none}
.fx-node{position:absolute;pointer-events:none;transform-origin:top left;will-change:transform,opacity}
.fx-tile-flying{border-radius:11px;background:#e0c7ae;
  box-shadow:0 4px 0 #ac957f,0 7px 16px #243d3675;
  padding:0}
.fx-tile-flying .fx-face{position:absolute;inset:0 0 4px;display:grid;place-items:center;
  border:2px solid #fff;border-radius:10px;
  background:linear-gradient(135deg,#fffefa,#f7eddb)}
.fx-tile-flying .fx-face svg{width:78%;height:78%}
.fx-tile-flying.fx-magnet{box-shadow:0 0 0 3px #8ce1c2,0 4px 16px #31a4887d}
.fx-tile-flying.fx-magic{box-shadow:0 0 0 3px #ffcf78,0 6px 22px #f7ad54ad}
.fx-tile-flying.fx-return{box-shadow:0 0 0 2px #87dcc7,0 4px 14px #1b88795e}
.fx-tile-flying.fx-shard{box-shadow:none}
.fx-spark{width:6px;height:6px;background:#71cfaa;border-radius:2px;
  box-shadow:0 0 7px 1px #71cfaa9c;transform-origin:center}
.fx-spark.gold{background:#ffd36e;box-shadow:0 0 8px #f5a930}
.fx-spark.ice{background:#96dff1;box-shadow:0 0 8px #8bd6f8}
.fx-pickaxe{filter:drop-shadow(0 2px 2px #b4874677);color:#c38a3d}
.fx-pickaxe svg{width:100%;height:100%;stroke-width:3.1}
.fx-swap-symbol{color:#3aa889;filter:drop-shadow(0 0 10px #e8fff5)}
.fx-swap-symbol svg{width:100%;height:100%;stroke-width:2.5}
.fx-source-hidden{opacity:.06!important;pointer-events:none!important}
.fx-slot-token{width:100%;height:100%;display:grid;place-items:center;
  transform-origin:center;pointer-events:none}
.fx-slot-token svg{width:85%;height:85%}
.slot.fx-reserved{background:#fff7e6;border-color:#efc67f;
  box-shadow:inset 0 0 0 2px #ffe3a6}
.slot.fx-match-ready{border-color:#e3bd64;background:#fff2cd}
@keyframes slotArrival{0%{transform:scale(.79);filter:brightness(1.3)}
  70%{transform:scale(1.08)}100%{transform:scale(1);filter:brightness(1)}}

#app[aria-busy=true] .board button,#app[aria-busy=true] .tools-row button{cursor:wait}
@media(prefers-reduced-motion:reduce){
  #effects{display:none!important}.fx-slot-token{animation:none!important}
}

.tile.fx-queued{outline:3px solid #64bea5;outline-offset:1px;filter:brightness(1.15)}
