:root {
  font-family: "Noto Sans", system-ui, sans-serif;
  color: #302d46;
  background: #f4f2f9;
  font-size: 14px;
  --accent: #6c55cc;
  --ink: #302d46;
  --line: #e4dfed;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
.puzzle-list button[hidden] {
  display: none;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  background: white;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  min-height: 42px;
  touch-action: manipulation;
}
button:hover {
  border-color: #b8a6e6;
  background: #f2edfd;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #ae95ec;
  outline-offset: 2px;
}
input,
select {
  color: inherit;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}
select {
  max-width: 100%;
}
h1,
h2,
p {
  margin-top: 0;
}
a {
  color: inherit;
}
.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 14px;
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.reader-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--accent);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -1px;
}
.reader-brand > span {
  font-size: 17px;
}
.reader-brand > strong {
  color: #4b3f68;
  font-size: 14px;
  letter-spacing: -0.3px;
}
.reader-top-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}
.reader-top-actions button {
  font-size: 11px;
}
.reader-shell {
  display: grid;
  grid-template-columns: 275px minmax(0, 1fr);
  min-height: calc(100dvh - 75px);
}
.reader-sidebar {
  padding: 26px 18px;
  background: #fff;
  border-right: 1px solid var(--line);
  max-height: calc(100dvh - 75px);
  overflow: auto;
  position: sticky;
  top: 75px;
}
.reader-sidebar h2 {
  font-size: 19px;
  letter-spacing: -0.6px;
  line-height: 1.5;
  margin-bottom: 15px;
}
.reader-sidebar > select {
  width: 100%;
  font-size: 12px;
}
.book-progress {
  padding: 18px 13px;
  margin: 18px 0;
  background: #f1ecfc;
  border-radius: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  color: #6e56a6;
}
.book-progress span {
  font-size: 11px;
}
.book-progress progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}
.reader-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 15px;
}
.reader-filters select {
  width: 100%;
  font-size: 11px;
  padding: 8px;
}
.puzzle-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.puzzle-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px;
  border-radius: 11px;
}
.puzzle-list .current {
  border-color: #9b7ee4;
  background: #f7f3ff;
  box-shadow: 0 0 0 2px #eee6ff;
}
.entry-number {
  display: grid;
  place-items: center;
  background: #eee8f8;
  border-radius: 9px;
  width: 30px;
  height: 32px;
  color: #8b70bd;
  font-size: 11px;
}
.puzzle-list strong {
  font-size: 12px;
}
.puzzle-list small {
  display: block;
  font-size: 10px;
  color: #8a7b9f;
  margin-top: 3px;
}
.puzzle-list button > span:last-child {
  margin-left: auto;
  color: #5eaf8d;
}
.reader-help {
  margin-top: 20px;
  width: 100%;
}
.small-copy {
  font-size: 10px;
  line-height: 1.7;
  color: #9989aa;
  margin: 15px 0;
}
.reader-main {
  padding: 30px clamp(16px, 4vw, 60px);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}
.reader-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 24px;
}
.reader-heading p {
  font-size: 12px;
  color: #9788a8;
  margin: 0 0 5px;
}
.reader-heading h1 {
  font-size: 29px;
  letter-spacing: -1px;
  margin: 0;
}
.reader-tabs {
  display: flex;
  gap: 5px;
  padding: 5px;
  background: #eae4f5;
  border-radius: 13px;
}
.reader-tabs button {
  border: 0;
  min-height: 34px;
  font-size: 11px;
  padding: 7px 12px;
  background: none;
}
.reader-tabs [aria-pressed="true"] {
  background: white;
  box-shadow: 0 2px 4px #43315c0d;
  color: var(--accent);
}
.play-card {
  background: white;
  padding: 22px clamp(12px, 3vw, 34px);
  border: 1px solid #e7e1ef;
  border-radius: 20px;
  box-shadow: 0 12px 38px #42236708;
  max-width: 100%;
  color: var(--game-ink);
}
.play-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--game-accent);
  font-size: 11px;
}
.play-meta > span {
  padding: 6px 10px;
  background: color-mix(in srgb, var(--game-accent) 10%, white);
  border-radius: 20px;
}
.play-meta > span:empty {
  display: none;
}
.play-help {
  font-size: 12px;
  line-height: 1.8;
  color: #897a96;
  margin: 17px 0 20px;
}
.widget-scroll {
  overflow: auto;
  padding: 5px;
  max-width: 100%;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: calc(min(100%, 620px) * var(--zoom));
  min-width: calc(var(--n) * 23px * var(--zoom));
  margin: 0 auto;
  border: 2px solid var(--game-ink);
  border-radius: 3px;
  overflow: hidden;
  aspect-ratio: 1;
}
.input-cell {
  min-width: 0;
  position: relative;
  border: 0 solid #c6c0ce;
  border-right-width: 1px;
  border-bottom-width: 1px;
  aspect-ratio: 1;
  display: flex;
  background: #fff;
}
.input-cell input {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  text-align: center;
  outline-offset: -3px;
  padding: 1px;
  font-family: var(--puzzle-font, "Noto Sans");
  font-size: clamp(10px, calc(290px / var(--n)), 29px);
  color: var(--game-accent);
  background: transparent;
  min-width: 0;
}
.input-cell.given {
  background: color-mix(in srgb, var(--game-accent) 6%, white);
}
.input-cell.given input {
  color: var(--game-ink);
  font-weight: 700;
}
.input-cell small {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 8px;
  z-index: 1;
  pointer-events: none;
}
.input-cell.wrong,
.wrong {
  background: #ffeded !important;
  box-shadow: inset 0 0 0 2px #d75b69;
}
.blocked {
  background: var(--game-ink);
}
.number-pad {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  max-width: 630px;
  gap: 7px;
  margin: 18px auto 0;
}
.number-pad button {
  font-weight: 700;
  color: var(--game-accent);
  background: color-mix(in srgb, var(--game-accent) 8%, white);
  min-height: 45px;
  padding: 7px;
}
.clues {
  list-style: none;
  padding: 0;
  columns: 2;
  margin-top: 20px;
}
.clues li {
  break-inside: avoid;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.7;
}
.letter-cell {
  min-height: 0;
  min-width: 0;
  border: 0;
  border-right: 1px solid #ebe5f0;
  border-bottom: 1px solid #ebe5f0;
  border-radius: 0;
  padding: 0;
  aspect-ratio: 1;
  font-family: var(--puzzle-font);
  font-size: clamp(10px, 2.5vw, 23px);
  user-select: none;
  touch-action: none;
}
.letter-cell.found {
  background: #ddf2e5;
  color: #226d4e;
}
.word-board {
  touch-action: none;
}
@media (pointer: coarse) {
  .widget-scroll .word-board,
  .widget-scroll .letter-cell,
  .widget-scroll .maze-board,
  .widget-scroll .maze-cell {
    touch-action: pan-x pan-y;
  }
}
.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}
.word-list span {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 11px;
}
.word-list .done {
  background: #ddf2e5;
  color: #357a5d;
  text-decoration: line-through;
}
.maze-board {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: calc(min(100%, 620px) * var(--zoom));
  min-width: calc(var(--n) * 13px * var(--zoom));
  aspect-ratio: 1;
  margin: auto;
  touch-action: none;
}
.maze-cell {
  padding: 0;
  min-height: 0;
  aspect-ratio: 1;
  border-style: solid;
  border-color: var(--game-ink);
  border-radius: 0;
  color: var(--game-accent);
  font-size: clamp(8px, 1.8vw, 18px);
  user-select: none;
}
.maze-cell.visited {
  background: #e9e0fa;
}
.maze-cell.player {
  background: #d9c8ff;
  color: #6541b3;
}
.move-pad {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 18px auto;
}
.move-pad button {
  min-width: 50px;
  font-size: 22px;
}
.nonogram {
  border-collapse: collapse;
  margin: auto;
  font-size: 11px;
}
.nonogram th {
  font-weight: 500;
  padding: 3px 5px;
  color: var(--game-ink);
  white-space: nowrap;
}
.nonogram thead th span {
  display: block;
}
.nonogram td {
  padding: 0;
  border: 1px solid #c6bbd6;
}
.nonogram td button {
  display: grid;
  place-items: center;
  width: calc(30px * var(--zoom));
  height: calc(30px * var(--zoom));
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 20px;
}
.nonogram .filled {
  background: var(--game-ink);
}
.widget-options {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.widget-options button {
  font-size: 11px;
}
.widget-options [aria-pressed="true"] {
  border-color: var(--game-accent);
  background: color-mix(in srgb, var(--game-accent) 10%, white);
}
.math-problems {
  max-width: 600px;
  margin: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.math-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  justify-content: flex-end;
}
.math-row strong {
  white-space: nowrap;
}
.math-row input {
  width: 90px;
  min-width: 0;
  text-align: center;
  font-size: 18px;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 650px;
  margin: auto;
}
.memory-card {
  aspect-ratio: 1;
  min-width: 0;
  font-family: var(--puzzle-font);
  font-size: clamp(12px, 2vw, 21px);
  font-weight: 700;
  overflow: hidden;
  color: white;
  border: 2px solid color-mix(in srgb, var(--game-accent) 80%, white);
  background: var(--game-accent);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--game-accent) 55%, #222);
}
.memory-card.face-up {
  background: #fff;
  color: var(--game-ink);
}
.memory-card.matched {
  opacity: 1;
  border-color: #8ec3a9;
  background: #ecf6f0;
  box-shadow: 0 3px 0 #b7d7c6;
}
.memory-card img,
.bingo-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bingo-draw {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 18px;
}
.bingo-draw img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  vertical-align: middle;
}
.bingo-cell {
  border-radius: 0;
  min-height: 0;
  min-width: 0;
  padding: 5px;
  aspect-ratio: 1;
  font-size: clamp(12px, 3vw, 24px);
  overflow: hidden;
}
.bingo-cell.marked {
  background: #e3d4ff;
  color: var(--game-accent);
  box-shadow: inset 0 0 0 3px var(--game-accent);
}
.draw-history {
  font-size: 11px;
  line-height: 1.8;
  color: #9c8baa;
  overflow-wrap: anywhere;
}
.domino-chain {
  padding: 12px;
  background: #f7f3fb;
  border-radius: 12px;
  margin-bottom: 15px;
}
.domino-chain > div:first-child {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.domino-chain button {
  font-size: 11px;
}
.tile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.domino-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c2b5d3;
  padding: 10px 14px;
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
  box-shadow: 0 3px 0 #ddd4e8;
}
.domino-tile.selected {
  outline: 3px solid var(--game-accent);
}
.dice-panel {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.dice-panel > strong {
  font-size: 30px;
  color: var(--game-accent);
}
.dice-panel b {
  font-size: 12px;
  color: #b77d36;
}
.game-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  min-width: 300px;
}
.board-space {
  border: 2px solid #ddd3e9;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  gap: 3px;
  background: #faf8fd;
  font-weight: 700;
}
.board-space small {
  font-size: 9px;
}
.board-space.event {
  background: #fff2d5;
  border-color: #edcf91;
}
.board-space.current {
  border-color: var(--game-accent);
  background: #eadfff;
  color: var(--game-accent);
  box-shadow: 0 4px 0 #d1c0e8;
}
.jigsaw-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  width: calc(min(100%, 650px) * var(--zoom));
  min-width: calc(var(--cols) * 25px * var(--zoom));
  margin: auto;
  border: 2px solid var(--game-ink);
}
.piece {
  border-radius: 0;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  background-color: #f0e8fa;
  background-repeat: no-repeat;
  font-size: clamp(8px, 2vw, 18px);
  position: relative;
  border: 1px solid #ffffffb0;
  box-shadow: inset 0 0 0 1px #7763933d;
}
.piece span {
  background: #ffffffd9;
  border-radius: 3px;
  padding: 1px 4px;
}
.piece.selected {
  outline: 3px solid #efb54e;
  outline-offset: -4px;
  z-index: 1;
}
.play-status {
  font-size: 12px;
  color: #9c8aaa;
  margin: 20px 0 14px;
  padding: 10px 13px;
  background: #f6f3fa;
  border-radius: 9px;
}
.play-status.complete {
  background: #e4f5eb;
  color: #287850;
  font-weight: 700;
}
.play-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.play-actions button {
  font-size: 11px;
}
.play-actions [data-action="check"] {
  background: var(--game-accent);
  color: white;
  border-color: transparent;
}
.reader-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  font-size: 10px;
  color: #9c8aaa;
  flex-wrap: wrap;
}
.reader-footer #reader-clock {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.reader-footer button {
  font-size: 11px;
}
.sheet-preview {
  overflow: auto;
  background: #e6e0ed;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  max-width: 100%;
}
.sheet-preview svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
  box-shadow: 0 7px 20px #40304e15;
}
.print-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.print-toolbar button {
  font-size: 11px;
}
.empty-reader {
  margin: 70px auto;
  max-width: 500px;
  text-align: center;
  line-height: 1.8;
}
.empty-reader h1 {
  font-size: 34px;
  color: var(--accent);
  letter-spacing: -1px;
}
#reader-notice {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translate(-50%, 15px);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  background: #554095;
  color: white;
  border-radius: 12px;
  padding: 13px 20px;
  max-width: min(90%, 600px);
  font-size: 12px;
  line-height: 1.7;
  box-shadow: 0 8px 25px #32204c25;
}
#reader-notice.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#print-area {
  display: none;
}
@media (max-width: 1000px) {
  .reader-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .reader-main {
    padding: 24px 20px;
  }
  .reader-top {
    padding: 12px 18px;
  }
  .reader-top-actions {
    gap: 5px;
  }
  .reader-top-actions button {
    font-size: 10px;
    padding: 8px;
  }
  .reader-brand strong {
    font-size: 12px;
  }
  .math-problems {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .reader-top {
    position: relative;
    align-items: flex-start;
    padding: 12px;
    flex-wrap: wrap;
  }
  .reader-brand {
    font-size: 23px;
  }
  .reader-top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .reader-top-actions button {
    min-height: 36px;
  }
  .reader-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .reader-sidebar {
    position: relative;
    top: auto;
    max-height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
  .reader-sidebar h2 {
    font-size: 15px;
    margin-bottom: 10px;
  }
  .reader-sidebar > select {
    max-width: 100%;
    width: 100%;
  }
  .book-progress {
    margin: 10px 0;
    padding: 9px 12px;
  }
  .reader-filters {
    margin-bottom: 8px;
  }
  .puzzle-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 7px;
  }
  .puzzle-list button {
    min-width: 145px;
    flex-shrink: 0;
  }
  .reader-help,
  .small-copy {
    display: none;
  }
  .reader-main {
    padding: 20px 12px;
  }
  .reader-heading {
    gap: 8px;
    margin-bottom: 15px;
  }
  .reader-heading h1 {
    font-size: 23px;
  }
  .reader-heading p {
    font-size: 10px;
    max-width: 200px;
  }
  .reader-tabs button {
    padding: 6px 9px;
    font-size: 10px;
  }
  .play-card {
    border-radius: 15px;
    padding: 15px 10px;
  }
  .play-help {
    font-size: 11px;
    margin: 14px 4px;
  }
  .play-meta {
    font-size: 10px;
  }
  .play-meta span {
    padding: 5px 8px;
  }
  .clues {
    columns: 1;
  }
  .cards-grid {
    gap: 7px;
  }
  .memory-card {
    padding: 5px;
  }
  .number-pad {
    gap: 5px;
  }
  .number-pad button {
    min-height: 40px;
  }
  .reader-footer {
    gap: 8px;
  }
  .sheet-preview {
    padding: 8px;
  }
  .nonogram td button {
    width: calc(26px * var(--zoom));
    height: calc(26px * var(--zoom));
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition:
      background 0.12s,
      box-shadow 0.12s;
  }
  .memory-card {
    transition:
      background 0.2s,
      transform 0.2s;
  }
  .memory-card.face-up {
    transform: translateY(2px);
  }
}
@media print {
  body {
    background: white;
  }
  #reader,
  #reader-notice {
    display: none !important;
  }
  #print-area {
    display: block;
  }
  .print-page {
    display: block;
    margin: 0;
    break-after: page;
    overflow: hidden;
  }
  .print-page:last-child {
    break-after: auto;
  }
  .print-page svg {
    display: block;
    width: 100%;
    height: 100%;
  }
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
