.water-sort-play { --game-play-width: 600px; }

.water-controls, .water-stats, .water-actions, .water-victory-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.water-controls, .water-stats, .water-status {
  color: var(--game-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.water-controls select { max-width: 100%; min-width: 0; }
.water-stats { gap: 4px clamp(10px, 2vw, 25px); margin: 14px 0 10px; }
.water-stats strong { color: var(--game-ink); font-variant-numeric: tabular-nums; }
.water-board {
  --water-tray: #e7edef;
  --water-rim: #7a9ba9;
  --water-white: #fbfeff;
  --water-ink: #3b5a67;
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(5px, 1.35vw, 10px);
  border-radius: 15px;
  padding: clamp(7px, 2vw, 18px);
  background: var(--water-tray);
  box-shadow: inset 0 0 0 1px var(--water-rim);
}
html[data-theme=dark] .water-board {
  --water-tray: #263746;
  --water-rim: #536b79;
  --water-white: #314958;
  --water-ink: #c6d8df;
}
.water-bottle {
  position: relative;
  display: grid;
  box-sizing: border-box;
  justify-items: center;
  align-content: start;
  gap: 6px;
  width: clamp(49px, 11vw, 68px);
  padding: 11px 0 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--water-ink);
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.water-glass {
  position: relative;
  display: block;
  width: clamp(36px, 8.5vw, 49px);
  height: clamp(85px, 19vw, 112px);
  box-sizing: border-box;
  border: 2px solid var(--water-rim);
  border-top: 0;
  border-radius: 0 0 13px 13px;
  background: var(--water-white);
  box-shadow: 0 3px 2px #1630401c, inset 2px 0 #fff3;
  transition: transform 130ms ease-out;
}
.water-glass::before {
  position: absolute;
  z-index: 1;
  top: -4px;
  left: -5px;
  right: -5px;
  height: 5px;
  border: 2px solid var(--water-rim);
  border-radius: 5px;
  background: var(--water-white);
  content: '';
}
.water-liquid {
  position: absolute;
  display: flex;
  flex-direction: column-reverse;
  inset: 5px 2px 2px;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.water-layer {
  flex: 0 0 25%;
  box-shadow: inset 0 1px #ffffff45;
}
.water-layer[data-color="1"] { background: repeating-linear-gradient(135deg, #ffffff42 0 2px, transparent 2px 7px), #e68481; }
.water-layer[data-color="2"] { background: radial-gradient(circle, #ffffff78 1px, transparent 1.5px) 0 0 / 7px 7px, #7da9df; }
.water-layer[data-color="3"] { background: repeating-linear-gradient(0deg, #fff6 0 1px, transparent 1px 5px), #9cbb6e; }
.water-layer[data-color="4"] { background: repeating-linear-gradient(90deg, #76571329 0 1px, transparent 1px 6px), #ecc46c; }
.water-layer[data-color="5"] { background: repeating-linear-gradient(45deg, #ffffff42 0 2px, transparent 2px 7px), #ad8adc; }
.water-layer[data-color="6"] { background: repeating-linear-gradient(90deg, #fff4 0 1px, transparent 1px 7px), repeating-linear-gradient(0deg, #fff4 0 1px, transparent 1px 7px), #69c8c5; }
.water-flow {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  color: #da5453;
}
.water-flow[data-color="2"] { color: #4a8acb; }
.water-flow[data-color="3"] { color: #739643; }
.water-flow[data-color="4"] { color: #bb8b2f; }
.water-flow[data-color="5"] { color: #8f63c3; }
.water-flow[data-color="6"] { color: #409c98; }
.water-flow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: .33 1.7;
  animation: water-flow 285ms ease-in-out both;
}
@keyframes water-flow {
  from { stroke-dashoffset: .4; opacity: .4; }
  65% { opacity: .9; }
  to { stroke-dashoffset: -1.02; opacity: 0; }
}
.water-number { font-size: 14px; font-weight: 650; line-height: 1.4; }
.water-bottle[data-selected] {
  border-color: #37718a;
  background: #8fc5e026;
}
.water-bottle[data-selected] .water-glass { transform: translateY(-5px); }
.water-bottle[data-hint-source] { border: 2px dashed #9b6224; }
.water-bottle[data-hint-target] { border: 2px solid #9b6224; }
.water-bottle[data-sorted] .water-number::after { content: ' ✓'; color: var(--game-accent); }
.water-bottle:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 1px; }
@media (hover:hover) {
  .water-bottle:hover { background: #89b8cc25; }
}
.water-actions { margin-top: 14px; }
.water-status { min-height: 23px; margin: 8px 0 0; text-align: center; }
.water-status[data-error] { color: #9d3d34; }
html[data-theme=dark] .water-status[data-error] { color: #ffc4b7; }
#show-victory[hidden], #next-level[hidden] { display: none; }

.water-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;
  background: var(--game-surface);
  color: var(--game-secondary);
  box-shadow: 0 18px 54px #14243840;
  overscroll-behavior: contain;
}
.water-victory::backdrop { background: #1326348c; }
.water-victory-body { padding: 24px clamp(18px, 6vw, 32px); text-align: center; }
.water-victory h2 { margin: 0; color: var(--game-accent); font-size: 22px; }
.water-victory p { margin: 9px 0 16px; line-height: 1.65; }

@media (max-width: 440px) {
  body[data-fourhao-game="water-sort"] .water-actions .game-page-button { min-height: 44px; padding-inline: 11px; }
}
@media (max-width: 360px) {
  .water-bottle { width: 45px; }
}
@media (prefers-reduced-motion: reduce) {
  .water-glass { transition: none; }
  .water-flow { display: none; }
}
.water-victory[open] {
  animation: water-victory-enter 220ms ease-out;
}
@keyframes water-victory-enter {
  from { opacity: .3; }
  55% { box-shadow: 0 0 0 5px #6fbbd641, 0 18px 45px #13263442; }
}
@media (prefers-reduced-motion: reduce) {
  .water-victory[open] { animation: none; }
}
