:root {
    --font-family: 'Poppins', sans-serif;

    --bg-dark: #1b1b1d;
    --surface-dark: #242426;
    --primary-dark: #bb86fc;
    --secondary-dark: #03dac6;
    --text-dark: #e1e1e1;
    --border-dark: #3a3a3c;
    --shadow-dark: rgba(0, 0, 0, 0.4);

    --bg-light: #f4f4f9;
    --surface-light: #ffffff;
    --primary-light: #6200ee;
    --secondary-light: #018786;
    --text-light: #121212;
    --border-light: #d1d1d6;
    --shadow-light: rgba(0, 0, 0, 0.1);

    --success-color-bg: #2e7d32;
    --error-color-bg: #c62828;
    --missing-color-bg: #1565c0;
    --text-on-color: #ffffff;

    --sum-success: #4CAF50;
    --sum-error: #f44336;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

body.light-mode {
    background-color: var(--bg-light);
    color: var(--text-light);
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 30px;
    border-radius: 16px;
    transition: background-color 0.3s, box-shadow 0.3s;
}

body.dark-mode .app-container {
    background-color: var(--surface-dark);
    box-shadow: 0 10px 30px var(--shadow-dark);
}

body.light-mode .app-container {
    background-color: var(--surface-light);
    box-shadow: 0 10px 30px var(--shadow-light);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid;
    padding-bottom: 15px;
}
body.dark-mode .app-header { border-color: var(--border-dark); }
body.light-mode .app-header { border-color: var(--border-light); }

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
}
body.dark-mode h1 { color: var(--primary-dark); }
body.light-mode h1 { color: var(--primary-light); }

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
}

.btn, select, input[type="number"], .theme-button {
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-align: center;
}

.btn, .theme-button {
    padding-left: 20px;
    padding-right: 20px;
}

.btn:hover, select:hover, input[type="number"]:hover, .theme-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-dark);
}

.btn-primary { background-color: var(--primary-light); color: white; }
body.dark-mode .btn-primary { background-color: var(--primary-dark); }

.btn-secondary { background-color: #6c757d; color: white; }
body.dark-mode .btn-secondary { background-color: #4a4a4e; }

.theme-button {
    font-size: 1.5rem;
    padding: 5px 10px;
    background: transparent;
    border: none;
}

select, input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

body.dark-mode select, body.dark-mode input[type="number"] {
    background-color: #4a4a4e;
    color: var(--text-dark);
    border-color: var(--border-dark);
}
body.light-mode select, body.light-mode input[type="number"] {
    background-color: #e9ecef;
    color: var(--text-light);
    border-color: var(--border-light);
}

input[type="number"]#prefill-input {
    width: 70px;
}

#numbers-info {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1rem;
    font-weight: 600;
}
body.dark-mode #numbers-info { color: var(--secondary-dark); }
body.light-mode #numbers-info { color: var(--secondary-light); }

#game-board {
    display: grid;
    margin: 0 auto;
    border: 2px solid;
    border-radius: 8px;
    overflow: hidden;
}
body.dark-mode #game-board { border-color: var(--border-dark); }
body.light-mode #game-board { border-color: var(--border-light); }

.cell, .sum-cell {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    border: 1px solid;
}
body.dark-mode .cell, body.dark-mode .sum-cell { border-color: var(--border-dark); }
body.light-mode .cell, body.light-mode .sum-cell { border-color: var(--border-light); }

.cell input {
    width: 100%;
    height: 100%;
    text-align: center;
    border: none;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0;
    background-color: transparent;
    color: inherit;
    /* transition: all 0.2s; */ /* <-- LIGNE SUPPRIMÉE */
}

.cell input:focus {
    outline: none;
}
body.dark-mode .cell input:focus { box-shadow: inset 0 0 0 3px var(--primary-dark); }
body.light-mode .cell input:focus { box-shadow: inset 0 0 0 3px var(--primary-light); }

.cell input.prefilled {
    color: var(--secondary-light);
    pointer-events: none;
}
body.dark-mode .cell input.prefilled { color: var(--secondary-dark); }

.cell input.correct-answer { background-color: var(--success-color-bg) !important; color: var(--text-on-color) !important; }
.cell input.incorrect-answer { background-color: var(--error-color-bg) !important; color: var(--text-on-color) !important; }
.cell input.missing-answer { background-color: var(--missing-color-bg) !important; color: var(--text-on-color) !important; }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

.sum-cell {
    font-weight: 700;
}
body.dark-mode .sum-cell { background-color: #333336; }
body.light-mode .sum-cell { background-color: #e9ecef; }

.sum-cell.correct { color: var(--sum-success) !important; }
.sum-cell.incorrect { color: var(--sum-error) !important; }