/* ==========================================================================
   SUDOKU IMAGE SOLVER - DESIGN SYSTEM & ENHANCED HUMAN UI STYLESHEET
   ========================================================================== */

:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-outfit: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-light: rgba(99, 102, 241, 0.15);

  --color-bg-base: #020617;
  --color-bg-surface: #0f172a;
  --color-bg-card: rgba(15, 23, 42, 0.85);
  --color-border: #1e293b;
  --color-border-subtle: rgba(255, 255, 255, 0.08);

  --color-text-main: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-text-dim: #64748b;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #f43f5e;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-sans);
  background-color: var(--color-bg-base);
  color: var(--color-text-main);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.14) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.10) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.6) 0px, transparent 100%);
  background-attachment: fixed;
}

.font-outfit { font-family: var(--font-outfit); }
.font-mono { font-family: var(--font-mono); }

/* ==========================================================================
   TAILWIND UTILITIES & SYSTEM TOKENS
   ========================================================================== */

.max-w-7xl { max-width: 80rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xs { max-width: 20rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.h-16 { height: 4rem; }
.h-11 { height: 2.75rem; }
.h-12 { height: 3rem; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.w-12 { width: 3rem; }
.w-14 { width: 3.5rem; }
.h-14 { height: 3.5rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-7 { width: 1.75rem; }
.h-7 { height: 1.75rem; }
.w-3\.5 { width: 0.875rem; }
.h-3\.5 { height: 0.875rem; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }

.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.shrink-0 { flex-shrink: 0; }

.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.grid-cols-10 { grid-template-columns: repeat(10, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:flex-row { flex-direction: row; }
  .sm\:items-center { align-items: center; }
  .sm\:inline { display: inline; }
  .sm\:block { display: block; }
  .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm\:text-sm { font-size: 0.875rem; }
  .sm\:text-base { font-size: 1rem; }
  .sm\:text-lg { font-size: 1.125rem; }
  .sm\:text-xl { font-size: 1.25rem; }
  .sm\:p-5 { padding: 1.25rem; }
  .sm\:p-6 { padding: 1.5rem; }
}

@media (min-width: 768px) {
  .md\:grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .md\:col-span-5 { grid-column: span 5 / span 12; }
  .md\:col-span-7 { grid-column: span 7 / span 12; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .lg\:col-span-5 { grid-column: span 5 / span 12; }
  .lg\:col-span-7 { grid-column: span 7 / span 12; }
  .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
}

.p-1 { padding: 0.25rem; }
.p-1\.5 { padding: 0.375rem; }
.p-2 { padding: 0.5rem; }
.p-2\.5 { padding: 0.625rem; }
.p-3 { padding: 0.75rem; }
.p-3\.5 { padding: 0.875rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-2\.5 { padding-left: 0.625rem; padding-right: 0.625rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-3\.5 { padding-left: 0.875rem; padding-right: 0.875rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-1\.5 { margin-top: 0.375rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-2\.5 { margin-top: 0.625rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-auto { margin-top: auto; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-1\.5 { margin-bottom: 0.375rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }

.text-\[10px\] { font-size: 10px; line-height: 14px; }
.text-\[11px\] { font-size: 11px; line-height: 15px; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-white { color: #ffffff; }
.text-slate-100 { color: #f1f5f9; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-indigo-200 { color: #c7d2fe; }
.text-indigo-300 { color: #a5b4fc; }
.text-indigo-400 { color: #818cf8; }
.text-emerald-300 { color: #6ee7b7; }
.text-emerald-400 { color: #34d399; }
.text-amber-300 { color: #fcd34d; }
.text-amber-400 { color: #fbbf24; }
.text-rose-300 { color: #fda4af; }
.text-rose-400 { color: #fb7185; }
.text-purple-300 { color: #d8b4fe; }

.bg-slate-800 { background-color: #1e293b; }
.bg-slate-800\/40 { background-color: rgba(30, 41, 59, 0.4); }
.bg-slate-800\/60 { background-color: rgba(30, 41, 59, 0.6); }
.bg-slate-800\/70 { background-color: rgba(30, 41, 59, 0.7); }
.bg-slate-900 { background-color: #0f172a; }
.bg-slate-900\/70 { background-color: rgba(15, 23, 42, 0.7); }
.bg-slate-900\/80 { background-color: rgba(15, 23, 42, 0.8); }
.bg-slate-900\/90 { background-color: rgba(15, 23, 42, 0.9); }
.bg-slate-950 { background-color: #020617; }
.bg-slate-950\/60 { background-color: rgba(2, 6, 23, 0.6); }
.bg-slate-950\/85 { background-color: rgba(2, 6, 23, 0.85); }
.bg-slate-950\/90 { background-color: rgba(2, 6, 23, 0.9); }

.bg-indigo-600 { background-color: #4f46e5; }
.bg-indigo-600\/20 { background-color: rgba(79, 70, 229, 0.2); }
.bg-indigo-600\/30 { background-color: rgba(79, 70, 229, 0.3); }
.bg-indigo-500\/10 { background-color: rgba(99, 102, 241, 0.1); }
.bg-indigo-500\/20 { background-color: rgba(99, 102, 241, 0.2); }
.bg-indigo-950 { background-color: #1e1b4b; }
.bg-indigo-950\/40 { background-color: rgba(30, 27, 75, 0.4); }
.bg-indigo-950\/60 { background-color: rgba(30, 27, 75, 0.6); }

.bg-emerald-500\/20 { background-color: rgba(16, 185, 129, 0.2); }
.bg-amber-500\/20 { background-color: rgba(245, 158, 11, 0.2); }
.bg-rose-500\/10 { background-color: rgba(244, 63, 94, 0.1); }
.bg-rose-500\/20 { background-color: rgba(244, 63, 94, 0.2); }
.bg-rose-950 { background-color: #4c0519; }
.bg-rose-950\/60 { background-color: rgba(76, 5, 25, 0.6); }
.bg-purple-500\/20 { background-color: rgba(168, 85, 247, 0.2); }

.bg-gradient-to-tr { background-image: linear-gradient(to top right, var(--tw-gradient-stops, #4f46e5, #6366f1, #38bdf8)); }
.bg-gradient-to-r { background-image: linear-gradient(to right, var(--tw-gradient-stops, #4f46e5, #2563eb)); }

.border { border-width: 1px; }
.border-2 { border-width: 2px; }
.border-4 { border-width: 4px; }
.border-t { border-top-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-dashed { border-style: dashed; }

.border-slate-700 { border-color: #334155; }
.border-slate-700\/60 { border-color: rgba(51, 65, 85, 0.6); }
.border-slate-700\/80 { border-color: rgba(51, 65, 85, 0.8); }
.border-slate-800 { border-color: #1e293b; }
.border-slate-800\/40 { border-color: rgba(30, 41, 59, 0.4); }
.border-slate-800\/60 { border-color: rgba(30, 41, 59, 0.6); }
.border-slate-800\/90 { border-color: rgba(30, 41, 59, 0.9); }
.border-slate-900 { border-color: #0f172a; }

.border-indigo-500 { border-color: #6366f1; }
.border-indigo-500\/20 { border-color: rgba(99, 102, 241, 0.2); }
.border-indigo-500\/30 { border-color: rgba(99, 102, 241, 0.3); }
.border-indigo-500\/40 { border-color: rgba(99, 102, 241, 0.4); }
.border-indigo-800 { border-color: #3730a3; }
.border-indigo-800\/40 { border-color: rgba(55, 48, 163, 0.4); }
.border-indigo-800\/60 { border-color: rgba(55, 48, 163, 0.6); }

.border-emerald-500 { border-color: #10b981; }
.border-emerald-500\/30 { border-color: rgba(16, 185, 129, 0.3); }
.border-amber-500 { border-color: #f59e0b; }
.border-amber-500\/30 { border-color: rgba(245, 158, 11, 0.3); }
.border-rose-500 { border-color: #f43f5e; }
.border-rose-500\/20 { border-color: rgba(244, 63, 94, 0.2); }
.border-rose-800 { border-color: #9f1239; }
.border-rose-800\/40 { border-color: rgba(159, 18, 57, 0.4); }
.border-rose-800\/60 { border-color: rgba(159, 18, 57, 0.6); }
.border-purple-500\/30 { border-color: rgba(168, 85, 247, 0.3); }

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); }
.shadow-indigo-500\/25 { box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.25); }
.shadow-indigo-600\/25 { box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.25); }
.shadow-indigo-600\/30 { box-shadow: 0 10px 30px -5px rgba(79, 70, 229, 0.30); }

.backdrop-blur { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.backdrop-blur-sm { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.backdrop-blur-md { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.top-1\/2 { top: 50%; }
.left-1\/2 { left: 50%; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

.cursor-pointer { cursor: pointer; }
.cursor-crosshair { cursor: crosshair; }
.select-none { user-select: none; -webkit-user-select: none; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.text-left { text-align: left; }
.text-center { text-align: center; }

/* Transitions */
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-colors { transition-property: color, background-color, border-color; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }

button {
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  transform: none !important;
}

/* ==========================================================================
   SUDOKU 9x9 GRID MATRIX STYLES (HUMAN TOUCH OPTIMIZED)
   ========================================================================== */

#sudokuGrid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  background-color: #1e293b;
  border: 2px solid #475569;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7);
  touch-action: manipulation;
}

.sudoku-cell {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-outfit);
  font-size: 1.25rem;
  font-weight: 600;
  position: relative;
  background-color: #0b1329;
  color: #f1f5f9;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.12s ease, transform 0.1s ease, color 0.12s ease;
  user-select: none;
  outline: none;
}

@media (min-width: 480px) {
  .sudoku-cell {
    width: 44px;
    height: 44px;
    font-size: 1.45rem;
  }
}

@media (min-width: 640px) {
  .sudoku-cell {
    width: 52px;
    height: 52px;
    font-size: 1.65rem;
  }
}

@media (min-width: 768px) {
  .sudoku-cell {
    width: 58px;
    height: 58px;
    font-size: 1.85rem;
  }
}

/* Thick 3x3 Box Borders */
.sudoku-cell.border-r-thick {
  border-right: 2px solid #818cf8;
}

.sudoku-cell.border-b-thick {
  border-bottom: 2px solid #818cf8;
}

/* Cell States */
.sudoku-cell.given-cell {
  font-weight: 800;
  color: #ffffff;
  background-color: #0e172e;
}

.sudoku-cell.given-cell::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #6366f1;
}

.sudoku-cell.solved-cell {
  font-weight: 700;
  color: #38bdf8;
}

.sudoku-cell.user-cell {
  font-weight: 700;
  color: #34d399;
}

.sudoku-cell.selected {
  background-color: rgba(99, 102, 241, 0.45) !important;
  box-shadow: inset 0 0 0 2px #a5b4fc, 0 0 15px rgba(99, 102, 241, 0.5);
  z-index: 10;
  transform: scale(1.02);
}

.sudoku-cell.highlight-peer {
  background-color: rgba(30, 41, 59, 0.95);
}

.sudoku-cell.highlight-same-val {
  background-color: rgba(67, 56, 202, 0.55);
  color: #ffffff;
  font-weight: 800;
}

.sudoku-cell.conflict {
  background-color: rgba(225, 29, 72, 0.5) !important;
  color: #fecdd3 !important;
  animation: pulse-conflict 0.9s infinite alternate;
  z-index: 11;
}

.sudoku-cell.animating {
  background-color: rgba(245, 158, 11, 0.5) !important;
  color: #fef3c7 !important;
  transform: scale(1.1);
  z-index: 15;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.7);
}

.sudoku-cell.hint-target {
  background-color: rgba(16, 185, 129, 0.45) !important;
  color: #d1fae5 !important;
  box-shadow: inset 0 0 0 2px #34d399, 0 0 18px rgba(16, 185, 129, 0.5);
  animation: pulse-hint 1.4s infinite;
  z-index: 12;
}

/* Keypad Button Count Pill */
.keypad-btn {
  position: relative;
  touch-action: manipulation;
}

.keypad-btn .count-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  color: #94a3b8;
  font-weight: 500;
}

.keypad-btn.completed {
  opacity: 0.35;
  border-color: transparent;
}

/* Candidates / Pencil Marks Mini-Grid */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  font-size: 8px;
  line-height: 1;
  font-family: var(--font-mono);
  color: #94a3b8;
  pointer-events: none;
}

@media (min-width: 640px) {
  .candidates-grid {
    font-size: 11px;
    padding: 2px;
  }
}

.candidate-num {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes pulse-conflict {
  0% { background-color: rgba(225, 29, 72, 0.35); }
  100% { background-color: rgba(225, 29, 72, 0.75); }
}

@keyframes pulse-hint {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   MODAL DIALOG STYLES
   ========================================================================== */

.modal {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal.hidden {
  display: none !important;
}

/* ==========================================================================
   PRINT STYLESHEET FOR SOLUTION REFERENCE SHEET
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  header, footer, .lg\:col-span-5, #keypadContainer, button {
    display: none !important;
  }
  main {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .lg\:col-span-7 {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
  }
  #sudokuGrid {
    background: #ffffff !important;
    border: 3px solid #000000 !important;
  }
  .sudoku-cell {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #cbd5e1 !important;
  }
  .sudoku-cell.border-r-thick {
    border-right: 3px solid #000000 !important;
  }
  .sudoku-cell.border-b-thick {
    border-bottom: 3px solid #000000 !important;
  }
  .sudoku-cell.solved-cell {
    color: #2563eb !important;
    font-weight: bold !important;
  }
}
