:root {
  color-scheme: light;
  --ink: #16324f;
  --muted: #5b708a;
  --paper: #fff6df;
  --paper-deep: #f6e1b7;
  --panel: rgba(255, 250, 237, 0.88);
  --line: rgba(87, 113, 139, 0.25);
  --blue-1: #8fd3ff;
  --blue-2: #1464a5;
  --blue-3: #083a68;
  --coral: #f38375;
  --gold: #e8b04f;
  --shadow: 0 22px 70px rgba(13, 46, 76, 0.2);
}

* { 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:
    radial-gradient(circle at 15% 10%, rgba(143, 211, 255, 0.5), transparent 28rem),
    radial-gradient(circle at 85% 0%, rgba(243, 131, 117, 0.28), transparent 24rem),
    linear-gradient(145deg, #dff4ff 0%, #fff1cf 55%, #f7d0ba 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px);
  background-size: 42px 42px;
}

button { font: inherit; }

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.top-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.top-links a {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(13, 46, 76, 0.08);
}

.hero {
  text-align: center;
  margin: 0 auto 18px;
  max-width: 790px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #326b89;
  font-weight: 900;
  font-size: .77rem;
}

.eyebrow.small { color: #b05d51; }

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  line-height: .92;
  letter-spacing: -.06em;
}

.lede {
  font-size: clamp(1rem, 2.4vw, 1.28rem);
  color: var(--muted);
  line-height: 1.55;
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px auto;
  max-width: 780px;
}

.scorebar div {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 13px 16px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(13, 46, 76, 0.08);
}

.scorebar span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}

.scorebar strong { font-size: 1.35rem; }

.game-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 34px;
  padding: clamp(18px, 3vw, 30px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.level-copy {
  display: grid;
  grid-template-columns: minmax(170px, .65fr) 1fr;
  gap: 8px 24px;
  align-items: start;
  margin-bottom: 22px;
}

.level-copy h2 { margin-bottom: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.level-copy p:last-child { color: var(--muted); line-height: 1.5; margin-bottom: 0; }

.boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.board-panel {
  background: rgba(255, 246, 223, 0.76);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 16px;
}

.board-panel h3 { margin-bottom: 12px; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  gap: 8px;
  width: min(100%, 390px);
  margin: 0 auto;
  padding: 14px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.72), rgba(255,241,203,.75)),
    var(--paper);
  border: 1px solid rgba(115, 99, 67, 0.18);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}

.cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: 15px;
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 -2px 0 rgba(78, 95, 112, 0.08), 0 5px 12px rgba(13, 46, 76, 0.08);
  position: relative;
  overflow: hidden;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 45% 55% 48% 52%;
  border: 2px solid rgba(255,255,255,.42);
  opacity: 0;
}

.cell.level-1 { background: linear-gradient(135deg, #b9e9ff, var(--blue-1)); }
.cell.level-2 { background: linear-gradient(135deg, #2384c9, var(--blue-2)); }
.cell.level-2::after { opacity: .75; }
.cell.over { outline: 3px solid var(--coral); }
.cell.match { outline: 3px solid rgba(42, 166, 111, 0.65); }

.play .cell { cursor: pointer; transition: transform .12s ease, outline-color .12s ease; }
.play .cell:focus-visible, .play .cell:hover { transform: translateY(-2px); outline: 3px solid var(--gold); }
.play.disabled .cell { cursor: not-allowed; opacity: .7; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin: 24px 0 12px;
}

.section-head h3 { margin-bottom: 0; }
.section-head p { margin-bottom: 0; color: var(--muted); }

.stamp-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.stamp-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.64);
  color: var(--ink);
  padding: 13px;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(13, 46, 76, 0.08);
}

.stamp-card.selected { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(20,100,165,.18); }
.stamp-card:disabled { cursor: not-allowed; opacity: .5; }
.stamp-name { display: block; font-weight: 900; }
.stamp-count { display: block; color: var(--muted); font-size: .9rem; margin-top: 3px; }

.mini-stamp {
  width: 58px;
  height: 58px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 5px;
  background: #f7e7c3;
  border-radius: 15px;
}

.mini-dot { border-radius: 7px; background: rgba(22, 100, 165, .14); }
.mini-dot.on { background: var(--blue-2); box-shadow: inset 0 0 0 2px rgba(255,255,255,.28); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.controls button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.68);
  color: var(--ink);
  padding: 11px 16px;
  font-weight: 900;
  cursor: pointer;
}

.controls button.primary {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, #1464a5, #0b416f);
}

.controls button:disabled { opacity: .45; cursor: not-allowed; }
.hidden { display: none !important; }

.message {
  min-height: 1.6em;
  margin: 14px 0 0;
  color: #265f7b;
  font-weight: 850;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .shell { width: min(100% - 18px, 640px); padding-top: 14px; }
  .scorebar { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .scorebar div { padding: 10px 8px; }
  .level-copy, .boards { grid-template-columns: 1fr; }
  .board { gap: 6px; padding: 10px; }
  .cell { border-radius: 12px; }
  .section-head { display: block; }
  .controls button { flex: 1 1 140px; }
}
