/**
 * Sudoku Game Styles (v5.0.0)
 * Classic 9x9 Sudoku Styling, Responsive Grid, Pencil Notes & EX Stage Theme
 * Compliance: Rules.md (Rule 3)
 */

#screen-sudoku {
  display: none !important;
  background: radial-gradient(circle at 50% 10%, #222b38 0%, #11151a 100%);
  color: #f8fafc;
  height: 100%;
  width: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#screen-sudoku.active {
  display: flex !important;
  flex-direction: column;
}

/* Sudoku Top Header */
.sudoku-header {
  padding: env(safe-area-inset-top, 8px) 12px 6px 12px;
  background: rgba(18, 22, 28, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sudoku-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sudoku-brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sudoku-brand-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sudoku-version-tag {
  font-size: 9px;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 1px 5px;
  border-radius: 6px;
}

.sudoku-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.sudoku-stage-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  color: #f1f5f9;
  font-weight: 800;
}

.sudoku-stage-badge.ex-badge {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.sudoku-mistakes {
  color: #ef4444;
}

/* Sudoku Game Main Area */
.sudoku-play-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px env(safe-area-inset-bottom, 12px) 12px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* 9x9 Board Frame */
.sudoku-board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 48vh;
  margin: auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sudoku-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: #0f1318;
  border: 3px solid #6366f1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.sudoku-board.ex-board {
  border-color: #ec4899;
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.35);
}

/* Cells */
.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px, 4vw, 24px);
  font-weight: 700;
  color: #38bdf8;
  background: rgba(30, 41, 59, 0.6);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background-color 0.12s ease;
  user-select: none;
}

/* 3x3 Box Borders */
.sudoku-cell:nth-child(3n) {
  border-right: 2px solid rgba(255, 255, 255, 0.35);
}
.sudoku-cell:nth-child(9n) {
  border-right: none;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid rgba(255, 255, 255, 0.35);
}
.sudoku-cell:nth-child(n+73):nth-child(-n+81) {
  border-bottom: none;
}

/* Initial Clues */
.sudoku-cell.is-clue {
  color: #ffffff;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.8);
}

/* Cell Highlights */
.sudoku-cell.is-selected {
  background: rgba(99, 102, 241, 0.45) !important;
  outline: 2px solid #818cf8;
  z-index: 2;
}

.sudoku-cell.is-related {
  background: rgba(255, 255, 255, 0.06);
}

.sudoku-cell.is-same-number {
  background: rgba(56, 189, 248, 0.22);
}

.sudoku-cell.is-conflict {
  background: rgba(239, 68, 68, 0.35) !important;
  color: #f87171 !important;
}

/* Notes Grid (3x3 Mini Grid inside Cell) */
.sudoku-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  box-sizing: border-box;
  pointer-events: none;
}

.sudoku-note-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 1.8vw, 11px);
  color: #94a3b8;
  font-weight: 600;
  line-height: 1;
}

/* Controls Toolbar (Undo, Erase, Notes, Hint) */
.sudoku-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  margin: 6px 0;
}

.sudoku-tool-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 4px;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.sudoku-tool-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.sudoku-tool-btn:active {
  transform: scale(0.95);
}

.sudoku-tool-btn.active-mode {
  background: rgba(99, 102, 241, 0.35);
  border-color: #818cf8;
  color: #a5b4fc;
}

.sudoku-tool-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Number Pad (1-9) */
.sudoku-numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  width: 100%;
}

.sudoku-num-btn {
  aspect-ratio: 1 / 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffffff;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
  position: relative;
}

.sudoku-num-btn:active {
  transform: scale(0.92);
  background: rgba(99, 102, 241, 0.4);
}

.sudoku-num-btn.completed-num {
  opacity: 0.3;
  pointer-events: none;
}

.sudoku-num-btn .num-count-indicator {
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  margin-top: -2px;
}

/* Modal Dialogs */
.sudoku-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sudoku-modal-overlay.active {
  display: flex;
}

.sudoku-modal-card {
  background: #1e242c;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sudoku-modal-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 8px;
  color: #f8fafc;
}

.sudoku-modal-stats {
  display: flex;
  justify-content: space-around;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px;
}

.sudoku-modal-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
}
