:root {
    --bg-color: #f8f9fa;
    --grid-bg: #ffffff;
    --border-thick: 3px solid #343a40;
    --border-thin: 1px solid #dee2e6;
    --text-primary: #212529;
    --accent-color: #0d6efd;
    --highlight-cell: #e7f1ff;
    --highlight-same: #cff4fc;
    --error-color: #f8d7da;
    --error-text: #842029;
    --fixed-text: #000000;
    --user-text: #0d6efd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    padding: 20px;
    transition: background 0.2s linear;
}

.app-container {
    width: 100%;
    max-width: 900px;
    max-height: 100vh;
    overflow-y: auto;
    scrollbar-width: none;
}
.app-container::-webkit-scrollbar { display: none; }

/* --- Header --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

h1 { font-size: 1.5rem; color: #343a40; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.info-bar {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
}

/* --- THEME TOGGLE (Florin Pop Style) --- */
.checkbox {
    opacity: 0;
    position: absolute;
}

.checkbox-label {
    background-color: #111;
    width: 50px;
    height: 26px;
    border-radius: 50px;
    position: relative;
    padding: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fa-moon { color: #f1c40f; }
.fa-sun { color: #f39c12; }

.checkbox-label .ball {
    background-color: #fff;
    width: 22px;
    height: 22px;
    position: absolute;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    transition: transform 0.2s linear;
}

/* Animate the ball when checked */
.checkbox:checked + .checkbox-label .ball {
    transform: translateX(24px);
}

/* --- Game Layout --- */
.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.board-container {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    background-color: var(--grid-bg);
    border: var(--border-thick);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.2rem, 4vw, 2rem);
    border: var(--border-thin);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s;
}

.cell:nth-child(3n) { border-right: var(--border-thick); }
.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) { border-bottom: var(--border-thick); }
.cell:nth-child(n+73) { border-bottom: none; }

.cell.selected { background-color: var(--highlight-cell); }
.cell.highlighted { background-color: var(--highlight-same); }
.cell.error { background-color: var(--error-color); color: var(--error-text); }
.cell.fixed { font-weight: 700; color: var(--fixed-text); }
.cell.user-input { font-weight: 500; color: var(--user-text); }

/* --- Controls --- */
.controls-sidebar { width: 100%; max-width: 500px; }
.instruction-text { text-align: center; color: #6c757d; margin-bottom: 15px; font-size: 0.95rem; }

button {
    font-family: inherit; border: none; cursor: pointer; border-radius: 6px; transition: all 0.2s;
}

.secondary-btn {
    width: 100%; padding: 12px; background-color: #e9ecef;
    color: #495057; font-weight: 600; border: 1px solid #ced4da;
}
.secondary-btn:hover { background-color: #dee2e6; }

/* Numpad */
.numpad {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 20px;
}
.num-btn {
    padding: 15px 0; background-color: white; border: 1px solid #dee2e6;
    font-size: 1.25rem; font-weight: 600; color: var(--accent-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.num-btn:active { background-color: var(--highlight-cell); transform: translateY(1px); }
.action-btn { background-color: #fff0f1; color: #dc3545; border-color: #f5c2c7; }

/* --- Overlay --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; justify-content: center;
    align-items: center; z-index: 100; backdrop-filter: blur(2px);
}
.hidden { display: none; }
.modal {
    background: white; padding: 40px; border-radius: 12px;
    text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); min-width: 300px;
}
.modal h2 { margin-bottom: 15px; color: var(--accent-color); }
.modal button {
    margin-top: 20px; padding: 10px 25px; background-color: var(--accent-color);
    color: white; font-size: 1rem;
}

/* --- Desktop --- */
@media (min-width: 850px) {
    .game-layout { flex-direction: row; align-items: flex-start; justify-content: center; }
    .controls-sidebar { width: 250px; margin-top: 0; }
    .numpad { display: none; }
    .instruction-text { text-align: left; margin-top: 20px; }
}

/* --- Dark Mode Colors --- */
body.dark-mode {
    --bg-color: #292c35;
    --grid-bg: #2d3748;
    --border-thick: 3px solid #94a3b8;
    --border-thin: 1px solid #4a5568;
    --text-primary: #f1f5f9;
    --fixed-text: #e2e8f0;
    --accent-color: #63b3ed;
    --highlight-cell: #2c5282;
    --highlight-same: #2b6cb0;
    --error-color: #742a2a;
    --error-text: #feb2b2;
    --user-text: #90cdf4;
}

body.dark-mode .num-btn, 
body.dark-mode .secondary-btn, 
body.dark-mode .modal {
    background-color: #2d3748; color: #f1f5f9; border-color: #4a5568;
}
body.dark-mode .action-btn {
    background-color: #742a2a; color: #feb2b2; border-color: #9b2c2c;
}
body.dark-mode h1 { color: #f1f5f9; }
body.dark-mode .checkbox-label { background-color: #111; }
