
.game-title { position: relative; width: fit-content; justify-self: center; }
.beta-label { position: absolute; top: 0; left: calc(100% + 5px); font-size: 11px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.sudoku-loading .scores, .sudoku-loading .play-layout { display: none; }
.sudoku-loading #theme { visibility: hidden; }
.puzzle-loading { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 20px; gap: 22px; transition: opacity 180ms ease-out; }
.puzzle-loading.is-leaving { opacity: 0; }
.sudoku-revealing .scores, .sudoku-revealing .play-layout { animation: puzzle-reveal 220ms ease-out both; }
@keyframes puzzle-reveal { from { opacity: 0; } to { opacity: 1; } }
.puzzle-loading p { margin: 0; color: var(--muted); font-size: 15px; }
.loading-digits { display: grid; grid-template-columns: repeat(3, 24px); gap: 9px; color: var(--primary); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.loading-digits span { animation: loading-digit 1800ms ease-in-out infinite; }
.loading-digits span:nth-child(2) { animation-delay: -1200ms; }
.loading-digits span:nth-child(3) { animation-delay: -400ms; }
.loading-digits span:nth-child(4) { animation-delay: -1600ms; }
.loading-digits span:nth-child(5) { animation-delay: -800ms; }
.loading-digits span:nth-child(6) { animation-delay: -200ms; }
.loading-digits span:nth-child(7) { animation-delay: -1000ms; }
.loading-digits span:nth-child(8) { animation-delay: -600ms; }
.loading-digits span:nth-child(9) { animation-delay: -1400ms; }
@keyframes loading-digit { 0%, 100% { opacity: .15; transform: translateY(2px); } 35%, 55% { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .loading-digits span, .sudoku-revealing .scores, .sudoku-revealing .play-layout { animation: none; } .puzzle-loading { transition: none; } }
.grid { display: grid; grid-template-columns: repeat(9, 1fr); border: 2px solid var(--edge); background: var(--board); }
.cell { width: 100%; min-width: 0; min-height: 0; aspect-ratio: 1; border: 0; border-right: 1px solid var(--key-border); border-bottom: 1px solid var(--key-border); border-radius: 0; padding: 0; text-align: center; font: 500 clamp(18px, 5vw, 25px)/1 sans-serif; background: var(--board); color: var(--text); caret-color: transparent; }
.cell:nth-child(3n) { border-right: 2px solid var(--edge); }
.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(--edge); }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.given { color: var(--text); font-weight: 750; background: var(--secondary); }
.cell.matching { background: color-mix(in srgb, #458bd6 22%, var(--board)); box-shadow: inset 0 0 0 1px color-mix(in srgb, #458bd6 50%, transparent); }
.cell.selected { background: color-mix(in srgb, var(--primary) 18%, var(--board)); outline: 2px solid var(--primary); outline-offset: -2px; }
.cell.invalid { color: #c34646; background: color-mix(in srgb, #c34646 12%, var(--board)); }
.cell.current { background: var(--primary); color: white; }
.actions { display: flex; justify-content: center; gap: 12px; }
.actions button { padding: 12px 18px; }
dialog { width: min(90vw, 390px); padding: 26px 20px; border: 1px solid var(--key-border); border-radius: 10px; background: var(--board); color: var(--text); text-align: center; }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog h2 { margin: 0; font-size: 23px; } dialog p { color: var(--muted); line-height: 1.6; margin: 14px 0 22px; }
.scores { justify-content: center; }
#start-screen { inset: 0; }
#start { min-width: 160px; min-height: 62px; font-size: 24px; }
.number-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 300px); margin: 20px auto 16px; }
.number-pad button { min-height: 48px; padding: 8px; background: var(--board); color: var(--text); font-size: 22px; font-weight: 650; border: 1px solid var(--key-border); box-shadow: 0 2px 0 var(--key-border); }
.number-pad button:enabled:hover { background: color-mix(in srgb, var(--primary) 12%, var(--board)); border-color: var(--primary); }
.number-pad button.complete { background: color-mix(in srgb, var(--primary) 18%, var(--board)); color: var(--primary); border-color: var(--primary); opacity: .5; box-shadow: none; cursor: default; }
.number-pad .erase { grid-column: 1 / -1; background: var(--board); color: var(--muted); font-size: 15px; }
@media (max-height: 800px) { .game-page { padding-top: 16px; padding-bottom: 16px; } .game-header { margin-bottom: 12px; } .number-pad { margin-top: 14px; gap: 6px; } .number-pad button { min-height: 44px; } }

.play-layout { display: grid; gap: 16px; }
.controls { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(110px, 1fr); gap: 12px; align-items: start; }
.number-pad { width: 100%; margin: 0; gap: 6px; }
.actions { flex-direction: column; gap: 10px; padding-top: 0; }
.actions button { padding: 12px 10px; font-size: 14px; }
@media (min-width: 760px) {
  .game-layout { --game-width: 760px; }
  .play-layout { grid-template-columns: minmax(0, 460px) minmax(230px, 1fr); gap: 28px; align-items: start; }
  .controls { grid-template-columns: 1fr; gap: 20px; }
  .number-pad { gap: 12px; }
  .actions { flex-direction: row; gap: 8px; }
  .actions button { flex: 1; }
  .number-pad button { aspect-ratio: 1; min-height: 0; padding: 12px; }
  .number-pad .erase { aspect-ratio: auto; min-height: 44px; }
}
@media (max-width: 759px) and (max-height: 740px) {
  .game-layout { width: min(100%, calc(100svh - 350px)); min-width: 270px; }
  .game-header { margin-bottom: 8px; }
  .scores { margin-bottom: 8px; }
  .play-layout { gap: 10px; }
  .controls { gap: 6px 10px; }
}
@media (min-width: 760px) and (max-height: 650px) {
  .game-layout { --game-width: 680px; }
  .play-layout { grid-template-columns: minmax(0, calc(100svh - 150px)) minmax(230px, 1fr); }
}

/* Keep game settings with the action buttons on both layouts. */
.action-settings { display: grid; gap: 14px; min-width: 0; }
.number-pad .erase { background: #8c4141; border-color: #8c4141; color: #fff; }
#new { background: var(--primary); color: #fff; }
#solve { background: #365c98; color: #fff; }
.number-pad .erase:hover { background: #753535; }
#new:hover { background: var(--primary-hover); }
#solve:hover { background: #294a80; }
:root[data-theme='dark'] .number-pad .erase { background: #a94d4d; border-color: #a94d4d; }
:root[data-theme='dark'] #solve { background: #406dad; }
.conflict-option { display: flex; align-items: center; justify-content: flex-start; text-align: left; gap: 7px; min-height: 36px; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.conflict-option input { appearance: none; width: 18px; height: 18px; margin: 0; flex: 0 0 18px; border: 1.5px solid var(--key-border); border-radius: 5px; background: var(--board); cursor: pointer; display: grid; place-content: center; }
.conflict-option input:checked { background: var(--primary); border-color: var(--primary); }
.conflict-option input:checked::after { content: ''; width: 8px; height: 4px; border-left: 2px solid white; border-bottom: 2px solid white; transform: translateY(-1px) rotate(-45deg); }
.conflict-option input:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.conflict-option:has(input:disabled) { opacity: .45; cursor: default; }

.conflict-option, .conflict-option input { -webkit-tap-highlight-color: transparent; }
.conflict-option input:focus:not(:focus-visible) { outline: none; box-shadow: none; }

#confirm .overlay-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#confirm .overlay-actions button { width: 100%; min-width: 0; padding: 12px 8px; }

/* Emphasize continuing; keep reset and reveal actions secondary. */
#confirm #cancel { background: var(--primary); color: #fff; }
#confirm #cancel:hover { background: var(--primary-hover); }
#confirm:not(.completed-new) #confirm-solve { background: var(--board); color: var(--muted); border: 1px solid var(--key-border); }
#confirm:not(.completed-new) #confirm-solve:hover { background: var(--secondary); color: var(--text); }

#confirm:not(.completed-new) #confirm-solve { background: #e5edf8; color: #365c98; border-color: #c3d3eb; }
#confirm:not(.completed-new) #confirm-solve:hover { background: #d6e3f5; color: #294a80; }
:root[data-theme='dark'] #confirm:not(.completed-new) #confirm-solve { background: #293c56; color: #bbd3f5; border-color: #42618b; }
:root[data-theme='dark'] #confirm:not(.completed-new) #confirm-solve:hover { background: #334b6a; color: #dbe9ff; }
#confirm.new-puzzle:not(.completed-new) #confirm-solve { background: #365c98; border-color: #365c98; color: white; }
#confirm.new-puzzle:not(.completed-new) #confirm-solve:hover { background: #294a80; border-color: #294a80; }
:root[data-theme='dark'] #confirm.new-puzzle:not(.completed-new) #confirm-solve { background: #406dad; border-color: #406dad; color: white; }
:root[data-theme='dark'] #confirm.new-puzzle:not(.completed-new) #confirm-solve:hover { background: #365c98; border-color: #365c98; }

#confirm { position: relative; padding-top: 46px; }
.dialog-close { position: absolute; top: 3px; right: 3px; color: var(--muted); -webkit-tap-highlight-color: transparent; }
.dialog-close svg { width: 19px; height: 19px; }

#confirm.completed-new .overlay-actions { margin-top: 24px; }
#confirm.completed-new #cancel { background: var(--secondary); color: var(--text); }
#confirm.completed-new #cancel:hover { background: var(--secondary-hover); }
#confirm.completed-new #confirm-solve { background: var(--primary); border-color: var(--primary); color: white; }
#confirm.completed-new #confirm-solve:hover { background: var(--primary-hover); }

.completion { inset: 0; flex-direction: column; gap: 12px; padding: 20px; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; animation: completion-arrive 280ms ease-out both; }
.completion h2 { margin: 0; font-size: clamp(23px, 6vw, 32px); font-weight: 750; color: var(--primary); }
.completion p { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.completion-dismiss { margin-top: 18px; font-size: 13px; color: var(--muted); }
.grid.won { animation: completion-blink 350ms ease-in-out 2; }
@keyframes completion-arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes completion-blink { 50% { opacity: .55; box-shadow: 0 0 0 3px var(--primary); } }
@media (prefers-reduced-motion: reduce) { .completion, .grid.won { animation: none; } }

/* The toolbar stays above the board; its panels float over play. */
.toolbar { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
#timer { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.menu-anchor { position: relative; justify-self: start; z-index: 6; }
#menu-toggle { padding: 9px 16px; }
.game-menu { position: absolute; top: calc(100% + 10px); left: 0; width: 220px; display: grid; gap: 10px; padding: 14px; border: 1px solid color-mix(in srgb, var(--key-border) 70%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--board) 87%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 12px 32px rgb(0 0 0 / .18); opacity: 0; visibility: hidden; transform: translateY(-7px); transition: opacity 180ms ease, transform 180ms ease, visibility 180ms; }
.game-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.game-menu button { width: 100%; padding: 12px; }
.checkpoint-tools { display: flex; gap: 5px; justify-self: end; }
.tool-icon { display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; background: var(--secondary); color: var(--text); }
.tool-icon svg, .number-pad svg { width: 24px; height: 24px; }
.checkpoint-confirm { position: absolute; top: calc(100% + 8px); right: 0; width: min(320px, 100%); z-index: 7; padding: 18px; background: color-mix(in srgb, var(--board) 93%, transparent); backdrop-filter: blur(18px); border: 1px solid var(--key-border); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .18); animation: completion-arrive 180ms ease-out; }
.checkpoint-confirm p { margin: 0 0 16px; font-size: 16px; line-height: 1.5; color: var(--text); }
.checkpoint-confirm > div { display: flex; gap: 10px; }
.checkpoint-confirm button { flex: 1; padding: 10px; }
.tool-icon.saved { animation: checkpoint-saved 450ms ease-out; }
@keyframes checkpoint-saved { 50% { transform: scale(1.12); } }
.controls { display: block; }
.number-pad { grid-template-columns: repeat(4, 1fr); gap: 9px; }
.number-pad button { display: grid; place-items: center; min-height: 48px; }
.number-pad .erase { grid-column: auto; font-size: 22px; }
.number-pad .pencil { background: #e5edf8; color: #365c98; border-color: #9cb5d9; }
.number-pad .pencil:enabled:hover { background: #d6e3f5; border-color: #365c98; }
.number-pad .pencil.active { background: #365c98; color: white; border-color: #365c98; box-shadow: inset 0 0 0 2px var(--board), 0 2px 0 #294a80; }
.number-pad .pencil.active:enabled:hover { background: #294a80; }
:root[data-theme='dark'] .number-pad .pencil { background: #293c56; color: #bbd3f5; border-color: #6386b5; }
:root[data-theme='dark'] .number-pad .pencil:enabled:hover { background: #334b6a; }
:root[data-theme='dark'] .number-pad .pencil.active { background: #406dad; color: white; }
:root[data-theme='dark'] .number-pad .pencil.active:enabled:hover { background: #365c98; }
.note-layer { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); pointer-events: none; }
.cell-notes { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 2px; color: var(--muted); font-size: clamp(9px, 2.7vw, 13px); line-height: 1; }
.cell-notes span { display: grid; place-items: center; }
#start-screen, .completion { z-index: 2; }
@media (min-width: 760px) {
  .number-pad { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .number-pad .erase { aspect-ratio: 1; min-height: 0; }
}
@media (max-width: 759px) and (max-height: 740px) {
  .game-layout { width: min(100%, calc(100svh - 290px)); }
}
@media (prefers-reduced-motion: reduce) { .game-menu { transition: none; } .tool-icon.saved, .checkpoint-confirm { animation: none; } }

/* Preserve the familiar digit block; actions occupy its spare column or row. */
.number-pad button:nth-child(1) { grid-row: 1; grid-column: 1; }
.number-pad button:nth-child(2) { grid-row: 1; grid-column: 2; }
.number-pad button:nth-child(3) { grid-row: 1; grid-column: 3; }
.number-pad button:nth-child(4) { grid-row: 2; grid-column: 1; }
.number-pad button:nth-child(5) { grid-row: 2; grid-column: 2; }
.number-pad button:nth-child(6) { grid-row: 2; grid-column: 3; }
.number-pad button:nth-child(7) { grid-row: 3; grid-column: 1; }
.number-pad button:nth-child(8) { grid-row: 3; grid-column: 2; }
.number-pad button:nth-child(9) { grid-row: 3; grid-column: 3; }
.number-pad .erase { grid-column: 4; grid-row: 1; }
.number-pad .pencil { grid-column: 4; grid-row: 2; }
.tool-icon:enabled:hover, .tool-icon:enabled:focus-visible { background: var(--secondary-hover); color: var(--text); }
.tool-icon { -webkit-tap-highlight-color: transparent; }
#checkpoint-confirm #checkpoint-detail { color: var(--muted); font-size: 14px; margin-top: -8px; }
@media (min-width: 760px) {
  .number-pad .erase { grid-column: 1; grid-row: 4; }
  .number-pad .pencil { grid-column: 2; grid-row: 4; }
}

/* Pencil mode: outlined when off, filled and marked when on. */
.number-pad .pencil { position: relative; border-width: 2px; }
.number-pad .pencil.active { box-shadow: inset 0 0 0 3px var(--board), 0 2px 0 #294a80; }
.number-pad .pencil.active::after { content: ''; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: white; }
.number-pad .pencil:disabled,
:root[data-theme='dark'] .number-pad .pencil:disabled { background: var(--secondary); color: var(--muted); border-color: var(--key-border); opacity: .25; box-shadow: none; cursor: not-allowed; }
.number-pad .pencil:disabled::after { display: none; }


.timer-controls { display: flex; align-items: center; justify-content: center; gap: 14px; }
#timer { margin: 0; }
.timer-controls .tool-icon { width: 30px; height: 44px; padding: 3px; background: transparent; flex-shrink: 0; }
.tool-icon:disabled { opacity: .25; cursor: default; }
@media (max-width: 759px) {
  .game-page { padding-inline: 12px; }
  .game-layout { width: min(100%, 432px); min-width: 0; }
  .toolbar { grid-template-columns: minmax(84px, 1fr) auto minmax(84px, 1fr); gap: 2px; }
  #menu-toggle { min-width: 72px; min-height: 44px; padding: 12px; }
  .timer-controls { gap: 6px; }
  .timer-controls .tool-icon { width: 24px; padding: 1px; }
  #timer { font-size: 22px; }
  .checkpoint-tools { gap: 4px; }
  .checkpoint-tools .tool-icon { width: 40px; height: 44px; padding: 8px; flex-shrink: 0; }
}
@media (max-width: 759px) and (max-height: 650px) {
  .game-page { padding-block: 8px; }
  .game-header { margin-bottom: 6px; }
  .number-pad { gap: 6px; }
  .number-pad button { min-height: 40px; padding: 6px; }
}

/* Move only the history icons; keep the toolbar's layout unchanged. */
#undo { transform: translateX(-8px); }
#redo { transform: translateX(8px); }

.checkpoint-tools { position: relative; }
.checkpoint-feedback {
  position: absolute;
  top: calc(100% + 3px);
  right: 0;
  z-index: 5;
  white-space: nowrap;
  pointer-events: none;
  padding: 4px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--board) 94%, transparent);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 400ms ease, transform 400ms ease;
}
.checkpoint-feedback.visible { opacity: 1; transform: translateY(0); transition-duration: 160ms; }
@media (prefers-reduced-motion: reduce) { .checkpoint-feedback { transition: none; transform: none; } }

#start-screen { gap: 14px; }
.privacy-link { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 13px; min-height: 32px; }
.privacy-link:hover { color: var(--text); background: transparent; }
.privacy-view { padding: clamp(14px, 4vw, 30px); gap: 10px; background: var(--board); text-align: center; overflow: auto; }
.privacy-view h2 { margin: 0; font-size: clamp(19px, 5vw, 24px); }
.privacy-view p { margin: 0; font-size: clamp(12px, 3.3vw, 14px); line-height: 1.5; color: var(--muted); }
.privacy-view #privacy-status { font-size: 12px; }
.privacy-view { z-index: 2; }

.mode-slot { justify-self: start; }
.manual-label { display: inline-block; padding: 5px 6px; border-radius: 6px; white-space: nowrap; font-size: 10px; font-weight: 650; letter-spacing: .02em; color: #365c98; background: #e5edf8; }
:root[data-theme='dark'] .manual-label { color: #bbd3f5; background: #293c56; }
.sudoku-loading .manual-label { visibility: hidden; }
#confirm-consequence { font-size: 13px; margin-top: -8px; }

.confirm-features { display: grid; gap: 10px; list-style: none; padding: 0; margin: 0 0 24px; text-align: left; }
.confirm-features li { display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.4; }
.confirm-features svg { display: block; width: 19px; height: 19px; }
.confirm-features .feature-on, .confirm-features .feature-off { flex: 0 0 19px; }
.confirm-features .feature-on { color: var(--primary); }
.confirm-features .feature-off { color: var(--muted); }

.checkpoint-tools .tool-icon:disabled { background: var(--secondary); color: var(--text); }
@media (min-width: 760px) { .manual-label { font-size: 13px; padding: 6px 8px; } }
#confirm-consequence { white-space: pre-line; }

@media (max-width: 360px) {
  .manual-label { max-width: 78px; white-space: normal; line-height: 1.2; text-align: center; }
}
