:root {
  --ink: #12324d;
  --deep-blue: #0c4f81;
  --soft-blue: #b9e7ff;
  --card: rgba(255, 255, 255, 0.86);
  --line: rgba(21, 78, 121, 0.20);
  --line-strong: #2f82bf;
  --shadow: 0 20px 55px rgba(22, 87, 128, 0.17);
}

* { 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 88% 14%, rgba(151, 217, 255, 0.98) 0 15rem, transparent 34rem),
    radial-gradient(circle at 14% 84%, rgba(196, 237, 255, 0.9) 0 18rem, transparent 34rem),
    linear-gradient(135deg, #effaff 0%, #dff5ff 45%, #aee3ff 100%);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 32px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 900;
  color: var(--deep-blue);
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 7.25rem);
  line-height: 0.95;
  letter-spacing: -0.075em;
  font-weight: 900;
  color: #112f49;
  text-shadow: 0 7px 0 rgba(255,255,255,0.78);
}

.tagline {
  max-width: 760px;
  margin: 22px auto 14px;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  line-height: 1.4;
  color: #486983;
  font-weight: 600;
}

a {
  color: #074f82;
  font-weight: 900;
  text-underline-offset: 5px;
}

.site-link {
  font-size: 1.05rem;
}

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

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
}

.label, .palette-card h2 {
  display: block;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.84rem;
  font-weight: 900;
  color: #486983;
}

.segmented, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 1px solid rgba(21, 78, 121, 0.18);
  border-radius: 14px;
  padding: 12px 18px;
  background: rgba(255,255,255,0.72);
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(32, 97, 140, 0.08);
}

button:hover, button:focus-visible {
  transform: translateY(-1px);
  outline: 3px solid rgba(47, 130, 191, 0.18);
}

button.active, .primary {
  background: linear-gradient(180deg, #105a91, #074b7c);
  color: white;
  border-color: transparent;
}

.status-row {
  min-height: 42px;
  margin: 18px 0;
  color: #486983;
  font-weight: 750;
}

.board-wrap {
  overflow: auto;
  padding: 4px;
}

.board {
  --size: 9;
  --box: 3;
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(34px, 1fr));
  width: min(100%, calc(var(--size) * 62px));
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
}

.cell {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  font-size: clamp(1.15rem, calc(12vw / var(--size) + 1rem), 2rem);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  user-select: none;
  position: relative;
}

.cell.box-right { border-right: 3px solid var(--line-strong); }
.cell.box-bottom { border-bottom: 3px solid var(--line-strong); }
.cell:nth-child(var(--size)n) { border-right: 0; }
.cell.given { font-weight: 900; }
.cell.editable { cursor: pointer; }
.cell.selected { outline: 4px solid rgba(7, 79, 130, 0.35); outline-offset: -4px; z-index: 2; }
.cell.same { filter: saturate(1.15) brightness(0.97); }
.cell.conflict { box-shadow: inset 0 0 0 4px rgba(225, 50, 50, 0.55); }

.palette-card {
  margin-top: 22px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255,255,255,0.68);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

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

.palette button {
  aspect-ratio: 1 / 1;
  padding: 6px;
  font-size: 1.55rem;
}

.clear { margin-top: 14px; width: 100%; }

footer {
  text-align: center;
  margin-top: 24px;
  color: #486983;
  font-weight: 700;
}

@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr; }
  .app-shell { padding-top: 30px; }
}
