.ice-play { --game-play-width: 524px; }
.ice-toolbar, .ice-stats, .ice-directions, .ice-actions, .ice-victory-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.ice-toolbar, .ice-stats, .ice-status {
  color: var(--game-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.ice-toolbar select { min-width: 0; max-width: 100%; }
.ice-stats { margin: 12px 0 9px; gap: 5px 20px; font-variant-numeric: tabular-nums; }
.ice-stats strong { color: var(--game-ink); white-space: nowrap; }

.ice-tray {
  --ice-grid: #b7d4e1;
  --ice-paper: #e2f2f8;
  --ice-tile: #e9f6fa;
  --ice-glint: #ffffffad;
  --ice-wall: #6f95b0;
  --ice-wall-hi: #abcbd9;
  --ice-wall-edge: #567b99;
  --ice-dock: #38768d;
  --ice-dock-bg: #d6ebf0;
  --ice-exit: #26705a;
  --ice-exit-bg: #cbeee2;
  --ice-snow: #ad6b12;
  --ice-snow-bg: #ffe3a7;
  --ice-hint: #5a76bb;
  box-sizing: border-box;
  width: min(100%, 446px);
  padding: clamp(5px, 1.5vw, 9px);
  margin-inline: auto;
  border: 1px solid var(--ice-grid);
  border-radius: 13px;
  background: var(--ice-paper);
  box-shadow: 0 3px 0 #667c971d;
}
.ice-tray[data-small] { max-width: 340px; }
html[data-theme=dark] .ice-tray {
  --ice-grid: #476981;
  --ice-paper: #24384d;
  --ice-tile: #29465d;
  --ice-glint: #a9d9fa17;
  --ice-wall: #56728d;
  --ice-wall-hi: #7798b0;
  --ice-wall-edge: #294359;
  --ice-dock: #a3d8e9;
  --ice-dock-bg: #34576c;
  --ice-exit: #b0e7ce;
  --ice-exit-bg: #28665d;
  --ice-snow: #f4d18c;
  --ice-snow-bg: #725222;
  --ice-hint: #afc6ff;
}
.ice-board {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: var(--ice-grid);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.ice-board:focus-visible { outline: 2px solid #4a80c3; outline-offset: 2px; }
.ice-square {
  display: grid;
  place-items: center;
  position: relative;
  box-sizing: border-box;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--ice-grid);
  border-width: 0 1px 1px 0;
  background: linear-gradient(142deg, var(--ice-glint), transparent 57%), var(--ice-tile);
  color: var(--ice-dock);
}
.ice-square[data-cell="#"] {
  background: linear-gradient(140deg, var(--ice-wall-hi), var(--ice-wall) 56%, var(--ice-wall-edge));
  box-shadow: inset 0 0 0 2px var(--ice-wall-edge);
}
.ice-square[data-cell="S"]::before {
  content: "";
  width: 38%;
  height: 38%;
  border-radius: 50%;
  border: 1px dashed var(--ice-grid);
}
.ice-square[data-cell="B"]::before {
  content: "";
  width: 42%;
  height: 42%;
  box-sizing: border-box;
  border: 2px solid var(--ice-dock);
  background: var(--ice-dock-bg);
  border-radius: 5px;
}
.ice-square[data-cell="C"]::before {
  content: "";
  width: 29%;
  height: 29%;
  box-sizing: border-box;
  border: 2px solid var(--ice-snow);
  background: var(--ice-snow-bg);
  transform: rotate(45deg);
  border-radius: 2px;
}
.ice-square[data-cell="C"][data-collected]::before {
  opacity: .42;
  border-width: 1px;
  background: transparent;
}
.ice-square[data-cell="E"] {
  color: var(--ice-exit);
  background: var(--ice-exit-bg);
  box-shadow: inset 0 0 0 2px var(--ice-exit);
  font-size: clamp(13px, 3vw, 22px);
  font-weight: 700;
}
.ice-square[data-hint]::after {
  position: absolute;
  inset: 14%;
  z-index: 1;
  border-radius: 4px;
  border: 1px dashed var(--ice-hint);
  content: "";
}
.ice-square[data-hint-stop]::after { border-width: 2px; border-style: solid; }
.ice-player {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: calc(100% / var(--columns));
  height: calc(100% / var(--rows));
  inset: var(--player-y) auto auto var(--player-x);
  pointer-events: none;
}
.ice-player svg { width: 82%; height: 82%; overflow: visible; }
.ice-directions { margin-top: 12px; }
body[data-fourhao-game=ice-maze] .ice-directions .game-page-button {
  min-width: 44px;
  min-height: 44px;
  padding: 3px 10px;
  font-size: 19px;
  font-weight: 650;
}
body[data-fourhao-game=ice-maze] .ice-directions .game-page-button[data-hint] {
  border-color: #5374bf;
  outline: 2px dashed #5374bf;
  outline-offset: 1px;
  color: #4260a1;
}
html[data-theme=dark] body[data-fourhao-game=ice-maze] .ice-directions .game-page-button[data-hint] { color: #bbd0ff; }
.ice-directions button:active { background: var(--game-accent-soft); }
.ice-actions { margin-top: 10px; }
.ice-status { margin: 9px 0 0; min-height: 1.6em; text-align: center; }
.ice-status[data-warning] { color: #a14239; }
html[data-theme=dark] .ice-status[data-warning] { color: #ffb8ad; }
#show-victory[hidden], #next-level[hidden], #checkpoints[hidden] { display: none; }
.ice-victory {
  box-sizing: border-box;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--game-line);
  border-radius: 14px;
  color: var(--game-secondary);
  background: var(--game-surface);
  box-shadow: 0 18px 54px #14243840;
  overscroll-behavior: contain;
}
.ice-victory::backdrop { background: #1326348c; }
.ice-victory-body { padding: 24px clamp(18px, 6vw, 32px); text-align: center; }
.ice-victory h2 { margin: 0; color: var(--game-accent); font-size: 22px; line-height: 1.45; }
.ice-victory p { margin: 9px 0 16px; line-height: 1.65; }

@media (prefers-reduced-motion: no-preference) {
  .ice-victory[open] { animation: ice-result-in 220ms ease-out; }
  @keyframes ice-result-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
