:root {
  color-scheme: light;
  --soil: #31261d;
  --ink: #1f2933;
  --muted: #667085;
  --paper: #fff8eb;
  --panel: #ffffff;
  --moss: #3f8f52;
  --moss-dark: #21643c;
  --clay: #cb6b43;
  --sky: #4c7ea8;
  --gold: #e0a93f;
  --line: #d8cbb8;
  --shadow: 0 18px 44px rgba(49, 38, 29, 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;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(76, 126, 168, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(224, 169, 63, 0.22), transparent 38%),
    var(--paper);
}

button,
a {
  font: inherit;
}

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

.top-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.top-nav a {
  color: var(--soil);
  text-decoration: none;
  font-weight: 750;
  padding: 9px 12px;
  border: 2px solid rgba(49, 38, 29, 0.16);
  background: rgba(255, 255, 255, 0.7);
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--clay);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.8rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.1rem, 8vw, 5rem);
  line-height: 0.95;
  color: var(--soil);
}

.lede {
  max-width: 740px;
  margin-bottom: 0;
  color: #3f4b55;
  font-size: clamp(1rem, 2vw, 1.24rem);
  line-height: 1.5;
}

.scoreboard {
  min-width: 150px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 5px 14px;
  padding: 14px;
  border: 2px solid rgba(49, 38, 29, 0.18);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.scoreboard span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.scoreboard strong {
  justify-self: end;
  color: var(--soil);
}

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

.play-panel,
.side-panel {
  border: 2px solid rgba(49, 38, 29, 0.14);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.play-panel {
  padding: 18px;
}

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

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.panel-head h2,
.brief-box h2 {
  margin-bottom: 5px;
  font-size: 1.15rem;
}

.panel-head p,
.brief-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

button {
  border: 0;
  background: var(--soil);
  color: #fff;
  font-weight: 850;
  padding: 11px 13px;
  cursor: pointer;
  min-height: 44px;
}

button:hover {
  filter: brightness(1.08);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid var(--soil);
}

.mode-group button {
  background: transparent;
  color: var(--soil);
}

.mode-group button.active {
  background: var(--moss-dark);
  color: #fff;
}

.actions {
  display: grid;
  gap: 10px;
}

#hintBtn {
  background: var(--sky);
}

#clearBtn,
#newBtn {
  background: var(--clay);
}

.message {
  min-height: 4.8em;
  margin: 0;
  padding: 12px;
  color: var(--soil);
  background: #fff4d8;
  border-left: 5px solid var(--gold);
  line-height: 1.45;
  font-weight: 650;
}

.nonogram {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(240px, 540px);
  grid-template-rows: minmax(58px, auto) minmax(240px, 540px);
  justify-content: center;
  gap: 7px;
  touch-action: manipulation;
}

.corner,
.col-clues,
.row-clues,
.grid {
  border: 2px solid var(--line);
  background: #fffdf7;
}

.corner {
  display: grid;
  place-items: end center;
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.col-clues {
  display: grid;
  align-items: end;
}

.row-clues {
  display: grid;
  align-items: stretch;
}

.clue-col,
.clue-row {
  display: flex;
  gap: 3px;
  color: var(--soil);
  font-weight: 850;
  font-size: clamp(0.72rem, 2vw, 0.9rem);
}

.clue-col {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 56px;
  padding: 5px 2px;
}

.clue-row {
  justify-content: flex-end;
  align-items: center;
  min-width: 62px;
  padding: 2px 7px;
}

.grid {
  display: grid;
  aspect-ratio: 1;
}

.cell {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid #cdbcaa;
  background: #f5ead9;
  color: var(--soil);
  padding: 0;
  position: relative;
}

.cell.planted {
  background:
    radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.24) 0 16%, transparent 17%),
    linear-gradient(145deg, var(--moss), var(--moss-dark));
}

.cell.marked::after {
  content: "x";
  color: #8d6b5c;
  font-size: clamp(1.1rem, 6vw, 2.2rem);
  font-weight: 900;
}

.cell.wrong {
  animation: buzz 0.22s linear 2;
  box-shadow: inset 0 0 0 4px #d84a3a;
}

.cell.revealed {
  box-shadow: inset 0 0 0 4px var(--gold);
}

.complete .cell.planted::before {
  content: "";
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: rgba(255, 248, 235, 0.92);
  box-shadow: 0 0 16px rgba(255, 248, 235, 0.85);
}

@keyframes buzz {
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

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

  .scoreboard {
    width: 100%;
  }
}

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

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

  .play-panel,
  .side-panel {
    padding: 12px;
  }

  .panel-head {
    display: grid;
  }

  .nonogram {
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: 58px minmax(0, 1fr);
    gap: 5px;
  }

  .corner {
    padding: 4px;
    font-size: 0.66rem;
  }

  .clue-row {
    min-width: 50px;
    padding: 2px 4px;
  }
}
