:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e4e2dd;
  --border-cell: #c9c6bf;
  --border-strong: #8a8680;
  --text-primary: #1f1e1c;
  --text-secondary: #6b6862;
  --accent: #2f6fed;
  --accent-bg: #eaf1fd;
  --danger: #d0342c;
  --success: #1a7f4e;
  --warning-bg: #fdf3e0;
  --warning-text: #8a5a10;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --btn-elev-shadow: 0 1px 2px rgba(31, 30, 28, 0.07), 0 3px 10px rgba(31, 30, 28, 0.1);
  --btn-elev-shadow-strong: 0 2px 4px rgba(31, 30, 28, 0.08), 0 6px 16px rgba(31, 30, 28, 0.12);
}
html[data-theme="dark"] {
  --bg: #121314;
  --surface: #1c1d1f;
  --border: #2e3033;
  --border-cell: #45484d;
  --border-strong: #8a9099;
  --text-primary: #f2f1ee;
  --text-secondary: #9a9893;
  --accent: #6b9aff;
  --accent-bg: #1e2f52;
  --danger: #ff6b64;
  --success: #4cba7f;
  --warning-bg: #3a2d12;
  --warning-text: #f0c674;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
}
body {
  background: var(--bg);
  color: var(--text-primary);
  margin: 0;
  min-height: 100dvh;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
h1 { font-size: 18px; font-weight: 600; margin: 0; }
#themeToggle {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 5px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#themeToggle:hover { background: var(--bg); color: var(--text-primary); }
html:not([data-theme="dark"]) #themeToggle,
html:not([data-theme="dark"]) .tab,
html:not([data-theme="dark"]) .view-tab,
html:not([data-theme="dark"]) .numpad button,
html:not([data-theme="dark"]) .controls button,
html:not([data-theme="dark"]) .league-cta,
html:not([data-theme="dark"]) .auth-mode-switch-btn {
  box-shadow: var(--btn-elev-shadow);
  border-color: color-mix(in srgb, var(--border) 70%, var(--border-strong));
}
html:not([data-theme="dark"]) .league-cta {
  box-shadow: var(--btn-elev-shadow-strong);
}
html:not([data-theme="dark"]) .play-dock {
  box-shadow: 0 -6px 24px rgba(31, 30, 28, 0.1);
  border-top-color: color-mix(in srgb, var(--border) 60%, var(--border-strong));
}
.subtitle { font-size: 13px; color: var(--text-secondary); margin: 0 0 1rem; }
.subtitle-hint { margin-top: -8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 1rem; }
.tab {
  flex: 1;
  min-height: 44px;
  padding: 8px 4px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.tab:disabled { opacity: 0.45; cursor: default; }
.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.stats-row strong { color: var(--text-primary); }
.game-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.game-mode-tab {
  flex: 1;
  text-align: center;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.game-mode-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}
html:not([data-theme="dark"]) .game-mode-tab {
  box-shadow: var(--btn-elev-shadow);
  border-color: color-mix(in srgb, var(--border) 70%, var(--border-strong));
}
.grid.grid-6 {
  grid-template-columns: repeat(6, 1fr);
  aspect-ratio: 1;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}
.grid.grid-6 .cell {
  font-size: clamp(18px, 5.5vw, 24px);
}
.grid.grid-6 .notes-grid {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.numpad-6 {
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}
.mini-input-hint {
  margin-top: 0;
  text-align: center;
}
.grid-wrap {
  position: relative;
  margin-bottom: 12px;
}
.grid-wrap .grid {
  margin-bottom: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.hint-float-panel {
  margin-bottom: 8px;
}
.hint-float-panel .hint-card {
  margin-bottom: 0;
}
.hint-float-panel .hint-dismiss {
  float: right;
  margin: -2px 0 4px 8px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--warning-text);
  cursor: pointer;
  text-decoration: underline;
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px, 4.8vw, 20px);
  border-right: 1px solid var(--border-cell);
  border-bottom: 1px solid var(--border-cell);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  min-height: 0;
}
.cell.thick-r { border-right: 2px solid var(--border-strong); }
.cell.thick-b { border-bottom: 2px solid var(--border-strong); }
.cell.given { font-weight: 600; color: var(--text-primary); cursor: default; }
.cell.entered { color: var(--accent); }
.cell.wrong { color: var(--danger); }
.cell.hl-row,
.cell.hl-col,
.cell.hl-box {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.cell.selected {
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.cell.hint { background: var(--warning-bg); }
.cell.hl-same:not(.wrong) {
  color: var(--accent);
  font-weight: 600;
}
.cell.has-notes {
  align-items: stretch;
  justify-content: stretch;
  padding: 1px;
}
.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(7px, 2.1vw, 10px);
  line-height: 1;
  color: var(--text-secondary);
  font-weight: 600;
}
.note.on { color: var(--accent); }
.play-dock {
  margin-bottom: 10px;
}
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.numpad button, .controls button {
  min-height: 48px;
  padding: 10px 6px;
  font-size: 18px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.controls button {
  font-size: 13px;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 4px;
}
.numpad button:hover:not(.complete), .controls button:hover { background: var(--bg); }
.controls button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}
.numpad button:disabled, .controls button:disabled { opacity: 0.45; cursor: default; }
.numpad button.complete {
  color: var(--text-secondary);
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  cursor: default;
  pointer-events: none;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.hint-card {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.hint-card .headline { font-weight: 600; margin-bottom: 3px; }
.hint-card button {
  margin-top: 8px;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--warning-text);
  background: transparent;
  color: var(--warning-text);
  cursor: pointer;
}
.status {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
}
.status.success { color: var(--success); }
.status.danger { color: var(--danger); }
.continue-card {
  background: var(--accent-bg);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.continue-card .headline { font-weight: 600; margin-bottom: 3px; color: var(--accent); }
.continue-card button {
  margin-top: 8px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.continue-card button.secondary {
  background: transparent;
  color: var(--accent);
  margin-left: 6px;
}
.loading-card {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 14px;
}
.error-card {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.45;
}
.leagues-card { max-width: 440px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.field-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-primary);
  margin-bottom: 12px;
}
.league-cta {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.league-cta.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  margin-top: 10px;
}
.league-cta:disabled { opacity: 0.5; cursor: not-allowed; }
.league-link-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}
.auth-mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.auth-mode-switch-btn {
  flex: 1;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  touch-action: manipulation;
}
.auth-mode-switch-btn.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--text-primary);
}
.auth-mode-hint {
  margin-bottom: 12px;
}
.league-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
}
.league-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.league-item {
  width: 100%;
  text-align: left;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
}
.league-item .name { font-size: 14px; font-weight: 600; display: block; }
.league-item .meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.league-back {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  padding: 0 0 10px;
  cursor: pointer;
}
.field-input[type="select"],
select.field-input { appearance: auto; }
.standing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}
.standing-row.you { border-color: var(--accent); background: var(--accent-bg); }
.standing-row .rank { font-weight: 700; min-width: 1.5rem; }
.standing-row .time { color: var(--text-secondary); font-size: 12px; }
.standing-row.compare-row .stats {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
  line-height: 1.35;
}
.standings-date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}
.standings-date-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.standings-date-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.standings-date-label {
  font-size: 13px;
  font-weight: 600;
  min-width: 8rem;
  text-align: center;
}
.league-section-title-spaced { margin-top: 20px; }
.compare-intro { margin: 0 0 10px; font-size: 12px; }
.recent-days-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.recent-days-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 280px;
}
.recent-days-table th,
.recent-days-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.recent-days-table th {
  text-align: left;
  font-weight: 600;
  background: var(--surface);
  position: sticky;
  top: 0;
}
.recent-days-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.recent-days-table td.you { background: var(--accent-bg); font-weight: 600; }
.recent-days-table tr:last-child td { border-bottom: none; }
.recent-days-table .day-label { font-weight: 600; }
.view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.view-tab {
  flex: 1;
  min-height: 44px;
  padding: 9px 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.view-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.past-puzzles {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.past-puzzles-intro {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.past-today-row { margin-bottom: 10px; }
.date-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(360px, 52vh);
  overflow-y: auto;
  padding-right: 2px;
}
.date-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.date-chip:hover { background: var(--bg); }
.date-chip.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.date-chip.today-chip {
  font-weight: 600;
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}
.date-chip.today-chip.active {
  border-color: var(--accent);
}
.chip-label { font-weight: 500; }
.chip-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}
.date-chip.unlocked .chip-badge {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}
.date-chip.locked .chip-badge {
  color: var(--accent);
  background: var(--accent-bg);
}
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
}
.page-nav a {
  color: var(--accent);
  text-decoration: none;
}
.page-nav a:hover { text-decoration: underline; }
.prose { font-size: 14px; line-height: 1.55; color: var(--text-primary); }
.prose h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-primary);
}
.prose h2:first-child { margin-top: 0; }
.prose h2 + p { margin-top: 0; }
.prose p { margin: 0 0 0.75rem; color: var(--text-secondary); }
.prose ul, .prose ol { margin: 0 0 0.75rem; padding-left: 1.25rem; color: var(--text-secondary); }
.prose li { margin-bottom: 0.35rem; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose a { color: var(--accent); }

.home-intro {
  margin: 0 0 12px;
  font-size: 13px;
}
.home-intro p { margin: 0; }
.site-footer-nav {
  margin-top: 16px;
  margin-bottom: 0;
  text-align: center;
}
.site-footer-nav a {
  color: var(--accent);
  text-decoration: none;
}
.seo-details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 13px;
}
.seo-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  list-style: none;
}
.seo-details summary::-webkit-details-marker { display: none; }
.seo-details-body {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.seo-details-body.prose p:last-child { margin-bottom: 0; }
.seo-h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
  color: var(--text-primary);
}
.seo-h2:first-child { margin-top: 0; }
.leagues-seo { margin-bottom: 0.75rem; }

.league-play-banner {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-bg);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
}
.league-play-banner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.league-play-banner a:hover { text-decoration: underline; }

.league-submit-status {
  font-size: 13px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--text-primary);
  text-align: center;
}
.league-submit-status.error {
  background: var(--warning-bg);
  color: var(--warning-text);
}
.ad-slot {
  margin: 14px 0 0;
  min-height: 0;
  text-align: center;
  overflow: hidden;
}
.ad-slot:empty {
  display: none;
}
.ad-consent-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  line-height: 1.45;
}
.ad-consent-bar p {
  margin: 0 0 10px;
  color: var(--text-secondary);
}
.ad-consent-bar a {
  color: var(--accent);
}
.ad-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ad-consent-actions .league-cta {
  flex: 1;
  min-width: 120px;
  margin: 0;
}

.completion-league-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-sizing: border-box;
}

.league-cta-link {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-top: 10px;
  box-sizing: border-box;
}
.league-item-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.league-item-row .league-item { flex: 1; }
.league-play-chip {
  flex-shrink: 0;
  align-self: center;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  touch-action: manipulation;
}
.play-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  text-align: center;
}
.prose a.play-link {
  color: #fff;
}
.play-link:hover { opacity: 0.92; }

.completion-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.45);
  animation: fadeIn 0.2s ease;
}
.completion-overlay[hidden] { display: none; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.completion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  text-align: center;
}
.completion-card .celebration {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 8px;
}
.completion-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
}
.completion-card .rank-line {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}
.completion-card .time-display {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}
.completion-card .time-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 14px;
}
.completion-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  text-align: left;
}
.completion-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.completion-stat strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 2px;
}
.completion-card .cta-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.completion-card button {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--accent);
  cursor: pointer;
}
.completion-card button.primary {
  background: var(--accent);
  color: #fff;
}
.completion-card button.secondary {
  background: transparent;
  color: var(--accent);
}
.completion-inline {
  background: var(--accent-bg);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  text-align: center;
  font-size: 13px;
}
.completion-inline .time-display {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 4px 0;
}
.completion-inline button {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

@media (max-width: 520px) {
  body {
    padding:
      max(0.5rem, env(safe-area-inset-top))
      max(0.5rem, env(safe-area-inset-right))
      max(0.25rem, env(safe-area-inset-bottom))
      max(0.5rem, env(safe-area-inset-left));
  }
  .card {
    padding: 1rem;
    border-radius: 12px;
  }
  .subtitle-hint {
    display: none;
  }
  .subtitle {
    margin-bottom: 0.75rem;
  }
  #gameState .subtitle.footer-links {
    font-size: 12px;
    line-height: 1.6;
  }
  .hint-float-panel {
    position: absolute;
    left: 8px;
    right: 8px;
    z-index: 6;
    margin: 0;
    padding: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
  }
  .hint-float-panel:not([hidden]) {
    pointer-events: auto;
  }
  .hint-float-panel .hint-card {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid color-mix(in srgb, var(--warning-text) 25%, transparent);
  }
  html[data-theme="dark"] .hint-float-panel .hint-card {
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
  }
  .play-dock {
    position: sticky;
    bottom: 0;
    z-index: 8;
    margin: 8px -1rem 0;
    padding: 10px 1rem max(10px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
  }
  html:not([data-theme="dark"]) .play-dock {
    box-shadow: 0 -8px 28px rgba(31, 30, 28, 0.14);
  }
  html[data-theme="dark"] .play-dock {
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }
  .view-tab {
    font-size: 12px;
    padding-inline: 6px;
  }
  .tab {
    font-size: 12px;
  }
}

@media (min-width: 521px) {
  .numpad:not(.numpad-6) {
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
  }
  .numpad-6 {
    grid-template-columns: repeat(6, 1fr);
    max-width: 420px;
  }
  .numpad button {
    min-height: 44px;
    font-size: 16px;
  }
}
