:root{--accent:#8ed8e3;--text:#edf2f8;--muted:#a3b2c4;--panel:#1d2734;--c1:#86cbd6;--c2:#f0c383;--c3:#a7b3e9;--c4:#b4d3a1;--c5:#db9fb5;--c6:#91bce6}
*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at 20% 0%,#213841 0%,#131923 55%);color:var(--text);font-family:system-ui,-apple-system,"PingFang SC",sans-serif;min-height:100svh}button,a{-webkit-tap-highlight-color:transparent}button{font:inherit;border:1px solid #ffffff18;border-radius:10px;background:#293647;color:var(--text);padding:11px 15px;cursor:pointer}button:disabled{opacity:.4;cursor:default}.primary{background:var(--accent);color:#152730;border-color:transparent;font-weight:700}a{color:var(--muted);text-decoration:none}.shell{max-width:960px;margin:auto;padding:30px 28px 20px}.heading{display:flex;align-items:center;justify-content:space-between;margin:26px 0}.eyebrow{font-size:11px;letter-spacing:2px;color:var(--accent);margin:0 0 8px}h1{font-size:42px;letter-spacing:-2px;margin:0;line-height:1.2}h1 span{color:var(--accent)}.heading-note{font-size:13px;color:var(--muted);line-height:1.7;margin:0}.game-layout{display:grid;grid-template-columns:minmax(0,500px) minmax(220px,1fr);gap:32px;align-items:start}.board-hud{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--muted);margin-bottom:12px}.board-hud b{color:var(--text);font-weight:500}#empty-count{white-space:nowrap}.board-frame{position:relative;border-radius:17px}.board{display:grid;grid-template-rows:repeat(9,1fr);aspect-ratio:1;background:#101923;border:2px solid #415465;border-radius:17px;overflow:hidden;padding:8px;gap:3px;touch-action:none;user-select:none;outline-offset:4px!important}.board-row{display:grid;grid-template-columns:repeat(9,minmax(0,1fr));gap:3px;min-height:0}.cell{border-radius:4px;background:#273543;position:relative;min-width:0;min-height:0;cursor:crosshair;border:1px solid #ffffff04}.board-row:nth-child(3n):not(:last-child){margin-bottom:4px}.cell:nth-child(3n):not(:last-child){margin-right:4px}.cell[data-box-shade="1"]{background-color:#2e3e4d}.cell[data-color="1"],.piece-cell[data-color="1"]{--block:var(--c1)}.cell[data-color="2"],.piece-cell[data-color="2"]{--block:var(--c2)}.cell[data-color="3"],.piece-cell[data-color="3"]{--block:var(--c3)}.cell[data-color="4"],.piece-cell[data-color="4"]{--block:var(--c4)}.cell[data-color="5"],.piece-cell[data-color="5"]{--block:var(--c5)}.cell[data-color="6"],.piece-cell[data-color="6"]{--block:var(--c6)}.cell.filled,.piece-cell{background:var(--block)!important;box-shadow:inset 0 2px 0 #ffffff35,inset 0 -2px 0 #0002;border-color:#ffffff20}.cell.preview{background:var(--block)!important;opacity:.6;box-shadow:inset 0 0 0 2px #e1ffff}.cell.invalid{background:#bb607580!important;box-shadow:inset 0 0 0 2px #e7a1b2}.cell.will-clear{box-shadow:inset 0 0 0 2px #f9e5ac;filter:brightness(1.2)}.cell.anchor:after{content:"";position:absolute;inset:3px;border:2px dashed #f5fafc;border-radius:3px}.cell.just-placed{animation:block-place .22s ease-out}.cell.just-cleared{animation:block-clear .4s ease-out}.tray-heading{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:12px;margin:19px 0 9px;color:var(--text)}.tray-heading small{font-size:11px;color:var(--muted)}#selection-note{color:var(--accent);font-size:11px}.tray{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.piece{height:108px;padding:12px 6px;display:flex;align-items:center;justify-content:center;position:relative;background:#1c2734;touch-action:none;user-select:none;transition:border-color .15s,background .15s}.piece.selected{border:2px solid var(--accent);background:#263e48}.piece.unavailable{border-style:dashed}.piece.unavailable .shape{opacity:.5}.piece-label{position:absolute;left:9px;top:6px;font-size:10px;color:var(--muted)}.piece-hint{position:absolute;bottom:4px;font-size:10px;color:#f0c383}.shape{display:grid;gap:3px;--unit:16px;grid-template-columns:repeat(var(--cols),var(--unit));grid-template-rows:repeat(var(--rows),var(--unit));pointer-events:none}.piece-cell{border-radius:3px;border:1px solid #ffffff30}.piece.used{opacity:.5}.piece.used:after{content:"已放置";font-size:12px;color:var(--muted)}.board-caption{font-size:11px;color:var(--muted);text-align:center;margin:12px 0 0;line-height:1.7}.message{min-height:2.8em;color:var(--accent);font-size:13px;line-height:1.7;margin:10px 0 0}.feedback-status{min-height:1.5em;margin:0;color:var(--muted)}.control-panel{background:var(--panel);border:1px solid #ffffff0b;padding:24px;border-radius:18px}.stats{display:grid;grid-template-columns:1fr 1fr;gap:10px}.stats span{color:var(--muted);font-size:11px}.stats strong{display:block;margin-top:8px;font-size:30px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.stats div:first-child strong{color:var(--accent)}.run-info{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);padding:18px 0;border-bottom:1px solid #ffffff0b}.run-info b{color:var(--text)}.streak-card{margin:20px 0}.streak-card span{font-size:11px;color:var(--muted)}.streak-card strong{display:block;margin:6px 0;font-size:20px;color:#f0c383}.streak-card p{font-size:12px;color:var(--muted);line-height:1.7;margin:0}.actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:20px 0}.actions button{font-size:12px;padding:11px 5px;white-space:nowrap}kbd{font:inherit;font-size:10px;border:1px solid #ffffff25;border-radius:3px;padding:1px 4px}.game-help{border-top:1px solid #ffffff0b;padding-top:9px}.game-over{position:absolute;inset:0;z-index:6;border-radius:17px;background:#101923ed;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px;backdrop-filter:blur(7px)}.game-over h2{font-size:25px;margin:9px 0}.game-over>strong{font-size:60px;color:var(--accent);margin:8px 0}.game-over>p:not(.eyebrow){color:var(--muted);font-size:12px;line-height:1.8}.end-actions{display:flex;gap:9px;margin-top:12px}.end-actions button{font-size:12px}footer{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin:25px 0 0}.lb-panel{margin-top:16px}[data-leaderboard-game="block-puzzle"]{--lb-accent:var(--accent);--lb-glow:#8ed8e322}.game-window .shell{max-width:760px;padding:16px}.game-window .heading{margin:12px 0}.game-window h1{font-size:27px}.game-window .heading-note,.game-window footer,.game-window .eyebrow{display:none}.game-window .game-layout{grid-template-columns:minmax(0,1fr) 210px;gap:16px}.game-window .control-panel{padding:16px}.game-window .piece{height:80px}.game-window .shape{--unit:12px}.game-window .board-caption{font-size:10px}.game-window .tray-heading{margin-top:10px}.game-window .stats strong{font-size:24px}.game-window .streak-card{margin:12px 0}.feedback-off .just-placed,.feedback-off .just-cleared{animation:none}@keyframes block-place{from{transform:scale(.65);filter:brightness(1.4)}to{transform:scale(1);filter:brightness(1)}}@keyframes block-clear{0%{background:#f9e5ac;box-shadow:0 0 16px #f9e5ac}100%{box-shadow:none}}
@media(max-width:700px){.shell{max-width:520px;padding:18px 16px 20px}.heading{margin:20px 0}.heading h1{font-size:34px}.heading-note{font-size:11px}.game-layout{grid-template-columns:1fr;gap:16px}.control-panel{padding:18px}.stats strong{font-size:27px}.streak-card{display:none}.run-info{padding:12px 0}.actions{margin:14px 0}.board-hud{font-size:11px}.piece{height:95px}.shape{--unit:15px}.page-nav{gap:6px}.back-link{font-size:12px;white-space:nowrap}.feedback-controls button{font-size:10px;padding:7px}.feedback-controls{gap:4px}.tray-heading small{font-size:10px}.message{font-size:12px}.board{padding:6px;gap:2px}.board-row{gap:2px}.cell:nth-child(3n):not(:last-child){margin-right:3px}.board-row:nth-child(3n):not(:last-child){margin-bottom:3px}.cell{border-radius:3px}footer{margin-top:20px}}
@media(max-width:480px){.game-window .game-layout{grid-template-columns:1fr}.game-window .control-panel{padding:12px}.game-window .run-info{padding:8px 0}.game-window .streak-card{display:none}}
@media(min-width:481px){.game-window .shell{max-width:calc(min(360px,max(180px,calc(100svh - 340px))) + 258px)}}
.game-window .message{font-size:11px;min-height:1.7em;margin-top:8px}.game-window .board-caption{margin-top:8px;line-height:1.5}
@media(max-width:360px){.shell{padding:16px 12px}.heading-note{display:none}.piece{height:88px}.shape{--unit:12px}.tray-heading{font-size:11px}.tray-heading small{display:none}}
/* 手机将实时成绩放到棋盘上方，撤销紧随待选块，玩的时候不用向下找。 */
@media(max-width:700px){
  body:not(.game-window) .game-layout{display:flex;flex-direction:column;gap:0}
  body:not(.game-window) .board-section,body:not(.game-window) .control-panel{display:contents}
  body:not(.game-window) .game-layout .stats{order:0;width:100%;background:var(--panel);border:1px solid #ffffff0b;border-radius:12px;padding:12px 14px;margin-bottom:16px}
  body:not(.game-window) .stats>div{display:flex;justify-content:space-between;align-items:center;gap:5px}
  body:not(.game-window) .stats strong{font-size:24px;margin:0}
  body:not(.game-window) .board-hud{order:1;width:100%}
  body:not(.game-window) .board-frame{order:2;width:100%}
  body:not(.game-window) .tray-heading{order:3;width:100%}
  body:not(.game-window) .tray{order:4;width:100%}
  body:not(.game-window) .actions{order:5;width:100%;margin:12px 0 0}
  body:not(.game-window) .board-caption{order:6;width:100%}
  body:not(.game-window) .message{order:7;width:100%}
  body:not(.game-window) .feedback-status{order:8;width:100%}
  body:not(.game-window) .run-info{order:9;width:100%}
  body:not(.game-window) .game-help{order:10;width:100%;margin-top:10px}
  body:not(.game-window) .lb-panel{order:11;width:100%}
}
@media(prefers-reduced-motion:reduce){.cell.just-placed,.cell.just-cleared{animation:none}.piece{transition:none}}

/* 放置反馈和阶段目标；预览是只读提示，不进入屏幕阅读器的实时播报队列。 */
.run-meta{display:flex;justify-content:space-between;gap:10px;margin:0 0 10px;font-size:11px;color:var(--muted)}
[data-ranked="true"] #run-status{color:var(--accent)}
.first-guide{display:flex;align-items:center;gap:12px;border:1px solid #8ed8e335;border-radius:12px;padding:11px 12px;margin-bottom:12px;background:#213844;font-size:12px;line-height:1.7}
.first-guide>span{flex:1;min-width:0}.first-guide small{display:block;color:var(--muted);font-size:10px}.first-guide button{flex:none;padding:6px 9px;font-size:11px}
.goal-bar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px;align-items:center;margin-bottom:13px;font-size:12px;color:var(--muted)}
.goal-bar strong{font-size:11px;color:#f0c383;white-space:nowrap}.goal-bar progress{grid-column:1/-1;appearance:none;border:0;width:100%;height:4px;border-radius:4px;overflow:hidden;background:#ffffff0d}
.goal-bar progress::-webkit-progress-bar{background:#ffffff0d}.goal-bar progress::-webkit-progress-value{background:var(--accent)}.goal-bar progress::-moz-progress-bar{background:var(--accent)}
.placement-preview{font-size:11px;color:var(--accent);min-height:2.8em;margin:10px 0 0;line-height:1.6;overflow-wrap:anywhere}
.placement-preview[data-invalid="true"]{color:#eda9ba}
.drag-ghost{position:fixed;left:0;top:0;z-index:30;pointer-events:none;opacity:.76;filter:drop-shadow(0 8px 10px #0006);will-change:transform}
.drag-ghost[data-invalid="true"]{opacity:.5}.drag-ghost .shape{gap:3px}
.clear-tile{position:absolute;animation:clear-shrink .32s ease-out forwards;transform-origin:center}
@keyframes clear-shrink{0%{transform:scale(1);opacity:1}30%{transform:scale(.9);opacity:.85}100%{transform:scale(.25);opacity:0}}
#final-achievements{white-space:pre-line;line-height:1.9;font-size:12px;color:#f0c383;margin:4px 0}
.play-stats{font-size:12px;color:var(--muted);line-height:1.7;border-top:1px solid #ffffff0b;margin-top:12px;padding-top:8px}
.play-stats summary{color:var(--text);cursor:pointer;padding:6px 0}.play-stats p{margin:8px 0}.play-stats button{font-size:11px;padding:7px 10px}
button:hover:not(:disabled){border-color:var(--accent)}.primary:hover:not(:disabled){background:#a9e6ed}
.feedback-off .clear-tile{animation:none;display:none}
.game-window .run-meta{margin-bottom:7px;font-size:10px}.game-window .first-guide{font-size:10px;padding:7px}.game-window .first-guide small{display:none}
.game-window .goal-bar{font-size:10px;gap:4px;margin-bottom:8px}.game-window .goal-bar strong{font-size:10px}
.game-window .placement-preview{font-size:10px;min-height:1.6em;margin-top:5px}.game-window .play-stats{display:none}
@media(min-width:481px){.game-window .shell{max-width:calc(min(360px,max(180px,calc(100svh - 405px))) + 258px)}}
@media(max-width:700px){
  .shell{padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}
  .heading{margin:10px 0}.heading h1{font-size:32px}.page-nav{margin-bottom:12px}.goal-bar{font-size:11px}
  .first-guide{font-size:10px;padding:9px 10px;margin-bottom:8px;gap:8px}.first-guide small{display:none}
  .piece{height:88px}
  body:not(.game-window) .run-meta{order:-6;width:100%;font-size:10px;margin-bottom:10px}
  body:not(.game-window) .game-layout .stats{order:-5;margin-bottom:12px}
  body:not(.game-window) .first-guide{order:-4;width:100%}
  body:not(.game-window) .goal-bar{order:-3;width:100%}
  body:not(.game-window) .board-frame{width:min(100%,max(240px,calc(100svh - 430px)));align-self:center}
  body:not(.game-window) .placement-preview{order:6;width:100%;margin-top:8px}
  body:not(.game-window) .board-caption{order:7;width:100%;margin-top:5px}
  body:not(.game-window) .message{order:8;width:100%;min-height:1.7em}
  body:not(.game-window) .play-stats{order:11;width:100%;margin-top:8px}
  body:not(.game-window) .lb-panel{order:12}
}
@media(max-height:740px) and (max-width:700px){.heading h1{font-size:29px}.heading-note{display:none}.piece{height:78px}.tray-heading{margin-top:12px}.heading{margin:10px 0}.board-caption{font-size:10px}.actions button{padding:8px 5px}}
@media(orientation:landscape) and (max-height:520px){.shell{padding-top:max(12px,env(safe-area-inset-top))}.heading{margin:8px 0}.heading-note{display:none}.heading h1{font-size:28px}.board-section{max-width:360px}.board-frame{max-width:260px;margin-inline:auto}.piece{height:72px}.shape{--unit:12px}}
@media(prefers-reduced-motion:reduce){.clear-tile{animation:none;display:none}.drag-ghost{filter:none;will-change:auto}}

@media(max-height:740px) and (max-width:700px){
  body:not(.game-window) .board-frame{width:min(100%,max(200px,calc(100svh - 460px)))}
  body:not(.game-window) .game-layout .stats{margin-bottom:8px;padding:10px 12px}
  .heading{margin:7px 0}.heading .eyebrow{display:none}.heading h1{font-size:27px}.page-nav{margin-bottom:8px}
  .tray-heading{margin:10px 0 7px}.placement-preview{min-height:1.6em;margin-top:6px}.actions{margin:8px 0 0}
  .first-guide{padding:7px 9px;line-height:1.5;margin-bottom:6px}
  .game-over{padding:12px}.game-over>.eyebrow{display:none}.game-over h2{font-size:18px;margin:6px 0}
  .game-over>strong{font-size:40px;margin:4px 0}.game-over>p:not(.eyebrow){font-size:10px;margin:7px 0;line-height:1.6}
  #final-achievements{font-size:10px;margin:4px 0}.end-actions{margin-top:8px}.end-actions button{padding:8px 10px;font-size:11px}
}
@media(max-height:620px) and (max-width:700px){.heading .eyebrow{display:none}.heading h1{font-size:24px}}
@media(orientation:landscape) and (max-height:520px) and (min-width:701px){
  body:not(.game-window) .shell{padding:12px max(16px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}
  body:not(.game-window) .heading,body:not(.game-window) footer{display:none}
  body:not(.game-window) .game-layout{grid-template-columns:minmax(0,1fr) 210px;gap:20px}
  body:not(.game-window) .board-section{display:grid;max-width:none;grid-template-columns:minmax(0,1fr) 150px;gap:6px 12px;grid-template-areas:"meta meta" "goal goal" "board heading" "board tray" "board preview" "caption caption" "message message"}
  body:not(.game-window) .run-meta{grid-area:meta;margin:0;font-size:10px}
  body:not(.game-window) .goal-bar{grid-area:goal;margin:0 0 3px}
  body:not(.game-window) .first-guide,body:not(.game-window) .board-hud{display:none}
  body:not(.game-window) .board-frame{grid-area:board;width:min(100%,max(190px,calc(100svh - 175px)));max-width:300px;margin:0 auto;align-self:start}
  body:not(.game-window) .tray-heading{grid-area:heading;margin:0;font-size:11px}.tray-heading small{display:none}
  body:not(.game-window) .tray{grid-area:tray;grid-template-columns:1fr;gap:6px}
  body:not(.game-window) .piece{height:62px;padding:7px 5px}
  body:not(.game-window) .placement-preview{grid-area:preview;min-height:0;margin:0;font-size:10px;line-height:1.5}
  body:not(.game-window) .board-caption{grid-area:caption;margin:0;font-size:10px}
  body:not(.game-window) .message{grid-area:message;margin:0;min-height:1.7em;font-size:11px}
  body:not(.game-window) .control-panel{padding:14px}.stats strong{font-size:24px}.run-info{padding:10px 0}
  body:not(.game-window) .streak-card,body:not(.game-window) .play-stats,body:not(.game-window) .game-help{display:none}
  body:not(.game-window) .actions{margin:12px 0}.actions button{padding:9px 5px}
  body:not(.game-window) .lb-panel{margin-top:10px;padding:0 10px}.lb-panel summary{min-height:44px;gap:5px}.lb-title{font-size:11px}
  body:not(.game-window) .game-over{padding:12px}.game-over h2{font-size:18px;margin:5px 0}.game-over>strong{font-size:40px;margin:3px 0}.game-over>.eyebrow{display:none}
  body:not(.game-window) .game-over>p:not(.eyebrow){font-size:10px;line-height:1.5;margin:6px 0}#final-achievements{font-size:10px}.end-actions button{font-size:11px;padding:8px}
}
