:root {
  --canvas: #fff9f2;
  --ink: #19233d;
  --blue: #2457db;
  --coral: #ff725e;
  --teal: #62d6b3;
  --gold: #ffd54a;
  font-family: ui-rounded, "Avenir Next", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, #fff0b8, transparent 22rem),
    var(--canvas);
  line-height: 1.45;
}
button,
a {
  font: inherit;
}
button {
  color: var(--ink);
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.62;
}
:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  color: white;
  background: var(--ink);
  transform: translateY(-180%);
}
.skip-link:focus {
  transform: translateY(0);
}
.game-header {
  border-bottom: 3px solid var(--ink);
  background: white;
}
.game-header__inner {
  display: flex;
  min-height: 68px;
  width: min(calc(100% - 2rem), 1040px);
  margin: auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.home-link,
button {
  min-height: 48px;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: white;
  font-weight: 800;
}
.home-link {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.game-main {
  width: min(calc(100% - 1.5rem), 1040px);
  margin: auto;
  padding: 1.25rem 0 3rem;
}
.card {
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: clamp(1rem, 3vw, 1.4rem);
  background: white;
  box-shadow: 0 5px 0 var(--ink);
}
.primary {
  color: white;
  background: var(--blue);
}
.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.round-head {
  margin: 0 0 1rem;
}
.round-head h1 {
  margin: 0.25rem 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
}
.round-head p {
  margin: 0.3rem 0;
}
.welcome-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: center;
  gap: 1.5rem;
}
.welcome-card h1 {
  margin: 0.2rem 0 0.4rem;
  font-size: clamp(2rem, 6vw, 3.4rem);
}
.welcome-card p {
  max-width: 48ch;
}
.opening-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.opening-board,
.ghost-board {
  display: grid;
  grid-template-columns: repeat(5, 32px);
  grid-template-rows: repeat(4, 32px);
  gap: 3px;
}
.opening-board i,
.ghost-empty {
  border-radius: 5px;
  background: #eee7dd;
}
.opening-board .target {
  border: 2px solid var(--ink);
  background: #fff;
}
.opening-pieces {
  display: grid;
  gap: 0.5rem;
}
.opening-pieces div {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 800;
}
.mini-shape {
  display: grid;
  grid-template-columns: repeat(3, 11px);
  grid-template-rows: repeat(3, 11px);
  width: 33px;
  height: 33px;
  color: var(--ink);
}
.mini-shape i {
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  font-size: 6px;
  font-style: normal;
  line-height: 1;
}
.mini-shape.coral i:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.mini-shape.coral i:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
.mini-shape.coral i:nth-child(3) {
  grid-column: 1;
  grid-row: 3;
}
.mini-shape.coral i:nth-child(4) {
  grid-column: 2;
  grid-row: 3;
}
.mini-shape.teal i:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.mini-shape.teal i:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}
.mini-shape.teal i:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}
.mini-shape.teal i:nth-child(4) {
  grid-column: 2;
  grid-row: 2;
}
.mini-shape.gold i:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.mini-shape.gold i:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
.mini-shape.gold i:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}
.coral {
  background: var(--coral);
}
.teal {
  background: var(--teal);
}
.gold {
  background: var(--gold);
}
.mini-shape.coral,
.mini-shape.teal,
.mini-shape.gold {
  background: transparent;
}
.mini-shape.coral i {
  background: var(--coral);
}
.mini-shape.teal i {
  background: var(--teal);
}
.mini-shape.gold i {
  background: var(--gold);
}
.layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(290px, 0.92fr);
  align-items: start;
  gap: 1rem;
  scroll-margin-top: 0.5rem;
}
.layout > .completion {
  margin-top: 0;
}
.board-card {
  min-width: 0;
}
.board-card > p:first-child {
  margin-top: 0;
  font-weight: 700;
}
.layout:has(.completion:not([hidden])) .board-card > p:first-child {
  display: none;
}
#board {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  grid-template-rows: repeat(4, 48px);
  gap: 3px;
  width: max-content;
  max-width: 100%;
}
.board-cell {
  display: grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 900;
}
.board-cell[hidden] {
  display: none;
}
.board-cell:disabled {
  opacity: 1;
}
.board-cell.coral,
.piece-cell.coral,
.ghost-cell.coral {
  background: var(--coral);
}
.board-cell.teal,
.piece-cell.teal,
.ghost-cell.teal {
  background: var(--teal);
}
.board-cell.gold,
.piece-cell.gold,
.ghost-cell.gold {
  background: var(--gold);
}
#pieces {
  display: grid;
  gap: 0.5rem;
}
.piece-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
}
.piece-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 3px var(--blue);
}
.selector-silhouette {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 30px;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
}
.selector-cell {
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  font-size: 5px;
  line-height: 1;
}
.piece-button.coral {
  background: #ffe0dc;
}
.piece-button.teal {
  background: #d9f8ee;
}
.piece-button.gold {
  background: #fff1ba;
}
#preview {
  display: grid;
  width: max-content;
  min-height: 90px;
  margin: 1rem auto 0.35rem;
  align-content: center;
  justify-content: center;
}
.piece-cell {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1.5px solid var(--ink);
  font-size: 0.7rem;
  font-weight: 900;
}
.anchor-copy {
  margin: 0.3rem 0 1rem;
  font-size: 0.92rem;
  font-weight: 700;
}
.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.actions button {
  min-height: 48px;
}
.actions button:last-child {
  grid-column: span 2;
}
.completion {
  margin-top: 1rem;
}
.completion h2 {
  margin-top: 0;
}
.completion-actions,
.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
#ending {
  scroll-margin-top: 0.5rem;
}
#feedback {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  font-weight: 800;
}
#ghost {
  margin-top: 0.8rem;
  padding: 0.8rem;
  border: 2px dashed var(--ink);
  border-radius: 12px;
  background: #f7f1ff;
}
#ghost p {
  margin: 0.1rem 0 0.65rem;
  font-weight: 700;
}
.ghost-board {
  grid-template-columns: repeat(5, 26px);
  grid-template-rows: repeat(4, 26px);
}
.ghost-cell {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px dashed var(--ink);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 900;
}
dialog {
  width: min(calc(100% - 1.5rem), 620px);
  max-height: calc(100dvh - 1.5rem);
  border: 3px solid var(--ink);
  border-radius: 20px;
  color: var(--ink);
  background: var(--canvas);
}
.help {
  position: relative;
  padding: 1.2rem;
}
.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}
.help h2 {
  margin-top: 0;
  padding-right: 5rem;
}
.help-diagram {
  display: grid;
  width: max-content;
  min-height: 100px;
  margin: 0.7rem 0;
  padding: 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: white;
}
.help-board {
  grid-template-columns: repeat(5, 28px) !important;
  grid-template-rows: repeat(4, 28px) !important;
  min-height: 0;
  gap: 2px;
}
.help-cell {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 900;
}
.help-cell.target {
  border: 1px solid var(--ink);
  background: white;
}
.help-cell.blank {
  background: #eee7dd;
}
.help-cell.overlap {
  border: 2px dashed var(--ink);
  background: linear-gradient(135deg, var(--coral) 0 50%, var(--teal) 50%);
}
.invalid-example {
  margin: 0.8rem 0;
  padding: 0.75rem;
  border: 2px dashed var(--ink);
  border-radius: 10px;
  background: #fff1ba;
  font-weight: 700;
}
.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.help-actions a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0.55rem;
  font-weight: 800;
  color: var(--ink);
}
.noscript {
  margin: 1rem auto;
  width: min(90%, 800px);
}
@media (max-width: 700px) {
  .welcome-card,
  .layout {
    grid-template-columns: 1fr;
  }
  .game-main {
    padding: 0.55rem 0 2rem;
  }
  .round-head {
    margin: 0 0 0.45rem;
  }
  .round-head h1 {
    margin: 0.1rem 0;
  }
  .round-head p {
    margin: 0.15rem 0;
  }
  .layout {
    row-gap: 0.4rem;
  }
  .welcome-card {
    gap: 1rem;
  }
  .opening-preview {
    justify-content: center;
  }
  .board-card {
    display: contents;
  }
  .controls {
    display: contents;
  }
  .board-card > p:first-child,
  .controls > h2,
  .anchor-copy {
    display: none;
  }
  #board {
    grid-row: 1;
    justify-self: center;
  }
  #feedback {
    grid-row: 2;
    justify-self: center;
    margin: 0.35rem 0 0;
    line-height: 1.3;
  }
  #feedback:empty {
    display: none;
  }
  #pieces {
    grid-row: 2;
  }
  #preview {
    grid-row: 3;
    min-height: 54px;
    margin: 0.25rem auto;
  }
  .actions {
    grid-row: 4;
  }
  #undo-note {
    grid-row: 5;
  }
  #ghost {
    grid-row: 6;
  }
  #complete,
  #ending {
    grid-row: 2;
    width: 100%;
  }
  .layout:has(#feedback:not(:empty)) #pieces {
    grid-row: 3;
  }
  .layout:has(#feedback:not(:empty)) #preview {
    grid-row: 4;
  }
  .layout:has(#feedback:not(:empty)) .actions {
    grid-row: 5;
  }
  .layout:has(#feedback:not(:empty)) #undo-note {
    grid-row: 6;
  }
  .layout:has(#feedback:not(:empty)) #ghost {
    grid-row: 7;
  }
  #feedback,
  #ghost {
    width: min(100%, 320px);
  }
  #pieces,
  .actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .piece-button {
    min-width: 0;
    padding: 0.35rem;
    font-size: 0.7rem;
    line-height: 1.1;
  }
  .selector-silhouette {
    display: grid;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    grid-template-columns: repeat(3, 8px);
    grid-template-rows: repeat(3, 8px);
  }
  .actions button {
    min-width: 0;
    padding: 0.35rem 0.2rem;
    font-size: 0.78rem;
    line-height: 1.1;
  }
  .actions button:last-child {
    grid-column: auto;
  }
  .game-header__inner {
    min-height: 60px;
  }
}
@media (max-width: 520px) {
  .game-header__inner:has(.cp-profile-slot:not([hidden])) {
    gap: 0.5rem;
  }
  .game-header__inner:has(.cp-profile-slot:not([hidden])) > strong {
    display: none;
  }
}
@media (max-width: 390px) {
  .game-main {
    width: calc(100% - 1rem);
  }
  .card {
    padding: 0.85rem;
  }
  .opening-preview {
    transform: scale(0.88);
    transform-origin: left center;
    width: 114%;
  }
}
@media (min-width: 700px) and (max-height: 330px) {
  .game-header__inner {
    min-height: 48px;
  }
  .game-main {
    padding: 0.35rem 0;
  }
  .welcome-card {
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
  }
  .welcome-card h1 {
    margin: 0;
    font-size: 2rem;
  }
  .welcome-card p {
    margin: 0.15rem 0;
    line-height: 1.25;
  }
  .opening-board {
    grid-template-columns: repeat(5, 20px);
    grid-template-rows: repeat(4, 20px);
    gap: 2px;
  }
  .opening-preview {
    gap: 0.55rem;
  }
  .opening-pieces {
    gap: 0.15rem;
  }
  .opening-pieces div {
    font-size: 0.67rem;
  }
  .mini-shape {
    grid-template-columns: repeat(3, 8px);
    grid-template-rows: repeat(3, 8px);
    width: 24px;
    height: 24px;
  }
  .mini-shape i {
    font-size: 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
