*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #070b14;
  --surface: rgba(255, 255, 255, 0.042);
  --surface-h: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-h: rgba(255, 255, 255, 0.2);
  --text: #dde3f5;
  --muted: #58698e;
  --sudoku: #e8a23a;
  --sudoku-glow: rgba(232, 162, 58, 0.22);
  --error: #e05252;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  min-height: 100vh;
}

.betaNotice {
  width: 100%;
  height: 22px;
  line-height: 22px;
  background: rgba(232, 162, 58, 0.1);
  color: rgba(240, 210, 160, 0.75);
  border-bottom: 1px solid rgba(232, 162, 58, 0.2);
  padding: 0 12px;
  text-align: center;
  font-size: 11px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  user-select: none;
}
.betaNoticeLink {
  color: rgba(232, 178, 90, 0.9);
  text-decoration: underline;
}
.betaNoticeLink:hover {
  color: rgba(240, 210, 160, 1);
}

header {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(7, 11, 20, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.hdr-home {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.15s;
}
.hdr-home:hover {
  color: var(--text);
}
.hdr-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}
.hdr-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sudoku);
}
.hdr-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.discord-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.95rem;
  border-radius: 100px;
  background: #5865f2;
  color: #fff;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition:
    opacity 0.18s,
    transform 0.18s;
  white-space: nowrap;
}
.discord-login-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.discord-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.5rem 0.28rem 0.28rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.discord-profile img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-menu-btn {
  font-size: 0.65rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0 0 0.1rem;
  transition:
    color 0.15s,
    transform 0.15s;
}
.profile-menu-btn:hover {
  color: var(--text);
}
.profile-menu-btn.open {
  transform: rotate(180deg);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #0c1220;
  border: 1px solid var(--border-h);
  border-radius: 12px;
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 120;
}
.profile-dropdown.open {
  display: flex;
}
.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.profile-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.profile-dropdown-item.profile-dropdown-danger {
  color: var(--error);
}
.profile-dropdown-item.profile-dropdown-danger:hover {
  background: rgba(224, 82, 82, 0.1);
}

/* ============== Settings modal ============== */
#settings-modal {
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(10px);
}

/*.settings-card {
  align-items: stretch;
  text-align: left;
}*/
#settings-modal .settings-card {
  max-width: 520px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2rem 2rem 1.75rem;
  align-items: stretch;
  text-align: left;
  animation: none;
}
.settings-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.settings-modal-head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
}
.settings-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
}
.settings-close-btn:hover {
  color: var(--text);
}

.settings-group {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.9rem;
}
.settings-group:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.settings-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
}
.settings-row-copy label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}
.settings-row-copy p {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.settings-row-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.settings-row-control-volume input[type="range"] {
  width: 110px;
}
.settings-row-control select,
.settings-row-control input[type="text"] {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
}
.settings-row-control input[type="text"] {
  width: 140px;
  outline: none;
}
.settings-row-control input[type="text"]:focus {
  border-color: var(--border-h);
}
.settings-empty {
  font-size: 0.8rem;
  color: var(--muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--sudoku);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.diff-switch {
  display: flex;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px;
}
.diff-btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 0.8rem;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.diff-btn:hover {
  color: var(--text);
}
.diff-btn.active {
  background: var(--sudoku);
  color: #241505;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.game-wrap {
  display: flex;
  justify-content: center;
}
.board-col {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}
.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.6rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 2px solid var(--border-h);
  border-radius: 14px;
  overflow: hidden;
}

.board.paused .cell-value,
.board.paused .cell-notes {
  visibility: hidden;
}
.board.paused .cell {
  background: transparent !important;
  cursor: default;
}

.board-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(7, 11, 20, 0.94);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  z-index: 10;
}
.board-overlay.open {
  display: flex;
}
.board-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}
.board-overlay-inner i {
  font-size: 1.8rem;
  color: var(--sudoku);
  margin-bottom: 0.2rem;
}
.board-overlay-inner span {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.board-overlay-inner p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.start-overlay .btn-primary {
  width: auto;
  padding: 0.7rem 1.6rem;
  margin-top: 0.3rem;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  user-select: none;
}
.cell.border-t {
  border-top: 2px solid var(--border-h);
}
.cell.border-l {
  border-left: 2px solid var(--border-h);
}
.cell.border-r {
  border-right: 2px solid var(--border-h);
}
.cell.border-b {
  border-bottom: 2px solid var(--border-h);
}

.cell-value {
  font-size: clamp(1rem, 3.6vw, 1.5rem);
  font-weight: 600;
  line-height: 1;
  color: var(--sudoku);
}
.cell.given .cell-value {
  color: var(--text);
  font-weight: 700;
}
.cell.user-value .cell-value {
  color: var(--sudoku);
}
.cell.error .cell-value {
  color: var(--error);
}

.cell.peer {
  background: rgba(232, 162, 58, 0.05);
}
.cell.selected {
  background: rgba(232, 162, 58, 0.22);
}
.cell.same-value:not(.selected) {
  background: rgba(232, 162, 58, 0.12);
}
.cell.error.selected {
  background: rgba(224, 82, 82, 0.22);
}
.cell.error.peer {
  background: rgba(224, 82, 82, 0.08);
}

.cell-notes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 2px;
}
.note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.5rem, 1.4vw, 0.62rem);
  color: transparent;
  font-weight: 600;
  line-height: 1;
}
.note.active {
  color: var(--muted);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0.4rem;
}
.num-btn {
  aspect-ratio: 1 / 1;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.num-btn:hover {
  background: var(--surface-h);
  border-color: var(--border-h);
}
.num-btn:active {
  transform: scale(0.94);
}
.num-btn.depleted {
  opacity: 0.3;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.action-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.65rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
.action-btn:hover {
  background: var(--surface-h);
  border-color: var(--border-h);
}
.action-btn.active {
  background: rgba(232, 162, 58, 0.18);
  border-color: rgba(232, 162, 58, 0.4);
  color: var(--sudoku);
}
.action-btn-accent {
  background: var(--sudoku);
  border-color: var(--sudoku);
  color: #241505;
}
.action-btn-accent:hover {
  opacity: 0.9;
  background: var(--sudoku);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}
.modal.open {
  display: flex;
}
.modal-card {
  background: #0c1220;
  border: 1px solid var(--border-h);
  border-radius: 20px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  animation: pop 0.25s ease both;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.win-icon {
  background: rgba(232, 162, 58, 0.15);
  color: var(--sudoku);
}
.lose-icon {
  background: rgba(224, 82, 82, 0.15);
  color: var(--error);
}

.modal-card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.4rem;
}

.modal-text {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

.modal-badge {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sudoku);
  background: rgba(232, 162, 58, 0.12);
  border: 1px solid rgba(232, 162, 58, 0.3);
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
}

.modal-stats {
  display: flex;
  gap: 1.25rem;
  margin: 0.25rem 0 0.5rem;
}
.modal-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.modal-stat span {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.modal-stat strong {
  font-size: 1.1rem;
}

.btn-primary {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.75rem;
  background: var(--sudoku);
  border: none;
  border-radius: 12px;
  color: #241505;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover {
  opacity: 0.9;
}

@media (max-width: 480px) {
  header {
    padding: 0 1rem;
  }
  .hdr-info {
    gap: 0.4rem;
  }
  .diff-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.68rem;
  }
  main {
    padding: 1.25rem 0.6rem 3rem;
  }
  .actions-row {
    flex-direction: column;
  }
}
