/* === ROOT VARIABLES === */
:root {
    /* Notion Light fallback */
    --bg: #ffffff;
    --bg-secondary: #f7f7f5;
    --border: #e8e8e5;
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --accent: #2383e2;
    --accent-soft: #e8f1fc;
    --error: #eb5757;
    --success: #0f9d58;
    --cell-highlight: #fdf6e3;
    --cell-same-number: #d4e8ff;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
    --transition: all 0.2s ease;
    --sidebar-width: 220px;
    --stats-width: 260px;
    --toolbar-height: 60px;
}

/* === THEME VARIATIONS === */
body.notion-dark {
    --bg: #191919;
    --bg-secondary: #2f2f2f;
    --border: #3f3f3f;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #4da3ff;
    --accent-soft: #1a3a5c;
    --error: #ff6b6b;
    --success: #40c057;
    --cell-highlight: #3a3a2a;
    --cell-same-number: #2a4a6a;
}

body.cream {
    --bg: #faf8f3;
    --bg-secondary: #f0ebe0;
    --border: #d9d4c3;
    --text-primary: #4a3f2e;
    --text-secondary: #8a7f6e;
    --accent: #b8860b;
    --accent-soft: #f5e6d3;
    --error: #c94c4c;
    --success: #6b8e23;
    --cell-highlight: #fff8e7;
    --cell-same-number: #e8d4a8;
}

body.paper {
    --bg: #f9f9f7;
    --bg-secondary: #eeeeec;
    --border: #d0d0ce;
    --text-primary: #2c2c2c;
    --text-secondary: #707070;
    --accent: #1a1a1a;
    --accent-soft: #e0e0de;
    --error: #a03030;
    --success: #2d5016;
    --cell-highlight: #fffef5;
    --cell-same-number: #dadad0;
}

body.forest {
    --bg: #1e3a2e;
    --bg-secondary: #2d4f3f;
    --border: #3d5f4f;
    --text-primary: #e8f0e8;
    --text-secondary: #a8c0a8;
    --accent: #7cb342;
    --accent-soft: #3a5a3e;
    --error: #d32f2f;
    --success: #66bb6a;
    --cell-highlight: #2a4a3a;
    --cell-same-number: #3a6a4a;
}

body.midnight {
    --bg: #0d1b2a;
    --bg-secondary: #1b263b;
    --border: #2d3d5c;
    --text-primary: #e0e7ff;
    --text-secondary: #8899bb;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --error: #ef4444;
    --success: #10b981;
    --cell-highlight: #1a2a4a;
    --cell-same-number: #2a4a7a;
}

/* === GLOBAL STYLES === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    overflow: hidden;
    transition: var(--transition);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.sidebar.collapsed .app-title {
    display: none;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 5px;
    border-radius: 6px;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--border);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-item:hover {
    background-color: var(--border);
}

.nav-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.nav-label {
    transition: opacity 0.3s ease, width 0.3s ease;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === TOOLBAR === */
.toolbar {
    height: var(--toolbar-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.toolbar-btn:hover {
    background-color: var(--border);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mistake-counter {
    padding: 6px 12px;
    border-radius: 8px;
    background-color: var(--bg);
    font-size: 14px;
    font-weight: 500;
}

.game-mode-badge,
.difficulty-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background-color: var(--accent-soft);
    color: var(--accent);
}

/* === BOARD CONTAINER === */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: auto;
}

/* === SUDOKU BOARD === */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background-color: var(--border);
    border: 3px solid var(--text-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    max-width: 540px;
    max-height: 540px;
    width: min(90vw, 540px);
    aspect-ratio: 1;
}

.sudoku-cell {
    aspect-ratio: 1;
    background-color: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 4vw, 28px);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    user-select: none;
}

.sudoku-cell:hover:not(.fixed) {
    background-color: var(--bg-secondary);
}

.sudoku-cell.fixed {
    color: var(--text-primary);
    font-weight: 700;
    cursor: default;
    background-color: var(--bg-secondary);
}

.sudoku-cell.selected {
    background-color: var(--accent-soft) !important;
    border: 2px solid var(--accent);
}

.sudoku-cell.highlight-row,
.sudoku-cell.highlight-col,
.sudoku-cell.highlight-box {
    background-color: var(--cell-highlight);
}

.sudoku-cell.highlight-same-number {
    background-color: var(--cell-same-number);
}

.sudoku-cell.error {
    background-color: var(--error);
    color: white;
    animation: shake 0.3s ease;
}

.sudoku-cell.completed {
    animation: cellPop 0.3s ease;
}

/* Box borders (3x3) */
.sudoku-cell:nth-child(3n) {
    border-right: 3px solid var(--text-primary);
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--text-primary);
}

/* Pencil notes */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
    gap: 1px;
}

.note-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(8px, 1.5vw, 10px);
    color: var(--text-secondary);
    font-weight: 400;
}

/* === NUMBER PAD === */
.number-pad {
    padding: 20px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
    max-width: 540px;
    margin: 0 auto 12px;
}

.num-btn {
    aspect-ratio: 1;
    background-color: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.num-btn:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.num-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.number-controls {
    display: flex;
    gap: 8px;
    max-width: 540px;
    margin: 0 auto;
}

.control-btn {
    flex: 1;
    padding: 12px;
    background-color: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.control-btn:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent);
}

.control-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* === STATS PANEL === */
.stats-panel {
    width: var(--stats-width);
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.stats-card {
    background-color: var(--bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stats-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Progress ring */
.progress-ring-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.strategy-assistant {
    margin-top: 16px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.strategy-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.mini-heatmap {
    margin-top: 16px;
    width: 90px;
    height: 90px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* === MODALS === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg);
    border-radius: 12px;
    box-shadow: var(--shadow-hover);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-content.wide {
    max-width: 800px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Difficulty buttons */
.difficulty-buttons,
.game-mode-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.difficulty-btn,
.mode-btn {
    padding: 14px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.difficulty-btn:hover,
.mode-btn:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.difficulty-btn.selected,
.mode-btn.selected {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.custom-clues-container {
    margin: 16px 0;
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
}

.custom-clues-container label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

#clue-count {
    width: 100%;
    margin-top: 8px;
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    cursor: pointer;
}

.setting-item input[type="checkbox"],
.setting-item input[type="radio"] {
    cursor: pointer;
}

.setting-item input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
}

/* Themes */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.theme-btn {
    background: none;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.theme-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.theme-preview {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f7f7f5 100%);
}

.notion-dark-preview {
    background: linear-gradient(135deg, #191919 0%, #2f2f2f 100%);
}

.cream-preview {
    background: linear-gradient(135deg, #faf8f3 0%, #f0ebe0 100%);
}

.paper-preview {
    background: linear-gradient(135deg, #f9f9f7 0%, #eeeeec 100%);
}

.forest-preview {
    background: linear-gradient(135deg, #1e3a2e 0%, #2d4f3f 100%);
}

.midnight-preview {
    background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
}

.theme-btn span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Leaderboard */
.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-weight: 500;
}

.tab-btn:hover {
    border-color: var(--accent);
}

.tab-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
}

.rank-badge {
    font-weight: 700;
    color: var(--accent);
    margin-right: 12px;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.achievement-card {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border);
    text-align: center;
    transition: var(--transition);
}

.achievement-card.unlocked {
    border-color: var(--success);
    background-color: var(--accent-soft);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.achievement-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.achievement-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Learn */
.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.lesson-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.lesson-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.lesson-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.lesson-difficulty {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: var(--accent-soft);
    color: var(--accent);
}

.lesson-content {
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    line-height: 1.6;
}

/* Archive */
.archive-item {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.archive-info {
    flex: 1;
}

.archive-date {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.archive-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Daily Challenge */
.daily-info {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 16px;
}

.daily-info p {
    margin-bottom: 8px;
}

#daily-countdown {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-top: 12px;
}

/* Completion */
.completion-body {
    text-align: center;
}

.completion-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.completion-stat {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.completion-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.completion-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.completion-rating {
    margin-bottom: 24px;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 32px;
    margin-top: 12px;
}

.star {
    cursor: pointer;
    transition: var(--transition);
}

.star:hover,
.star.filled {
    color: #ffd700;
}

.completion-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Shortcuts */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
}

.shortcut-item kbd {
    background-color: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 12px;
    display: inline-block;
}

.shortcut-item span {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.primary-btn {
    padding: 12px 24px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.danger-btn {
    padding: 10px 20px;
    background-color: var(--error);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.danger-btn:hover {
    transform: translateY(-2px);
}

/* Pause overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pause-content {
    text-align: center;
    color: white;
}

.pause-content h2 {
    font-size: 48px;
    margin-bottom: 16px;
}

.pause-content p {
    font-size: 18px;
    margin-bottom: 24px;
    opacity: 0.8;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes cellPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--success); }
    50% { box-shadow: 0 0 20px var(--success); }
}

/* Focus mode */
body.focus-mode .sidebar,
body.focus-mode .stats-panel {
    transform: translateX(-100%);
}

body.focus-mode .stats-panel {
    transform: translateX(100%);
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 1200px) {
    .stats-panel {
        transform: translateX(100%);
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
    }
    
    .stats-panel.visible {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 60px;
    }
    
    .sidebar {
        width: 60px;
    }
    
    .sidebar .nav-label {
        display: none;
    }
    
    .app-title {
        display: none;
    }
    
    .toolbar {
        padding: 0 10px;
        height: 50px;
    }
    
    .toolbar-btn {
        font-size: 18px;
        padding: 6px 10px;
    }
    
    .game-mode-badge,
    .difficulty-badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .number-grid {
        grid-template-columns: repeat(9, 1fr);
        gap: 4px;
    }
    
    .num-btn {
        font-size: 16px;
    }
    
    .number-controls {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .difficulty-buttons,
    .game-mode-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .theme-grid,
    .achievements-grid,
    .shortcuts-grid {
        grid-template-columns: 1fr;
    }
    
    .completion-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .board-container {
        padding: 10px;
    }
    
    .number-pad {
        padding: 10px;
    }
    
    .toolbar-center {
        display: none;
    }
}

/* === PRINT STYLES === */
@media print {
    .sidebar,
    .toolbar,
    .stats-panel,
    .number-pad,
    .modal {
        display: none !important;
    }
    
    .main-content {
        width: 100%;
    }
    
    .board-container {
        padding: 0;
    }
    
    .sudoku-board {
        max-width: 100%;
        box-shadow: none;
    }
}

/* === CUSTOM SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

:root {
    --focus: #0b7184;
    --accent-cyan: #178b9b;
    --on-accent: #ffffff;
}

html {
    background: var(--bg);
}

body {
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app-container,
.sidebar,
.main-content,
.stats-panel {
    min-width: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.theme-btn.selected,
.theme-btn[aria-pressed="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

body.basilisk {
    color-scheme: dark;
    --bg: #080b1e;
    --bg-secondary: #11132f;
    --bg-elevated: #181a3b;
    --border: #2c3061;
    --border-strong: #4e589c;
    --text-primary: #f7f4f0;
    --text-secondary: #c1bfd0;
    --accent: #9b8cff;
    --accent-bright: #c3b8ff;
    --accent-blue: #76b8ff;
    --accent-cyan: #72e6ed;
    --accent-soft: #242453;
    --error: #ff88a7;
    --error-soft: #3c1d3c;
    --success: #6fe4c0;
    --cell-bg: #0e1230;
    --cell-fixed: #171a3b;
    --cell-hover: #202452;
    --cell-highlight: #1a1e4a;
    --cell-same-number: #273265;
    --cell-line: #303768;
    --grid-line: #5963a3;
    --grid-major: #aeb5e8;
    --focus: #72e6ed;
    --on-accent: #090b1f;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
    --shadow-hover: 0 0 0 1px rgba(114, 230, 237, 0.25), 0 16px 40px rgba(0, 0, 0, 0.4);
    --board-shadow: 0 0 0 1px rgba(155, 140, 255, 0.18), 0 20px 55px rgba(3, 4, 20, 0.45), 0 0 35px rgba(88, 83, 204, 0.12);
    background: radial-gradient(circle at 8% -10%, rgba(104, 83, 255, 0.18), transparent 34rem), radial-gradient(circle at 92% 110%, rgba(42, 100, 190, 0.12), transparent 30rem), var(--bg);
}

body.basilisk .sidebar {
    background: linear-gradient(180deg, rgba(24, 26, 59, 0.96), rgba(13, 15, 38, 0.98));
    border-right-color: rgba(119, 128, 214, 0.35);
}

body.basilisk .main-content {
    background: transparent;
}

body.basilisk .sidebar-header {
    gap: 8px;
    padding: 18px 14px;
    border-bottom-color: rgba(119, 128, 214, 0.25);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    overflow: visible;
}

.brand-mark-orbit {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.4;
    opacity: 0.75;
}

.brand-mark-eye {
    fill: rgba(155, 140, 255, 0.14);
    stroke: var(--accent-cyan);
    stroke-width: 1.4;
}

.brand-mark-pupil {
    fill: var(--accent-cyan);
    filter: drop-shadow(0 0 5px rgba(114, 230, 237, 0.7));
}

body.basilisk .brand-copy {
    min-width: 0;
}

body.basilisk .brand-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--accent-cyan);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.16em;
    line-height: 1.1;
    text-transform: uppercase;
}

body.basilisk .app-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.015em;
    line-height: 1.08;
    text-shadow: 0 0 18px rgba(155, 140, 255, 0.2);
}

.sidebar.collapsed .brand-copy {
    display: none;
}

.sidebar.collapsed .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
}

.sidebar.collapsed .sidebar-header {
    gap: 2px;
    justify-content: center;
    padding-left: 4px;
    padding-right: 4px;
}

.sidebar.collapsed .icon-btn {
    padding: 4px;
    font-size: 16px;
}

body.basilisk .nav-item {
    min-height: 44px;
    color: var(--text-secondary);
}

body.basilisk .nav-item:hover {
    background: rgba(155, 140, 255, 0.12);
    color: var(--text-primary);
}

body.basilisk .toolbar {
    min-width: 0;
    background: rgba(17, 19, 47, 0.82);
    border-bottom-color: rgba(119, 128, 214, 0.28);
    box-shadow: 0 8px 24px rgba(3, 4, 20, 0.12);
    backdrop-filter: blur(14px);
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    min-width: 0;
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-brand > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-brand-mark {
    color: var(--accent-cyan);
    font-size: 16px;
    line-height: 1;
    text-shadow: 0 0 10px rgba(114, 230, 237, 0.7);
}

body.basilisk .toolbar-btn,
body.basilisk .icon-btn {
    color: var(--text-secondary);
}

body.basilisk .toolbar-btn:hover,
body.basilisk .icon-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-bright);
}

body.basilisk .mistake-counter,
body.basilisk .game-mode-badge,
body.basilisk .difficulty-badge {
    border: 1px solid rgba(119, 128, 214, 0.35);
    background: rgba(36, 36, 83, 0.72);
    color: var(--text-primary);
}

body.basilisk .game-mode-badge,
body.basilisk .difficulty-badge {
    color: var(--accent-cyan);
    border-color: rgba(114, 230, 237, 0.28);
}

body.basilisk .board-container {
    min-height: 0;
    background: radial-gradient(circle at 50% 45%, rgba(61, 61, 148, 0.1), transparent 55%);
}

body.basilisk .sudoku-board {
    width: min(100%, 540px, calc(100vh - 260px));
    max-width: 100%;
    max-height: min(540px, calc(100vh - 260px));
    border: 2px solid var(--grid-major);
    border-radius: 14px;
    background: var(--grid-line);
    box-shadow: var(--board-shadow);
}

@supports (height: 100dvh) {
    body.basilisk .sudoku-board {
        width: min(100%, 540px, calc(100dvh - 260px));
        max-height: min(540px, calc(100dvh - 260px));
    }
}

body.basilisk .sudoku-cell {
    min-width: 0;
    color: var(--accent-blue);
    background: var(--cell-bg);
    border-color: var(--cell-line);
    box-shadow: none;
}

body.basilisk .sudoku-cell:hover:not(.fixed):not(.error) {
    background: var(--cell-hover);
}

body.basilisk .sudoku-cell.fixed {
    color: var(--text-primary);
    background: var(--cell-fixed);
    font-weight: 750;
}

body.basilisk .sudoku-cell.selected {
    z-index: 2;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(155, 140, 255, 0.32), rgba(114, 230, 237, 0.14)) !important;
    border: 2px solid var(--accent-cyan);
    outline: 2px solid var(--accent-cyan);
    outline-offset: -4px;
    box-shadow: 0 0 16px rgba(114, 230, 237, 0.3);
}

body.basilisk .sudoku-cell.selected::after {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    content: "";
}

body.basilisk .sudoku-cell.highlight-row,
body.basilisk .sudoku-cell.highlight-col,
body.basilisk .sudoku-cell.highlight-box {
    background-color: var(--cell-highlight);
    background-image: linear-gradient(135deg, rgba(155, 140, 255, 0.08), transparent 60%);
}

body.basilisk .sudoku-cell.highlight-same-number {
    background-color: var(--cell-same-number);
    box-shadow: inset 0 -3px 0 var(--accent-cyan);
}

body.basilisk .sudoku-cell:nth-child(3n) {
    border-right-color: var(--grid-major);
}

body.basilisk .sudoku-cell:nth-child(n+19):nth-child(-n+27),
body.basilisk .sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom-color: var(--grid-major);
}

body.basilisk .sudoku-cell.error {
    z-index: 3;
    color: #ffeaf1;
    background: var(--error-soft) !important;
    outline: 2px dashed var(--error);
    outline-offset: -4px;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

body.basilisk .sudoku-cell.error::after {
    position: absolute;
    top: 4px;
    right: 5px;
    color: var(--error);
    content: "!";
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

body.basilisk .sudoku-cell.completed {
    box-shadow: inset 0 0 0 2px var(--success);
}

body.basilisk .sudoku-cell:focus-visible {
    z-index: 4;
    outline: 3px solid var(--accent-cyan);
    outline-offset: -5px;
    box-shadow: 0 0 0 2px rgba(8, 11, 30, 0.9), 0 0 18px rgba(114, 230, 237, 0.65);
}

body.basilisk .note-cell {
    color: var(--text-secondary);
    font-weight: 500;
}

body.basilisk .notes-grid {
    gap: 2px;
    padding: 4px;
}

body.basilisk .number-pad {
    background: linear-gradient(180deg, rgba(17, 19, 47, 0.9), rgba(12, 14, 35, 0.98));
    border-top-color: rgba(119, 128, 214, 0.28);
}

body.basilisk .number-grid,
body.basilisk .number-controls {
    width: min(100%, 540px);
    max-width: 100%;
}

body.basilisk .num-btn,
body.basilisk .control-btn {
    min-height: 44px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

body.basilisk .num-btn:hover,
body.basilisk .control-btn:hover,
body.basilisk .difficulty-btn:hover,
body.basilisk .mode-btn:hover,
body.basilisk .theme-btn:hover,
body.basilisk .lesson-btn:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 0 14px rgba(155, 140, 255, 0.16);
}

body.basilisk .num-btn.active,
body.basilisk .control-btn.active,
body.basilisk .difficulty-btn.selected,
body.basilisk .mode-btn.selected,
body.basilisk .tab-btn.active,
body.basilisk .primary-btn {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 18px rgba(155, 140, 255, 0.28);
}

body.basilisk .num-btn.active:hover,
body.basilisk .control-btn.active:hover,
body.basilisk .difficulty-btn.selected:hover,
body.basilisk .mode-btn.selected:hover,
body.basilisk .tab-btn.active:hover,
body.basilisk .primary-btn:hover {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
}

body.basilisk .stats-panel {
    background: linear-gradient(180deg, rgba(17, 19, 47, 0.94), rgba(12, 14, 35, 0.98));
    border-left-color: rgba(119, 128, 214, 0.28);
}

body.basilisk .stats-card {
    background: rgba(24, 26, 59, 0.84);
    border: 1px solid rgba(119, 128, 214, 0.3);
    box-shadow: var(--shadow);
}

body.basilisk .stats-title,
body.basilisk .modal-header h2,
body.basilisk .settings-section h3,
body.basilisk #daily-countdown,
body.basilisk .progress-text,
body.basilisk .completion-value,
body.basilisk .rank-badge {
    color: var(--accent-cyan);
}

body.basilisk .strategy-assistant {
    background: rgba(36, 36, 83, 0.7);
    border-left-color: var(--accent-cyan);
}

body.basilisk .modal {
    background: rgba(4, 5, 18, 0.78);
    backdrop-filter: blur(12px);
}

body.basilisk .modal-content {
    background: var(--bg-elevated);
    border: 1px solid rgba(119, 128, 214, 0.38);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 30px rgba(88, 83, 204, 0.12);
}

body.basilisk .modal-header {
    background: rgba(24, 26, 59, 0.78);
    border-bottom-color: rgba(119, 128, 214, 0.28);
}

body.basilisk .modal-close {
    min-width: 44px;
    min-height: 44px;
    color: var(--text-secondary);
}

body.basilisk .modal-close:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
}

body.basilisk .difficulty-btn,
body.basilisk .mode-btn,
body.basilisk .tab-btn,
body.basilisk .theme-btn,
body.basilisk .lesson-btn,
body.basilisk .leaderboard-entry,
body.basilisk .custom-clues-container,
body.basilisk .daily-info,
body.basilisk .completion-stat,
body.basilisk .shortcut-item,
body.basilisk .lesson-content,
body.basilisk .archive-item,
body.basilisk .achievement-card {
    background: rgba(13, 15, 38, 0.58);
    border-color: var(--border);
}

body.basilisk .theme-btn {
    color: var(--text-primary);
}

body.basilisk .theme-btn.selected,
body.basilisk .theme-btn[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 1px var(--accent-cyan), 0 0 18px rgba(114, 230, 237, 0.14);
}

body.basilisk .theme-btn span small {
    display: block;
    margin-top: 3px;
    color: var(--accent-cyan);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.basilisk .theme-preview {
    border: 1px solid rgba(119, 128, 214, 0.35);
}

.basilisk-preview {
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 25% 20%, rgba(155, 140, 255, 0.48), transparent 48%), linear-gradient(135deg, #080b1e, #23245d 58%, #163e67);
}

.basilisk-preview::after {
    position: absolute;
    inset: 14px;
    border: 1px solid rgba(114, 230, 237, 0.75);
    background: repeating-linear-gradient(0deg, transparent 0 15px, rgba(174, 181, 232, 0.35) 15px 16px), repeating-linear-gradient(90deg, transparent 0 15px, rgba(174, 181, 232, 0.35) 15px 16px);
    content: "";
}

body.basilisk .progress-ring-bg {
    stroke: var(--border-strong);
}

body.basilisk .progress-ring-fill {
    stroke: var(--accent-cyan);
    filter: drop-shadow(0 0 4px rgba(114, 230, 237, 0.55));
}

body.basilisk .star:hover,
body.basilisk .star.filled {
    color: var(--accent-cyan);
}

body.basilisk textarea,
body.basilisk input[type="text"] {
    color: var(--text-primary);
    background: var(--cell-bg);
    border-color: var(--border-strong);
}

body.basilisk input[type="checkbox"],
body.basilisk input[type="radio"],
body.basilisk input[type="range"] {
    accent-color: var(--accent-cyan);
}

body.basilisk .danger-btn {
    color: var(--on-accent);
    background: var(--error);
}

body.basilisk .danger-btn:hover {
    background: #ffabc0;
}

body.basilisk .pause-content {
    color: var(--text-primary);
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    z-index: 9999;
    max-width: calc(100vw - 32px);
    padding: 12px 24px;
    color: var(--on-accent);
    background: var(--accent);
    border: 1px solid var(--accent-cyan);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    transform: translateX(-50%);
    transition: opacity 0.3s ease;
    text-align: center;
}

@media (max-width: 1200px) {
    body.basilisk .stats-panel {
        box-shadow: -18px 0 42px rgba(3, 4, 20, 0.35);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 56px;
    }

    body.basilisk .sidebar {
        width: 56px;
    }

    body.basilisk .sidebar-header {
        position: relative;
        justify-content: center;
        height: 76px;
        padding: 10px 4px;
    }

    body.basilisk .sidebar-header .icon-btn {
        position: absolute;
        right: 4px;
        bottom: 4px;
        width: 24px;
        height: 24px;
        padding: 2px;
        font-size: 15px;
    }

    body.basilisk .brand-copy,
    body.basilisk .brand-kicker,
    body.basilisk .app-title {
        display: none;
    }

    body.basilisk .brand-mark {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    body.basilisk .nav-item {
        justify-content: center;
        gap: 0;
        padding: 12px 8px;
    }

    body.basilisk .nav-label {
        display: none;
    }

    body.basilisk .toolbar {
        min-height: 52px;
        height: auto;
        flex-wrap: wrap;
        gap: 4px 8px;
        padding: 6px 8px;
    }

    body.basilisk .toolbar-left {
        flex: 1 1 auto;
    }

    body.basilisk .toolbar-right {
        flex: 0 0 auto;
    }

    body.basilisk .toolbar-center {
        order: 3;
        display: flex;
        flex: 0 0 100%;
        justify-content: center;
        min-height: 28px;
        padding-top: 4px;
        border-top: 1px solid rgba(119, 128, 214, 0.22);
    }

    body.basilisk .mobile-brand {
        display: inline-flex;
    }

    body.basilisk .game-mode-badge,
    body.basilisk .difficulty-badge {
        display: none;
    }

    body.basilisk .toolbar-btn {
        min-width: 32px;
        min-height: 36px;
        padding: 5px 7px;
    }

    body.basilisk .mistake-counter {
        padding: 5px 7px;
        font-size: 11px;
        white-space: nowrap;
    }

    body.basilisk .board-container {
        width: 100%;
        padding: 12px 8px;
    }

    body.basilisk .sudoku-board {
        width: min(100%, 540px);
    }

    body.basilisk .number-pad {
        padding: 10px 8px;
    }

    body.basilisk .number-grid {
        grid-template-columns: repeat(9, minmax(0, 1fr));
        gap: 4px;
        margin-bottom: 8px;
    }

    body.basilisk .num-btn {
        min-width: 0;
        aspect-ratio: auto;
    }

    body.basilisk .number-controls {
        gap: 6px;
    }

    body.basilisk .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    body.basilisk .toolbar-center {
        display: flex;
    }

    body.basilisk .mobile-brand {
        font-size: 10px;
    }

    body.basilisk .toolbar {
        gap: 2px 4px;
    }

    body.basilisk .toolbar-left,
    body.basilisk .toolbar-right {
        gap: 2px;
    }

    body.basilisk .toolbar-btn {
        min-width: 28px;
        padding-left: 4px;
        padding-right: 4px;
    }

    body.basilisk .mistake-counter {
        padding-left: 4px;
        padding-right: 4px;
        font-size: 10px;
    }

    body.basilisk .number-controls {
        flex-direction: column;
    }

    body.basilisk .control-btn {
        min-height: 40px;
        padding: 8px;
    }

    body.basilisk .modal-content {
        width: 96%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

.animations-off *,
.animations-off *::before,
.animations-off *::after {
    animation: none !important;
    transition: none !important;
}
