/* Extracted from sudoku.txt <style> with minor tweaks */
#sudoku9 {
  position: relative;
}

/* Number bar */
.num-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 360px;
  margin: 20px auto 10px auto;
}
.num-row button {
  width: 55px;
  height: 40px;
  background: #ffffff !important;
  border: 1px solid #ccc !important;
  color: #333 !important;
  font-size: 18px !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}
.num-row button:hover {
  background: #f3f3f3 !important;
}
.num-row button.clear {
  font-size: 20px !important;
}

/* Wrapper */
.sdk {
  --bg: #f7fbff;
  --accent: #027aff;
  --accent2: #18b0ff;
  --text: #0e1a25;
  --muted: #5a7184;
  --border: #d6e6f2;
  --boardBorder: #000;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  max-width: 900px;
  margin: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}
.sdk h2 {
  text-align: center;
  color: var(--accent);
  margin: 12px 0 10px;
  font-family: 'Cinzel', serif;
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
  margin: 10px 0 16px;
}
.toolbar .row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
label {
  color: var(--muted);
  font-size: 14px;
}
.stats-row {
  justify-content: flex-start;
}
.buttons-row {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}
.autocheck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: #456;
}

/* Chips, stats, buttons */
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  transition: 0.2s;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.stat {
  background: #f1f7ff;
  border: 1px solid #cfe5ff;
  border-radius: 10px;
  padding: 6px 10px;
  text-align: center;
  font-size: 13px;
}
.stat.small {
  font-size: 12px;
}
.stat b {
  display: block;
  color: #015fdf;
  font-size: 18px;
  margin-top: 2px;
}
.primary,
.ghost {
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  background: #fff;
  transition: 0.2s;
}
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
}
.primary:hover {
  filter: brightness(1.05);
}
.ghost:hover {
  background: #eef4ff;
}
.ghost.small {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}
.ghost.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Leaderboards */
#eqsy-leaderboard,
#eqsy-leaderboard-daily {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
#eqsy-leaderboard h3,
#eqsy-leaderboard-daily h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.lb-sub {
  margin: 4px 0 10px;
  color: #6b7280;
  font-size: 0.9rem;
}
.board-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.board-tabs .tab {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}
.board-tabs .tab.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
#sdk-leaderboard-table table,
#sdk-daily-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
#sdk-leaderboard-table th,
#sdk-leaderboard-table td,
#sdk-daily-table th,
#sdk-daily-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}
#sdk-leaderboard-table th,
#sdk-daily-table th {
  background: #eff4ff;
  font-weight: 600;
}
.lb-more {
  margin-top: 8px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lb-pagination {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.lb-pagination button {
  border-radius: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.lb-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* Dark table text visibility */
.sdk.dark #sdk-leaderboard-table th,
.sdk.dark #sdk-daily-table th {
  background: #0e1b2b;
  color: #e5eef7;
  border-bottom: 1px solid #223142;
}
.sdk.dark #sdk-leaderboard-table td,
.sdk.dark #sdk-daily-table td {
  color: #cfe1ff;
  border-bottom: 1px solid #223142;
}
.daily-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.daily-bar input[type='date'] {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
}

/* Board */
.board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px auto 10px;
}
.cell.highlight {
  background: #dbeafe !important;
}
.cell.same-num {
  background: #bfdbfe !important;
}
.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1/1;
  width: 90vw;
  max-width: 540px;
  max-height: 80vh;
  border: 3px solid var(--boardBorder);
}
.cell {
  position: relative;
  background: #f9fafb;
  border: 1px solid #cfd9e4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  font-size: 22px;
  font-weight: 600;
  aspect-ratio: 1/1;
}
.cell.fixed {
  background: #e8f1ff;
  font-weight: 700;
}
.cell.selected {
  outline: 3px solid #2563eb;
  outline-offset: -2px;
}
.cell.wrong {
  background: #ffe5e5;
  animation:
    shake 0.15s linear 2,
    blinkWrong 1s ease-in-out 1;
}
@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-1px);
  }
  50% {
    transform: translateX(1px);
  }
  75% {
    transform: translateX(-1px);
  }
  100% {
    transform: translateX(0);
  }
}
@keyframes blinkWrong {
  0% {
    filter: none;
  }
  50% {
    filter: brightness(1.15) saturate(1.2);
  }
  100% {
    filter: none;
  }
}

/* Colorful 3x3 blocks */
.cell.blk-0 {
  background: #fdf2f2;
}
.cell.blk-1 {
  background: #eff6ff;
}
.cell.blk-2 {
  background: #ecfdf5;
}
.cell.blk-3 {
  background: #fefce8;
}
.cell.blk-4 {
  background: #f5f3ff;
}
.cell.blk-5 {
  background: #f0f9ff;
}
.cell.blk-6 {
  background: #fdf2ff;
}
.cell.blk-7 {
  background: #fff7ed;
}
.cell.blk-8 {
  background: #f4f4f5;
}
.cell.fixed.blk-* {
  filter: brightness(0.96);
}

/* Thick borders between 3x3 blocks */
.cell:nth-child(3n) {
  border-right: 3px solid var(--boardBorder) !important;
}
.cell:nth-child(9n + 1) {
  border-left: 3px solid var(--boardBorder) !important;
}
.cell:nth-child(n + 1):nth-child(-n + 9) {
  border-top: 3px solid var(--boardBorder) !important;
}
.cell:nth-child(n + 73) {
  border-bottom: 3px solid var(--boardBorder) !important;
}
.cell:nth-child(n + 28):nth-child(-n + 36),
.cell:nth-child(n + 55):nth-child(-n + 63) {
  border-top: 3px solid var(--boardBorder) !important;
}

/* Draft / candidates */
.drafts {
  position: absolute;
  inset: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 1px;
  font-size: 10px;
  font-weight: 500;
  color: #6b7280;
  pointer-events: none;
}
.drafts .d {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Powerups */
.powerups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin: 4px 0 8px;
}
.power-label {
  font-size: 0.85rem;
  color: #4b5563;
  margin-right: 4px;
}
.power-btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}
.power-btn:hover {
  background: #eef4ff;
}

/* Result */
.result {
  text-align: center;
  min-height: 22px;
  margin: 4px 0 10px;
  font-size: 0.95rem;
}

/* Stats */
.sdk-stats {
  margin-top: 6px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 8px;
}
.sdk-stats h3 {
  font-size: 0.95rem;
  margin: 0 0 4px;
}
.sdk-stats ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: #4b5563;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  opacity: 0.92;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  z-index: 120;
  pointer-events: none;
  animation: popfade 1.2s ease-out forwards;
}
@keyframes popfade {
  0% {
    transform: translate(-50%, -6px) scale(0.96);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -20px) scale(1);
    opacity: 0;
  }
}

/* Dark mode */
.sdk.dark {
  --bg: #0d1420;
  --text: #e5eef7;
  --muted: #9ab1c7;
  --border: #243345;
  --accent: #5aa0ff;
  --accent2: #7cc2ff;
  --boardBorder: #dbe5f7;
  background: #0d1420;
  color: var(--text);
  border-color: #1c2836;
  box-shadow: none;
}
.sdk.dark .ghost {
  background: #111b2a;
  border-color: #223142;
  color: #d9e7f5;
}
.sdk.dark .ghost.active {
  background: #3b79ff;
  border-color: #3b79ff;
  color: #fff;
}
.sdk.dark .primary {
  background: linear-gradient(135deg, #3b79ff, #5aa0ff);
}
.sdk.dark .stat {
  background: #0f2136;
  border-color: #1f3552;
}
.sdk.dark .board {
  border-color: #dbe5f7;
}
.sdk.dark .cell {
  background: #101a29;
  border-color: #28405c;
  color: #e5eef7;
}
.sdk.dark .cell.fixed {
  background: #0e253f;
}
.sdk.dark .cell.highlight {
  background: #17324b !important;
}
.sdk.dark .cell.same-num {
  background: #1d3f63 !important;
}
.sdk.dark .drafts {
  color: #b8c7d9;
}
.sdk.dark .cell.selected {
  outline-color: #5aa0ff;
}
.sdk.dark .cell.wrong {
  background: #3b1620;
  outline-color: #ff5b7d;
}
.sdk.dark #eqsy-leaderboard,
.sdk.dark #eqsy-leaderboard-daily {
  background: #0d1420;
  border-color: #223142;
}
.sdk.dark #eqsy-leaderboard .tab,
.sdk.dark #eqsy-leaderboard-daily .tab {
  background: #0e1b2b;
  border-color: #223142;
  color: #cfe1ff;
}
.sdk.dark #eqsy-leaderboard .tab.active,
.sdk.dark #eqsy-leaderboard-daily .tab.active {
  background: #3b79ff;
  color: #fff;
}
.sdk.dark .power-btn {
  background: #111b2a;
  border-color: #223142;
  color: #e5e7eb;
}
.sdk.dark .power-btn:hover {
  background: #1f2937;
}

/* Modal */
.win {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.75);
  z-index: 150;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 18px 18px 14px;
  max-width: 360px;
  width: 90%;
  border: 1px solid #e5e7eb;
}
.sdk.dark .modal {
  background: #0d1420;
  border-color: #223142;
  color: #e5eef7;
}
.modal h2 {
  margin-top: 0;
}
.modal input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  margin: 8px 0 10px;
}
.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Mobile landscape tweaks */
@media (max-width: 900px) and (orientation: landscape) {
  #sudoku9 {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .board {
    width: 90vw !important;
    max-width: 90vw !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: auto !important;
  }
  .num-row.floating {
    position: relative !important;
    margin-top: 20px !important;
  }
}
