:root {
  --radius: 0.75rem;
  --background: oklch(0.99 0 0);
  --foreground: oklch(0.18 0.01 260);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.18 0.01 260);
  --primary: oklch(0.22 0.01 260);
  --primary-foreground: oklch(0.99 0 0);
  --secondary: oklch(0.96 0.005 260);
  --secondary-foreground: oklch(0.22 0.01 260);
  --muted: oklch(0.96 0.005 260);
  --muted-foreground: oklch(0.5 0.01 260);
  --accent: oklch(0.72 0.18 145);
  --accent-foreground: oklch(0.13 0.01 260);
  --destructive: oklch(0.62 0.22 27);
  --destructive-foreground: oklch(0.99 0 0);
  --border: oklch(0.92 0.005 260);
  --shadow: 0 14px 40px oklch(0.18 0.01 260 / 0.07);
}

.dark {
  --background: oklch(0.13 0.01 260);
  --foreground: oklch(0.97 0.005 260);
  --card: oklch(0.17 0.01 260);
  --card-foreground: oklch(0.97 0.005 260);
  --primary: oklch(0.97 0.005 260);
  --primary-foreground: oklch(0.18 0.01 260);
  --secondary: oklch(0.22 0.01 260);
  --secondary-foreground: oklch(0.97 0.005 260);
  --muted: oklch(0.22 0.01 260);
  --muted-foreground: oklch(0.65 0.01 260);
  --accent: oklch(0.76 0.2 145);
  --accent-foreground: oklch(0.13 0.01 260);
  --destructive: oklch(0.67 0.22 27);
  --destructive-foreground: oklch(0.97 0.005 260);
  --border: oklch(1 0 0 / 0.12);
  --shadow: 0 18px 42px oklch(0 0 0 / 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition:
    background-color 0.4s ease,
    color 0.4s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 12% 0%, oklch(0.84 0.08 145 / 0.25), transparent 35%),
    radial-gradient(circle at 100% 90%, oklch(0.78 0.06 260 / 0.2), transparent 45%),
    var(--background);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(to right, oklch(0 0 0 / 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(0 0 0 / 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2;
}

.tizzle-mark {
  position: absolute;
  left: 1rem;
  top: 1rem;
  display: inline-flex;
  align-items: center;
  color: var(--foreground);
  text-decoration: none;
}

.tizzle-mark-icon {
  width: 34px;
  height: 34px;
  opacity: 0.85;
  transition:
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tizzle-mark:hover .tizzle-mark-icon,
.tizzle-mark:focus-visible .tizzle-mark-icon {
  transform: rotate(180deg);
  opacity: 1;
}

.tizzle-pill {
  margin-left: 0.5rem;
  display: none;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.22rem 0.52rem;
  color: var(--foreground);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tizzle-mark:hover .tizzle-pill,
.tizzle-mark:focus-visible .tizzle-pill {
  opacity: 1;
}

.theme-toggle {
  position: fixed;
  right: 1.25rem;
  top: 1.25rem;
  z-index: 40;
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.12);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 9px 20px oklch(0 0 0 / 0.2);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle-icon-wrap {
  position: relative;
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.theme-icon {
  position: absolute;
  inset: 0;
  height: 1.25rem;
  width: 1.25rem;
  transition: all 0.5s ease;
}

.theme-icon-sun {
  transform: rotate(0deg) scale(1);
  opacity: 1;
}

.theme-icon-moon {
  transform: rotate(-90deg) scale(0);
  opacity: 0;
}

.dark .theme-icon-sun {
  transform: rotate(90deg) scale(0);
  opacity: 0;
}

.dark .theme-icon-moon {
  transform: rotate(0deg) scale(1);
  opacity: 1;
}

.app-shell {
  margin: 0 auto;
  width: min(1080px, 100%);
  padding: 5.25rem 1rem 1.4rem;
}

.hero {
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.hero h1 {
  margin: 0.3rem 0 0;
  font-size: clamp(2.1rem, 9vw, 2.8rem);
  letter-spacing: -0.03em;
  font-weight: 800;
}

.subtitle {
  margin: 0.3rem 0 0;
  font-size: 0.92rem;
  color: var(--muted-foreground);
}

.difficulty-switch {
  position: relative;
  margin: 1.2rem auto 0;
  display: inline-flex;
  width: min(360px, 100%);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 0.25rem;
  box-shadow: var(--shadow);
}

.difficulty-slider {
  position: absolute;
  left: 0.25rem;
  top: 0.25rem;
  height: calc(100% - 0.5rem);
  width: calc((100% - 0.5rem) / 3);
  border-radius: 999px;
  background: var(--secondary);
  transition: transform 0.28s ease;
}

.difficulty-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 2.1rem;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.game-layout {
  margin-top: 1.2rem;
  display: grid;
  gap: 1rem;
}

.board-card,
.control-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.board-card {
  padding: 0.85rem;
}

.board-status {
  margin-bottom: 0.8rem;
}

#status-message {
  margin: 0;
  font-size: 0.84rem;
  color: var(--card-foreground);
}

#meta-line {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--muted-foreground);
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0;
  border: 2px solid var(--foreground);
  border-radius: 0.7rem;
  overflow: hidden;
  background: var(--muted);
}

.cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: clamp(0.86rem, 3.8vw, 1.14rem);
  font-weight: 700;
  text-align: center;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.1s ease;
}

.cell:not(.is-fixed):active {
  transform: scale(0.96);
}

.cell.is-fixed {
  background: var(--secondary);
}

.cell.is-related {
  background: oklch(0.78 0.07 145 / 0.2);
}

.cell.is-selected {
  background: oklch(0.75 0.18 145 / 0.9);
  color: var(--accent-foreground);
}

.cell.is-conflict {
  background: oklch(0.69 0.2 27 / 0.28);
  color: var(--destructive);
}

.cell.is-wrong {
  box-shadow: inset 0 0 0 2px var(--destructive);
}

.cell.border-right-heavy {
  border-right: 2px solid var(--foreground);
}

.cell.border-bottom-heavy {
  border-bottom: 2px solid var(--foreground);
}

.control-card {
  padding: 0.82rem;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.56rem;
}

.key-btn,
.action-btn {
  min-height: 2.75rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 0.88rem;
  font-weight: 700;
  transition: transform 0.15s ease;
}

.key-btn:active,
.action-btn:active {
  transform: scale(0.97);
}

.key-btn.is-selected-number {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.actions {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.56rem;
}

.action-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  grid-column: span 2;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.74rem;
  color: var(--muted-foreground);
}

@media (min-width: 700px) {
  .tizzle-pill {
    display: inline-block;
  }

  .app-shell {
    padding-inline: 1.5rem;
  }

  .board-card,
  .control-card {
    border-radius: 1.2rem;
  }

  .cell {
    font-size: 1.18rem;
  }
}

@media (min-width: 980px) {
  .app-shell {
    padding-top: 5.8rem;
  }

  .game-layout {
    margin-top: 1.4rem;
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
  }

  .board-card {
    padding: 1rem;
  }

  .control-card {
    position: sticky;
    top: 6rem;
  }
}
