/* Variables CSS */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #f472b6;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
    --border-radius-lg: 24px;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Container principal */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Écrans */
.screen {
    display: none;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

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

/* Logo et titre */
.logo {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

.logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

/* Sections du menu */
.menu-section {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.menu-section h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-align: center;
}

/* Boutons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

/* Boutons d'opération */
.operation-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.btn-operation {
    flex-direction: column;
    padding: 20px 15px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-primary);
    border: 2px solid transparent;
}

.btn-operation:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}

.btn-operation .btn-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.btn-mix {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-mix:hover {
    border-color: transparent;
    opacity: 0.9;
}

/* Boutons de difficulté */
.difficulty-buttons {
    display: flex;
    gap: 10px;
}

.btn-difficulty {
    flex: 1;
    flex-direction: column;
    padding: 12px 8px;
    background: #f1f5f9;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.btn-difficulty.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-difficulty span:first-child {
    font-size: 1rem;
    margin-bottom: 4px;
}

/* Stats preview */
.stats-preview {
    display: flex;
    gap: 15px;
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

/* Écran de sélection de difficulté */
.difficulty-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.selected-operation {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.op-icon {
    font-size: 1.5rem;
}

.spacer {
    width: 44px;
}

.difficulty-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.difficulty-content h2 {
    text-align: center;
    color: white;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.difficulty-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.difficulty-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    border: none;
    border-radius: var(--border-radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    border-left: 5px solid transparent;
}

.difficulty-card:active {
    transform: scale(0.98);
}

.difficulty-card.easy {
    border-left-color: #22c55e;
}

.difficulty-card.easy:hover {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.difficulty-card.medium {
    border-left-color: #f59e0b;
}

.difficulty-card.medium:hover {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.difficulty-card.hard {
    border-left-color: #ef4444;
}

.difficulty-card.hard:hover {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.difficulty-card.expert {
    border-left-color: #8b5cf6;
}

.difficulty-card.expert:hover {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

.difficulty-stars {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.difficulty-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.difficulty-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-icon {
    font-size: 1rem;
}

.info-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Mode sombre pour les cartes de difficulté */
@media (prefers-color-scheme: dark) {
    .difficulty-card.easy:hover {
        background: linear-gradient(135deg, #1a2e1a 0%, #1f3d1f 100%);
    }

    .difficulty-card.medium:hover {
        background: linear-gradient(135deg, #2e2a1a 0%, #3d3520 100%);
    }

    .difficulty-card.hard:hover {
        background: linear-gradient(135deg, #2e1a1a 0%, #3d2020 100%);
    }

    .difficulty-card.expert:hover {
        background: linear-gradient(135deg, #251a2e 0%, #302040 100%);
    }
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Écran de jeu */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
}

.btn-icon-only {
    width: 44px;
    height: 44px;
    padding: 0;
    background: #f1f5f9;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.game-stats {
    display: flex;
    gap: 15px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.timer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.timer.warning {
    color: var(--warning-color);
    animation: pulse 1s ease infinite;
}

.timer.danger {
    color: var(--error-color);
    animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Barre de progression */
.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, #86efac 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Contenu du jeu */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.question-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 30px 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.question-number {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.question {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Feedback */
.feedback {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback.show {
    opacity: 1;
}

.feedback.correct {
    color: var(--success-color);
}

.feedback.wrong {
    color: var(--error-color);
}

/* Zone de réponse */
.answer-section {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.answer-input {
    width: 100%;
    padding: 16px 20px;
    border: 3px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    margin-bottom: 15px;
}

.answer-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.answer-input.correct {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.answer-input.wrong {
    border-color: var(--error-color);
    background: #fef2f2;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-10px);
    }
    40%, 80% {
        transform: translateX(10px);
    }
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 1.1rem;
}

.btn-submit:hover {
    opacity: 0.9;
}

/* Affichage série */
.streak-display {
    text-align: center;
    margin-top: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
}

#streak-icon {
    transition: transform 0.3s ease;
}

.streak-display.hot #streak-icon {
    animation: fire 0.5s ease infinite;
}

@keyframes fire {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* Écran de résultats */
.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.result-emoji {
    font-size: 5rem;
    margin-bottom: 15px;
    animation: celebrate 1s ease;
}

@keyframes celebrate {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.result-content h2 {
    font-size: 2rem;
    color: white;
    margin-bottom: 10px;
}

.result-content > p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
}

/* Stats de résultat */
.result-stats {
    display: flex;
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
}

.result-stat {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px 15px;
    box-shadow: var(--shadow-sm);
}

.result-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.result-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Détails des résultats */
.result-details {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    width: 100%;
    margin-bottom: 25px;
    box-shadow: var(--shadow-sm);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.detail-item span:first-child {
    color: var(--text-secondary);
}

.detail-item span:last-child {
    font-weight: 600;
}

/* Boutons de résultat */
.result-buttons {
    display: flex;
    gap: 15px;
    width: 100%;
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--success-color) 0%, #16a34a 100%);
    color: white;
}

.btn-secondary {
    flex: 1;
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Responsive design */
@media (max-width: 400px) {
    .container {
        padding: 15px;
    }

    .logo h1 {
        font-size: 1.7rem;
    }

    .logo-icon {
        font-size: 3rem;
    }

    .question {
        font-size: 2rem;
    }

    .btn-operation {
        padding: 15px 10px;
    }

    .btn-operation .btn-icon {
        font-size: 1.5rem;
    }

    .result-stats {
        flex-direction: column;
    }

    .result-stat-value {
        font-size: 1.5rem;
    }
}

@media (min-height: 700px) {
    .game-content {
        justify-content: flex-start;
        padding-top: 30px;
    }
}

/* Désactiver le zoom sur les inputs iOS */
@supports (-webkit-touch-callout: none) {
    .answer-input {
        font-size: 16px;
    }
}

/* Mode sombre (optionnel basé sur les préférences système) */
@media (prefers-color-scheme: dark) {
    :root {
        --card-bg: rgba(30, 30, 40, 0.95);
        --text-primary: #f3f4f6;
        --text-secondary: #9ca3af;
    }

    .btn-operation {
        background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
        color: white;
    }

    .btn-operation:hover {
        background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    }

    .btn-difficulty {
        background: #374151;
        color: #9ca3af;
    }

    .btn-icon-only {
        background: #374151;
        color: white;
    }

    .answer-input {
        background: #1f2937;
        border-color: #374151;
        color: white;
    }

    .answer-input:focus {
        border-color: var(--primary-color);
    }

    .detail-item {
        border-color: #374151;
    }

    .btn-secondary {
        color: white;
    }
}
