/* Leak-Y-Pipe
   Same family as the other games: navy table, cream tiles. Here the tiles carry brass pipes,
   the board's own pipes are steel, and the water is bright blue. Dark-first, with a light version. */

:root {
  --bg: #e3ebf3;
  --bg-dot: #cfdbe7;
  --surface: #ffffff;
  --surface-edge: #cbd8e5;
  --ink: #152230;
  --muted: #5b6f84;
  --cell: #d5e1ec;
  --cell-edge: #b9cadb;
  --tile: #f4e9cf;
  --tile-ink: #3a2f17;
  --tile-edge: #cbb98f;
  --accent: #3e6fe0;
  --accent-edge: #2a52b3;
  --good: #2fae6c;
  --bad: #e2604f;
  --dl: #7fc4ee;
  --tl: #3b7fd4;
  --dw: #ee8aa4;
  --mult-ink: #10202b;
  --water: #2aa7f0;
  --lv-medium: #3e6fe0;
  --lv-hard: #c98a14;
  --steel: #a9b8c6;
  --steel-case: #6a7d90;
  --steel-shine: #e6eef5;
  --brass: #d39a4c;
  --brass-case: #8f5e22;
  --brass-shine: #f6d6a2;
  --cell-fixed: #c8d5e2;
  --rock: #8a96a2;
  --rock-line: #6b7782;
  --drain: #2a3b4b;
  --font: "Outfit", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
/* dark: follows the device unless the player has picked a side in Settings */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111c26;
    --bg-dot: #1a2835;
    --surface: #182633;
    --surface-edge: #24384a;
    --ink: #eef3f8;
    --muted: #8ea2b6;
    --cell: #1f3242;
    --cell-edge: #14222d;
    --accent: #5b86f0;
    --accent-edge: #3b63c7;
    --good: #4fc28c;
    --bad: #ee6f5f;
    --water: #39b7ff;
    --lv-medium: #5b86f0;
    --steel: #7e93a6;
    --steel-case: #3f5366;
    --steel-shine: #b9c9d7;
    --cell-fixed: #172734;
    --rock: #4c5c6b;
    --rock-line: #34424f;
    --drain: #0c151d;
  }
}
:root[data-theme="dark"] {
  --bg: #111c26;
  --bg-dot: #1a2835;
  --surface: #182633;
  --surface-edge: #24384a;
  --ink: #eef3f8;
  --muted: #8ea2b6;
  --cell: #1f3242;
  --cell-edge: #14222d;
  --accent: #5b86f0;
  --accent-edge: #3b63c7;
  --good: #4fc28c;
  --bad: #ee6f5f;
  --water: #39b7ff;
  --lv-medium: #5b86f0;
  --steel: #7e93a6;
  --steel-case: #3f5366;
  --steel-shine: #b9c9d7;
  --cell-fixed: #172734;
  --rock: #4c5c6b;
  --rock-line: #34424f;
  --drain: #0c151d;
}

html, body { margin: 0; height: 100%; overflow: hidden; }

/* every screen fits the height it's given: sizes shrink on short screens */

/* ---- the logo: the name as a row of tiles ---- */
.logo { display: flex; gap: 4px; justify-content: center; }
.logo i {
  width: clamp(20px, 3.6vh, 30px); height: clamp(22px, 4vh, 33px); border-radius: 6px;
  background: var(--tile); color: var(--tile-ink);
  box-shadow: 0 3px 0 var(--tile-edge);
  display: grid; place-items: center;
  font-style: normal; font-weight: 900; font-size: clamp(0.8rem, 2.1vh, 1.1rem);
}
.logo s { width: clamp(4px, 0.8vh, 7px); align-self: center; height: 3px; border-radius: 2px; background: var(--muted); opacity: 0.6; text-decoration: none; }
.big-logo { gap: 5px; }
.big-logo i { width: clamp(30px, 8.6vw, 38px); height: clamp(33px, 9.2vw, 42px); font-size: clamp(1.1rem, 3.4vh, 1.4rem); border-radius: 8px; }
.small-logo { gap: 2px; }
.small-logo s { width: 4px; }
.small-logo i { width: 18px; height: 22px; font-size: 0.72rem; border-radius: 5px; box-shadow: 0 2px 0 var(--tile-edge); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.date { margin-top: clamp(8px, 1.6vh, 14px); }
.logo-spin i { animation: hop 1.2s ease-in-out infinite; }
.logo-spin i:nth-child(2n) { animation-delay: 0.15s; }
.logo-spin i:nth-child(3n) { animation-delay: 0.3s; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ---- type ---- */

.heading { font-size: 1.6rem; margin: 0; font-weight: 900; letter-spacing: -0.01em; text-align: center; }
.lede { margin: 0; font-size: 1.05rem; color: var(--muted); text-align: center; }
.date { margin: 6px 0 0; text-align: center; color: var(--muted); font-weight: 700; }
.quiet { margin: 0; color: var(--muted); text-align: center; }

.lede[hidden], .breakdown[hidden], .today-line[hidden] { display: none; }

/* ---- buttons ---- */

button:focus-visible { outline: 3px solid var(--water); outline-offset: 3px; }
.big {
  appearance: none; border: 0; width: 100%;
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 5px 0 var(--accent-edge);
  color: #fff;
  font-size: clamp(1.05rem, 2.6vh, 1.25rem); font-weight: 900;
  padding: clamp(11px, 2vh, 16px) 20px;
  margin-bottom: 5px;
  transition: transform 0.06s, box-shadow 0.06s;
}
.big:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-edge); }

.big.secondary:active:not(:disabled) { box-shadow: 0 1px 0 var(--surface-edge); }
.big.confirm { background: var(--brass); color: var(--mult-ink); box-shadow: 0 5px 0 #c76983; }

.soft:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--surface-edge); }
.soft:disabled { opacity: 0.5; }
.soft[hidden], .big[hidden] { display: none; }

/* ---- menu ---- */

.menu-row { display: flex; gap: 10px; flex: none; }

/* ---- people lists (leaderboard) ---- */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(5px, 1vh, 8px); min-height: 0; overflow: hidden; align-content: start; }

.people .state { margin-left: auto; font-size: 0.95rem; color: var(--muted); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.people .state b { color: var(--ink); font-size: 1.05rem; }
.people .state.is-playing { color: var(--brass); }

.ranks .pos.p1 { color: var(--brass); }
.ranks .tag { font-size: 0.72rem; font-weight: 900; color: var(--accent); margin-left: 6px; }

/* ---- the game ---- */
.game { justify-content: flex-start; gap: clamp(6px, 1.2vh, 10px); }
.hud { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; flex: none; }
.hud-title { margin: 0; text-align: center; font-weight: 900; font-size: 1.05rem; letter-spacing: -0.01em; }

.play-area {
  flex: 1 1 0; min-height: 0; container-type: size;
  display: flex; justify-content: center; align-items: center;
}
/* --u is one square of the board; everything is sized from it so the game always fits */
.zb {
  --n: 5;
  --u: min(13vw, 6vh);
  /* room outside the board only on the sides with the tap or drain: --xs / --ys count them */
  --wide: max(calc(var(--n) * 1.07 + 0.1 + var(--xs) * 0.6 + (2 - var(--xs)) * 0.08), calc(var(--tc) * 0.85 + 0.2));
  --tall: calc(var(--n) * 1.07 + 0.1 + var(--ys) * 0.6 + (2 - var(--ys)) * 0.08);
  --u: min(calc(100cqw / max(var(--wide), calc(var(--tc) * 0.85 + 0.3))), calc(100cqh / (var(--tall) + 0.7 + var(--tr) * 0.86 + 0.5)));
  --g: calc(var(--u) * 0.07);
  --p: calc(var(--u) * 0.6);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.22);
}
.zb.read { --u: min(calc(100cqw / var(--wide)), calc(100cqh / var(--tall))); }
.rig { padding: calc(var(--u) * 0.08); }
.rig.p0 { padding-top: var(--p); } .rig.p1 { padding-right: var(--p); } .rig.p2 { padding-bottom: var(--p); } .rig.p3 { padding-left: var(--p); }
.board {
  position: relative;
  display: grid; grid-template-columns: repeat(var(--n), var(--u)); grid-template-rows: repeat(var(--n), var(--u)); gap: var(--g);
  padding: var(--g); border-radius: calc(var(--u) * 0.22);
  background: var(--surface); border: 1.5px solid var(--surface-edge);
}
.cell {
  position: relative; border-radius: calc(var(--u) * 0.15);
  background: var(--cell); box-shadow: inset 0 calc(var(--u) * 0.04) 0 var(--cell-edge);
  touch-action: none;
}
.cell.drop { outline: 3px solid var(--accent); outline-offset: -3px; }
.cell > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* pipes: a dark casing, the pipe, a highlight, and water when it's flowing */
.pipe { overflow: visible; display: block; }
.pipe path { fill: none; stroke-linecap: butt; }
.pipe .case { stroke: var(--pipe-case); stroke-width: 36; }
.pipe .body { stroke: var(--pipe); stroke-width: 26; }
.pipe .shine { stroke: var(--pipe-shine); stroke-width: 5; transform: translate(-4px, -4px); opacity: 0.6; }
.pipe .flange rect { fill: var(--pipe-case); }
.pipe.steel { --pipe: var(--steel); --pipe-case: var(--steel-case); --pipe-shine: var(--steel-shine); }
.pipe.brass { --pipe: var(--brass); --pipe-case: var(--brass-case); --pipe-shine: var(--brass-shine); }
.pipe .water, .stub .water {
  stroke: var(--water); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 10 8; animation: flow 0.6s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -18; } }
.rocks .r1 { fill: var(--rock); }
.rocks .r2 { fill: none; stroke: var(--rock-line); stroke-width: 4; stroke-linecap: round; }

/* the tap and the drain, just outside the board */
.stub {
  position: absolute; z-index: 3; pointer-events: none;
  width: var(--u); height: var(--p);
  --cx: calc(var(--g) + var(--c) * (var(--u) + var(--g)) + var(--u) / 2);
  --cy: calc(var(--g) + var(--r) * (var(--u) + var(--g)) + var(--u) / 2);
  --B: calc(var(--n) * var(--u) + (var(--n) + 1) * var(--g));
}
.stub svg { width: 100%; height: 100%; display: block; overflow: visible; }
.stub[data-side="0"] { left: var(--cx); top: calc(var(--p) / -2); transform: translate(-50%, -50%); }
.stub[data-side="1"] { left: calc(var(--B) + var(--p) / 2); top: var(--cy); transform: translate(-50%, -50%) rotate(90deg); }
.stub[data-side="2"] { left: var(--cx); top: calc(var(--B) + var(--p) / 2); transform: translate(-50%, -50%) rotate(180deg); }
.stub[data-side="3"] { left: calc(var(--p) / -2); top: var(--cy); transform: translate(-50%, -50%) rotate(270deg); }
.stub path { fill: none; }
.stub .case { stroke: var(--steel-case); stroke-width: 36; }
.stub .body { stroke: var(--steel); stroke-width: 26; }
.valve { fill: var(--water); stroke: var(--surface); stroke-width: 4; }
.valve-stem { fill: var(--steel-case); }
.valve-spoke { stroke: #fff; stroke-width: 5; stroke-linecap: round; }
.tap .valve { animation: turn 4s linear infinite; transform-origin: 50px 16px; }
.drain { fill: var(--drain); stroke: var(--steel-case); stroke-width: 5; }
.drain-grate { stroke: var(--steel); stroke-width: 4; stroke-linecap: round; }
.port .drain-splash { transform-origin: 50px 50px; }
.p-tap .wheel { animation: turn 4s linear infinite; transform-origin: 50px 50px; }
.drain-splash { fill: none; stroke: var(--water); stroke-width: 4; animation: splash 0.9s ease-out infinite; transform-origin: 50px 20px; }
@keyframes splash { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* the leak: water spilling from the end of the pipe */
.drip {
  position: absolute; z-index: 4; pointer-events: none; width: 0; height: 0;
  --cx: calc(var(--g) + var(--c) * (var(--u) + var(--g)) + var(--u) / 2);
  --cy: calc(var(--g) + var(--r) * (var(--u) + var(--g)) + var(--u) / 2);
  left: var(--cx); top: var(--cy);
}
.drip[data-side="0"] { top: calc(var(--cy) - var(--u) / 2 - var(--g) / 2); }
.drip[data-side="1"] { left: calc(var(--cx) + var(--u) / 2 + var(--g) / 2); }
.drip[data-side="2"] { top: calc(var(--cy) + var(--u) / 2 + var(--g) / 2); }
.drip[data-side="3"] { left: calc(var(--cx) - var(--u) / 2 - var(--g) / 2); }
.drip i {
  position: absolute; left: calc(var(--u) * -0.12); top: calc(var(--u) * -0.12);
  width: calc(var(--u) * 0.24); height: calc(var(--u) * 0.24);
  background: var(--water); border-radius: 50% 0 50% 50%; transform: rotate(-45deg);
  animation: drop 1.1s ease-in infinite;
}
.drip i + i { animation-delay: 0.55s; }
.drip b {
  position: absolute; left: calc(var(--u) * -0.24); top: calc(var(--u) * 0.32);
  width: calc(var(--u) * 0.48); height: calc(var(--u) * 0.12); border-radius: 50%;
  background: var(--water); opacity: 0.5; animation: puddle 1.1s ease-out infinite;
}
@keyframes drop { 0% { transform: translateY(0) rotate(-45deg) scale(0.4); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(calc(var(--u) * 0.38)) rotate(-45deg) scale(1); opacity: 0.2; } }
@keyframes puddle { 0%, 60% { transform: scaleX(0.4); opacity: 0; } 80% { opacity: 0.55; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes turn { to { transform: rotate(360deg); } }

/* tiles you place: brass pipe on a cream tile */
.tile {
  position: relative; width: 100%; height: 100%;
  border-radius: calc(var(--u) * 0.15);
  background: var(--tile);
  box-shadow: 0 calc(var(--u) * 0.06) 0 var(--tile-edge);
  touch-action: none; cursor: grab; overflow: hidden;
}
.tile > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile.lifted { opacity: 0.3; }
.tile.ghost { position: fixed; z-index: 90; pointer-events: none; margin: 0; transform: scale(1.12); box-shadow: 0 8px 18px rgb(0 0 0 / 0.35); opacity: 0.95; }
.read .tile, .locked .tile { cursor: default; }
.flowing .board { box-shadow: 0 0 0 3px var(--water); transition: box-shadow 0.3s; }

.tools { display: flex; gap: calc(var(--u) * 0.2); }
.tools button {
  appearance: none; display: inline-flex; align-items: center; gap: 6px;
  padding: calc(var(--u) * 0.08) calc(var(--u) * 0.3);
  border-radius: 999px; border: 1.5px solid var(--surface-edge); background: var(--surface);
  font-weight: 800; font-size: calc(var(--u) * 0.26);
}
.tools svg { width: calc(var(--u) * 0.3); height: calc(var(--u) * 0.3); fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tools button:active { background: var(--bg); }
.rack {
  display: grid; grid-template-columns: repeat(var(--tc), calc(var(--u) * 0.78)); grid-auto-rows: calc(var(--u) * 0.78); gap: var(--g);
  padding: var(--g); border-radius: calc(var(--u) * 0.22);
  background: var(--surface); border: 1.5px solid var(--surface-edge);
}
.slot { border-radius: calc(var(--u) * 0.13); background: var(--cell); box-shadow: inset 0 calc(var(--u) * 0.04) 0 var(--cell-edge); touch-action: none; }
.slot.drop { outline: 3px solid var(--accent); outline-offset: -3px; }

.level-pill {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  background: var(--lv, var(--water)); color: #fff;
  font-size: 0.85em; font-weight: 900; vertical-align: 1px;
}
.lv-easy { --lv: #2e9b63; } .lv-medium { --lv: #5b86f0; } .lv-hard { --lv: #e2604f; }   /* the same three colours as Odd One Out and Speed Word Search */
.today-line .level-pill { margin-right: 8px; }
.hud .level-pill { justify-self: end; font-size: 0.8rem; padding: 1px 10px; white-space: nowrap; }

/* ---- paused ---- */
.pause-badge {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--water); box-shadow: 0 6px 0 #1a7fbd;
  display: grid; place-items: center; fill: var(--mult-ink);
  transform: rotate(-6deg);
}

/* ---- results ---- */

.done-head .k { margin: 0; color: var(--muted); font-weight: 800; }

.breakdown { margin: 0; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }

.done-buttons .two { display: flex; gap: 10px; }
.done-board { flex: 1 1 0; min-height: 0; }
.review {
  margin: 0; padding: 0; list-style: none; flex: 0 1 auto; min-height: 0; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-content: start;
}
.review li {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 12px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--surface-edge);
  font-weight: 900; font-size: clamp(0.85rem, 2.1vh, 1rem);
}
.review .dir { color: var(--muted); font-weight: 800; flex: none; }
.review .w { letter-spacing: 0.03em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.review .p { margin-left: auto; color: var(--good); font-variant-numeric: tabular-nums; }
.review .none { grid-column: 1 / -1; background: none; border: 0; justify-content: center; color: var(--muted); }

/* ---- panels fill the whole screen ---- */
.back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; flex: none;
  border: 0; background: var(--bg); color: var(--ink); font: inherit; font-weight: 900;
  padding: 5px 12px 5px 6px; margin-left: 0; min-height: 32px; box-sizing: border-box; border-radius: 12px; cursor: pointer;
}

/* (top-aligned like the other screens) */

#board .people { flex: 1 1 auto; }

.ri {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  background: var(--tile); color: var(--tile-ink); box-shadow: 0 4px 0 var(--tile-edge);
  display: grid; place-items: center; font-weight: 900; font-size: 1rem;
}

.ri-sum { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-edge); font-size: 1.4rem; }
.ri-pipe { background: var(--tile); padding: 0; overflow: hidden; }
.ri-pipe svg, .mini-tile svg { width: 100%; height: 100%; stroke: none; }
.ri-water { background: var(--water); box-shadow: 0 4px 0 #1a7fbd; }
.ri-water svg { stroke: #fff; }

/* stats: small grouped rows so the whole page fits without scrolling */
#stat-grid { display: grid; gap: clamp(8px, 1.6vh, 14px); }

.stat { background: var(--bg); border-radius: 14px; padding: clamp(6px, 1.2vh, 10px) 6px; display: grid; gap: 2px; justify-items: center; text-align: center; }

/* ---- tutorial ---- */

.tut-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex: none; min-height: 40px; }
.tut-dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; justify-self: center; }

.tut-dots li.on { width: 22px; background: var(--accent); }
.tut-dots li.past { background: var(--good); }

.tut-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: clamp(6px, 1.4vh, 12px); text-align: center; }
.tut-stage .play-area { flex: 1 1 0; min-height: 180px; }
.tut-card { background: var(--surface); border: 1.5px solid var(--surface-edge); border-radius: 18px; padding: 14px 16px; display: grid; gap: 12px; justify-items: center; }
.tut-row { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.mini-tile {
  position: relative; width: 58px; height: 58px; border-radius: 10px; background: var(--tile);
  box-shadow: 0 3px 0 var(--tile-edge); overflow: hidden; flex: none;
}
.mini-tile.steel-bg { background: var(--cell-fixed); box-shadow: none; }
.mini-tile svg { position: absolute; inset: 0; }
.tut-label { display: grid; gap: 4px; justify-items: center; font-weight: 800; font-size: 0.85rem; color: var(--muted); }
.tut-sum { font-weight: 900; font-size: 1.1rem; text-align: center; }

.tut-note.good { color: var(--good); }

/* ---- testing mode: a strip along the bottom ---- */
.test-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  padding: 5px 12px calc(env(safe-area-inset-bottom) + 5px);
  background: repeating-linear-gradient(-45deg, #f2b23a 0 14px, #f5c25c 14px 28px);
  color: #2b1d00; font-weight: 900; font-size: 13px; letter-spacing: .04em;
  text-align: center; text-transform: uppercase; box-shadow: 0 -2px 0 #c98a14;
}

body.testing #app { padding-bottom: calc(env(safe-area-inset-bottom) + 36px); }

/* Discord on phones covers the top of the game with its own bar: keep clear of it */
html.discord-mobile #app { padding-top: calc(env(safe-area-inset-top) + 60px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- terms and privacy pages ---- */

.doc .quiet { margin-bottom: 20px; text-align: left; }
.doc a { color: var(--accent); }

/* testing mode: pick the level before playing */
.level-pick { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 2px solid var(--surface-edge); }
.level-pick[hidden] { display: none; }
.level-pick button { flex: 1; border: 0; border-radius: 10px; padding: 7px 0; font-weight: 900; background: transparent; color: var(--muted); }
.level-pick button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--surface-edge); }

/* every square of the board looks the same: empty, rock, fixed pipe, tap or drain */
.cell.open.drop { outline: 3px solid var(--accent); outline-offset: -3px; }
/* a tile that was just tapped turns into place */
.tile.spun > svg { animation: spin-in 0.16s ease-out; }
@keyframes spin-in { from { transform: rotate(-90deg); } }

/* the Y in the name is a Y-shaped pipe */
.logo i.ypipe svg { width: 82%; height: 82%; display: block; }

/* Extreme: the tap button under the board, and the leak warning */
.tap-bar { flex: none; display: grid; gap: 4px; }
.tap-bar[hidden] { display: none; }
.tap-bar .big { background: var(--water); box-shadow: 0 5px 0 #1a7fbd; }
.leak-note { margin: 0; min-height: 1.3em; text-align: center; color: var(--bad); font-weight: 900; }

/* the name, written in pipes (drawn by client/pipeword.js) */
.logo .pipeword { display: block; height: clamp(26px, 5vh, 40px); width: auto; overflow: visible; }
.big-logo .pipeword { height: clamp(40px, 9vh, 64px); max-width: 100%; }
.small-logo .pipeword { height: 24px; }
.logo-spin .pipeword { height: 48px; }
.pipeword.flowing .pw-water { stroke-dasharray: 0.9 0.6; animation: pw-flow 0.9s linear infinite; }
@keyframes pw-flow { to { stroke-dashoffset: -1.5; } }

/* your pipes are just pipes: no tile under them (brass, where the board's own pipes are steel) */
.tile { background: transparent; box-shadow: none; border-radius: 0; overflow: visible; }
.tile.ghost { box-shadow: none; filter: drop-shadow(0 8px 10px rgb(0 0 0 / 0.4)); }
.tile.lifted { opacity: 0.25; }
.mini-tile, .ri-pipe { background: var(--cell); box-shadow: none; }

/* the logo in the top bar shrinks before anything gets pushed off a narrow screen */
.hud .logo { min-width: 0; }
.hud .logo .pipeword { max-width: 100%; height: clamp(20px, 4.5vh, 34px); }

/* ---- big screens (desktop, tablet): the whole game grows with the window instead of staying phone-sized ---- */
@media (min-height: 800px) and (min-width: 760px) {
  html { font-size: clamp(16px, 2vh, 26px); }
  body { font-size: clamp(17px, 2.1vh, 28px); }
  .screen { max-width: clamp(440px, 56vh, 760px); }
}

/* ---- settings ---- */

:root[data-theme="dark"] { color-scheme: dark; }

/* sheets scroll when their content doesn't fit (a long leaderboard, a phone on its side) rather than being cut off */
.ranks { overflow-y: auto; }
@media (max-height: 480px) {
  #stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #stat-grid > *, .stat-group, .stat-row, .stat { min-width: 0; }
  .stat .n { font-size: 1.15rem; }
  .stat .k { font-size: 0.78rem; }
}

/* the tutorial on a short screen: tighter text and buttons so the steps still fit */
@media (max-height: 480px) {
  .tut { gap: 6px; }
  .tut .heading { font-size: 1.25rem; }
  .tut .lede { font-size: 0.95rem; line-height: 1.3; }
  .tut-nav .big { padding-top: 9px; padding-bottom: 9px; min-height: 0; }
  .tut-note { min-height: 0; margin: 0; }
}

/* cracks: a split in the pipe itself, with water running out of it */
.cell.leaky { z-index: 5; }
/* the square where the water has just found a crack shakes before it lets go */
.cell.rumble { z-index: 5; }
.cell.rumble > svg { animation: rumble 0.08s linear infinite, swell 0.75s ease-in forwards; animation-delay: 0s, calc(var(--since, 0ms) * -1); }
@keyframes rumble { 0% { transform: translate(0, 0); } 25% { transform: translate(1.6px, -1px); } 50% { transform: translate(-1.6px, 1px); } 75% { transform: translate(1px, 1.6px); } 100% { transform: translate(0, 0); } }
@keyframes swell { to { scale: 1.08; } }
@media (prefers-reduced-motion: reduce) { .cell.rumble > svg { animation: none; } }
.crack-gap { fill: none; stroke: var(--water); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.crack-line { fill: none; stroke: #150f1c; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cdrop { fill: var(--water); animation: cdrop 1s ease-in infinite; }
.cdrop.d2 { animation-delay: 0.5s; }
@keyframes cdrop { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-22px) scale(1); opacity: 0; } }
.crack.mid .spray { opacity: 0; }
.crack.mid.wet .spray { fill: var(--water); animation: spray 0.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.crack.mid.wet .s2 { animation-delay: 0.2s; } .crack.mid.wet .s3 { animation-delay: 0.4s; } .crack.mid.wet .s4 { animation-delay: 0.6s; }
@keyframes spray { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }

/* shown on the first tutorial step for players who have been through an older tutorial */

@media (max-height: 480px) { .tut-updated { padding: 2px 10px; font-size: 0.72rem; } }

/* ---- colour-blind mode: blue and orange instead of green and red, with a mark beside the colour ---- */

:root[data-cb="1"] .lv-easy { --lv: #0072b2; }
:root[data-cb="1"] .leak-note::before { content: "\2715\00a0"; }

/* ---- practice: a blue strip along the bottom ---- */

/* Practice: a quiet button, almost the colour of the page, so the eye stays on Play and Results */

/* Practice: a pop-up with the game's levels, like the language pop-up */
.practice-pop { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.practice-pop[hidden] { display: none; }
.practice-card { background: var(--surface); border-radius: 22px; padding: 18px; width: 100%; max-width: 340px; }
.practice-card h3 { margin: 0 0 14px; text-align: center; font-weight: 900; font-size: 1.3rem; color: var(--ink); }
.practice-row { display: grid; gap: 10px; }
.practice-row button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--surface-edge); background: var(--bg); color: var(--ink); font: inherit; font-weight: 900; font-size: 1.1rem; text-align: left; cursor: pointer; }
.practice-row button:active { transform: translateY(1px); }
.practice-row i { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* Podium rows on the leaderboard: gold, silver and bronze behind the whole row */
   /* same inset on every row so the podium colour has room and names still line up */

/* other games: a button on the menu opens a popup with the other games' app icons */

          /* the main block sits centred between the top and the two buttons, which stay at the bottom */

/* today's leaderboard, locked until today's puzzle is finished */

/* every panel ends with one blue Close button at the bottom (there is no Back button at the top) */
   /* the last leaderboard row always clears the Close button */

/* Surrender: a quiet red link on the pause screen, and the red "Surrendered" on the leaderboard and menu */

/* Languages are switched off (LANGUAGES_ON in client/i18n.js): no Language button, no leaderboard flag */
/* every panel: the content sits in the vertical middle and only the Close button stays at the bottom */

/* Other games on a short screen (a phone on its side): three across, so all the games and Close fit without scrolling */
@media (max-height: 520px) {
  .other-games { grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
  .other-games img { width: clamp(40px, 15vh, 64px); }
  .other-games button { gap: 4px; }
}

/* a phone on its side: the menu and the result screen are taller than the screen, so they scroll from the top (they used to be cut off at both ends) */
@media (max-height: 520px) {
  .screen.menu, .screen.done { overflow-y: auto; overscroll-behavior: contain; justify-content: flex-start; padding-bottom: 8px; }
}

