@font-face {
  font-family: Manrope;
  src: url("./manrope-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("./manrope-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("./manrope-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --md-sys-color-primary: #2856e8;
  --md-sys-color-on-primary: #fff;
  --md-sys-color-primary-container: #fff0bf;
  --md-sys-color-on-primary-container: #21334f;
  --md-sys-color-secondary-container: #dfe9ff;
  --md-sys-color-on-secondary-container: #17418d;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #691313;
  --md-sys-color-surface: #fcfbf8;
  --md-sys-color-surface-container-lowest: #fff;
  --md-sys-color-surface-container-low: #f0f4fc;
  --md-sys-color-surface-container: #eaf0ff;
  --md-sys-color-surface-container-high: #dde7fa;
  --md-sys-color-on-surface: #29364b;
  --md-sys-color-on-surface-variant: #52627b;
  --md-sys-color-outline: #8c9db8;
  --md-sys-color-outline-variant: #cad5e4;
  --md-sys-color-scrim: #15233f;
  --md-shape-medium: 12px;
  --md-shape-extra-large: 28px;
  --md-shape-full: 999px;
  --md-target: 48px;
  --md-label-size: 14px;
  --md-label-line-height: 20px;
  --gutter: 24px;
  --board-size: 576px;
  --game-gap: 16px;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  color-scheme: light;
  font-family: Manrope, system-ui, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: var(--md-sys-color-primary); text-underline-offset: 3px; }
:is(button, select, summary, a):focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; pointer-events: none; }
[hidden] { display: none !important; }

.header-inner, .layout {
  width: min(100% - var(--gutter) * 2, var(--board-size));
  margin-inline: auto;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 84px; gap: 8px; }
.brand-title { margin: 0; min-width: 0; font: inherit; }
.brand {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px;
  font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -.45px;
  text-decoration: none; white-space: nowrap;
}
.brand-mark { display: block; width: 36px; height: 36px; flex: none; }
.header-actions { display: flex; flex: none; }
.game-switcher {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 128px; min-height: 44px; padding: 0 11px; border: 0;
  border-radius: var(--md-shape-full); background: transparent;
  color: var(--md-sys-color-on-surface); font-size: 12px; line-height: 20px; text-align: left;
}
.game-switcher::before {
  content: ''; position: absolute; inset-inline: 0; top: 50%; height: 28px;
  transform: translateY(-50%); z-index: -1; pointer-events: none;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-full);
  background: var(--md-sys-color-surface-container-lowest);
}
.game-context { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
#modeLabel { font-weight: 500; }
#currentDifficulty, .context-dot { color: var(--md-sys-color-on-surface-variant); }
.game-switcher svg { width: 16px; height: 16px; }
.game-switcher:hover::before { border-color: var(--md-sys-color-outline); }
.game-switcher:focus-visible { outline: 0; }
.game-switcher:focus-visible::before { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }
.level-select { position: relative; display: grid; align-items: center; }
.level-select svg { position: absolute; inset-inline-end: 14px; width: 16px; height: 16px; pointer-events: none; }
.difficulty-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block: 16px; font-size: 13px; line-height: 20px; }
.difficulty-field .level-select { width: 62%; }
.difficulty-field select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: var(--md-target);
  padding: 0 40px 0 14px; border: 1px solid var(--md-sys-color-outline-variant); border-radius: 12px;
  background: var(--md-sys-color-surface-container-lowest); font-size: 15px; font-weight: 600; cursor: pointer;
}
.layout { padding-block: 4px 16px; }
.game { display: grid; gap: var(--game-gap); align-items: start; }
.puzzle, .play-controls { min-width: 0; }

.board-wrap { position: relative; container-type: inline-size; }
#board {
  --sudoku-cell-outline: var(--md-sys-color-outline-variant);
  display: grid; grid-template-rows: repeat(9, minmax(0, 1fr)); width: 100%; aspect-ratio: 1;
  border: 1.2px solid var(--md-sys-color-outline); border-radius: 12px;
  overflow: hidden; background: var(--md-sys-color-surface-container-lowest); user-select: none;
}
.board-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); min-height: 0; }
.cell {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0;
  border-right: 1px solid var(--sudoku-cell-outline);
  border-bottom: 1px solid var(--sudoku-cell-outline);
  padding: 0; background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-primary);
  font-size: clamp(16px, 6.1cqi, 32px); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums;
}
.cell:nth-child(3n) { border-right: 2px solid var(--md-sys-color-outline); }
.cell:last-child { border-right: 0; }
.board-row:nth-child(3n) .cell { border-bottom: 2px solid var(--md-sys-color-outline); }
.board-row:last-child .cell { border-bottom: 0; }
.cell.given { color: var(--md-sys-color-on-surface); font-weight: 600; }
.cell.peer { background: var(--md-sys-color-surface-container-low); }
.cell.same { background: var(--md-sys-color-secondary-container); }
.cell.selected {
  z-index: 1; color: var(--md-sys-color-on-primary-container); background: var(--md-sys-color-primary-container);
  box-shadow: inset 0 0 0 2px var(--md-sys-color-primary);
}
.cell:focus-visible { z-index: 2; outline-offset: -3px; }
.cell.invalid { color: var(--md-sys-color-on-error-container); background: var(--md-sys-color-error-container); }
.cell.invalid::after { content: "!"; position: absolute; right: 3px; bottom: 2px; font-size: 11px; font-weight: 800; }
.pencil-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%;
  padding: 1px; font-size: clamp(7px, 2.6cqi, 14px); color: var(--md-sys-color-on-surface-variant);
}
.pencil-grid span { display: grid; place-items: center; }
.selected .pencil-grid, .invalid .pencil-grid { color: inherit; }

.entry-heading {
  display: grid; grid-template-columns: repeat(3, 1fr); justify-items: center;
  width: 240px; height: 67px; margin: 22px auto 0; padding: 0;
}
.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button {
  min-width: 0; min-height: var(--md-target);
  background-color: var(--button-fill, transparent);
  background-color: color-mix(in srgb, var(--button-fill, transparent), currentColor var(--state-opacity, 0%));
}
.entry-heading button {
  --button-fill: var(--md-sys-color-surface-container-lowest);
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: 50%;
  color: var(--md-sys-color-on-surface-variant); font-weight: 500;
}
.entry-heading svg { width: 20px; height: 20px; }
.entry-heading button span {
  position: absolute; top: 49px; left: 50%; width: 80px; transform: translateX(-50%);
  font-size: 12px; line-height: 18px; text-align: center; white-space: nowrap; pointer-events: none;
}
.entry-heading button[aria-pressed=true] {
  --button-fill: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-primary); border-color: currentColor;
}

.play-controls { position: relative; container-type: inline-size; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; }
.keypad button {
  position: relative;
  --button-fill: var(--md-sys-color-surface-container);
  min-height: 52px; padding: 0; border: 1px solid transparent;
  border-radius: 17px; color: var(--md-sys-color-primary);
  font-size: 25px; line-height: 1; font-weight: 400; font-variant-numeric: tabular-nums;
}
.keypad.notes-mode button[data-digit]:not(:disabled) {
  --button-fill: var(--md-sys-color-surface-container-low);
  font-size: 18px; font-weight: 600; border-style: dashed;
}
.keypad .current-value, .keypad button[aria-pressed=true] {
  --button-fill: var(--md-sys-color-primary); border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary); font-weight: 600;
}
.keypad.notes-mode button[data-digit][aria-pressed=true] {
  --button-fill: var(--md-sys-color-primary); border-style: solid;
  border-color: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
}
@container (min-width: 480px) {
  .keypad { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 9px; }
  .keypad button { min-height: 56px; font-size: 27px; }
}

.feedback, .save-status {
  margin: 12px 0 0; padding: 0; color: var(--md-sys-color-on-surface-variant);
  font-size: 13px; line-height: 20px; font-weight: 400;
}
.feedback.error, .save-status { color: var(--md-sys-color-on-error-container); }

.option-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.option-actions button { padding-inline: 8px; gap: 6px; font-size: 13px; white-space: nowrap; }
.option-actions button svg { width: 18px; height: 18px; }
.option-utilities { display: grid; gap: 0; margin-top: 20px; padding-block: 8px; border-block: 1px solid var(--md-sys-color-outline-variant); }
.option-utilities button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 0; text-align: left; font-size: 14px; }
.option-utilities button:disabled { color: var(--md-sys-color-on-surface-variant); }
.option-utilities button svg { width: 18px; height: 18px; }

.primary, .secondary, .icon-button, .help-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 16px; border-radius: var(--md-shape-full);
  font-size: var(--md-label-size); line-height: var(--md-label-line-height); font-weight: 690; text-align: center;
}
.primary { --button-fill: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); text-decoration: none; }
.secondary { border: 1px solid var(--md-sys-color-outline); color: var(--md-sys-color-primary); }
.clock {
  display: flex; align-items: center; gap: 12px; margin-top: 8px;
  color: var(--md-sys-color-on-surface-variant); font-size: 14px; font-variant-numeric: tabular-nums;
}
.icon-button { --button-fill: var(--md-sys-color-surface-container); width: var(--md-target); padding: 0; }
.site-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 32px; padding-top: 8px; border-top: 1px solid var(--md-sys-color-outline-variant); }
.promotion { container-type: inline-size; margin-inline: calc(var(--gutter) * -1); }
.promotion-inner { width: 320px; margin: 24px auto 0; }
.promotion-label { margin: 0 0 4px; color: var(--md-sys-color-on-surface-variant); font-size: 10px; line-height: 14px; text-align: right; }
.promotion a, .promotion img { display: block; width: 320px; height: 100px; }
.promotion img { max-width: none; }
@container (max-width: 319px) { .promotion-inner { display: none; } }
.help-button { padding-inline: 8px; color: var(--md-sys-color-primary); font-size: 12px; }
.site-foot > .help-button { padding-left: 0; text-decoration: none; color: var(--md-sys-color-on-surface-variant); }
.about-puzzle { flex: 1; color: var(--md-sys-color-on-surface-variant); font-size: 12px; line-height: 1.7; }
.about-puzzle summary { min-height: 48px; display: flex; align-items: center; justify-content: flex-end; cursor: pointer; list-style: none; }
.about-puzzle[open] { flex-basis: 100%; }
.about-puzzle[open] summary { justify-content: flex-start; }
.about-puzzle p { max-width: 64ch; }
.about-puzzle a { display: inline-flex; align-items: center; min-height: 48px; }

:is(.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button):focus-visible { --state-opacity: 12%; }
:is(.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button):active:not(:disabled) { --state-opacity: 12%; }
@media (hover: hover) {
  :is(.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button):hover:not(:disabled) { --state-opacity: 8%; }
  :is(.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button):hover:active:not(:disabled) { --state-opacity: 12%; }
}
:is(.entry-heading button, .keypad button, .secondary, .icon-button):disabled {
  --button-fill: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
}
.entry-heading button:disabled { --button-fill: var(--md-sys-color-surface-container-lowest); }
.secondary:disabled { border-color: var(--md-sys-color-outline-variant); }
@media (prefers-reduced-motion: no-preference) {
  :is(.entry-heading button, .keypad button, .primary, .secondary, .icon-button, .help-button) { transition: background-color 120ms ease-out; }
}

.pause-cover {
  position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center;
  gap: 8px; padding: 12px; text-align: center; background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-shape-medium);
}
.pause-cover h2, dialog h2 { font-size: 24px; font-weight: 670; line-height: 32px; margin: 0; }
.pause-cover p { font-size: 14px; line-height: 20px; margin: 0 0 8px; }
dialog {
  border: 0; border-radius: var(--md-shape-extra-large);
  background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-on-surface);
  padding: 24px; width: min(100% - 32px, 460px); max-height: 85vh; max-height: 85dvh; overflow: auto;
}
dialog::backdrop {
  background: #15233f61;
  background: color-mix(in srgb, var(--md-sys-color-scrim) 38%, transparent);
}
dialog h2 { margin-bottom: 12px; }
dialog p { font-size: 14px; line-height: 20px; color: var(--md-sys-color-on-surface-variant); margin: 0 0 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.dialog-actions button { padding-inline: 12px; }
.dialog-actions .secondary { border: 0; }
#wonDialog { text-align: center; }
#wonDialog button, #infoDialog form button { margin-top: 16px; width: 100%; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.settings-heading h2 { margin: 0; font-size: 22px; }
.dialog-close { display: grid; place-items: center; min-width: 48px; min-height: 48px; padding: 0; border-radius: 24px; color: var(--md-sys-color-on-surface-variant); }
.dialog-close:hover { background: var(--md-sys-color-surface-container); }
#printSheet { display: none; }
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.skip { position: fixed; left: 12px; top: -120px; padding: 12px; background: var(--md-sys-color-surface-container-lowest); z-index: 99; }
.skip:focus { top: 12px; }

@media (max-width: 599px) {
  :root { --gutter: 15px; }
  .header-inner { min-height: 64px; }
  .layout { padding-top: 16px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; }
  .game-switcher { width: 110px; gap: 6px; padding-inline: 9px; font-size: 11px; }
  .game-switcher svg { width: 14px; height: 14px; }
}

@media (max-width: 374px) {
  :root { --gutter: 12px; }
  .brand { gap: 6px; font-size: 15px; }
  .brand-mark { width: 28px; height: 28px; }
}

@media (max-width: 339px) {
  .brand { gap: 5px; }
  .brand-mark { width: 24px; height: 24px; }
  .game-context { gap: 3px; }
  .game-switcher { width: 104px; gap: 4px; padding-inline: 8px; }
}

@media (max-width: 420px) and (max-height: 700px) and (orientation: portrait) {
  .keypad button { min-height: 48px; }
}

@media (max-width: 360px) and (max-height: 650px) and (orientation: portrait) {
  .header-inner { min-height: 56px; }
  .layout { padding-top: 0; }
  .game { --game-gap: 8px; }
  .keypad { gap: 6px; }
  .keypad button { min-height: 48px; }
  .entry-heading { margin-top: 14px; }
}

@media (forced-colors: active) {
  .game-switcher::before { border-color: ButtonText; background: Canvas; }
  .game-switcher:focus-visible::before { outline-color: Highlight; }
  .cell.selected, .entry-heading button[aria-pressed=true], .keypad .current-value, .keypad button[aria-pressed=true] { outline: 2px solid Highlight; outline-offset: -2px; }
  .cell.selected:focus-visible, .entry-heading button[aria-pressed=true]:focus-visible { outline: 3px solid Highlight; outline-offset: -3px; }
  .keypad button, .entry-heading button, .primary, .icon-button { border: 1px solid ButtonText; }
}

@media print {
  @page { size: auto; margin: 16mm; }
  body { background: white; color: black; }
  .site-header, .layout, dialog, .skip, noscript { display: none !important; }
  #printSheet { display: block; max-width: 170mm; margin: 0 auto; }
  #printSheet h1 { font-size: 27px; margin: 0 0 10px; }
  #printSheet p { font: 12px/1.6 Arial; color: black; }
  #printBoard { display: grid; grid-template-columns: repeat(9,1fr); width: 165mm; height: 165mm; border: 2px solid black; margin: 8mm 0; }
  #printBoard span { display: grid; place-items: center; border-bottom: 1px solid #777; border-right: 1px solid #777; font: 25px Arial; color: black; }
  #printBoard span:nth-child(3n) { border-right: 2px solid black; }
  #printBoard span:nth-child(9n) { border-right: 0; }
  #printBoard span:nth-child(n+19):nth-child(-n+27), #printBoard span:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid black; }
  #printBoard span:nth-child(n+73) { border-bottom: 0; }
}
