/* pipes — 水管連接 */

.app { max-width: 600px; padding-bottom: 32px; }

/* ── HUD ───────────────────────────────────────────── */
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.hud-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 6px; text-align: center; box-shadow: var(--shadow-sm); min-width: 0;
}
.hud-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; white-space: nowrap; }
.hud-value {
  font-size: 20px; font-weight: 800; color: var(--accent); margin-top: 2px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }

/* ── Toolbar ───────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }
.size-btn[aria-pressed="true"], #wrap-btn[aria-pressed="true"] {
  background: #0277bd; color: #fff; box-shadow: 0 0 0 2px #81d4fa inset;
}
#wrap-btn:disabled { opacity: 0.55; }

.status-line {
  display: flex; justify-content: space-between; font-size: 13px; font-weight: 700;
  color: var(--text-strong); margin: 4px 2px 8px;
}
#connected.all { color: #0277bd; }
body.dark #connected.all { color: #4fc3f7; }

/* ── Board ─────────────────────────────────────────── */
.board-wrap { display: flex; justify-content: center; }
.board {
  --n: 5;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 2px;
  width: min(100%, 520px);
  padding: 6px;
  background: #13233a;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), inset 0 0 0 2px #1f3a5c;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  box-sizing: border-box;
}
.board.wrap { box-shadow: var(--shadow-lg), inset 0 0 0 2px #4fc3f7; outline: 2px dashed #4fc3f7; outline-offset: 3px; }
.board.solved { box-shadow: var(--shadow-lg), 0 0 0 3px #4fc3f7, 0 0 26px rgba(79,195,247,0.55); }
.board.site-paused { visibility: hidden; }

.tile {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: #1c3150;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.tile:focus-visible { outline: 2px solid #ffd54f; outline-offset: 1px; z-index: 1; }
.tile.wet { background: #1d3b5e; }
.tile.source { background: #24476e; }
.tile svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transition: transform 0.14s ease-out;
  pointer-events: none;
}
.pipe { stroke: #7f8ea3; stroke-width: 24; stroke-linecap: butt; fill: none; transition: stroke 0.2s; }
.hub  { fill: #7f8ea3; transition: fill 0.2s; }
.outlet { fill: #13233a; stroke: #7f8ea3; stroke-width: 7; transition: stroke 0.2s, fill 0.2s; }
.tile.wet .pipe { stroke: #29b6f6; }
.tile.wet .hub { fill: #29b6f6; }
.tile.wet .outlet { stroke: #29b6f6; fill: #b3e5fc; }
.src-core { fill: #0288d1; stroke: #e1f5fe; stroke-width: 6; }
.src-drop { fill: #e1f5fe; }
.leak { fill: #ff5252; display: none; }
.tile.wet .leak.on { display: block; }

.board.solved .tile.wet .pipe { stroke: #4fc3f7; }

/* ── Actions ───────────────────────────────────────── */
.action-row { display: flex; justify-content: center; gap: 8px; margin: 12px 0 6px; }
.legend { font-size: 12px; color: var(--text-muted); text-align: center; margin: 6px 4px; line-height: 1.5; }
.solved-count b { color: var(--text-strong); }

/* ── Overlay ───────────────────────────────────────── */
.pp-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 20, 35, 0.55); padding: 16px;
}
.pp-overlay[hidden] { display: none; }
.pp-card {
  background: var(--surface); color: var(--text-strong); border-radius: var(--radius-lg);
  padding: 22px 26px; text-align: center; box-shadow: var(--shadow-lg); max-width: 340px; width: 100%;
}
.pp-icon { font-size: 40px; }
.pp-title { font-size: 22px; font-weight: 800; margin: 6px 0; }
.pp-sub { font-size: 14px; color: var(--text); margin-bottom: 14px; line-height: 1.6; }
.btn.primary { background: #0277bd; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #01579b; }

@media (max-width: 420px) {
  .hud { gap: 5px; }
  .hud-value { font-size: 17px; }
  .board { padding: 4px; gap: 1px; }
}
