:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --bg-accent: #eef7f4;
  --surface: #ffffff;
  --surface-soft: #f2f5f8;
  --surface-strong: #e7edf3;
  --ink: #252b33;
  --muted: #68727f;
  --line: #dbe3eb;
  --major-line: #9faebb;
  --accent: #3c86f6;
  --accent-soft: #e8f2ff;
  --accent-strong: #1665d8;
  --same-highlight: #d7e9ff;
  --mint: #1f9d78;
  --mint-soft: #e8f7f1;
  --warning: #f2a943;
  --danger: #df4b4b;
  --danger-soft: #ffe9e9;
  --shadow: 0 18px 48px rgba(54, 70, 89, 0.12);
  --soft-shadow: 0 10px 24px rgba(54, 70, 89, 0.08);
  --radius: 8px;
  --board-size: min(88vw, 620px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151719;
  --bg-accent: #17211f;
  --surface: #1f2328;
  --surface-soft: #272c32;
  --surface-strong: #333940;
  --ink: #f2f5f7;
  --muted: #a7b0ba;
  --line: #3b444d;
  --major-line: #87929e;
  --accent: #75aaff;
  --accent-soft: #1d334e;
  --accent-strong: #9fc2ff;
  --same-highlight: #263f5f;
  --mint: #5bd2a8;
  --mint-soft: #17382f;
  --warning: #f3bd66;
  --danger: #ff7777;
  --danger-soft: #4a2528;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  --soft-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

[data-theme="beige"] {
  color-scheme: light;
  --bg: #f5eddc;
  --bg-accent: #efe1c8;
  --surface: #fffaf0;
  --surface-soft: #f5ead5;
  --surface-strong: #ead9b9;
  --ink: #332c22;
  --muted: #786b59;
  --line: #decda9;
  --major-line: #ad9873;
  --accent: #9f6f35;
  --accent-soft: #f0dec0;
  --accent-strong: #6f4a1f;
  --same-highlight: #ead4ac;
  --mint: #5f8f64;
  --mint-soft: #e2efd9;
  --warning: #bd8330;
  --danger: #be4d43;
  --danger-soft: #f7ddd3;
  --shadow: 0 18px 48px rgba(91, 70, 40, 0.14);
  --soft-shadow: 0 10px 24px rgba(91, 70, 40, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, var(--bg-accent), transparent 26rem),
    linear-gradient(145deg, var(--bg), var(--surface-soft));
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 20%);
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in srgb, var(--surface), transparent 4%);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 820;
  text-decoration: none;
  white-space: nowrap;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  border-radius: var(--radius);
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(60, 134, 246, 0.18);
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}

.main-nav a,
.nav-soon,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.active,
.nav-toggle:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 62%);
}

.nav-soon {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 62%);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.language-control {
  display: grid;
  gap: 4px;
  min-width: 132px;
}

.language-control label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 740;
  text-transform: uppercase;
}

.language-control select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.theme-control {
  min-width: 118px;
}

.language-control select,
.nav-toggle,
.icon-button,
.pill-button,
.select-wrap select,
.number-button,
.tool-button {
  min-height: 42px;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.nav-toggle,
.icon-button,
.pill-button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  cursor: pointer;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-weight: 800;
}

.pill-button.primary,
.tool-button.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(60, 134, 246, 0.24);
}

.pill-button.success {
  color: #ffffff;
  background: var(--mint);
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(31, 157, 120, 0.2);
}

button:hover,
select:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 68%);
  outline-offset: 3px;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
  box-shadow: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1180px) minmax(120px, 160px);
  gap: 18px;
  align-items: start;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, var(--board-size)) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}

.board-panel,
.side-panel,
.ad-slot {
  background: color-mix(in srgb, var(--surface), transparent 4%);
  border: 1px solid color-mix(in srgb, var(--line), transparent 16%);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.board-panel {
  position: relative;
  padding: clamp(10px, 2vw, 16px);
}

.board-panel.daily-active {
  border-color: color-mix(in srgb, var(--accent), transparent 46%);
  box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%);
}

.ad-slot {
  position: sticky;
  top: 18px;
  display: grid;
  min-height: 520px;
  align-content: start;
  place-items: stretch;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.sidebar-stack {
  display: grid;
  gap: 12px;
  width: 100%;
}

.sidebar-card {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 26%);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-soft), var(--surface) 26%);
  box-shadow: var(--soft-shadow);
  text-align: start;
}

.card-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: uppercase;
}

.card-main {
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.25;
}

.card-badge {
  justify-self: start;
  padding: 5px 8px;
  color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 58%);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 760;
}

.daily-state {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.daily-state.complete {
  color: var(--mint);
}

.sidebar-card.daily-complete {
  border-color: color-mix(in srgb, var(--mint), transparent 46%);
  background: color-mix(in srgb, var(--mint-soft), var(--surface) 48%);
}

.card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.mini-button {
  min-height: 36px;
  padding: 0 12px;
  color: #ffffff;
  border-radius: var(--radius);
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(60, 134, 246, 0.18);
  cursor: pointer;
}

.streak-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.streak-track span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--accent));
  transition: width 180ms ease-out;
}

.week-progress {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.week-day {
  display: grid;
  gap: 3px;
  place-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 5px 2px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 32%);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 760;
}

.week-day span:last-child {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
}

.week-day.done {
  color: var(--mint);
  border-color: color-mix(in srgb, var(--mint), transparent 48%);
  background: var(--mint-soft);
}

.week-day.done span:last-child {
  color: #ffffff;
  background: var(--mint);
}

.mini-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.mini-stat-row strong {
  color: var(--ink);
}

.ad-right .sidebar-card {
  text-align: center;
}

.ad-right .mini-stat-row {
  justify-content: space-between;
  text-align: start;
}

.switch-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  transition: background 160ms ease;
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  transition: transform 160ms ease;
}

.switch-button[aria-pressed="true"] .switch-track {
  background: var(--accent);
}

.switch-button[aria-pressed="true"] .switch-track span {
  transform: translateX(18px);
}

.promo-card {
  background: linear-gradient(135deg, var(--surface-soft), color-mix(in srgb, var(--mint-soft), var(--surface) 52%));
}

.ad-content {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 260px;
  width: 100%;
  border: 1px dashed color-mix(in srgb, var(--muted), transparent 45%);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-soft), transparent 18%);
}

.ad-title {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 760;
  text-transform: uppercase;
}

.ad-copy {
  max-width: 11rem;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
}

.stat.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger), transparent 45%);
}

.stat.danger .stat-value {
  color: var(--danger);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  font-weight: 760;
  white-space: nowrap;
}

.board-wrap {
  position: relative;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  direction: ltr;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--major-line);
  border-radius: var(--radius);
  background: var(--major-line);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface), transparent 40%);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  color: var(--accent-strong);
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  transition: background 170ms ease-out, color 170ms ease-out, transform 170ms ease-out, box-shadow 170ms ease-out;
  user-select: none;
  will-change: background, box-shadow, transform;
}

.cell:hover {
  transform: none;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent), transparent 72%);
}

.cell[data-col="2"],
.cell[data-col="5"] {
  border-right: 2px solid var(--major-line);
}

.cell[data-row="2"],
.cell[data-row="5"] {
  border-bottom: 2px solid var(--major-line);
}

.cell[data-col="8"] {
  border-right: 0;
}

.cell[data-row="8"] {
  border-bottom: 0;
}

.cell.given {
  color: var(--ink);
  background: color-mix(in srgb, var(--surface-soft), var(--surface) 35%);
  cursor: default;
}

.cell.locked {
  color: var(--mint);
  background: color-mix(in srgb, var(--mint-soft), var(--surface) 24%);
  cursor: default;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mint), transparent 56%);
}

.cell.lock-feedback {
  animation: correctPop 220ms ease-out, lockGlow 700ms ease-out;
}

.cell.peer {
  background: color-mix(in srgb, var(--mint-soft), var(--surface) 18%);
}

.cell.box-peer {
  background: color-mix(in srgb, var(--mint-soft), var(--surface) 34%);
}

.cell.line-peer {
  background: color-mix(in srgb, var(--accent-soft), var(--surface) 42%);
}

.cell.same {
  background: var(--same-highlight);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent), transparent 62%);
}

.cell.selected {
  z-index: 1;
  background: color-mix(in srgb, var(--accent-soft), var(--surface) 10%);
  box-shadow:
    inset 0 0 0 3px var(--accent),
    0 0 0 3px color-mix(in srgb, var(--accent), transparent 72%),
    0 14px 30px rgba(60, 134, 246, 0.28);
  animation: selectPulse 170ms ease-out;
}

.cell.conflict {
  color: var(--danger);
  background: var(--danger-soft);
}

.cell.error-feedback {
  animation: errorShake 240ms ease-out, errorFlash 260ms ease-out;
}

.cell.correct-feedback {
  animation: correctPop 190ms ease-out;
}

.cell .value {
  font-size: clamp(1.2rem, 7vw, 2.75rem);
  line-height: 1;
  font-weight: 690;
  letter-spacing: 0;
}

.cell.given .value {
  font-weight: 780;
}

.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 82%;
  height: 82%;
  color: var(--muted);
  font-size: clamp(0.48rem, 2.2vw, 0.78rem);
  font-weight: 720;
  line-height: 1;
}

.note {
  display: grid;
  place-items: center;
  min-width: 0;
  opacity: 0;
}

.note.on {
  opacity: 1;
}

.win .sudoku-board {
  animation: boardGlow 1500ms ease-in-out infinite alternate;
}

.side-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-soft), color-mix(in srgb, var(--accent-soft), var(--surface) 44%));
}

.menu-title strong {
  font-size: 1rem;
}

.menu-chip {
  padding: 5px 8px;
  color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 58%);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 760;
  white-space: nowrap;
}

.controls-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.select-wrap {
  display: grid;
  gap: 6px;
  flex: 1;
  position: relative;
}

.select-wrap label,
.section-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 740;
  text-transform: uppercase;
  letter-spacing: 0;
}

.select-wrap select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 38px 0 12px;
  cursor: pointer;
}

.select-wrap select.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.difficulty-menu {
  position: relative;
}

.difficulty-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  cursor: pointer;
}

.difficulty-trigger .chevron {
  color: var(--muted);
  font-size: 0.78rem;
}

.difficulty-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 16;
  display: none;
  gap: 4px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.difficulty-menu.open .difficulty-options {
  display: grid;
  animation: slideIn 140ms ease-out;
}

.difficulty-option {
  min-height: 36px;
  padding: 0 10px;
  color: var(--ink);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  text-align: start;
  cursor: pointer;
}

.difficulty-option:hover,
.difficulty-option.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

#newGame {
  margin-top: 24px;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  direction: ltr;
  gap: 8px;
}

.number-button {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 48px;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  font-size: 1.2rem;
  font-weight: 780;
  cursor: pointer;
  will-change: transform, box-shadow, background;
}

.number-button:hover {
  transform: scale(1.05);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 54%);
  box-shadow: 0 10px 22px rgba(60, 134, 246, 0.16);
}

.number-button:active,
.number-button.pressed {
  animation: numberPress 170ms ease-out;
}

.number-button.selected-number {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(60, 134, 246, 0.24);
}

.number-button.digit-complete {
  opacity: 1;
  color: var(--mint);
  background: var(--mint-soft);
  border-color: color-mix(in srgb, var(--mint), transparent 48%);
}

.number-button.set-complete-feedback {
  animation: numberComplete 650ms ease-out;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tool-button[aria-pressed="true"],
.icon-button[aria-pressed="true"] {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), transparent 50%);
}

.hint-meter {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.meter-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--accent));
  transition: width 240ms ease;
}

.message {
  min-height: 44px;
  padding: 12px;
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
  border-radius: var(--radius);
  background: var(--surface-soft);
  line-height: 1.45;
}

.win-banner {
  display: none;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(135deg, var(--mint), var(--accent));
  box-shadow: var(--soft-shadow);
}

.win-banner.visible {
  display: flex;
  animation: slideIn 220ms ease;
}

.win-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
  opacity: 0;
  background: color-mix(in srgb, var(--bg), transparent 22%);
  backdrop-filter: blur(10px);
  transition: opacity 180ms ease-out;
}

.win-modal.visible {
  pointer-events: auto;
  opacity: 1;
}

.win-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 22%);
  border-radius: calc(var(--radius) + 8px);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(10px) scale(0.96);
  transition: transform 180ms ease-out;
}

.stats-card {
  width: min(620px, 100%);
}

.win-modal.visible .win-card {
  transform: translateY(0) scale(1);
}

.win-card h2 {
  margin: 4px 0 8px;
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  line-height: 1.05;
}

.win-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.win-stat {
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
}

.win-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 740;
  text-transform: uppercase;
}

.win-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.lose-card {
  border-color: color-mix(in srgb, var(--danger), transparent 45%);
}

.lose-card h2 {
  color: var(--danger);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.modal-actions .pill-button {
  flex: 1 1 150px;
}

.site-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 20%);
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in srgb, var(--surface), transparent 4%);
  box-shadow: var(--soft-shadow);
}

.site-footer div {
  display: grid;
  align-content: start;
  gap: 8px;
}

.site-footer strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.site-footer a,
.site-footer span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-strong);
}

.loading-cover {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 5;
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in srgb, var(--surface), transparent 12%);
  backdrop-filter: blur(10px);
}

.loading-cover.visible {
  display: grid;
}

.loader {
  display: grid;
  gap: 12px;
  place-items: center;
  color: var(--muted);
  font-weight: 720;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--surface-strong);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

.confetti-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 3px;
  opacity: 0;
  animation: confettiFall 2800ms ease-in forwards;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes selectPulse {
  from { transform: scale(0.94); }
  to { transform: scale(1); }
}

@keyframes numberPress {
  0% { transform: scale(1.05); }
  45% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

@keyframes correctPop {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes lockGlow {
  0% { box-shadow: inset 0 0 0 2px var(--mint), 0 0 0 rgba(31, 157, 120, 0); }
  55% { box-shadow: inset 0 0 0 2px var(--mint), 0 0 22px rgba(31, 157, 120, 0.24); }
  100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mint), transparent 56%); }
}

@keyframes numberComplete {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  55% { transform: translateX(3px); }
  80% { transform: translateX(-1px); }
}

@keyframes errorFlash {
  0% { box-shadow: inset 0 0 0 3px var(--danger), 0 0 0 rgba(223, 75, 75, 0); }
  55% { box-shadow: inset 0 0 0 3px var(--danger), 0 0 24px rgba(223, 75, 75, 0.28); }
  100% { box-shadow: inset 0 0 0 1px transparent, 0 0 0 rgba(223, 75, 75, 0); }
}

@keyframes boardGlow {
  from { box-shadow: 0 0 0 rgba(31, 157, 120, 0); }
  to { box-shadow: 0 0 36px rgba(31, 157, 120, 0.32); }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .ad-slot {
    display: none;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .side-panel {
    order: 2;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 520px);
    padding-top: 18px;
  }

  .subtitle {
    display: none;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-panel,
  .side-panel {
    border-radius: var(--radius);
  }

  .number-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: sticky;
    bottom: 10px;
    z-index: 12;
    padding: 8px;
    border: 1px solid color-mix(in srgb, var(--line), transparent 24%);
    border-radius: calc(var(--radius) + 4px);
    background: color-mix(in srgb, var(--surface), transparent 4%);
    box-shadow: var(--soft-shadow);
    backdrop-filter: blur(12px);
  }

  .number-button {
    height: 52px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .win-stats,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
