:root {
  --bg: #101c2d;
  --panel: #17283d;
  --panel2: #20354c;
  --text: #f4ecdc;
  --muted: #b8c4ce;
  --gold: #e6bf78;
  --border: #40536a;
  --ink: #20354c;
  --paper: #f4eddd;
  --red: #be4551;
  --cell: 32px;
  color-scheme: dark;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 85% 0, #25374e 0, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.55;
}
body.light {
  --bg: #eee9df;
  --panel: #fcf9f2;
  --panel2: #e3dccc;
  --text: #21334a;
  --muted: #4e6276;
  --gold: #805915;
  --border: #a7a39b;
  --paper: #fffdf5;
  color-scheme: light;
}
button,
select,
input {
  font: inherit;
}
button,
select,
.importLabel {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel2);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  min-height: 44px;
}
button:hover {
  border-color: var(--gold);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.primary {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  font-weight: 700;
}
.light .primary {
  color: #fff;
}
.textButton {
  background: transparent;
  border: 0;
  color: var(--muted);
}
header {
  max-width: 1440px;
  margin: auto;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
  font-size: 17px;
}
.brand small {
  display: block;
  letter-spacing: 0.2em;
  font-size: 10px;
  color: var(--gold);
  margin-top: 5px;
}
.brandmark {
  font-size: 42px;
  color: var(--gold);
}
nav {
  display: flex;
  gap: 8px;
}
nav button {
  background: transparent;
  border-color: transparent;
}
main {
  max-width: 1360px;
  margin: auto;
  padding: 32px 40px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1,
h2 {
  font-family: Georgia, serif;
  font-weight: 400;
}
h1 {
  font-size: 42px;
  line-height: 1.18;
  margin-bottom: 18px;
}
h2 {
  font-size: 28px;
  margin-bottom: 12px;
}
h3 {
  font-size: 19px;
}
em {
  font-weight: 400;
  color: var(--gold);
}
.intro {
  padding: 38px 0 42px;
  max-width: 850px;
}
.intro > p:not(.eyebrow) {
  color: var(--muted);
}
.eyebrow {
  letter-spacing: 0.17em;
  font-size: 11px;
  font-weight: 750;
  color: var(--gold);
  margin-bottom: 12px;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 24px 0 15px;
}
.libraryTitle,
.playHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.libraryTitle h2 {
  margin-bottom: 0;
}
.filters {
  display: flex;
  gap: 14px;
  margin: 24px 0 12px;
  flex-wrap: wrap;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.filters label {
  flex: 1;
  min-width: 145px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.puzzleCard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 190px;
  position: relative;
}
.cardArt {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font:
    42px Georgia,
    serif;
  background: linear-gradient(135deg, transparent, #ffffff06);
  border-radius: 8px;
  margin-bottom: 8px;
}
.cardArt canvas {
  height: 76px;
  width: 76px;
  image-rendering: pixelated;
}
.puzzleCard strong {
  font-size: 16px;
}
.puzzleCard small {
  color: var(--muted);
  font-size: 12px;
}
.badge {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.08em;
}
.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 265px;
  gap: 24px;
  align-items: start;
}
.boardPanel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}
.boardBar,
.boardFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  color: var(--muted);
  font-size: 12px;
}
.boardBar button {
  font-size: 13px;
  padding: 4px 12px;
}
.tools {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 14px;
  border-block: 1px solid var(--border);
  flex-wrap: wrap;
}
.tools button {
  font-size: 13px;
  padding: 6px 10px;
}
.tools button[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
  font-weight: 750;
}
.light .tools button[aria-pressed="true"] {
  color: white;
}
.zoom {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.scroller {
  max-height: 70vh;
  min-height: 300px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
  touch-action: none;
  background: var(--panel);
  scrollbar-color: var(--border) var(--panel);
}
.scroller.pan {
  cursor: grab;
}
.scroller.pan:active {
  cursor: grabbing;
}
#board {
  display: grid;
  width: max-content;
  isolation: isolate;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  margin: auto;
}
.cell {
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-left: 1px solid #a3a7a8;
  border-top: 1px solid #a3a7a8;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  font-size: calc(var(--cell) * 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0;
  border-radius: 0;
  min-height: 0;
  cursor: crosshair;
}
.cell.majorX {
  border-left: 2px solid var(--ink);
}
.cell.majorY {
  border-top: 2px solid var(--ink);
}
.cell.filled {
  background: var(--ink);
  color: var(--paper);
}
.cell.active:not(.filled) {
  background: #e4dbc8;
}
.cell.selected {
  outline: 3px solid #b98120;
  outline-offset: -4px;
  z-index: 2;
}
.cell.mistake:after {
  content: "!";
  position: absolute;
  right: 1px;
  top: -2px;
  font-size: 12px;
  background: #a82739;
  color: white;
  border-radius: 3px;
  padding: 0 2px;
  line-height: 1.15;
}
.cell.deduction:before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px dashed #a86d13;
  pointer-events: none;
}
.clue {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--text);
  background: var(--panel);
  font-weight: 700;
  gap: 3px;
  position: sticky;
  z-index: 3;
  font-size: 14px;
  line-height: 1.1;
}
.clue.row {
  left: 0;
  padding-right: 8px;
  border-top: 1px solid var(--border);
}
.clue.col {
  top: 0;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 8px;
  border-left: 1px solid var(--border);
}
.clue.corner {
  left: 0;
  top: 0;
  z-index: 4;
  align-items: center;
  justify-content: center;
  font-weight: 400;
  color: var(--gold);
  font-size: 20px;
}
.clue.active {
  background: var(--panel2);
  color: var(--gold);
}
.clue.complete {
  box-shadow: inset 0 -3px var(--gold);
}
.clue.complete:after {
  content: "✓";
  font-size: 10px;
  color: var(--gold);
}
.clue.col.complete:after {
  position: absolute;
  top: 0;
  right: 1px;
}
.clue.invalid {
  outline: 2px dotted var(--red);
  outline-offset: -3px;
}
.clue.hintLine {
  background: var(--gold);
  color: var(--bg);
}
.clueNumber {
  border: 0;
  background: none;
  color: inherit;
  min-height: 0;
  padding: 2px;
  border-radius: 2px;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}
.clueNumber.crossed {
  text-decoration: line-through;
  opacity: 0.55;
}
.sideCard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
}
.sideCard p {
  font-size: 14px;
  color: var(--muted);
}
.sideCard h2 {
  font-size: 24px;
}
.twoButtons {
  display: flex;
  gap: 8px;
  margin: 20px 0 10px;
}
.twoButtons button {
  flex: 1;
}
.wide {
  width: 100%;
  margin-bottom: 10px;
}
.result {
  border-color: var(--gold);
}
#revealArt canvas {
  width: 100%;
  max-width: 170px;
  image-rendering: pixelated;
  background: var(--paper);
  padding: 12px;
  border-radius: 6px;
  animation: reveal 0.7s ease-out;
}
#pauseCover {
  position: absolute;
  inset: 54px 0 0;
  background: var(--panel);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 20px;
}
#pauseCover > span {
  font-size: 50px;
  color: var(--gold);
}
[hidden] {
  display: none !important;
}
footer {
  max-width: 1360px;
  margin: 24px auto;
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 600px;
  width: calc(100% - 28px);
  padding: 30px;
  max-height: 90vh;
  overflow: auto;
}
dialog::backdrop {
  background: #07111bd9;
  backdrop-filter: blur(5px);
}
dialog p {
  color: var(--muted);
}
dialog label {
  margin: 14px 0;
}
dialog .check {
  flex-direction: row;
  align-items: flex-start;
  font-size: 15px;
  color: var(--text);
  gap: 12px;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--gold);
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 25px 0;
}
.importLabel {
  display: inline-flex;
  color: var(--text);
  margin: 10px 0;
}
.importLabel input {
  max-width: 100%;
  font-size: 12px;
}
.helpExample {
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  gap: 30px;
}
.helpExample b {
  letter-spacing: 0.15em;
}
#lessonBoard {
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  margin: 20px auto;
}
#lessonBoard button {
  width: 42px;
  height: 42px;
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  border-radius: 3px;
  padding: 0;
}
#lessonBoard .on {
  background: var(--gold);
}
#lessonBoard .lessonClue {
  font-size: 14px;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lessonTarget {
  outline: 3px dashed var(--gold);
}
#status {
  min-height: 24px;
  margin-top: 20px;
  color: var(--gold);
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
@media (max-width: 980px) {
  .desk {
    grid-template-columns: minmax(0, 1fr);
  }
  aside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .sideCard {
    margin: 0;
  }
  main {
    padding: 24px;
  }
  header {
    padding: 18px 24px;
  }
  .intro h1 {
    font-size: 36px;
  }
}
@media (max-width: 600px) {
  header {
    padding: 14px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .brand {
    font-size: 15px;
  }
  .brandmark {
    font-size: 32px;
  }
  nav {
    width: 100%;
    justify-content: space-between;
  }
  nav button {
    padding: 6px 10px;
    font-size: 13px;
  }
  main {
    padding: 20px 12px;
  }
  .intro {
    padding: 12px 3px 30px;
  }
  .intro h1 {
    font-size: 31px;
  }
  .intro > p {
    font-size: 14px;
  }
  .actions button {
    font-size: 13px;
    padding: 9px 12px;
  }
  .filters {
    gap: 8px;
  }
  .filters label {
    min-width: 45%;
  }
  .filters select {
    max-width: 100%;
    font-size: 13px;
  }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .puzzleCard {
    padding: 12px;
    min-height: 175px;
  }
  .puzzleCard strong {
    font-size: 14px;
  }
  .playHeading h1 {
    font-size: 28px;
  }
  .playHeading {
    align-items: flex-start;
    gap: 10px;
  }
  .playHeading button {
    font-size: 12px;
    padding: 6px 9px;
  }
  .playHeading .eyebrow {
    font-size: 10px;
  }
  .tools {
    padding: 8px;
    gap: 5px;
  }
  .tools button {
    padding: 6px 8px;
    font-size: 12px;
  }
  .zoom {
    width: 100%;
    justify-content: flex-end;
  }
  .scroller {
    padding: 8px;
    max-height: 62vh;
    min-height: 250px;
  }
  .boardBar,
  .boardFooter {
    padding: 8px;
    font-size: 10px;
  }
  .boardBar #cellReadout {
    max-width: 65%;
  }
  aside {
    display: block;
  }
  .sideCard {
    margin-top: 12px;
    padding: 18px;
  }
  .sideCard .twoButtons {
    margin: 10px 0;
  }
  .sideCard > p {
    margin-bottom: 12px;
  }
  .boardFooter {
    flex-wrap: wrap;
  }
  footer {
    padding: 20px 12px;
    flex-direction: column;
    gap: 4px;
  }
  .libraryTitle h2 {
    font-size: 25px;
  }
  dialog {
    padding: 22px;
  }
  #lessonBoard button {
    width: 36px;
    height: 36px;
  }
}
/* No padded strip above or beside the sticky clue rails when panning. */
.scroller {
  padding: 0;
}
#board {
  margin: 18px auto;
}
@media (max-width: 600px) {
  #board {
    margin: 8px auto;
  }
}
.clueNumber:disabled {
  opacity: 1;
  cursor: default;
}

/* Games navigation uses normal header/menu flow, never the playfield overlay. */
a.return-games{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:6px 10px;box-sizing:border-box;color:inherit;font:600 13px/1.25 system-ui,sans-serif;letter-spacing:normal;text-decoration:underline;text-underline-offset:3px;white-space:nowrap;border-radius:5px}
a.return-games:hover{background:#ffffff14}a.return-games:focus-visible{outline:2px solid currentColor;outline-offset:2px}
header nav{flex-wrap:wrap;align-items:center}.phone .phoneDialog nav .return-games{grid-column:1/-1}
