:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #62717f;
  --paper: #f6f0e7;
  --panel: #fffaf1;
  --line: #d8c7ad;
  --water: #4aa7b0;
  --water-dark: #247684;
  --brick: #b85d4b;
  --gate: #6d543e;
  --gold: #d79b36;
  --green: #5f8f51;
}

* {
  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;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(74, 167, 176, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(184, 93, 75, 0.14), transparent 42%),
    var(--paper);
}

button,
a {
  font: inherit;
}

.shell {
  width: min(940px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.top-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.top-links a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.86);
  padding: 9px 12px;
  border-radius: 7px;
  font-weight: 700;
}

.hero {
  margin-bottom: 18px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 8px;
  font-size: clamp(2.3rem, 8vw, 5.2rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.lede {
  margin: 0;
  max-width: 680px;
  color: #354555;
  font-size: 1.06rem;
  line-height: 1.55;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.9);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(61, 45, 26, 0.12);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin: 18px 0;
}

.scoreboard div {
  min-height: 72px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.44);
}

.scoreboard strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
}

.boat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.boat-card h2 {
  margin: 3px 0 0;
  font-size: 1.4rem;
}

.draught {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 10px;
}

.target {
  display: grid;
  place-items: center;
  height: 58px;
  border-radius: 8px;
  background: #e8f3f3;
  border: 2px solid #a6ced0;
  font-weight: 900;
  color: var(--water-dark);
}

.locks {
  position: relative;
  min-height: 360px;
  padding: 22px;
  overflow: hidden;
}

.waterline {
  position: absolute;
  inset: auto -5% 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(74, 167, 176, 0.22), rgba(74, 167, 176, 0.62));
  border-top: 3px solid rgba(36, 118, 132, 0.35);
  pointer-events: none;
}

.chambers {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  min-height: 270px;
}

.chamber {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  min-width: 0;
}

.chamber-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  font-weight: 900;
}

.well {
  position: relative;
  min-height: 190px;
  border: 5px solid var(--gate);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background:
    repeating-linear-gradient(90deg, rgba(109, 84, 62, 0.08) 0 10px, transparent 10px 22px),
    #d7b991;
  overflow: hidden;
}

.water {
  position: absolute;
  inset: auto 0 0;
  height: 33%;
  background: linear-gradient(180deg, #6dc1c8, var(--water-dark));
  transition: height 180ms ease;
}

.boat {
  position: absolute;
  left: 50%;
  bottom: calc(var(--boat-bottom, 28%) + 4px);
  width: 72px;
  height: 30px;
  transform: translateX(-50%);
  transition: bottom 180ms ease;
}

.boat::before {
  content: "";
  position: absolute;
  inset: 10px 4px 0;
  background: var(--brick);
  border-radius: 0 0 18px 18px;
  border: 2px solid #763a31;
}

.boat::after {
  content: "";
  position: absolute;
  left: 29px;
  top: 0;
  width: 14px;
  height: 17px;
  background: var(--gold);
  border-radius: 3px 3px 0 0;
}

.pump-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pump-row button,
.controls button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.pump-row button:disabled,
.controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  padding: 14px;
  margin-top: 18px;
}

.controls .secondary,
.pump-row .secondary {
  color: var(--ink);
  background: #eadcc7;
}

.message {
  position: relative;
  z-index: 1;
  margin: 18px 0 0;
  color: #31424c;
  font-weight: 800;
  min-height: 24px;
}

.manifest {
  margin-top: 18px;
  padding: 18px;
}

.manifest h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.manifest ul {
  margin: 0;
  padding-left: 20px;
  color: #43515e;
  line-height: 1.55;
}

.matched .well {
  outline: 3px solid rgba(95, 143, 81, 0.55);
}

.overdrawn {
  color: #9a3b31;
}

@media (max-width: 720px) {
  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .boat-card,
  .controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .draught {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chambers {
    gap: 8px;
  }

  .locks {
    padding: 14px;
  }

  .well {
    min-height: 170px;
    border-width: 4px;
  }

  .boat {
    width: 54px;
  }
}
