:root {
  color-scheme: light;
  --paper: #f5f8fd;
  --white: #ffffff;
  --ink: #243653;
  --muted: #4d607a;
  --line: #c7d4e5;
  --accent: #cce5ff;
  --blue: #245aac;
  --rule: #455a79;
  --error: #9b2d42;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-tap-highlight-color: #245aac30;
}
* { box-sizing: border-box; }
body { margin: 0; }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:where(button, a, main):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip {
  position: fixed; z-index: 5; top: 12px; left: 12px; padding: .65rem .9rem;
  color: var(--white); background: var(--ink); border-radius: 5px; text-decoration: none;
}
.skip:not(:focus) { clip-path: inset(50%); pointer-events: none; }
.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner, main { width: min(100% - 56px, 936px); margin-inline: auto; }
.masthead-inner { min-height: 62px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { display: flex; align-items: center; gap: .65rem; font-size: 1.15rem; font-weight: 750; letter-spacing: -.045em; }
.quiet { min-height: 44px; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: transparent; }
.quiet:hover { background: var(--white); }
main { scroll-margin-top: 12px; }
.heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: .75rem 1.05rem; margin: 27px 0 19px; }
h1, h2 { text-wrap: balance; }
h1 { font: normal clamp(3rem, 6.3vw, 4.7rem)/.94 Georgia, "Times New Roman", serif; letter-spacing: -.075em; margin: 0 0 0 -.04em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 312px); gap: 28px; align-items: start; }
.playfield { position: relative; min-width: 0; }
.board {
  display: grid; grid-template: repeat(9, minmax(0, 1fr)) / repeat(9, minmax(0, 1fr));
  border: 2px solid var(--rule); background: var(--white); width: 100%; aspect-ratio: 1;
  border-radius: 6px; overflow: hidden; user-select: none;
}
.cell {
  display: grid; place-items: center; position: relative; border: 0; border-right: 1px solid #d1dceb;
  border-bottom: 1px solid #d1dceb; background: transparent; border-radius: 0; padding: 0;
  font-size: clamp(1.18rem, 4.9vw, 2.28rem); font-variant-numeric: tabular-nums;
  font-weight: 570; line-height: 1; color: var(--blue); min-width: 0; min-height: 0;
}
.cell:nth-child(9n+3), .cell:nth-child(9n+6) { border-right: 2px solid var(--rule); }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+19):nth-child(-n+27), .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--rule); }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.given { color: var(--ink); font-weight: 750; }
.cell.peer { background: #edf5ff; }
.cell.match { background: #dceaff; }
.cell.incorrect { color: var(--error); background: #fbe8ed; }
.cell.incorrect::after {
  content: ""; position: absolute; inset: auto 34% 16%;
  border-bottom: 2px solid currentColor;
}
.cell.selected { background: var(--accent); box-shadow: inset 0 0 0 2px var(--blue); }
.cell.selected.incorrect { background: #f8dce4; box-shadow: inset 0 0 0 2px var(--error); }
.cell:focus-visible { outline-offset: -5px; z-index: 1; }
@media (hover: hover) {
  .cell:hover:not(.selected) { filter: brightness(.97); }
}
.pencil {
  position: absolute; inset: 7%; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  color: var(--muted); font-size: clamp(.56rem, 1.65vw, .88rem); font-weight: 700;
}
.pencil span { display: grid; place-items: center; }
.veil {
  position: absolute; inset: 0; background: var(--white); border: 2px solid var(--rule);
  display: grid; place-content: center; text-align: center; gap: 15px; border-radius: 6px;
}
.veil strong { font: normal 2.25rem Georgia, serif; }
.console { padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #edf3fb; min-width: 0; }
.stats { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 11px 16px; margin-bottom: 15px; }
.time { display: flex; gap: 10px; align-items: center; }
.label, .progress label { display: block; color: var(--muted); font-size: .82rem; }
.stat-number { display: block; font-size: 1.44rem; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.wrong-count { text-align: right; }
.pause { display: grid; place-items: center; background: transparent; border: 1px solid var(--line); width: 44px; height: 44px; border-radius: 5px; padding: 0; }
.pause span { width: 11px; height: 13px; border-inline: 3px solid currentColor; }
.progress { grid-column: 1 / -1; }
.progress div { display: flex; justify-content: space-between; gap: .3rem; }
#progress-count { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
progress { display: block; appearance: none; border: 0; background: #d6e3f5; border-radius: 3px; overflow: hidden; width: 100%; height: 5px; margin-top: 5px; accent-color: var(--blue); }
progress::-webkit-progress-bar { background: #d6e3f5; }
progress::-webkit-progress-value { background: var(--blue); }
progress::-moz-progress-bar { background: var(--blue); }
.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-bottom: 9px; }
.tools button {
  border: 1px solid transparent; background: transparent; min-height: 49px;
  padding: .25rem .1rem .3rem; border-radius: 5px; font-size: .76rem; font-weight: 670;
}
.tools button:hover:not(:disabled), .pause:hover:not(:disabled) { background: #dceaff; }
.tools button[aria-pressed="true"] { background: var(--accent); border-color: var(--blue); }
.tools button:disabled, .pause:disabled { opacity: .54; }
.tool-icon { display: block; height: 24px; font-size: 1.3rem; line-height: 1; }
#hint-count { color: var(--blue); font: 700 .69rem/1 "Avenir Next", "Segoe UI", system-ui, sans-serif; vertical-align: .12em; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.keypad button {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  background: var(--white); border: 1px solid var(--line); border-radius: 6px;
  min-height: 59px; padding: 4px 2px; font-size: 1.61rem;
  font-weight: 690; line-height: 1; font-variant-numeric: tabular-nums;
}
.keypad button:hover:not(:disabled) { background: #e5f0ff; }
.keypad button:disabled { opacity: .62; }
.keypad .done .key-digit { text-decoration: line-through; text-decoration-thickness: 1px; }
.game-status { min-height: 2.5rem; margin: 9px 0 4px; font-size: .85rem; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }
.game-status.failure { color: var(--error); font-weight: 650; }
.primary { min-height: 44px; border: 1px solid var(--blue); border-radius: 6px; background: var(--blue); color: var(--white); padding: .66rem .85rem; font-weight: 720; }
.primary:hover { background: #1b478a; }
.new-game { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; text-align: left; }
.keyboard { margin: 15px 0 30px; color: var(--muted); font-size: .84rem; }
.keyboard b { margin-inline: .2rem; }
dialog {
  background: var(--white); color: var(--ink); border: 1px solid var(--rule); border-radius: 9px;
  padding: 24px; width: min(100% - 32px, 410px); max-height: 90dvh; overscroll-behavior: contain;
}
dialog::backdrop { background: #243653a8; }
dialog h2 { font: normal 1.85rem Georgia, serif; margin: 0; }
dialog p { line-height: 1.5; margin: 12px 0 19px; overflow-wrap: anywhere; }
dialog form { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

@media (max-width: 720px) {
  .masthead-inner, main { width: min(100% - 28px, 520px); }
  .masthead-inner { min-height: 49px; }
  .masthead .quiet { border-color: transparent; padding-inline: .5rem; }
  .heading { justify-content: space-between; margin: 12px 0 11px; column-gap: .5rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .console { padding: 9px; }
  .stats { grid-template-columns: auto minmax(0, 1fr) auto; margin-bottom: 7px; gap: 5px 8px; }
  .progress { grid-row: 1; grid-column: 2; align-self: center; }
  .wrong-count { grid-column: 3; }
  .progress div { flex-wrap: wrap; justify-content: center; gap: 0 .35rem; }
  .time { gap: 5px; }
  .stat-number { font-size: 1.13rem; }
  .label, .progress label, #progress-count { font-size: .78rem; }
  .tools { margin-bottom: 5px; }
  .tools button { min-height: 44px; font-size: .8rem; }
  .tool-icon { height: 20px; font-size: 1.12rem; }
  .keypad { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; }
  .keypad button { min-height: 45px; font-size: clamp(1.04rem, 4.75vw, 1.6rem); }
    .game-status { min-height: 1rem; margin: 6px 0; font-size: .8rem; }
  .keyboard { margin: 10px 0 20px; }
}
@media (max-width: 360px) {
  .masthead-inner, main { width: calc(100% - 20px); }
  .console { padding-inline: 6px; }
  .progress div { flex-direction: column; align-items: center; }
}

.masthead { background: var(--white); }
.masthead-inner { min-height: 64px; }
.wordmark { color: var(--ink); text-decoration: none; font-size: 1.4rem; }
nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }
nav a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--muted); }
a { text-decoration: none; }
a:hover, nav a:hover, a.wordmark:hover, .masthead a[aria-current]:hover { color: #315e97; }
.masthead nav a { padding-inline: 6px;  }
.masthead a[aria-current] { color: var(--blue); font-weight: 650; }
.heading { align-items: center; justify-content: space-between; }
.intro h1 { font-size: clamp(2rem,5vw,3rem); line-height: 1.08; letter-spacing: -.045em; }
.level-label { display: inline-flex; align-items: center; gap: 9px; font-size: .86rem; color: var(--muted); }
select { min-height: 44px; font: inherit; font-weight: 650; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: white; color: var(--ink); }
.tools button { font-weight: 530; min-height: 60px; }
.tools .tool-icon { display: flex; justify-content: center; align-items: center; position: relative; height: 34px; color: var(--blue); }
.tool-icon svg { height: 30px; width: 30px; }
#hint-count { position: absolute; left: calc(50% + 12px); top: 0; }
.intro, .article { line-height: 1.65; }
.intro { border-top: 1px solid var(--line); margin: 32px 0 44px; padding-top: 18px; }
.intro p, .article p { max-width: 68ch; }
.intro h2, .article h2 { line-height: 1.2; letter-spacing: -.035em; }
main a, footer a { color: var(--blue); }
a:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.article { padding-block: 42px; }
.article h1 { font-size: clamp(2.2rem,6vw,4rem); overflow-wrap: anywhere; }
.article h2 { margin-top: 1.5em; }
footer { background: #e8eff9; border-top: 1px solid var(--line); }
.footer-inner { width: min(100% - 56px,936px); margin: auto; padding-block: 28px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
.footer-inner p { color: var(--muted); margin: 6px 0; font-size: .88rem; }
@media(max-width:720px) {
  .footer-inner { width: min(100% - 28px,520px); }
  .masthead-inner { min-height: 54px; }
  .heading { margin-block: 14px; }
  .level-label { gap: 5px; }
  .tools button { min-height: 54px; }
}

.brand-zone { font-weight: 500; color: var(--blue); }
@media (max-width: 420px) {
  .masthead .wordmark { font-size: 1.08rem; gap: 5px; }
  .masthead nav { gap: 2px; }
  .masthead nav a { padding-inline: 4px; }
}

.heading { justify-content: flex-start; gap: 6px 16px; }
.heading .quiet { border-color: var(--line); }
#daily[aria-pressed="true"] { background: var(--accent); }
.relaxed-label { gap: 4px; }
#relaxed { margin: 0; accent-color: var(--blue); }
.daily-date { color: var(--muted); font-size: .85rem; }
.replay { width: 100%; margin-bottom: 6px; }
.replay[hidden] { display: none; }
