:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-strong: #fff8e7;
  --ink: #172026;
  --muted: #5c6972;
  --line: #d9ded6;
  --teal: #087f8c;
  --coral: #d1495b;
  --amber: #f7b801;
  --blue: #276fbf;
  --shadow: 0 20px 45px rgba(23, 32, 38, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

a {
  color: inherit;
}

.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  display: block;
}

.top-links,
.site-footer {
  color: var(--muted);
  font-size: 14px;
}

.top-links {
  display: flex;
  gap: 18px;
}

.top-links a,
.site-footer a {
  text-decoration: none;
}

.top-links a:hover,
.site-footer a:hover {
  color: var(--ink);
}

main {
  overflow: hidden;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(320px, 1.12fr);
  align-items: center;
  gap: 32px;
  width: min(1120px, calc(100% - 32px));
  min-height: calc(100svh - 92px);
  margin: 0 auto;
  padding: 18px 0 42px;
}

.game-copy {
  max-width: 520px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 11ch;
  margin-bottom: 18px;
  font-size: 52px;
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.intro {
  max-width: 48ch;
  color: var(--muted);
  font-size: 18px;
}

.mode-bar,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-bar {
  margin-top: 28px;
}

.segmented,
.actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.segmented {
  min-width: 112px;
  padding: 0 18px;
}

.segmented.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.size-control {
  display: grid;
  gap: 8px;
  max-width: 220px;
  margin-top: 18px;
}

.size-control label,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.size-control select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.game-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.scorebar > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
  padding: 10px;
}

.scorebar strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.1;
}

.status {
  min-height: 24px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 15px;
}

.board-wrap {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(8, 127, 140, 0.07), rgba(247, 184, 1, 0.08)),
    #f9faf8;
  padding: 12px;
}

.board {
  display: grid;
  width: min(100%, 548px);
  aspect-ratio: 1;
  gap: 8px;
  touch-action: manipulation;
}

.tile {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.38),
    0 8px 16px rgba(23, 32, 38, 0.16);
  cursor: pointer;
}

.tile:focus-visible,
.tile.is-selected {
  outline: 4px solid #ffffff;
  outline-offset: -7px;
  box-shadow:
    inset 0 0 0 2px var(--ink),
    0 10px 20px rgba(23, 32, 38, 0.18);
}

.tile.is-fixed {
  cursor: default;
}

.tile.is-fixed::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.22);
  content: "";
}

.board.show-cues .tile::before {
  position: absolute;
  top: 7px;
  left: 7px;
  min-width: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  content: attr(data-cue);
  font-size: 12px;
  font-weight: 850;
  line-height: 24px;
  text-align: center;
  text-shadow: none;
}

.actions {
  margin-top: 14px;
}

.actions button {
  flex: 1 1 116px;
  padding: 0 14px;
}

.actions button:hover,
.segmented:hover {
  border-color: var(--ink);
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.share-output {
  width: 100%;
  min-height: 94px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
  color: var(--ink);
  padding: 10px;
  resize: vertical;
}

.content-band {
  padding: 58px 0;
  background: var(--surface);
}

.content-band.alt {
  background: var(--surface-strong);
}

.content-inner {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
}

.content-inner p,
.steps {
  color: var(--muted);
  font-size: 17px;
}

.steps {
  display: grid;
  gap: 12px;
  max-width: 720px;
  padding-left: 22px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.link-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 16px;
  text-decoration: none;
}

.link-card:hover {
  border-color: var(--ink);
}

.link-card span {
  font-size: 17px;
  font-weight: 850;
}

.link-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

details {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

details:last-child {
  border-bottom: 1px solid var(--line);
}

summary {
  cursor: pointer;
  font-weight: 800;
}

details p {
  max-width: 68ch;
  margin: 12px 0 0;
}

.site-footer {
  min-height: 82px;
  flex-wrap: wrap;
}

@media (max-width: 880px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 20px;
    min-height: auto;
    padding-top: 12px;
  }

  .game-copy {
    max-width: none;
  }

  h1 {
    max-width: 13ch;
    font-size: 42px;
  }

  .intro {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: center;
    min-height: 62px;
    gap: 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand img {
    width: 30px;
    height: 30px;
  }

  .top-links {
    gap: 12px;
    font-size: 13px;
  }

  .game-layout {
    gap: 14px;
    padding-top: 0;
  }

  .eyebrow {
    margin-bottom: 6px;
  }

  h1 {
    max-width: 20ch;
    margin-bottom: 10px;
    font-size: 34px;
  }

  .intro {
    margin-bottom: 0;
    font-size: 15px;
  }

  .mode-bar {
    margin-top: 14px;
  }

  .game-panel {
    padding: 10px;
  }

  .scorebar {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .scorebar > div {
    padding: 8px;
  }

  .scorebar strong {
    font-size: 20px;
  }

  .status {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .board {
    gap: 6px;
  }

  .board-wrap {
    padding: 8px;
  }

  .actions button {
    flex-basis: calc(50% - 5px);
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .link-grid {
    grid-template-columns: 1fr;
  }
}
