:root {
  color-scheme: light;
  --ink: #233238;
  --muted: #607078;
  --paper: #f7f3ea;
  --panel: #fffdf7;
  --line: #d8d0bd;
  --field: #dfeccf;
  --field-2: #cfe3bc;
  --sky: #b7ddea;
  --sky-deep: #7eb6c9;
  --crop: #6e9f44;
  --wet: #3e84a5;
  --flood: #7e5aa7;
  --stone: #8b8172;
  --warn: #b95d44;
  --good: #2f7d57;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(126, 182, 201, 0.38), rgba(247, 243, 234, 0.2) 38%),
    repeating-linear-gradient(90deg, rgba(110, 159, 68, 0.1) 0 18px, transparent 18px 36px),
    var(--paper);
}

button,
a {
  font: inherit;
}

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

.top-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
}

.top-nav a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid rgba(35, 50, 56, 0.2);
  background: rgba(255, 253, 247, 0.78);
  padding: 8px 12px;
  border-radius: 7px;
  font-weight: 700;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #52685b;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.lede {
  max-width: 670px;
  margin: 14px 0 0;
  color: #41535a;
  font-size: 1.04rem;
  line-height: 1.48;
}

.score-card,
.panel {
  border: 1px solid rgba(92, 78, 55, 0.22);
  background: rgba(255, 253, 247, 0.88);
  box-shadow: 0 14px 38px rgba(72, 88, 60, 0.13);
}

.score-card {
  min-width: 168px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 8px;
}

.score-card span,
.label,
.section-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.score-card strong {
  font-size: 1.35rem;
}

.game-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: 8px;
  padding: 16px;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.status-row > div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid rgba(96, 112, 120, 0.18);
  border-radius: 7px;
  background: rgba(247, 243, 234, 0.66);
}

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

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 8px;
  width: min(100%, 620px);
  margin: 0 auto;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid rgba(65, 83, 90, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 48%),
    var(--field);
  overflow: hidden;
}

.cell:nth-child(odd) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 52%),
    var(--field-2);
}

.cell.stone {
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.12) 0 5px, transparent 5px 10px),
    var(--stone);
}

.cell.crop::before {
  content: "";
  position: absolute;
  inset: 19% 22% 28%;
  border-radius: 50% 50% 44% 44%;
  background: var(--crop);
  box-shadow:
    -10px 8px 0 -3px rgba(85, 126, 52, 0.86),
    10px 8px 0 -3px rgba(85, 126, 52, 0.86);
}

.cell.crop::after {
  content: attr(data-water) " / " attr(data-need);
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 34px;
  padding: 3px 5px;
  border-radius: 6px;
  color: #fff;
  background: rgba(35, 50, 56, 0.78);
  font-weight: 900;
  font-size: clamp(0.68rem, 2.5vw, 0.86rem);
  text-align: center;
}

.cell.done {
  outline: 3px solid rgba(47, 125, 87, 0.55);
}

.cell.flooded {
  outline: 3px solid rgba(126, 90, 167, 0.62);
}

.cell.flooded::after {
  background: var(--flood);
}

.cloud {
  position: absolute;
  inset: 10% 8% auto;
  height: 44%;
  border-radius: 999px;
  background: #fff;
  box-shadow:
    16px 7px 0 -2px #f4fbff,
    -14px 10px 0 -4px #eef8ff,
    0 18px 0 -6px #d7edf6,
    0 8px 16px rgba(54, 88, 103, 0.24);
  z-index: 3;
}

.rain-drop {
  position: absolute;
  left: 50%;
  bottom: 19%;
  width: 8px;
  height: 16px;
  border-radius: 8px 8px 10px 10px;
  background: var(--wet);
  transform: translateX(-50%);
  opacity: 0;
}

.cell.raining .rain-drop {
  animation: rain 0.42s ease-out;
}

@keyframes rain {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 18px); }
}

.controls-panel {
  display: grid;
  gap: 16px;
}

.brief h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.brief p,
.message {
  margin: 0;
  color: #485e64;
  line-height: 1.42;
}

.cards {
  display: grid;
  gap: 9px;
  margin-top: 9px;
}

.card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid rgba(65, 83, 90, 0.2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.card:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.card:hover:not(:disabled),
.card:focus-visible {
  border-color: var(--sky-deep);
  outline: 3px solid rgba(126, 182, 201, 0.28);
}

.arrow {
  display: grid;
  place-items: center;
  width: 46px;
  height: 40px;
  border-radius: 7px;
  background: rgba(183, 221, 234, 0.55);
  font-size: 1.55rem;
  font-weight: 900;
}

.card strong {
  display: block;
  font-size: 0.98rem;
}

.card span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  justify-self: end;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(110, 159, 68, 0.14);
  color: #456d2e;
  font-size: 0.78rem;
  font-weight: 900;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  color: #47585f;
  font-size: 0.86rem;
}

.legend span {
  display: flex;
  gap: 7px;
  align-items: center;
}

.legend i {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
}

.legend .crop { background: var(--crop); }
.legend .wet { background: var(--wet); }
.legend .flood { background: var(--flood); }
.legend .stone { background: var(--stone); }

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

.actions button {
  min-height: 42px;
  border: 1px solid rgba(65, 83, 90, 0.24);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

#finishBtn {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.message {
  min-height: 44px;
  padding: 10px 12px;
  border-left: 4px solid var(--sky-deep);
  background: rgba(183, 221, 234, 0.22);
  border-radius: 0 7px 7px 0;
}

.message.good {
  border-color: var(--good);
  background: rgba(47, 125, 87, 0.12);
}

.message.warn {
  border-color: var(--warn);
  background: rgba(185, 93, 68, 0.12);
}

@media (max-width: 860px) {
  .hero,
  .game-wrap {
    grid-template-columns: 1fr;
  }

  .score-card {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .board {
    gap: 6px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 18px, 1120px);
    padding-top: 10px;
  }

  .top-nav {
    margin-bottom: 14px;
  }

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

  .panel {
    padding: 11px;
  }

  .status-row,
  .legend,
  .actions {
    grid-template-columns: 1fr;
  }

  .card {
    grid-template-columns: 44px 1fr auto;
    min-height: 54px;
  }

  .arrow {
    width: 38px;
    height: 36px;
  }
}
