/* 2048 的关卡、复盘和主题独立于其它游戏。 */
[data-game="2048"] .lab-tools { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
[data-game="2048"] .lab-tools :is(a,button) { padding:6px 9px; font-size:11px; line-height:1.5; border:1px solid #3c4656; border-radius:8px; background:#1a202b; color:#d2dbea; text-decoration:none; cursor:pointer; }
[data-game="2048"] .run-meta { display:flex; justify-content:space-between; gap:8px; margin-top:7px; color:#9ca9bc; font-size:11px; }
[data-game="2048"] .practice-note { padding:9px 11px; border:1px solid #726040; background:#342b1d; color:#f3d399; border-radius:10px; font-size:12px; line-height:1.6; }
[data-game="2048"] .practice-note button { padding:3px 8px; margin-left:6px; font-size:11px; }
[data-game="2048"] .tile-inner:is(.len7,.len8,.len9) { font-size:calc(var(--cell-size) * .19); }
[data-game="2048"] .tile-inner.material-tile { font-size:calc(var(--cell-size) * var(--tile-font-scale,.44)); }
[data-game="2048"] .end-stats { display:grid; grid-template-columns:repeat(2,1fr); gap:8px 20px; font-size:12px; color:#cbd6e6; margin:2px 0 8px; }
[data-game="2048"] .end-stats strong { color:#ffe0a0; }
[data-game="2048"] .end-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:7px; }
[data-game="2048"] .end-actions button { padding:7px 10px; font-size:12px; }
[data-game="2048"] .overlay p { max-width:32em; }
:is([data-game="2048"],[data-game="2048-challenges"]) .fx-number-orbit { width:var(--orbit-size); height:var(--orbit-size); border:2px solid var(--fx-color); border-radius:50%; box-shadow:0 0 14px var(--fx-color),inset 0 0 8px var(--fx-color); animation:number-orbit .85s cubic-bezier(.16,.65,.22,1) var(--orbit-delay) both; }
:is([data-game="2048"],[data-game="2048-challenges"]) .fx-number-ray { width:var(--ray-length); height:2px; transform-origin:0 50%; border-radius:100%; background:linear-gradient(90deg,transparent,var(--fx-color),transparent); animation:number-ray .8s cubic-bezier(.13,.7,.28,1) both; }
:is([data-game="2048"],[data-game="2048-challenges"]) .fx-number-star { color:var(--fx-color); font-size:17px; text-shadow:0 0 8px var(--fx-color); animation:number-star .95s ease-out both; }
:is([data-game="2048"],[data-game="2048-challenges"]) .fx-number-crown { animation:number-crown .95s ease-out; }
@keyframes number-orbit { 0% { transform:translate(-50%,-50%) scale(.15) rotateX(50deg); opacity:.9; } 45% { opacity:.65; } 100% { transform:translate(-50%,-50%) scale(2.2) rotateX(50deg); opacity:0; } }
@keyframes number-ray { 0% { transform:rotate(var(--ray-angle)) translateX(12px) scaleX(.1); opacity:0; } 20% { opacity:.8; } 100% { transform:rotate(var(--ray-angle)) translateX(90px) scaleX(1); opacity:0; } }
@keyframes number-star { 0% { transform:translate(-50%,-50%) scale(.2); opacity:0; } 20% { opacity:1; } 100% { transform:translate(var(--dx),var(--dy)) scale(.4) rotate(120deg); opacity:0; } }
@keyframes number-crown { 25% { box-shadow:inset 0 0 0 2px #ffffffa0,0 0 25px #d0bcff80; } 100% { box-shadow:none; } }
@media(prefers-reduced-motion:reduce) { :is([data-game="2048"],[data-game="2048-challenges"]) .fx-number-crown { animation:none; } }
.lab-dialog { width:min(560px,calc(100vw - 28px)); max-height:calc(100dvh - 36px); overflow:auto; padding:24px; border:1px solid #414c5f; border-radius:22px; background:#151c27; color:#edf3fb; box-shadow:0 30px 120px #0009; font-family:inherit; }
.lab-dialog::backdrop { background:#050a13bd; backdrop-filter:blur(8px); }
.lab-dialog-top { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.lab-dialog h2 { margin:4px 0 0; font-size:25px; letter-spacing:-.035em; }
.lab-eyebrow { margin:0; color:#e6b56b; font-size:10px; letter-spacing:.14em; }
.lab-close { width:34px; height:34px; padding:0; flex:none; font-size:22px; }
.lab-description { color:#a9b7ca; font-size:12px; line-height:1.8; margin:16px 0 20px; }
.theme-dialog { width:min(760px,calc(100vw - 28px)); }
.theme-dialog[open] { display:flex; flex-direction:column; overflow:hidden; }
.theme-dialog > :is(.lab-dialog-top,.lab-description) { flex:none; }
.theme-dialog .lab-content { overflow:auto; min-height:0; padding:2px 3px 6px; scrollbar-width:thin; }
.theme-toolbar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; margin-bottom:15px; }
.theme-filters { display:flex; gap:4px; padding:3px; border:1px solid #ffffff1a; background:#00000015; border-radius:9px; }
.theme-filters button { font-size:11px; padding:5px 11px; background:transparent; border-color:transparent; border-radius:6px; }
.theme-filters button[aria-pressed="true"] { background:#788ba033; border-color:#9faec533; }
.theme-selection { margin:0; color:inherit; opacity:.75; font-size:11px; }
.theme-picker { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.theme-picker > button { display:flex; flex-direction:column; align-items:stretch; padding:9px; text-align:left; min-width:0; border:1px solid #8191a442; border-radius:13px; background:#788ba012; transition:border-color .15s,box-shadow .15s; }
.theme-picker > button[aria-pressed="true"] { border-color:var(--accent,#e9b364); box-shadow:0 0 0 1px var(--accent,#e9b364); }
.theme-card-label { display:flex; align-items:center; justify-content:space-between; gap:5px; margin:10px 2px 1px; }
.theme-picker strong { font-size:12px; font-weight:600; margin:0; }
.theme-selected { font-size:12px; color:var(--accent,#e9b364); }
.theme-swatch { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(0,1fr)); gap:5px; height:105px; border-radius:8px; padding:7px; background:var(--preview-board); border:1px solid var(--preview-edge); }
.theme-swatch > span { display:grid; place-items:center; min-width:0; font-size:calc(clamp(12px,2.4vw,17px) * var(--tile-preview-fit,1)); font-weight:700; border-radius:5px; }
[data-theme="ink"] .theme-swatch { border-radius:3px 7px 4px 6px; background:repeating-linear-gradient(91deg,#53664008 0 1px,transparent 1px 3px),var(--preview-board); }
[data-theme="glass"] .theme-swatch { border-radius:12px; background:radial-gradient(at 0 0,#cdc2e7,transparent),var(--preview-board); }
[data-theme="walnut"] .theme-swatch { background:repeating-linear-gradient(94deg,#0e060a11 0 1px,transparent 1px 7px),var(--preview-board); box-shadow:inset 0 1px 2px #0005; }
[data-theme="brass"] .theme-swatch { border-radius:3px; border-color:#b2945880; box-shadow:inset 0 0 0 2px #070908; }
[data-theme="paper"] .theme-swatch { border-radius:3px; box-shadow:1px 2px 0 #77654c25; }
[data-theme="ocean"] .theme-swatch { background:radial-gradient(ellipse at 15% 0%,#27728277,transparent 75%),var(--preview-board); border-radius:13px; }
[data-theme="pixel"] .theme-swatch { border-radius:0; border:2px solid var(--preview-edge); box-shadow:inset 0 0 0 2px #0d1420; }
.collection-details { margin-top:20px; border-top:1px solid #8191a440; padding-top:15px; }
.collection-details > summary { cursor:pointer; color:inherit; font-size:12px; }
.theme-demo-row { display:flex; align-items:end; flex-wrap:wrap; gap:10px; margin-top:16px; }
.theme-demo-row label { display:flex; flex:1 1 110px; align-items:center; gap:8px; font-size:11px; color:var(--muted,#a7b8cf); }
.theme-demo-row select { min-width:0; flex:1; padding:9px 7px; border:1px solid #8191a466; border-radius:7px; color:inherit; background:var(--panel,#1a2534); font:inherit; }
.theme-demo { flex:1 1 130px; margin:0; padding:10px; font-size:12px; }
.collection-heading { margin:24px 0 12px; font-size:12px; color:#bcc9dc; }
.evolution-collection { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.collection-tile { display:flex; min-height:72px; flex-direction:column; align-items:center; justify-content:center; gap:5px; border:1px solid #ffffff14; border-radius:10px; color:#fff; }
.collection-tile strong { font-size:calc(20px * var(--tile-number-fit,1)); }
.collection-tile small { font-size:10px; color:#d1deeb; }
.collection-tile.undiscovered { background:#202b3a; color:#78889f; border-style:dashed; }
.collection-tile.undiscovered small { color:#78889f; }
.review-summary { padding:10px; border-radius:9px; color:#dbbc8a; background:#2b2a29; font-size:11px; text-align:center; line-height:1.7; }
.review-board { width:min(100%,300px); aspect-ratio:1; margin:18px auto 12px; display:grid; grid-template-columns:repeat(4,1fr); gap:7px; padding:9px; border-radius:14px; background:#293446; }
.review-board span { display:grid; place-items:center; border-radius:7px; background:#354154; color:#f6f9ff; font-size:clamp(14px,5vw,23px); font-weight:700; min-width:0; }
.review-board > .material-tile { font-size:calc(clamp(14px,5vw,23px) * var(--tile-number-fit,1)); }
.review-caption { font-size:12px; color:#b9c8db; text-align:center; min-height:1.6em; }
.review-controls { display:flex; align-items:center; gap:12px; }
.review-controls input { width:100%; accent-color:#e8b565; }
.review-controls button { width:40px; padding:8px; }
.review-actions { display:flex; justify-content:center; gap:8px; margin-top:18px; }
.review-actions button { font-size:12px; }
@media(min-width:760px) {
  body:not(.game-window) [data-game="2048"] > .practice-note { grid-column:1 / -1; grid-row:7; }
}
@media(max-width:759px) {
  body:not(.game-window) [data-game="2048"] > .practice-note { order:3; }
  [data-game="2048"] .lab-tools { margin-top:5px; }
  [data-game="2048"] .lab-tools :is(a,button) { padding:5px 8px; }
  [data-game="2048"] .overlay { padding:16px; gap:8px; }
}
.game-window [data-game="2048"] .lab-tools { gap:4px; }
.game-window [data-game="2048"] .lab-tools :is(a,button) { font-size:10px; padding:4px 5px; }
.game-window [data-game="2048"] .practice-note { grid-column:1 / -1; grid-row:6; }
.game-window [data-game="2048"] .end-stats { gap:5px 12px; font-size:10px; }
.game-window [data-game="2048"] .end-actions button { font-size:10px; padding:5px 7px; }
@media(max-width:420px) {
  .lab-dialog { padding:18px; border-radius:17px; }
  .lab-dialog h2 { font-size:22px; }
  .theme-picker { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }.theme-picker > button { padding:7px; }
  .theme-picker strong { font-size:11px; }.theme-swatch { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:repeat(3,minmax(0,1fr)); height:95px; gap:4px; padding:6px; }
  .theme-toolbar { gap:8px; }.theme-filters button { padding:5px 10px; }
  .evolution-collection { gap:6px; }.collection-tile { min-height:62px; }
}
@media(pointer:coarse) {
  body:not(.game-window) :is(.feedback-controls button,.lab-tools a,.lab-tools button,.review-controls button,.lab-close,.review-actions button,.challenge-actions button) { min-height:40px; }
  body:not(.game-window) .feedback-controls button { font-size:11px; }
}
@media(pointer:coarse) and (orientation:landscape) and (min-width:600px) and (max-height:500px) {
  body:not(.game-window):has([data-game="2048"]) { --board-size:min(400px,calc(100svh - 82px),calc(100vw - 280px)); --cell-size:calc((var(--board-size) - 5 * var(--gap)) / 4); padding:12px; }
  body:not(.game-window) .shell[data-game="2048"] { display:grid; width:calc(var(--board-size) + 240px); grid-template-columns:var(--board-size) minmax(0,1fr); gap:10px 16px; }
  body:not(.game-window) .shell[data-game="2048"] > .page-nav { grid-column:1 / -1; grid-row:1; margin:0; }
  body:not(.game-window) .shell[data-game="2048"] > .board { grid-column:1; grid-row:2 / 5; }
  body:not(.game-window) .shell[data-game="2048"] > header { grid-column:2; grid-row:2; flex-direction:column; align-items:stretch; gap:6px; margin:0; }
  body:not(.game-window) [data-game="2048"] h1 { font-size:28px; }
  body:not(.game-window) [data-game="2048"] .goal-card { margin:0; padding:6px 8px; }
  body:not(.game-window) [data-game="2048"] .scores { gap:6px; }
  body:not(.game-window) [data-game="2048"] .score-card { flex:1; min-width:0; padding:5px 8px; }
  body:not(.game-window) .shell[data-game="2048"] > .toolbar { grid-column:2; grid-row:3; margin:0; }
  body:not(.game-window) [data-game="2048"] .toolbar > .hint { display:none; }
  body:not(.game-window) [data-game="2048"] .actions { display:grid; width:100%; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
  body:not(.game-window) [data-game="2048"] .actions button { min-width:0; min-height:40px; padding:6px 2px; font-size:12px; }
  body:not(.game-window) .shell[data-game="2048"] > :is(.ai-bar,.game-help,footer,.lb-panel,.practice-note) { grid-column:1 / -1; grid-row:auto; }
}

/* 主题工作台：同一组数字比较所有材质，试播不离开面板。 */
.lab-dialog,.theme-library { overscroll-behavior:contain; }
.theme-dialog { width:min(960px,calc(100vw - 24px)); }
.theme-dialog .lab-description { margin:8px 0 16px; }
.theme-workspace { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,.94fr); gap:24px; align-items:start; }
.theme-library { max-height:min(590px,calc(100dvh - 210px)); overflow:auto; scrollbar-width:thin; padding:2px 4px 8px 2px; }
.theme-workspace .theme-picker { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.theme-workspace .theme-toolbar { gap:8px; }
.theme-workspace .theme-selection { display:none; }
.theme-preview { position:sticky; top:0; min-width:0; padding:16px; border:1px solid #8191a433; border-radius:16px; background:var(--panel,#1a2534); }
.theme-preview-title { margin:0; font-size:17px; font-weight:650; letter-spacing:-.02em; }
.theme-preview-stage.review-board { position:relative; width:100%; max-width:320px; margin:14px auto 10px; }
.theme-preview-tiles { display:contents; }
.theme-preview-tiles > span { min-width:0; font-size:calc(clamp(13px,2.2vw,22px) * var(--tile-number-fit,1)); }
.theme-preview-status { min-height:18px; margin:8px 0 12px; color:var(--muted,#a7b8cf); font-size:11px; text-align:center; }
.theme-trials { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; padding:4px; border:1px solid #8191a433; border-radius:10px; }
.theme-trials button { min-width:0; min-height:36px; padding:7px 4px; font-size:11px; border:0; background:transparent; }
.theme-trials button:hover:not(:disabled) { background:color-mix(in srgb,var(--accent,#e9b364) 14%,transparent); }
.theme-preview .theme-demo-row { margin-top:12px; }
.theme-preview .theme-demo-row label { flex-basis:100%; }
.theme-preview .theme-demo { flex-basis:100%; min-height:36px; }
.theme-preview .theme-demo-row select { color:var(--text,#edf3fb); background-color:var(--panel,#1a2534); }
.theme-preview-fx.theme-viewport-fx { position:absolute; z-index:6; border-radius:inherit; }
.preview-slide { animation:preview-slide .24s cubic-bezier(.2,.7,.2,1) both; }
.preview-merge { animation:preview-merge .26s ease-out both; }
@keyframes preview-slide { from { transform:translateX(var(--preview-travel)); } to { transform:translateX(0); } }
@keyframes preview-merge { 0% { transform:scale(.84); } 55% { transform:scale(1.08); } 100% { transform:scale(1); } }
@media(max-width:700px) {
  .theme-workspace { grid-template-columns:minmax(0,1fr); gap:16px; }
  .theme-library { grid-row:2; max-height:none; overflow:visible; padding:0 2px 4px; }
  .theme-preview { grid-row:1; z-index:2; top:-1px; padding:12px; border-radius:12px; }
  .theme-dialog .lab-content { padding-top:0; }
  .theme-preview-stage.review-board { width:min(220px,100%); margin:8px auto; gap:5px; padding:7px; }
  .theme-preview-title { font-size:14px; }
  .theme-preview-status { margin:5px 0 8px; font-size:10px; }
  .theme-preview .theme-demo-row { margin-top:8px; flex-wrap:nowrap; align-items:center; gap:8px; }
  .theme-preview .theme-demo-row label { flex-basis:100px; font-size:10px; }
  .theme-preview .theme-demo { flex:0 0 82px; font-size:11px; }
  .theme-preview .theme-demo-row select { width:80px; padding:7px 4px; }
  .theme-workspace .theme-swatch { height:76px; }
}
@media(max-height:650px) { .theme-preview { position:relative; }.theme-preview-stage.review-board { width:min(180px,100%); } }
@media(max-width:360px) { .theme-preview { padding:10px; }.theme-preview-stage.review-board { width:min(180px,100%); }.theme-dialog .lab-description { font-size:11px; line-height:1.5; margin:6px 0 10px; } }
@media(pointer:coarse) { .theme-trials button,.theme-preview .theme-demo { min-height:40px; } }
@media(prefers-reduced-motion:reduce) { .preview-slide,.preview-merge { animation:none; } }
