:root {
  --bg-night: #08111d;
  --bg-dusk: #2a1f3b;
  --bg-sunset: #6d3346;
  --panel: rgba(18, 15, 28, 0.78);
  --line: rgba(255, 170, 106, 0.28);
  --text: #fff3e7;
  --muted: #e1c0ad;
  --accent-gold: #ffd95d;
  --accent-orange: #ff9350;
  --accent-rose: #cf6d8e;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 12%, rgba(255, 217, 93, 0.2), transparent 24%),
    radial-gradient(circle at 68% 24%, rgba(255, 147, 80, 0.24), transparent 34%),
    radial-gradient(circle at 18% 8%, rgba(207, 109, 142, 0.2), transparent 36%),
    linear-gradient(140deg, var(--bg-night), var(--bg-dusk) 54%, var(--bg-sunset));
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 170, 106, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 170, 106, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 78%);
}

.sudoku-shell {
  width: min(1200px, 94vw);
  margin: 20px auto 34px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.top-panel,
.stats-panel {
  grid-column: 1 / -1;
}

.top-panel {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.difficulty-wrap {
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #ffd9a0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.difficulty-wrap select {
  min-width: 120px;
  border-radius: 10px;
  border: 1px solid rgba(255, 190, 126, 0.28);
  background: rgba(7, 12, 20, 0.56);
  color: var(--text);
  font-family: "Rajdhani", sans-serif;
  font-size: 0.95rem;
  padding: 8px 10px;
  cursor: pointer;
}

.kicker {
  margin: 0;
  color: #ffd9a0;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1 {
  margin-top: 5px;
  font-size: clamp(1.35rem, 2.7vw, 2.05rem);
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.05rem;
}

.action-btn,
.touch-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  color: #2b1203;
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-gold));
  font-family: "Orbitron", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.action-btn:hover,
.touch-btn:hover {
  filter: saturate(1.1);
}

.stats-panel {
  padding: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stat {
  border: 1px solid rgba(255, 190, 126, 0.24);
  border-radius: 11px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.stat span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #ffd6b2;
  font-weight: 700;
}

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

.board-panel {
  position: relative;
  padding: 14px;
  display: grid;
  place-items: center;
}

.board {
  width: min(100%, 640px);
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid rgba(255, 190, 126, 0.3);
  background: rgba(8, 16, 28, 0.5);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
}

.cell {
  border: 1px solid rgba(255, 190, 126, 0.24);
  background: rgba(255, 255, 255, 0.02);
  color: #fff6e5;
  padding: 0;
  margin: 0;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s ease;
}

.cell:hover {
  background: rgba(255, 147, 80, 0.14);
}

.cell.fixed {
  background: rgba(255, 210, 120, 0.2);
  color: #331d06;
}

.cell.related {
  background: rgba(255, 147, 80, 0.1);
}

.cell.selected {
  background: rgba(79, 212, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(199, 239, 255, 0.66);
}

.cell.conflict {
  background: rgba(255, 90, 90, 0.3);
}

.cell.box-left {
  border-left-width: 2px;
  border-left-color: rgba(255, 190, 126, 0.52);
}

.cell.box-right {
  border-right-width: 2px;
  border-right-color: rgba(255, 190, 126, 0.52);
}

.cell.box-top {
  border-top-width: 2px;
  border-top-color: rgba(255, 190, 126, 0.52);
}

.cell.box-bottom {
  border-bottom-width: 2px;
  border-bottom-color: rgba(255, 190, 126, 0.52);
}

.digit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(0.9rem, 2.1vw, 1.35rem);
  font-weight: 700;
  z-index: 2;
}

.notes-grid {
  position: absolute;
  inset: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: clamp(0.42rem, 1vw, 0.62rem);
  color: #ffd7b6;
  opacity: 0.85;
}

.note {
  display: grid;
  place-items: center;
}

.cell.has-value .notes-grid {
  opacity: 0;
}

.overlay {
  position: absolute;
  inset: 14px;
  border-radius: 12px;
  display: none;
  place-items: center;
  text-align: center;
  background: rgba(8, 14, 24, 0.82);
  color: #fff4e7;
  padding: 20px;
}

.overlay.show {
  display: grid;
}

.overlay h2 {
  font-size: clamp(1.2rem, 2.8vw, 1.9rem);
  color: #ffdda5;
}

.overlay p {
  margin-top: 8px;
}

.side-panel {
  padding: 15px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.side-copy {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.keypad {
  margin-top: 9px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.touch-btn {
  border-radius: 10px;
  padding: 11px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 1.04rem;
}

.clear-btn {
  grid-column: 1 / -1;
}

.notes-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #ffd9a0;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.notes-toggle input {
  accent-color: #ffb468;
}

.side-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.ghost-btn {
  border: 1px solid rgba(255, 190, 126, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #ffe2c3;
  font-family: "Rajdhani", sans-serif;
  font-size: 0.98rem;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 10px 11px;
  cursor: pointer;
}

.ghost-btn:hover {
  background: rgba(255, 147, 80, 0.14);
}

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

@media (max-width: 860px) {
  .top-panel {
    flex-direction: column;
    align-items: flex-start;
  }

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

@media (max-width: 620px) {
  .stats-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
