:root {
  color-scheme: light;
  --bg: #fdf6df;
  --sand: #f4e0a6;
  --panel: rgba(255, 250, 236, 0.92);
  --ink: #3c2f21;
  --accent: #ed7a54;
  --accent-2: #4d7bc4;
  --line: rgba(89, 64, 38, 0.16);
  --shadow: rgba(82, 104, 153, 0.24);
  --good: #2c9b68;
  --warn: #c86d2a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, #fff8e8 0%, #fdf2cc 32%, #f2dda0 100%);
  color: var(--ink);
}

.shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.topnav {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.topnav a { color: var(--accent-2); text-decoration: none; font-weight: 700; }
.topnav a:hover { text-decoration: underline; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(112, 84, 48, 0.12);
}
.hero, .hud, .controls-card, .board-card, .legend, .notes {
  padding: 18px;
  margin-bottom: 16px;
}
.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--warn);
}
.hero h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); }
.subtitle { margin: 10px 0 0; line-height: 1.5; max-width: 48rem; }
.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.hud div {
  background: rgba(255,255,255,0.52);
  border-radius: 16px;
  padding: 12px 14px;
}
.label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #87684a;
  margin-bottom: 4px;
}
.board-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.round-copy, .step-label, .picker-copy, .message, .notes p { margin: 6px 0 0; line-height: 1.45; }
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 480px);
  margin: 0 auto;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(104, 78, 46, 0.12);
  border-radius: 18px;
  background: linear-gradient(180deg, #fbefcb 0%, #f2db99 100%);
  display: grid;
  place-items: center;
  font-size: clamp(1.25rem, 4vw, 2rem);
  overflow: hidden;
}
.tile.shaded::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(74,100,150,0.38), rgba(74,100,150,0.12));
}
.tile.wall { background: linear-gradient(180deg, #8f836c, #71634c); }
.tile.planter { background: linear-gradient(180deg, #7fb46d, #537b42); }
.tile.selected {
  outline: 4px solid rgba(77, 123, 196, 0.48);
  outline-offset: 2px;
}
.tile.targeted { animation: pulse 1s ease-in-out infinite; }
.tile button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  width: 100%;
  height: 100%;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.tile .stack {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
}
.tile .mini {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.9rem;
  z-index: 2;
}
.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.legend div { display: flex; align-items: center; gap: 8px; }
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: inline-block;
  border: 1px solid rgba(40, 32, 22, 0.16);
}
.swatch.parasol { background: linear-gradient(135deg, #ff8d6d, #f1d08a); }
.swatch.scoop { background: linear-gradient(135deg, #fff4c1, #ff9c7b); }
.swatch.wall { background: #7b6c55; }
.swatch.planter { background: #659451; }
.swatch.shadow { background: rgba(74,100,150,0.32); }
.swatch.sun { background: #ffd257; }
.controls-card { text-align: center; }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(2, 72px);
  gap: 10px;
  justify-content: center;
  margin: 16px auto 14px;
  grid-template-areas:
    ". up ."
    "left down right";
}
.move {
  border: 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 20px rgba(95, 73, 40, 0.12);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-2);
}
.move:active { transform: translateY(1px) scale(0.99); }
.up { grid-area: up; }
.left { grid-area: left; }
.right { grid-area: right; }
.down { grid-area: down; }
.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}
button.primary { background: var(--accent); color: #fffdfb; }
button.alt { background: var(--accent-2); color: #fff; }
button.hidden { display: none; }
.message { min-height: 1.6em; font-weight: 700; }
.message.good { color: var(--good); }
.message.warn { color: var(--warn); }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@media (max-width: 720px) {
  .shell { padding: 16px 12px 28px; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-head { flex-direction: column; }
  .board { gap: 6px; }
  .tile { border-radius: 14px; }
}
