:root {
  color-scheme: light;
  --ink: #25303a;
  --muted: #667381;
  --paper: #f7f1e6;
  --line: #d9cbb6;
  --brass: #c6852d;
  --red: #b84a3e;
  --green: #317f62;
  --blue: #2f6f96;
  --plum: #755a8d;
  --shadow: 0 20px 50px rgba(30, 36, 42, 0.16);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.52) 0 25%, transparent 25% 50%, rgba(255,255,255,0.35) 50% 75%, transparent 75%) 0 0 / 34px 34px,
    #d8e3df;
  color: var(--ink);
}
button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 0.72rem 0.95rem;
  touch-action: manipulation;
}
button:disabled { cursor: not-allowed; opacity: 0.48; }
.shell { width: min(980px, calc(100% - 28px)); margin: 0 auto; padding: 20px 0 36px; }
.top-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.top-nav a {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(37,48,58,0.16);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 800;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
}
.hero { margin-bottom: 18px; }
.eyebrow, .label {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1, h2 { letter-spacing: 0; }
h1 { font-size: clamp(2.2rem, 8vw, 4.7rem); line-height: 0.96; margin-bottom: 12px; }
.lede { color: #4b5965; font-size: clamp(1rem, 2.6vw, 1.2rem); line-height: 1.45; max-width: 720px; }
.game-panel, .rules {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(37,48,58,0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.game-panel { padding: clamp(14px, 3vw, 24px); }
.status-row { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
.status-row > div { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.78rem; }
.status-row strong { display: block; font-size: 1.28rem; margin-top: 4px; }
.pipes { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
.pipe { background: #fbf8f2; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 10px; min-width: 0; padding: 12px; }
.pipe.ready { border-color: rgba(49,127,98,0.65); box-shadow: 0 0 0 3px rgba(49,127,98,0.12); }
.pipe.burst { border-color: rgba(184,74,62,0.7); box-shadow: 0 0 0 3px rgba(184,74,62,0.14); }
.pipe-top { align-items: start; display: flex; justify-content: space-between; gap: 8px; }
.pipe-name { font-weight: 900; }
.pressure { color: var(--brass); font-size: 2rem; font-weight: 950; line-height: 1; }
.gauge { background: #e6ddd0; border-radius: 999px; height: 18px; overflow: hidden; position: relative; }
.fill { background: linear-gradient(90deg, var(--blue), var(--green), var(--brass)); border-radius: inherit; display: block; height: 100%; transition: width 160ms ease; }
.target-mark, .burst-mark { bottom: 0; position: absolute; top: 0; width: 3px; }
.target-mark { background: var(--ink); }
.burst-mark { background: var(--red); }
.pipe button { background: var(--blue); width: 100%; }
.pipe button:disabled { background: #6c7a86; }
.workbench { border-top: 1px solid rgba(37,48,58,0.12); padding-top: 16px; }
.section-head { align-items: end; display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: 1rem; margin-bottom: 0; }
.section-head span { color: var(--muted); font-size: 0.95rem; font-weight: 750; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card { background: var(--paper); border: 2px solid transparent; box-shadow: none; color: var(--ink); min-height: 118px; padding: 12px; text-align: left; }
.card.selected { border-color: var(--brass); outline: 3px solid rgba(198,133,45,0.18); }
.card.used { opacity: 0.45; }
.card-title { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title strong { font-size: 1rem; }
.badge { background: rgba(37,48,58,0.1); border-radius: 999px; padding: 0.18rem 0.48rem; }
.effect { color: #4d5a66; display: block; font-size: 0.92rem; font-weight: 700; line-height: 1.35; }
.message { background: #eef5f2; border: 1px solid rgba(49,127,98,0.22); border-radius: 8px; color: #27443a; font-weight: 750; line-height: 1.4; margin: 16px 0; min-height: 54px; padding: 0.9rem 1rem; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#undoBtn, #resetBtn { background: var(--plum); }
#nextBtn { background: var(--green); }
.rules { margin-top: 18px; padding: clamp(14px, 3vw, 20px); }
.rules h2 { font-size: 1rem; margin-bottom: 8px; }
.rules ul { color: #4b5965; line-height: 1.5; margin: 0; padding-left: 1.2rem; }
@media (max-width: 720px) {
  .status-row, .pipes { grid-template-columns: 1fr; }
  .controls button { flex: 1 1 160px; }
}
