/* ============================================================
   깨알도구
   스도쿠
   ============================================================ */

.tool-page {
  --tool-page-max-width: 900px;
}

/* ============================================================
   GAME
   ============================================================ */

.sudoku-game {
  width: 100%;
}

/* ============================================================
   TOOLBAR
   ============================================================ */

.sudoku-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  margin-bottom: 10px;
}

.difficulty-control {
  display: flex;
  align-items: center;
  gap: 7px;

  color: var(--text-soft, #64748b);

  font-size: 12px;
  font-weight: 800;
}

.difficulty-control select {
  min-height: 36px;

  padding: 0 30px 0 11px;

  border: 1px solid var(--line, #d9dee7);
  border-radius: 9px;

  background: #fff;

  color: var(--text, #1e293b);

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.sudoku-toolbar-actions {
  display: flex;
  gap: 6px;
}

.sudoku-toolbar-actions button {
  min-height: 36px;

  padding: 0 12px;

  border: 1px solid var(--line, #d9dee7);
  border-radius: 9px;

  background: #fff;

  color: var(--text-soft, #64748b);

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.sudoku-toolbar-actions button:hover:not(:disabled) {
  background: #f8fafc;
}

.sudoku-toolbar-actions button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ============================================================
   HUD
   ============================================================ */

.sudoku-hud {
  display: grid;

  grid-template-columns: repeat(4, minmax(0, 1fr));

  gap: 6px;

  margin-bottom: 8px;
}

.sudoku-hud > div {
  min-width: 0;

  padding: 8px 6px;

  border: 1px solid var(--line, #d9dee7);
  border-radius: 10px;

  background: #fff;

  text-align: center;
}

.sudoku-hud span {
  display: block;

  margin-bottom: 2px;

  color: var(--text-soft, #64748b);

  font-size: 12px;
  font-weight: 800;
}

.sudoku-hud strong {
  display: block;

  color: var(--text, #1e293b);

  font-size: 13px;
  font-weight: 900;

  font-variant-numeric: tabular-nums;
}

/* ============================================================
   MESSAGE
   ============================================================ */

.sudoku-message {
  min-height: 22px;

  margin-bottom: 8px;

  color: #64748b;

  font-size: 12px;
  font-weight: 700;

  text-align: center;
}

/* ============================================================
   BOARD
   ============================================================ */

.sudoku-board-wrap {
  position: relative;

  width: min(100%, 560px);

  margin: 0 auto;
}

.sudoku-board {
  display: grid;

  grid-template-columns: repeat(9, 1fr);

  width: 100%;

  aspect-ratio: 1 / 1;

  overflow: hidden;

  border: 3px solid #334155;
  border-radius: 12px;

  background: #334155;

  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
}

/* ============================================================
   CELL
   ============================================================ */

.sudoku-cell {
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 0;
  min-height: 0;

  margin: 0;
  padding: 0;

  border: 0;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;

  background: #fff;

  color: #334155;

  font-family: inherit;

  font-size: clamp(17px, 5.4vw, 31px);

  font-weight: 700;

  line-height: 1;

  cursor: pointer;

  user-select: none;

  -webkit-user-select: none;

  -webkit-tap-highlight-color: transparent;
}

.sudoku-cell:hover {
  background: #f8fafc;
}

.sudoku-cell.box-right {
  border-right: 3px solid #334155;
}

.sudoku-cell.box-bottom {
  border-bottom: 3px solid #334155;
}

.sudoku-cell.given {
  background: #f8fafc;

  color: #0f172a;

  font-weight: 900;
}

.sudoku-cell.user-value {
  color: #2563eb;
}

.sudoku-cell.peer {
  background: #eef5ff;
}

.sudoku-cell.same-value {
  background: #dbeafe;
}

.sudoku-cell.selected {
  background: #bfdbfe;

  box-shadow: inset 0 0 0 2px #3b82f6;

  z-index: 2;
}

.sudoku-cell.error {
  background: #fee2e2;

  color: #dc2626;
}

.sudoku-cell.selected.error {
  background: #fecaca;

  box-shadow: inset 0 0 0 2px #ef4444;
}

/* ============================================================
   NOTES
   ============================================================ */

.sudoku-notes {
  position: absolute;

  inset: 3px;

  display: grid;

  grid-template-columns: repeat(3, 1fr);

  grid-template-rows: repeat(3, 1fr);

  color: #64748b;

  font-size: clamp(6px, 1.7vw, 10px);

  font-weight: 700;

  line-height: 1;
}

.sudoku-notes span {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   ACTION BUTTONS
   ============================================================ */

.sudoku-action-row {
  display: grid;

  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 7px;

  width: min(100%, 560px);

  margin: 12px auto 8px;
}

.sudoku-action-button {
  display: grid;

  grid-template-columns: auto 1fr auto;

  align-items: center;

  gap: 6px;

  min-height: 44px;

  padding: 7px 10px;

  border: 1px solid var(--line, #d9dee7);
  border-radius: 11px;

  background: #fff;

  color: #475569;

  cursor: pointer;
}

.sudoku-action-button:hover:not(:disabled) {
  background: #f8fafc;
}

.sudoku-action-button > span {
  font-size: 17px;
}

.sudoku-action-button strong {
  text-align: left;

  font-size: 12px;
  font-weight: 900;
}

.sudoku-action-button small {
  color: #94a3b8;

  font-size: 12px;
  font-weight: 800;
}

.sudoku-action-button.active {
  border-color: #60a5fa;

  background: #eff6ff;

  color: #2563eb;
}

.sudoku-action-button.active small {
  color: #2563eb;
}

.sudoku-action-button:disabled {
  opacity: 0.4;

  cursor: default;
}

/* ============================================================
   NUMBER PAD
   ============================================================ */

.sudoku-number-pad {
  display: grid;

  grid-template-columns: repeat(9, minmax(0, 1fr));

  gap: 5px;

  width: min(100%, 560px);

  margin: 0 auto;
}

.sudoku-number-pad button {
  aspect-ratio: 1 / 1;

  min-width: 0;

  border: 1px solid #cbd5e1;
  border-radius: 10px;

  background: #fff;

  color: #2563eb;

  font-size: clamp(15px, 4vw, 22px);

  font-weight: 900;

  cursor: pointer;

  -webkit-tap-highlight-color: transparent;
}

.sudoku-number-pad button:hover {
  border-color: #93c5fd;

  background: #eff6ff;
}

.sudoku-number-pad button:active {
  transform: translateY(1px);
}

/* ============================================================
   KEYBOARD HELP
   ============================================================ */

.sudoku-keyboard-help {
  display: flex;

  flex-wrap: wrap;

  justify-content: center;

  gap: 5px;

  width: min(100%, 560px);

  margin: 9px auto 0;
}

.sudoku-keyboard-help span {
  padding: 3px 6px;

  border-radius: 999px;

  background: #f1f5f9;

  color: #64748b;

  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   COMPLETE
   ============================================================ */

.sudoku-complete {
  position: absolute;

  inset: 0;

  z-index: 20;

  display: flex;

  align-items: center;
  justify-content: center;

  padding: 18px;

  border-radius: 12px;

  background: rgba(248, 250, 252, 0.92);

  backdrop-filter: blur(5px);
}

.sudoku-complete[hidden] {
  display: none;
}

.sudoku-complete-card {
  width: min(330px, 100%);

  padding: 22px 18px;

  border: 1px solid #dbe3ed;
  border-radius: 18px;

  background: #fff;

  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);

  text-align: center;
}

.complete-icon {
  margin-bottom: 5px;

  font-size: 34px;
}

.sudoku-complete-card h2 {
  margin: 0;

  color: #0f172a;

  font-size: 22px;
}

.sudoku-complete-card > p {
  margin: 5px 0 12px;

  color: #64748b;

  font-size: 12px;
}

.complete-stats {
  display: grid;

  grid-template-columns: repeat(2, 1fr);

  gap: 7px;

  margin-bottom: 10px;
}

.complete-stats > div {
  padding: 8px;

  border-radius: 10px;

  background: #f8fafc;
}

.complete-stats span {
  display: block;

  color: #94a3b8;

  font-size: 12px;
  font-weight: 800;
}

.complete-stats strong {
  display: block;

  margin-top: 2px;

  color: #334155;

  font-size: 13px;
}

.complete-best {
  min-height: 17px;

  color: #2563eb !important;

  font-weight: 800;
}

.complete-new-button {
  width: 100%;

  min-height: 40px;

  border: 0;
  border-radius: 10px;

  background: #334155;

  color: #fff;

  font-size: 12px;
  font-weight: 900;

  cursor: pointer;
}

/* ============================================================
   GUIDE
   ============================================================ */

.sudoku-guide {
  margin-top: 24px;

  padding-top: 20px;

  border-top: 1px solid var(--line, #e2e8f0);
}

.sudoku-guide h2 {
  margin: 0 0 10px;

  font-size: 15px;
}

.sudoku-guide-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 8px;
}

.sudoku-guide-grid > div {
  padding: 12px;

  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;

  background: #fff;
}

.sudoku-guide-grid strong {
  display: block;

  margin-bottom: 4px;

  color: #334155;

  font-size: 12px;
}

.sudoku-guide-grid p {
  margin: 0;

  color: #64748b;

  font-size: 12px;
  line-height: 1.65;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .sudoku-toolbar {
    align-items: stretch;
  }

  .difficulty-control {
    flex: 1 1 auto;
  }

  .difficulty-control select {
    flex: 1;
  }

  .sudoku-toolbar-actions button {
    padding: 0 8px;

    font-size: 12px;
  }

  .sudoku-hud {
    gap: 4px;
  }

  .sudoku-hud > div {
    padding: 7px 3px;
  }

  .sudoku-board {
    border-radius: 9px;
  }

  .sudoku-action-button {
    grid-template-columns: 1fr;

    justify-items: center;

    gap: 1px;

    min-height: 53px;

    padding: 5px;
  }

  .sudoku-action-button strong {
    text-align: center;

    font-size: 12px;
  }

  .sudoku-action-button small {
    font-size: 12px;
  }

  .sudoku-number-pad {
    gap: 3px;
  }

  .sudoku-number-pad button {
    border-radius: 7px;
  }

  .sudoku-guide-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   VERY SMALL
   ============================================================ */

@media (max-width: 390px) {
  .sudoku-toolbar {
    flex-direction: column;
  }

  .sudoku-toolbar-actions {
    display: grid;

    grid-template-columns: repeat(2, 1fr);
  }

  .sudoku-toolbar-actions button {
    width: 100%;
  }

  .sudoku-cell {
    font-size: clamp(15px, 6vw, 24px);
  }
}
