/* Sudoku Professional Game Styling - Mobile Optimized & Responsive (v1.6) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.sudoku-wrapper { box-sizing: border-box; max-width: 950px; margin: 0 auto; color: #1e293b; font-family: 'Inter', sans-serif; }
.sudoku-wrapper * { box-sizing: border-box; }

/* Container - Less padding on mobile to maximize screen space */
.sudoku-container { background-color: #ffffff; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 15px -3px rgba(0,0,0,0.1); padding: 15px; margin-top: 10px; border: 1px solid #f1f5f9; }

/* Header & Typography */
.sudoku-header { text-align: center; margin-bottom: 15px; }
.sudoku-header h1 { color: #0f172a; margin-bottom: 4px; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.sudoku-header p { color: #64748b; font-size: 0.95rem; margin: 0; }

/* Layout */
.sudoku-game-area { display: flex; flex-direction: column; gap: 20px; margin-top: 15px; }
.sudoku-board { display: flex; flex-direction: column; align-items: center; width: 100%; position: relative; }
.sudoku-controls-side { display: flex; flex-direction: column; width: 100%; gap: 15px; }

/* Buttons General - Optimized for touch */
.sudoku-btn { background: #3b82f6; color: white; border: none; padding: 12px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; font-family: 'Inter', sans-serif; transition: all 0.2s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.05); touch-action: manipulation; }
.sudoku-btn:hover:not(:disabled) { background: #2563eb; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(37,99,235,0.2); }
.sudoku-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* Difficulty Top Bar */
.sudoku-controls-top { margin-bottom: 15px; }
.diff-group { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; background: #f8fafc; padding: 4px; border-radius: 8px; border: 1px solid #e2e8f0; }
.diff-btn { background: transparent; color: #475569; box-shadow: none; flex: 1; min-width: 60px; padding: 8px 4px; font-size: 12px; }
.diff-btn:hover:not(:disabled) { background: #e2e8f0; box-shadow: none; color: #0f172a; }
.diff-btn.active { background: #ffffff; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
#btn-extreme.active { color: #dc2626; }
#btn-daily.active { color: #ea580c; background: #fff7ed; border-color: #fdba74; }

/* Stats Bar & Pause Button */
.sudoku-stats-bar { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 13px; border: 1px solid #e2e8f0; }
.stat-box { display: flex; align-items: center; gap: 5px; color: #334155; }
.stat-error span { color: #ef4444; }
.stat-success span { color: #10b981; }
.timer-box { display: flex; align-items: center; gap: 10px; }
#btn-pause { background: #e2e8f0; border: none; color: #334155; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: 0.2s; touch-action: manipulation; }
#btn-pause:hover { background: #cbd5e1; color: #0f172a; }

/* Pause Overlay */
.pause-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 10; border-radius: 8px; }
.pause-overlay h2 { color: #0f172a; margin-bottom: 5px; font-size: 1.5rem; }
.pause-overlay p { color: #64748b; margin-bottom: 20px; font-size: 14px; }

/* Toolbar (Undo, Erase, Notes, Hint) */
.action-toolbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.toolbar-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #f1f5f9; color: #475569; border: none; padding: 10px 4px; border-radius: 8px; cursor: pointer; font-size: 11px; font-weight: 600; transition: 0.2s; font-family: 'Inter', sans-serif; touch-action: manipulation; }
.toolbar-btn .icon { font-size: 16px; margin-bottom: 2px; }
.toolbar-btn:hover { background: #e2e8f0; color: #0f172a; }
.toolbar-btn.active-notes { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Number Pad (Mobile: 5 columns x 2 rows, Desktop: 3x3) */
.number-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.number-btn { background: #ffffff; border: 1px solid #cbd5e1; color: #0f172a; height: 50px; display: flex; justify-content: center; align-items: center; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 22px; transition: all 0.15s ease; font-family: sans-serif; box-shadow: 0 2px 4px rgba(0,0,0,0.05); touch-action: manipulation; }
.number-btn:active { background: #f8fafc; transform: scale(0.95); }

/* Keyboard Hint */
.keyboard-hint { text-align: center; color: #94a3b8; margin-top: 5px; font-style: italic; font-size: 12px; display: none; }

/* --- SUDOKU GRID (Fixed Aspect Ratio for Mobile & Desktop) --- */
.sudoku-grid { display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); gap: 1px; background-color: #cbd5e1; border: 2px solid #0f172a; width: 100%; max-width: 450px; aspect-ratio: 1/1; margin: 0 auto; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); touch-action: manipulation; box-sizing: border-box; }

.sudoku-cell { width: 100%; height: 100%; min-width: 0; background-color: #ffffff; display: flex; justify-content: center; align-items: center; font-size: clamp(16px, 5vw, 24px); font-weight: 400; cursor: pointer; user-select: none; transition: background-color 0.1s; position: relative; font-family: sans-serif; color: #334155; touch-action: manipulation; box-sizing: border-box; border-radius: 0; appearance: none; padding: 0; margin: 0; }

/* 3x3 Block Borders */
.sudoku-cell:nth-child(3n) { border-right: 2px solid #0f172a; }
.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 #0f172a; }

/* Cell States (Visual Hierarchy for Crosshairs) */
.sudoku-cell:hover { background-color: #f1f5f9; }
.sudoku-cell.highlighted { background-color: #e2e8f0; } 
.sudoku-cell.same-number { background-color: #cbd5e1; } 
.sudoku-cell.selected { background-color: #93c5fd; } 

.sudoku-cell.prefilled { color: #0f172a; font-weight: 600; pointer-events: none; }
.sudoku-cell.correct { color: #2563eb; }
.sudoku-cell.error { color: #ef4444; background-color: #fef2f2; font-weight: 600; }

/* Notes Grid inside Cell */
.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 100%; height: 100%; padding: 1px; }
.note-val { display: flex; align-items: center; justify-content: center; font-size: clamp(8px, 2.5vw, 11px); color: #64748b; line-height: 1; font-weight: 500; font-family: sans-serif; }

/* --- LEADERBOARD (Premium UI) --- */
.leaderboard-section { margin-top: 35px; }
.leaderboard-header h3 { text-align: left; color: #0f172a; font-size: 1.2rem; margin-bottom: 12px; border-bottom: 2px solid #e2e8f0; padding-bottom: 8px; display: flex; align-items: center; gap: 8px;}
.leaderboard-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }

.sudoku-leaderboard-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.sudoku-leaderboard-table th { background: #f8fafc; color: #64748b; font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: 0.05em; padding: 12px 15px; border-bottom: 2px solid #e2e8f0; }
.sudoku-leaderboard-table td { padding: 12px 15px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; transition: background-color 0.2s;}

/* Highlighting Top 3 Rows */
.sudoku-leaderboard-table tr.rank-1 { background-color: #fffbeb; } /* Light Gold */
.sudoku-leaderboard-table tr.rank-2 { background-color: #f8fafc; } /* Light Silver */
.sudoku-leaderboard-table tr.rank-3 { background-color: #fdf4ff; } /* Light Bronze */
.sudoku-leaderboard-table tr:hover { background-color: #f1f5f9; }
.sudoku-leaderboard-table tr:last-child td { border-bottom: none; }

/* Medals & Typography */
.rank-cell { width: 60px; text-align: center; }
.medal { font-size: 22px; line-height: 1; display: inline-block; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15)); transform: scale(1.1); }
.rank-number { font-weight: 700; color: #94a3b8; font-size: 15px; }

.player-cell strong { color: #334155; font-weight: 600; font-size: 14px; }
.rank-1 .player-cell strong { color: #b45309; font-size: 15px; } /* Gold Text */
.rank-2 .player-cell strong { color: #475569; }
.rank-3 .player-cell strong { color: #9d174d; }

/* Time Display (Monospace for alignment) */
.time-cell { font-family: 'Courier New', Courier, monospace; font-weight: 700; color: #3b82f6; font-size: 15px; letter-spacing: 0.5px;}
.rank-1 .time-cell { color: #b45309; }

.empty-state { text-align: center; padding: 25px; color: #64748b; font-style: italic; font-size: 14px; }

/* --- MODAL STYLING --- */
.sudoku-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 9999; padding: 15px; }
.sudoku-modal-content { background: #ffffff; padding: 25px 20px; border-radius: 16px; text-align: center; max-width: 380px; width: 100%; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;}
.sudoku-modal-content h2 { color: #0f172a; margin-top: 0; margin-bottom: 5px; font-size: 1.4rem; font-weight: 700; }
.time-display { font-size: 1rem; color: #475569; margin-bottom: 20px; }
.modal-subtext { font-size: 13px; color: #64748b; margin-bottom: 15px; }
#player-name-input { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 16px; box-sizing: border-box; text-align: center; font-family: 'Inter', sans-serif;}
#player-name-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.btn-primary { margin-top: 15px; width: 100%; padding: 14px; font-size: 15px; }
.modal-footer { margin-top: 20px; padding-top: 20px; border-top: 1px solid #f1f5f9; }
.btn-secondary { background: #f1f5f9; color: #475569; width: 100%; box-shadow: none; }
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }

/* --- DESKTOP / TABLET ADJUSTMENTS --- */
@media (min-width: 768px) {
    .sudoku-container { padding: 30px; margin-top: 20px; }
    .sudoku-header h1 { font-size: 2.2rem; }
    .sudoku-game-area { flex-direction: row; align-items: flex-start; gap: 30px; }
    .sudoku-board { flex: 2; max-width: 500px; }
    .sudoku-grid { border: 3px solid #0f172a; }
    .sudoku-controls-side { flex: 1; max-width: 300px; gap: 20px; }
    
    .diff-btn { padding: 10px 15px; font-size: 14px; }
    .action-toolbar { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .toolbar-btn { padding: 12px 8px; font-size: 12px; }
    
    /* Change Numpad to 3x3 for Desktop */
    .number-pad { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .number-btn { height: 60px; font-size: 24px; border-radius: 10px; }
    .number-btn:hover { background: #f8fafc; border-color: #94a3b8; transform: translateY(-2px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
    
    .keyboard-hint { display: block; }
    .sudoku-stats-bar { font-size: 16px; padding: 15px 25px; }
    .leaderboard-header h3 { font-size: 1.2rem; }
    .sudoku-leaderboard-table { font-size: 14px; }
    .sudoku-leaderboard-table th { font-size: 12px; padding: 12px 20px; }
    .sudoku-leaderboard-table td { padding: 12px 20px; }
}