:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7fb;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f6f7fb;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  user-select: none;
}

button,
select,
input {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100vw, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 2px;
  color: #687187;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  text-transform: capitalize;
}

.timer {
  min-width: 78px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  text-align: center;
  font-weight: 800;
  touch-action: manipulation;
}

.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 3px solid #172033;
  background: #172033;
  gap: 1px;
}

.cell {
  position: relative;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #2563eb;
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: manipulation;
}

.cell:nth-child(3n) {
  border-right: 2px solid #172033;
}

.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 #172033;
}

.cell strong {
  font-size: clamp(1.28rem, 7vw, 2.05rem);
  line-height: 1;
}

.cell small {
  width: 86%;
  height: 86%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  color: #69758b;
  font-size: clamp(0.52rem, 2.6vw, 0.78rem);
  line-height: 1;
}

.cell small span {
  display: grid;
  place-items: center;
}

.given {
  color: #172033;
  font-weight: 900;
}

.related {
  background: #eef4ff;
}

.same {
  background: #dceafe;
}

.selected {
  background: #bfdbfe;
  outline: 3px solid #2563eb;
  outline-offset: -3px;
}

.conflict,
.wrong {
  color: #dc2626;
  background: #fee2e2;
}

.tools,
.numbers,
.file-actions {
  display: grid;
  gap: 8px;
}

.tools {
  grid-template-columns: repeat(4, 1fr);
}

.numbers {
  grid-template-columns: repeat(9, 1fr);
}

.file-actions {
  grid-template-columns: repeat(2, 1fr);
}

.tools button,
.numbers button,
.file-actions button,
.settings select {
  min-height: 44px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-weight: 800;
  touch-action: manipulation;
}

.numbers button {
  min-height: 52px;
  color: #2563eb;
  font-size: 1.2rem;
}

.numbers .complete-number {
  border-color: #e5e7eb;
  background: #f1f3f6;
  color: #9aa3b2;
}

.tools button:disabled {
  opacity: 0.42;
}

.tools .active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  color: #3f495c;
  font-size: 0.93rem;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings select {
  padding: 0 10px;
}

.complete {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #dcfce7;
  color: #166534;
  font-weight: 800;
  text-align: center;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 800;
}

.update-banner button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 900;
  padding: 0 12px;
  touch-action: manipulation;
}

.status {
  margin: 0;
  color: #3f495c;
  font-size: 0.93rem;
  font-weight: 700;
  text-align: center;
}

@media (min-width: 760px) {
  .shell {
    padding-top: 28px;
  }
}
