:root {
  color-scheme: light;
  --ink: #16222a;
  --muted: #66727b;
  --paper: #f7f1e6;
  --panel: #fffaf0;
  --water: #9fd1d5;
  --water-deep: #4e9aa6;
  --reed: #7c8d48;
  --quay: #5aa66a;
  --parcel: #d8863a;
  --ferry: #283f66;
  --line: rgba(22, 34, 42, 0.16);
  --shadow: 0 18px 45px rgba(30, 53, 64, 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(180deg, rgba(247, 241, 230, 0.92), rgba(238, 231, 215, 0.96)),
    repeating-linear-gradient(90deg, rgba(78, 154, 166, 0.12) 0 18px, transparent 18px 42px);
  color: var(--ink);
}

button,
a {
  font: inherit;
}

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

.top-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 26px;
}

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

.hero {
  max-width: 760px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--water-deep);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 8vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  margin: 16px 0 0;
  max-width: 650px;
  color: #40515a;
  font-size: 1.04rem;
  line-height: 1.55;
}

.game-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 3vw, 24px);
}

.status-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.status-row div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf7;
  padding: 10px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.status-row strong {
  display: block;
  margin-top: 3px;
  font-size: 1.2rem;
}

.board-wrap {
  display: grid;
  place-items: center;
  padding: 10px;
  background: #d8e7df;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.board {
  width: min(88vw, 560px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  touch-action: manipulation;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(145deg, var(--water), #78bbc3);
  color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.cell:focus-visible {
  outline: 3px solid #f0c45d;
  outline-offset: 2px;
}

.cell:hover {
  filter: brightness(1.04);
}

.cell.blocked {
  cursor: default;
  background: linear-gradient(145deg, #8ea15d, var(--reed));
  color: #f7f1e6;
}

.cell.exit {
  background: linear-gradient(145deg, #83c878, var(--quay));
}

.cell.reachable {
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08), 0 0 0 3px rgba(240, 196, 93, 0.82);
}

.current {
  position: absolute;
  inset: auto 7px 6px auto;
  color: rgba(22, 34, 42, 0.58);
  font-size: clamp(0.75rem, 3vw, 1.2rem);
  font-weight: 900;
}

.parcel {
  position: absolute;
  inset: 8px auto auto 8px;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--parcel);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13);
}

.ferry {
  z-index: 2;
  width: 56%;
  height: 42%;
  border-radius: 48% 48% 42% 42%;
  background: var(--ferry);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 5px 9px rgba(0, 0, 0, 0.18);
}

.ferry::before {
  content: "";
  display: block;
  width: 55%;
  height: 35%;
  margin: 8% auto 0;
  border-radius: 4px;
  background: #f4d67f;
}

.message {
  min-height: 2.8em;
  margin: 14px 0;
  color: #40515a;
  font-weight: 700;
  line-height: 1.4;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.controls button {
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fffdf7;
  padding: 11px 10px;
  font-weight: 800;
  cursor: pointer;
}

.controls button:disabled {
  cursor: not-allowed;
  background: #9da8ad;
}

.rules {
  margin-top: 24px;
  color: #40515a;
}

.rules h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.2rem;
}

.rules ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 18px, 560px);
    padding-top: 12px;
  }

  .top-nav {
    justify-content: stretch;
  }

  .top-nav a {
    flex: 1;
    text-align: center;
    padding-inline: 8px;
  }

  .status-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .board {
    gap: 4px;
  }

  .controls {
    grid-template-columns: repeat(2, 1fr);
  }
}
