:root {
  color-scheme: dark;
  --bg: #070806;
  --panel: #12170f;
  --panel-soft: #182011;
  --ink: #f7f2e6;
  --muted: #aaa895;
  --line: #34402e;
  --line-strong: #72845d;
  --acid: #b6f44f;
  --hot: #ff7042;
  --cool: #7bb9c8;
  --bad: #ff4f5f;
  --cell: #10150d;
  --cell-alt: #161d11;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(7, 8, 6, 0.72), var(--bg)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(182, 244, 79, 0.035) 0 1px, transparent 1px 72px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--acid);
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.studio-link {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.studio-link:hover {
  color: var(--ink);
}

.game-title {
  text-align: center;
}

.game-title p {
  margin: 0 0 4px;
  color: var(--acid);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.86;
}

.icon-button {
  justify-self: end;
  min-width: 72px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 900;
}

.game-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  background: rgba(18, 23, 15, 0.92);
  padding: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stats div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--cell);
}

.stats span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stats strong {
  font-size: 24px;
}

.difficulty-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.segment {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  font-weight: 850;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--acid);
  color: #101608;
}

.mode-row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--cell);
  color: var(--ink);
  font-weight: 800;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--acid);
}

.slop-status {
  min-height: 74px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 112, 66, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 112, 66, 0.16), transparent 54%),
    var(--cell);
  color: #f8d8c7;
  line-height: 1.35;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.actions button {
  min-height: 42px;
  font-weight: 850;
}

.board-wrap {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 680px);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  background: var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--cell);
  color: var(--ink);
  font-size: clamp(22px, 5.5vw, 44px);
  font-weight: 850;
  line-height: 1;
}

.cell:nth-child(3n) {
  border-right-width: 3px;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom-width: 3px;
}

.cell:nth-child(9n) {
  border-right-width: 1px;
}

.cell.given {
  background: var(--cell-alt);
  color: var(--cool);
}

.cell.selected {
  background: #27351a;
  outline: 2px solid var(--acid);
  outline-offset: -4px;
}

.cell.peer {
  background: #1c2615;
}

.cell.same-number {
  background: #263118;
}

.cell.invalid {
  color: var(--bad);
}

.cell.solved {
  color: var(--acid);
}

.cell.slop-zone::after {
  position: absolute;
  inset: 5px;
  pointer-events: none;
  border: 1px dashed rgba(255, 112, 66, 0.7);
  content: "";
}

.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  width: 76%;
  color: var(--muted);
  font-size: clamp(8px, 1.6vw, 13px);
  font-weight: 800;
  line-height: 1;
}

.notes span {
  display: grid;
  place-items: center;
  min-height: 1em;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  width: min(100%, 680px);
}

.number-pad button {
  aspect-ratio: 1;
  min-width: 0;
  color: var(--acid);
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 900;
}

.number-pad button.exhausted {
  color: var(--muted);
  opacity: 0.5;
}

.result-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--acid);
  background: var(--panel);
  color: var(--ink);
  padding: 24px;
}

.result-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.result-dialog h2 {
  margin-bottom: 10px;
  font-size: 32px;
}

.result-dialog p {
  color: var(--muted);
  line-height: 1.5;
}

.result-dialog button {
  width: 100%;
  min-height: 46px;
  background: var(--acid);
  color: #101608;
  font-weight: 900;
}

@media (max-width: 880px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .game-title {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: left;
  }

  .studio-link {
    grid-row: 2;
  }

  .icon-button {
    grid-row: 2;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    order: 2;
  }

  .board-wrap {
    order: 1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 12px;
  }

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

  .stats div {
    min-height: 58px;
    padding: 8px;
  }

  .stats span {
    font-size: 10px;
  }

  .stats strong {
    font-size: 17px;
  }

  .number-pad {
    gap: 4px;
  }
}
