.block-play { --game-play-width: 522px; }
.block-toolbar, .block-stats, .block-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.block-toolbar, .block-stats, .block-status {
  color: var(--game-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.block-toolbar select { min-width: 0; max-width: 100%; }
.block-stats { gap: 4px clamp(10px, 4vw, 20px); margin: 10px 0; font-variant-numeric: tabular-nums; }
.block-stats strong { color: var(--game-ink); }
body[data-fourhao-game="block-puzzle"] {
  --stone-1: #768498;
  --stone-2: #75a68d;
  --stone-3: #c88775;
  --stone-4: #ad92c8;
  --stone-5: #d3a653;
  --stone-6: #72a1c0;
  --stone-7: #9aa65e;
  --frame: #c7bfce;
  --grid: #d9d3df;
  --board-cell: #f2eff5;
  --ghost: #357951;
  --blocked: #b44944;
}
html[data-theme=dark] body[data-fourhao-game="block-puzzle"] {
  --frame: #666075;
  --grid: #463e55;
  --board-cell: #322d3e;
  --ghost: #9cdbb4;
  --blocked: #ff938c;
}
.block-board-frame {
  position: relative;
  width: min(100%, 420px);
  margin-inline: auto;
}
.block-board, .block-effects {
  box-sizing: border-box;
  display: grid;
  grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr));
  gap: clamp(1px, .6vw, 3px);
  width: 100%;
  padding: 5px;
  border: 1px solid var(--frame);
  border-radius: 10px;
}
.block-board {
  position: relative;
  aspect-ratio: 1;
  background: var(--grid);
  touch-action: manipulation;
}
.block-cell {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  appearance: none;
  border: 0;
  border-radius: 3px;
  background: var(--stone, var(--board-cell));
  cursor: crosshair;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.block-cell[data-color], .block-piece-tile, .block-release {
  box-shadow: inset 0 1px 0 #ffffff61, inset 0 -2px 0 #15112232;
}
[data-color="1"] { --stone: var(--stone-1); }
[data-color="2"] { --stone: var(--stone-2); }
[data-color="3"] { --stone: var(--stone-3); }
[data-color="4"] { --stone: var(--stone-4); }
[data-color="5"] { --stone: var(--stone-5); }
[data-color="6"] { --stone: var(--stone-6); }
[data-color="7"] { --stone: var(--stone-7); }
.block-cell[data-preview]::after {
  position: absolute;
  inset: 2px;
  border: 2px solid var(--preview, var(--ghost));
  border-radius: 2px;
  background: color-mix(in srgb, var(--preview, var(--ghost)) 30%, transparent);
  content: "";
  pointer-events: none;
}
.block-cell[data-preview="invalid"] { --preview: var(--blocked); }
.block-cell:focus-visible, .block-slot:focus-visible {
  z-index: 1;
  outline: 2px solid var(--game-accent);
  outline-offset: 1px;
}
.block-effects {
  position: absolute;
  inset: 0;
  padding: 5px;
  border-color: transparent;
  pointer-events: none;
}
.block-release {
  border-radius: 3px;
  opacity: .98;
  background: var(--stone);
}
.block-line-flash {
  z-index: 1;
  align-self: center;
  height: 10%;
  background: #efffdf;
  border-radius: 99px;
  box-shadow: 0 0 9px #fff1c1;
}
.block-line-flash[data-axis="col"] { align-self: stretch; justify-self: center; width: 10%; height: auto; }
.block-tray {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(4px, 1.5vw, 9px);
  width: min(100%, 420px);
  margin: 12px auto 0;
}
.block-slot {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  min-width: 0;
  min-height: 76px;
  padding: 8px 3px;
  appearance: none;
  border: 1px solid var(--game-line);
  border-radius: 9px;
  background: var(--game-soft);
  color: var(--game-muted);
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.block-slot[aria-pressed="true"] {
  border-color: var(--game-accent);
  background: var(--game-accent-soft);
  box-shadow: inset 0 0 0 1px var(--game-accent);
}
.block-slot:disabled { opacity: .56; cursor: default; }
.block-slot[data-empty] { border-style: dashed; }
.block-piece {
  --piece-size: clamp(11px, 4vw, 19px);
  display: grid;
  grid-template: repeat(var(--height), var(--piece-size)) / repeat(var(--width), var(--piece-size));
  gap: 1px;
  pointer-events: none;
}
.block-piece-tile { border-radius: 2px; background: var(--stone); }
.block-drag {
  position: fixed;
  z-index: 15;
  opacity: .66;
  pointer-events: none;
}
.block-drag .block-piece { gap: 2px; }
.block-actions { margin-top: 12px; }
.block-status { min-height: 3.2em; text-align: center; margin: 9px 0 0; }
.block-status[data-error] { color: var(--blocked); }
body[data-fourhao-game="block-puzzle"] .game-page-button[hidden] { display: none; }
.block-result {
  box-sizing: border-box;
  width: min(380px, calc(100% - 28px));
  max-height: calc(100dvh - 32px);
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--game-line);
  border-radius: 16px;
  color: var(--game-ink);
  background: var(--game-surface);
  box-shadow: 0 16px 55px #1b173041;
  text-align: center;
}
.block-result::backdrop { background: #281d3699; }
.block-result h2 { margin: 0 0 7px; font-size: 23px; }
.block-result p { margin: 0; color: var(--game-secondary); line-height: 1.7; }
@media (prefers-reduced-motion: no-preference) {
  .block-result[open] { animation: block-result-in 225ms ease-out both; }
  @keyframes block-result-in {
    from { opacity: 0; transform: translateY(7px) scale(.98); }
    to { opacity: 1; transform: none; }
  }
}
