.arcade-page[data-game="klotski"] {
  --game-ink: #fff4e6;
  --game-muted: #e1c4ad;
  --game-line: #87634b;
  --game-accent: #ffcf89;
  background: radial-gradient(ellipse at 74% 10%, #593b2a, transparent 64%), #201613;
}
.arcade-page[data-game="klotski"] .merge-nav { border-color: #a67e5f45; }
.arcade-page[data-game="klotski"] .merge-nav-button {
  border-color: #88634a;
  background: linear-gradient(158deg, #4b3428, #34231c);
  color: #f8e5d4;
  box-shadow: inset 0 1px #ffdfc41a, 0 2px #140b0870;
}
.arcade-page[data-game="klotski"] .merge-nav-button:hover {
  border-color: #c2936c;
  background: linear-gradient(158deg, #5f4232, #432d23);
  color: #fff5e8;
}
.arcade-page[data-game="klotski"] .wallet-button {
  border-color: #c79853;
  background: linear-gradient(158deg, #4f391d, #362614);
  color: #ffe7a8;
}
.arcade-page[data-game="klotski"] .game-tool[aria-pressed="true"] {
  border-color: #e6bd70;
  background: #533a22;
  color: #ffe8ad;
}
.arcade-page[data-game="klotski"] .merge-button {
  border-color: #8f684e;
  background: linear-gradient(158deg, #51382b, #3a271f);
  color: #faebdc;
  box-shadow: inset 0 1px #ffe2c71a, 0 2px #150c0970;
}
.arcade-page[data-game="klotski"] .merge-button:hover:not(:disabled) {
  border-color: #c99972;
  background: linear-gradient(158deg, #654736, #4b3227);
  color: #fff6ea;
}
.arcade-page[data-game="klotski"] .merge-button:disabled {
  border-color: #5d4537;
  background: #2f211b;
  color: #a68c79;
  box-shadow: none;
}
.arcade-page[data-game="klotski"] .merge-primary {
  border-color: #f4c673;
  background: linear-gradient(160deg, #ffe2a4, #f1b95f);
  color: #2c190c;
}
.arcade-page[data-game="klotski"] .merge-dialog:not(.game-leaderboard):not(.klotski-map):not(.klotski-result) {
  background: #33241d;
  border-color: #8f694f;
  color: #fff2e3;
}
.arcade-page[data-game="klotski"] .game-menu-links a {
  border-color: #8a644b;
  background: #463126;
  color: #faecde;
}
.arcade-page[data-game="klotski"] .game-menu-links a[aria-current="page"] {
  border-color: #efc473;
  background: #614328;
  color: #ffe8ad;
}
.arcade-page[data-game="klotski"] .game-wallet {
  background: linear-gradient(150deg, #432e23, #2c1e18);
  border-color: #c2955d;
}
.klotski-layout { padding: clamp(.55rem, 1.4vw, .95rem) 0 1.2rem; }
.klotski-launch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .52rem; margin: .72rem 0 .55rem; }
.klotski-campaign { margin-top: .5rem; }
.klotski-launch-card {
  display: grid; grid-template-columns: 1fr auto; gap: .3rem .15rem; align-items: center; min-height: 4.5rem; min-width: 0;
  padding: .62rem .75rem; border: 1px solid #a47b58; border-radius: .78rem; text-align: left;
  color: #ffedda; background: linear-gradient(145deg, #664734, #473129); font: inherit; cursor: pointer;
  transition: transform var(--xh-dur-fast, 180ms) var(--xh-ease-spring, ease), border-color var(--xh-dur-fast, 180ms) var(--xh-ease-spring, ease);
}
.klotski-launch-card > strong { grid-area: 1 / 1; font-size: 1rem; }
.klotski-launch-card > small { grid-area: 2 / 1 / 3 / -1; color: #f5d7be; font-size: .75rem; overflow-wrap: anywhere; }
.klotski-route-mark { grid-area: 1 / 2; color: #ffd18b; font-weight: 900; }
.klotski-daily-card { border-color: #b48a5b; background: linear-gradient(145deg, #523b2c, #38271f); }
.klotski-daily-card small { color: #f5dbbd; }
.klotski-daily-card[aria-pressed="true"] { border-color: #f4cf86; background: linear-gradient(145deg, #68492e, #483121); }
.klotski-help { font-size: .84rem; max-width: 23rem; color: #f1d6c7; }
.klotski-help summary { min-height: 44px; padding-block: .62rem; width: fit-content; cursor: pointer; }
.klotski-help p { margin-bottom: .5rem; }
.klotski-stage {
  --castle-width: min(17.5rem, calc((100dvh - 23.2rem) * .8)); --gate-trim: #ad784d; --gate-wood: #704832; --floor-surface: #322019;
  --floor-grid: #e5ad7d30; --gate-glow: #ffe0a799;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center;
  padding: clamp(.62rem, 1.5vw, .95rem) clamp(.75rem, 2vw, 1.35rem);
}
.klotski-stage[data-look="brick"] { --gate-trim: #b67a62; --gate-wood: #754536; --floor-surface: #361f24; }
.klotski-stage[data-look="jade"] { --gate-trim: #809278; --gate-wood: #4d5d48; --floor-surface: #252e27; --floor-grid: #ccd4ae30; }
.klotski-stage[data-look="night"] {
  --gate-trim: #8790ad; --gate-wood: #4c566a; --floor-surface: #242b42; --floor-grid: #bac4ea28;
  background: radial-gradient(ellipse at 58% 0%, #48516f 0, #2c2c3c 65%, #202839 115%);
}
.klotski-stage :is(.klotski-heading, .klotski-tally, .klotski-frame, .klotski-tools) { width: min(100%, var(--castle-width)); max-width: none; }
.klotski-heading { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin: 0 auto .48rem; }
.klotski-heading p { margin: 0; color: #f0c8ac; line-height: 1.2; font-size: .73rem; font-weight: 650; }
.klotski-heading h2 { margin: .13rem 0 0; color: #ffe8d5; font-size: clamp(1.22rem, 3.6vw, 1.65rem); line-height: 1.2; }
.klotski-stage .klotski-tally { margin-bottom: .49rem; }
.klotski-tally > div { padding: .3rem .18rem .24rem; }
.klotski-tally dt { font-size: .72rem; white-space: nowrap; }
.klotski-tally dd { margin: 0; color: #ffe5b3; font-size: clamp(1.06rem, 3.7vw, 1.39rem); line-height: 1.18; font-weight: 850; font-variant-numeric: tabular-nums; }
.klotski-tally > div:nth-child(2) { border-color: #c39362; background: #533a30; }
.klotski-stage .klotski-frame {
  border: 1px solid var(--gate-trim); border-top: .28rem solid var(--gate-trim);
  background: repeating-linear-gradient(92deg, #2e181611 0 2px, transparent 2px 21px), var(--gate-wood);
  box-shadow: 0 .44rem 0 #201610, 0 .85rem 1.8rem #1a11168c;
}
.klotski-frame .klotski-board {
  background-color: var(--floor-surface);
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--floor-grid) calc(25% - 1px) 25%),
    repeating-linear-gradient(180deg, transparent 0 calc(20% - 1px), var(--floor-grid) calc(20% - 1px) 20%);
}
.klotski-stage .klotski-exit { transition: box-shadow .18s, background .18s; }
.klotski-stage.is-near-exit .klotski-exit { color: #ffecc7; background: #684122; box-shadow: 0 -.2rem 1rem var(--gate-glow); }
.klotski-stage .klotski-board.is-solved + .klotski-exit { color: #e0f9c0; background: #354c31; box-shadow: 0 -.15rem .75rem #b8e99263; }
.klotski-piece.is-last { filter: brightness(1.07); }
.klotski-board.is-solved .klotski-lead { outline: 2px solid #ffc66d; outline-offset: -3px; filter: brightness(1.12); }
.klotski-target {
  position: absolute; z-index: 2; display: grid; place-items: center; touch-action: manipulation;
  inset: calc(var(--y) * 20% + 3px) auto auto calc(var(--x) * 25% + 3px);
  width: calc(var(--w) * 25% - 6px); height: calc(var(--h) * 20% - 6px);
  margin: 0; padding: 0; border: 1px dashed #f3ce94; border-radius: .4rem; background: #b8773649;
  color: #ffe7ba; font: 850 clamp(1.12rem, 4vw, 1.53rem)/1 var(--sans); cursor: pointer;
}
.klotski-target.is-hinted { background: #9a6427; border: 2px solid #fff0bf; color: #fff6dc; }
.klotski-board.is-dragging .klotski-target { visibility: hidden; }
.klotski-guide { margin: .34rem auto 0; text-align: center; color: #f6ddc7; font-size: .81rem; line-height: 1.35; }
.klotski-tools { margin-top: .34rem; }
.klotski-tools .arcade-status { margin-top: .12rem; block-size: 1.8em; color: #ffe3b5; }
.klotski-tools .arcade-actions { justify-content: center; margin-top: .32rem; }
.klotski-tools .arcade-actions button { min-height: 40px; }
.klotski-medal, .klotski-result-medal {
  display: inline-block; width: fit-content; padding: .22rem .45rem; border-radius: .37rem;
  border: 1px solid #efc19985; color: #1d1711; font-size: .75rem; line-height: 1.2; font-weight: 850; white-space: nowrap;
}
.klotski-medal[data-medal="gold"], .klotski-result-medal[data-medal="gold"] { background: linear-gradient(140deg, #fff1bc, #e9ae54); }
.klotski-medal[data-medal="silver"], .klotski-result-medal[data-medal="silver"] { background: linear-gradient(140deg, #eef6ff, #b2c5e0); }
.klotski-medal[data-medal="bronze"], .klotski-result-medal[data-medal="bronze"] { background: linear-gradient(140deg, #f5d4b8, #d7a584); }
.klotski-map, .klotski-result {
  width: min(34rem, calc(100% - 1.35rem)); max-height: 88dvh; overflow: auto;
  border-color: #a07a60; background: radial-gradient(ellipse at 35% 0%, #634834, transparent 69%), #312721; color: #fff0df;
}
.klotski-result .game-dialog-header {
  position: sticky; top: -.85rem; z-index: 3; padding: .33rem .1rem;
  border-radius: .42rem; background: #4b362a; box-shadow: 0 .18rem .7rem #271b1680;
}
.klotski-dialog-note { margin: .52rem 0 .65rem; color: #f0cfb3; font-size: .86rem; }
.klotski-map-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem;
  list-style: none; margin: 0; padding: 0;
}
.klotski-chapter {
  display: grid; grid-template-columns: minmax(1.65rem, 2.6rem) minmax(0, 1fr);
  gap: .46rem; align-items: center; width: 100%; min-height: 4.5rem; padding: .48rem; text-align: left;
  border: 1px solid #a5836b; border-radius: .64rem; color: #fff0e1; background: #523a2e; font: inherit; cursor: pointer;
}
.klotski-chapter[aria-current="true"] { border-color: #f4ce91; background: #694932; }
.klotski-chapter[data-state="passed"] { background: #57472f; border-color: #d6af65; }
.klotski-chapter[data-state="next"] { box-shadow: inset 0 0 1.2rem #ffd29529; border-color: #f6cf87; }
.klotski-map[open] .klotski-chapter[data-state="next"] { animation: unlock-glow .65s ease-out both; }
.klotski-chapter[data-state="locked"] { background: #403932; border-color: #796a5d; opacity: .76; cursor: default; }
.klotski-chapter[data-state="locked"] .klotski-preview { filter: grayscale(1) brightness(.77); }
.klotski-chapter-intro { grid-column: 1/-1; padding: .55rem .3rem .16rem; color: #ffe2b0; }
.klotski-chapter-intro p { margin: .2rem 0 0; font-size: .83rem; line-height: 1.45; color: #edd4be; }
.klotski-heading .klotski-story-tag { margin-top: .2rem; color: #ffe0a5; }
.klotski-result .campaign-prize { color: #fadc9f; }
.klotski-chapter-text { display: grid; min-width: 0; gap: .16rem; }
.klotski-chapter strong { font-size: .95rem; line-height: 1.15; }
.klotski-chapter small { color: #f2d8c4; font-size: .71rem; }
.klotski-chapter .klotski-medal { font-size: .67rem; padding: .16rem .3rem; }
.klotski-preview { display: block; width: 100%; position: relative; aspect-ratio: 4 / 5; border: 1px solid #b6956d; border-radius: .29rem; background: #30211b; }
.klotski-preview > span {
  position: absolute; inset: calc(var(--y) * 20% + 1px) auto auto calc(var(--x) * 25% + 1px);
  width: calc(var(--w) * 25% - 2px); height: calc(var(--h) * 20% - 2px); border-radius: .14rem; background: #c29a6f;
}
.klotski-preview .klotski-preview-lead { background: #f7c77b; }
.klotski-preview .klotski-preview-partner { background: #dd9ca6; }
.klotski-preview .klotski-preview-scout { background: #a8b990; }
.klotski-preview span.is-moved { outline: 2px solid #fff3cc; outline-offset: -2px; }
.klotski-result-main {
  display: flex; gap: .72rem; align-items: center; padding: .68rem .72rem; margin-top: .66rem; border: 1px solid #caa273;
  border-radius: .72rem; background: linear-gradient(125deg, #543e2c, #413527);
}
.klotski-result-main strong { color: #fff2de; font-size: clamp(.91rem, 4vw, 1.17rem); }
.klotski-result-main p { color: #ffe1c3; font-size: .83rem; line-height: 1.42; margin: .2rem 0 0; }
.klotski-result-medal {
  display: grid; flex: none; place-items: center; min-width: 3rem; aspect-ratio: 1; padding: .43rem;
  border: 2px solid #fee2a3; border-radius: .62rem; line-height: 1; font-size: .94rem; box-shadow: 0 .16rem 0 #21160ea1;
}
.klotski-result-actions { justify-content: flex-start; }
.klotski-result-actions .merge-button { min-height: 44px; }
.klotski-replay { border-top: 1px solid #b38f7194; margin-top: .7rem; padding-top: .65rem; text-align: center; }
.klotski-replay .merge-modes { width: fit-content; margin: 0 auto .62rem; }
.klotski-replay-board { width: min(100%, 11rem, 25dvh); margin-inline: auto; }
.klotski-replay-board > span { border-radius: .25rem; }
.klotski-replay-controls { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .45rem; align-items: center; }
.klotski-replay-controls input { width: 100%; accent-color: #efc286; }
.klotski-replay-controls .merge-button { min-height: 44px; min-width: 44px; padding: .4rem; }
.klotski-layout :is(button, summary):focus-visible, :is(.klotski-result, .klotski-map) :is(button, input):focus-visible {
  outline: 2px solid #fff0bf; outline-offset: 2px;
}
.game-focus .klotski-stage { --castle-width: min(100%, 23rem, max(13rem, calc(78dvh - 9.5rem))); }
.game-focus .klotski-stage :is(.klotski-heading, .klotski-tally, .klotski-frame, .klotski-tools) { width: min(100%, var(--castle-width)); }

@keyframes klotski-stamp {
  from { opacity: .25; transform: rotate(-6deg) scale(1.26); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .klotski-result[open] .klotski-result-medal { animation: klotski-stamp var(--xh-dur-base, 260ms) var(--xh-ease-pop, cubic-bezier(.34, 1.38, .64, 1)) both; }
}
.game-reduced-motion :is(.klotski-result-medal, .klotski-launch-card, .klotski-exit) { animation: none !important; transition: none !important; }
@media (hover: hover) {
  .klotski-launch-card:hover { transform: translateY(-2px); border-color: #fbd5a3; }
  .klotski-chapter:not(:disabled):hover, .klotski-target:hover { border-color: #ffdfae; filter: brightness(1.13); }
}
@media (max-width: 50rem) {
  .klotski-launch { margin: .45rem 0 .25rem; gap: .42rem; }
  .klotski-launch-card { min-height: 3.15rem; padding: .36rem .5rem; }
  .klotski-campaign { margin-top: .32rem; }
  .klotski-campaign .campaign-actions .merge-button { min-height: 38px; padding-block: .22rem; font-size: .8rem; }
  .klotski-help summary { min-height: 35px; padding-block: .37rem; }
  .klotski-stage { --castle-width: min(16.2rem, 68vw); padding: .55rem; }
  .klotski-heading { margin-bottom: .32rem; }
  .klotski-stage .klotski-tally { margin-bottom: .35rem; }
  .klotski-tools { margin-top: .32rem; }
  .klotski-guide { margin-top: .25rem; font-size: .78rem; }
}
@media (orientation: landscape) and (min-width: 30rem) {
  .game-focus .klotski-stage.game-compact-play { --castle-width: 100%; grid-template-columns: minmax(0, calc(var(--game-wide-board) * .8 - 1.1rem)) minmax(0, 1fr); }
  .game-focus .klotski-stage :is(.klotski-heading, .klotski-tally) { margin-bottom: 0; }
  .game-focus .klotski-tools .arcade-actions { justify-content: flex-start; }
}
@media (orientation: landscape) and (max-height: 35rem) {
  .game-focus .klotski-launch { gap: .3rem; }
  .game-focus .klotski-launch-card { min-height: 44px; gap: .24rem; padding: .36rem .53rem; }
  .game-focus .klotski-launch-card small { display: none; }
  .game-focus .klotski-stage { padding: .55rem; }
}
