:root {
  --sudoku-ink: #1a2b33;
  --sudoku-muted: #5a6f78;
  --sudoku-chrome: #1a3a44;
  --sudoku-accent: #2a7a8c;
  --sudoku-accent-dark: #1f6270;
  --sudoku-given-bg: #e8eef0;
  --sudoku-selected: #c5e4eb;
  --sudoku-conflict: #f8d4d4;
  --sudoku-line: #1a3a44;
  --sudoku-thin: #9aadb4;
  --sudoku-pad: #f4f7f8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--sudoku-ink);
  background:
    radial-gradient(ellipse at top, #e8f0f4 0%, transparent 55%),
    linear-gradient(180deg, #f2f5f7 0%, #e6ecef 100%);
  min-height: 100vh;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sudoku-chrome {
  background: var(--sudoku-chrome);
  color: #fff;
  padding: 0.65rem 1rem;
}

.sudoku-chrome__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 36rem;
  margin: 0 auto;
}

.sudoku-chrome__logo {
  color: #fff;
  text-decoration: none;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.sudoku-chrome__links {
  display: flex;
  gap: 0.85rem;
}

.sudoku-chrome__links a {
  color: #d7eef2;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.sudoku-chrome__links a:hover {
  color: #fff;
  text-decoration: underline;
}

.sudoku-main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 1.5rem;
}

.sudoku-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.sudoku-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sudoku-play-date {
  font-weight: 700;
  font-size: 0.95rem;
}

.sudoku-difficulty {
  font-size: 0.85rem;
  color: var(--sudoku-muted);
  text-transform: capitalize;
}

#sudoku-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--sudoku-chrome);
}

.sudoku-actions {
  display: flex;
  gap: 0.5rem;
}

.sudoku-btn {
  appearance: none;
  border: none;
  background: var(--sudoku-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
}

.sudoku-btn:hover {
  background: var(--sudoku-accent-dark);
}

.sudoku-btn--secondary {
  background: #d7e0e4;
  color: var(--sudoku-ink);
}

.sudoku-btn--secondary:hover:not(:disabled) {
  background: #c5d0d5;
}

.sudoku-btn--pause {
  background: #d7e0e4;
  color: var(--sudoku-ink);
}

.sudoku-btn--pause:hover:not(:disabled) {
  background: #c5d0d5;
}

.sudoku-btn--pause[aria-pressed="true"] {
  background: var(--sudoku-accent);
  color: #fff;
}

.sudoku-btn--pause[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--sudoku-accent-dark);
}

.sudoku-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.sudoku-status {
  min-height: 1.35rem;
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  color: var(--sudoku-muted);
}

.sudoku-status--ok {
  color: #1f6b45;
  font-weight: 600;
}

.sudoku-status--err {
  color: #9b2c2c;
  font-weight: 600;
}

.sudoku-board-wrap {
  position: relative;
  width: min(100vmin, 40rem);
  max-width: 100%;
  margin: 0 auto;
}

.sudoku-pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 238, 240, 0.94);
  pointer-events: auto;
}

.sudoku-pause-overlay[hidden] {
  display: none;
}

.sudoku-pause-overlay__label {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sudoku-chrome);
}

.sudoku-board-wrap.is-paused .sudoku-board {
  pointer-events: none;
}

.sudoku-board-wrap.is-paused .sudoku-cell__digit,
.sudoku-board-wrap.is-paused .sudoku-cell__corners,
.sudoku-board-wrap.is-paused .sudoku-cell__centres {
  visibility: hidden;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  border: 3px solid var(--sudoku-line);
  background: #fff;
  user-select: none;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-size: clamp(1.05rem, 4.8vmin, 1.85rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--sudoku-thin);
  border-bottom: 1px solid var(--sudoku-thin);
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  touch-action: manipulation;
}

.sudoku-cell:nth-child(9n) {
  border-right: none;
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom: none;
}

.sudoku-cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 2px solid var(--sudoku-line);
}

.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--sudoku-line);
}

.sudoku-cell--given {
  background: var(--sudoku-given-bg);
  font-weight: 800;
  color: var(--sudoku-ink);
  cursor: default;
}

.sudoku-cell--selected:not(.sudoku-cell--given) {
  background: var(--sudoku-selected);
}

.sudoku-cell--selected.sudoku-cell--given {
  outline: 2px solid var(--sudoku-accent);
  outline-offset: -2px;
  z-index: 1;
}

.sudoku-cell--conflict {
  background: var(--sudoku-conflict);
  color: #9b2c2c;
}

.sudoku-cell--conflict.sudoku-cell--selected:not(.sudoku-cell--given) {
  background: #f0b8b8;
}

.sudoku-cell__digit {
  line-height: 1;
  pointer-events: none;
}

.sudoku-cell__corners {
  position: absolute;
  inset: 1px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
  z-index: 1;
}

.sudoku-cell__corner {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.45rem, 2vmin, 0.7rem);
  font-weight: 600;
  line-height: 1;
  color: var(--sudoku-muted);
}

.sudoku-cell__centres {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  font-size: clamp(0.5rem, 2.2vmin, 0.8rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--sudoku-accent-dark);
  padding: 0 1px;
  text-align: center;
  overflow: hidden;
}

.sudoku-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.85rem auto 0;
  width: min(100vmin, 40rem);
  max-width: 100%;
}

.sudoku-mode {
  appearance: none;
  position: relative;
  border: 1px solid #c5d0d5;
  background: #fff;
  color: var(--sudoku-ink);
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
}

.sudoku-mode:hover {
  background: #eef3f5;
}

.sudoku-mode.is-active {
  border-color: var(--sudoku-accent);
  background: var(--sudoku-selected);
  box-shadow: inset 0 0 0 1px var(--sudoku-accent);
}

.sudoku-mode__glyph {
  position: absolute;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--sudoku-ink);
  pointer-events: none;
}

.sudoku-mode__glyph--answer {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
}

.sudoku-mode__glyph--corner {
  top: 0.35rem;
  left: 0.45rem;
  font-size: 0.85rem;
}

.sudoku-mode__glyph--centre {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
  margin: 0.65rem auto 0;
  width: min(100vmin, 40rem);
  max-width: 100%;
  padding: 0.65rem;
  background: var(--sudoku-pad);
  border-radius: 10px;
}

.sudoku-pad__btn {
  appearance: none;
  border: 1px solid #c5d0d5;
  background: #fff;
  color: var(--sudoku-ink);
  font: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.sudoku-pad__btn:active {
  background: var(--sudoku-selected);
}

.sudoku-pad__btn--clear {
  grid-column: span 2;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

@media (max-width: 40rem) {
  .sudoku-main {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  .sudoku-toolbar,
  .sudoku-status {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .sudoku-board-wrap,
  .sudoku-board,
  .sudoku-modes,
  .sudoku-pad {
    width: 100vmin;
    max-width: 100vmin;
    border-radius: 0;
  }

  .sudoku-modes {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    box-sizing: border-box;
  }

  .sudoku-pad {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

@media (max-width: 360px) {
  .sudoku-pad__btn {
    min-height: 44px;
    font-size: 1.15rem;
  }
}
