:root {
  color-scheme: light;
  --ink: #24313f;
  --muted: #617184;
  --paper: #fff8ed;
  --panel: #ffffff;
  --line: #d7c8aa;
  --grass: #d7ead2;
  --blanket: #fff2cf;
  --accent: #dd5a3d;
  --accent-dark: #a43b27;
  --blue: #277aa3;
  --shadow: 0 18px 46px rgba(70, 52, 32, 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(90deg, rgba(255, 255, 255, 0.32) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--grass);
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font: inherit;
  font-weight: 750;
  min-height: 44px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(36, 49, 63, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

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

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

.top-nav a {
  border: 1px solid rgba(36, 49, 63, 0.18);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  font-weight: 750;
}

.hero {
  margin-bottom: 18px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  line-height: 0.95;
}

.lede {
  max-width: 690px;
  margin: 14px 0 0;
  color: #475263;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  line-height: 1.45;
}

.game-panel,
.rules {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(36, 49, 63, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-panel {
  padding: clamp(14px, 3vw, 24px);
}

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

.status-row > div {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
}

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

.board-wrap {
  display: grid;
  place-items: center;
  margin: 10px 0 18px;
}

.board {
  --cell: min(12.8vw, 68px);
  display: grid;
  grid-template-columns: repeat(6, var(--cell));
  grid-template-rows: repeat(6, var(--cell));
  gap: 6px;
  background: rgba(36, 49, 63, 0.1);
  border: 1px solid rgba(36, 49, 63, 0.14);
  border-radius: 8px;
  padding: 8px;
}

.cell {
  position: relative;
  border: 1px dashed rgba(36, 49, 63, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  min-width: 0;
}

.cell.target {
  background:
    linear-gradient(45deg, rgba(221, 90, 61, 0.12) 25%, transparent 25% 50%, rgba(39, 122, 163, 0.12) 50% 75%, transparent 75%),
    var(--blanket);
  background-size: 18px 18px;
  cursor: pointer;
}

.cell.filled {
  border-style: solid;
  color: white;
  display: grid;
  font-weight: 900;
  place-items: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
}

.cell.invalid-flash {
  animation: shake 0.22s linear;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-3px); }
  66% { transform: translateX(3px); }
}

.tool-row,
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.tool-row {
  margin-bottom: 18px;
}

.tool-row button {
  background: var(--blue);
  box-shadow: 0 6px 0 rgba(39, 122, 163, 0.18);
}

.section-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 1rem;
}

.pieces {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.piece-card {
  background: var(--paper);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  min-height: 116px;
  padding: 10px;
  text-align: left;
  box-shadow: none;
}

.piece-card.selected {
  border-color: var(--accent);
  outline: 3px solid rgba(221, 90, 61, 0.18);
}

.piece-card.used {
  opacity: 0.45;
}

.piece-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 850;
  margin-bottom: 8px;
}

.mini-grid {
  display: grid;
  gap: 3px;
  width: max-content;
}

.mini-dot {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(36, 49, 63, 0.12);
}

.mini-dot.on {
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.message {
  min-height: 2.8rem;
  margin: 16px 0;
  color: var(--accent-dark);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.controls button:first-child {
  background: var(--accent);
  box-shadow: 0 6px 0 rgba(221, 90, 61, 0.18);
}

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

.rules h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.rules ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #4c5c6a;
  line-height: 1.55;
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 16px, 980px);
    padding-top: 12px;
  }

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

  .board {
    --cell: min(13.2vw, 54px);
    gap: 4px;
    padding: 6px;
  }

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

  .piece-card {
    min-height: 106px;
    padding: 8px;
  }

  button {
    flex: 1 1 150px;
  }
}
