/**
 * CogniTest Sudoku Styling
 * Responsive 9x9 Board, 3x3 Thick Grid Dividers, Notes, Touch Numpad & Dark-Slate Aesthetic
 */

:root {
  --sudoku-bg: #090d16;
  --sudoku-card-bg: #0f172a;
  --sudoku-border: #334155;
  --sudoku-border-thick: #38bdf8;
  --sudoku-cell-bg: #1e293b;
  --sudoku-cell-given: #f8fafc;
  --sudoku-cell-user: #38bdf8;
  --sudoku-cell-selected: #0284c7;
  --sudoku-cell-highlight: rgba(56, 189, 248, 0.15);
  --sudoku-cell-same-num: rgba(56, 189, 248, 0.35);
  --sudoku-cell-error: #ef4444;
}

.sudoku-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 12px 40px;
}

.sudoku-header-box {
  background: var(--sudoku-card-bg);
  border: 1px solid var(--sudoku-border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.sudoku-week-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.sudoku-week-select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--sudoku-border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* Difficulty Tabs */
.sudoku-diff-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.sudoku-diff-tab {
  flex: 1;
  min-width: 90px;
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid var(--sudoku-border);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.sudoku-diff-tab:hover {
  background: #334155;
  color: #f8fafc;
}

.sudoku-diff-tab.active {
  background: linear-gradient(135deg, #0369a1 0%, #0369a1 100%);
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.sudoku-sub-puzzles {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sudoku-sub-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.sudoku-sub-btn.active {
  background: #0369a1;
  color: #ffffff;
  border-color: #38bdf8;
}

/* HUD bar */
.sudoku-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sudoku-card-bg);
  border: 1px solid var(--sudoku-border);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 14px;
  font-size: 0.92rem;
  font-weight: 600;
}

.sudoku-hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sudoku-hud-val {
  font-weight: 800;
  color: #38bdf8;
  font-family: monospace;
  font-size: 1.05rem;
}

/* Sudoku Board Wrapper */
.sudoku-board-card {
  position: relative;
  background: var(--sudoku-card-bg);
  border: 2px solid var(--sudoku-border-thick);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  margin-bottom: 20px;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #0b1120;
  border: 2px solid var(--sudoku-border-thick);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sudoku-cell-bg);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: clamp(1.1rem, 4vw, 1.85rem);
  font-weight: 700;
  color: var(--sudoku-cell-user);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}

/* 3x3 Box thick borders */
.sudoku-cell.border-left-thick { border-left: 2px solid var(--sudoku-border-thick); }
.sudoku-cell.border-top-thick { border-top: 2px solid var(--sudoku-border-thick); }
.sudoku-cell.border-right-thick { border-right: 2px solid var(--sudoku-border-thick); }
.sudoku-cell.border-bottom-thick { border-bottom: 2px solid var(--sudoku-border-thick); }

.sudoku-cell.is-given {
  color: var(--sudoku-cell-given);
  font-weight: 800;
  background: #1e293b;
}

.sudoku-cell.is-selected {
  background: var(--sudoku-cell-selected) !important;
  color: #ffffff !important;
}

.sudoku-cell.is-highlight-area {
  background: var(--sudoku-cell-highlight);
}

.sudoku-cell.is-same-number:not(.is-selected) {
  background: var(--sudoku-cell-same-num);
  color: #ffffff;
}

.sudoku-cell.is-error {
  color: var(--sudoku-cell-error) !important;
  background: rgba(239, 68, 68, 0.25) !important;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Notes inside cell */
.sudoku-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 2px;
  pointer-events: none;
}

.sudoku-notes-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.5rem, 1.6vw, 0.72rem);
  font-weight: 600;
  color: #94a3b8;
  line-height: 1;
}

/* Toolbar Action Buttons */
.sudoku-actions-toolbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.sudoku-tool-btn {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid var(--sudoku-border);
  padding: 10px 4px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sudoku-tool-btn:hover {
  background: #334155;
  color: #ffffff;
}

.sudoku-tool-btn.active {
  background: #0369a1;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.sudoku-tool-btn span.icon {
  font-size: 1.15rem;
}

/* Number Pad 1-9 */
.sudoku-numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}

.sudoku-numpad-btn {
  aspect-ratio: 1 / 1.1;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--sudoku-border);
  border-radius: 8px;
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sudoku-numpad-btn:hover:not(.is-exhausted) {
  background: #0369a1;
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
}

.sudoku-numpad-btn.is-exhausted {
  opacity: 0.3;
  cursor: not-allowed;
  background: #0f172a;
}

/* Pause Overlay */
.sudoku-pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

/* Victory Modal */
.sudoku-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sudoku-modal-overlay.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.sudoku-modal-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 2px solid #38bdf8;
  box-shadow: 0 20px 50px rgba(2, 132, 199, 0.4);
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  padding: 30px 24px;
  text-align: center;
  color: #ffffff;
}

.sudoku-vic-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 480px) {
  .sudoku-container { padding: 10px 6px 30px; }
  .sudoku-numpad { gap: 4px; }
  .sudoku-actions-toolbar { gap: 4px; }
  .sudoku-tool-btn { font-size: 0.75rem; padding: 8px 2px; }
}

.sudoku-controls span[style*="font-size"], .sudoku-action-btn span { font-size: 0.75rem; }
