/* ============================================
   Chroma Blend - Feuille de styles
   Design inspiré du thème pulsepattern
   ============================================ */

/* --- Reset scoped --- */
#game-main * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* --- Variables --- */
#game-main {
    --cb-cyan: #00BCD4;
    --cb-magenta: #E91E63;
    --cb-yellow: #FFEB3B;
    --cb-green: #4CAF50;
    --cb-orange: #FF9800;
    --cb-purple: #9C27B0;
    --cb-bg-dark: #0f0c29;
    --cb-bg-medium: #302b63;
    --cb-bg-light: #24243e;
    --cb-text-primary: #e0e0e0;
    --cb-text-secondary: #888;
    --cb-accent: #e94560;
    --cb-accent2: #7b2ff7;

    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--cb-bg-dark), var(--cb-bg-medium), var(--cb-bg-light));
    color: var(--cb-text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* --- Container principal --- */
#game-main #game-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* --- Écrans --- */
#game-main .screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-main .screen.active {
    display: flex;
}

#game-main .screen.overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
}

/* --- Écran d'accueil --- */
#game-main #home-screen {
    background: linear-gradient(135deg, var(--cb-bg-dark), var(--cb-bg-medium), var(--cb-bg-light));
}

#game-main .game-title {
    font-size: clamp(2.2rem, 8vw, 3.5rem);
    font-weight: 700;
    background: linear-gradient(90deg, var(--cb-cyan), var(--cb-magenta), var(--cb-yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    animation: cbTitlePulse 2s ease-in-out infinite;
    letter-spacing: 2px;
    text-transform: uppercase;
}

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

#game-main .tagline {
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    color: var(--cb-text-secondary);
    margin-bottom: 2rem;
}

/* --- Boutons du menu --- */
#game-main .menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 80%;
    max-width: 300px;
}

#game-main .menu-btn {
    padding: 12px 36px;
    font-size: clamp(0.95rem, 3.5vw, 1.1rem);
    font-weight: 600;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: rgba(255, 255, 255, 0.08);
    color: var(--cb-text-primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
}

#game-main .menu-btn.primary {
    background: linear-gradient(135deg, var(--cb-accent), #ff6b6b);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

#game-main .menu-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.5);
}

#game-main .menu-btn.btn-rules-menu {
    background: linear-gradient(135deg, #ff6fd8, var(--cb-accent2));
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

#game-main .menu-btn:active {
    transform: scale(0.95);
}

#game-main .menu-btn:hover {
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

/* --- Sélection de niveau --- */
#game-main .level-select {
    margin-top: 2rem;
    width: 90%;
    max-width: 400px;
}

#game-main .level-select h2 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
    color: #b0b0ff;
}

#game-main #levels-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#game-main .level-btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    color: var(--cb-text-primary);
    transition: all 0.3s ease;
}

#game-main .level-btn.unlocked {
    background: linear-gradient(135deg, var(--cb-cyan), var(--cb-accent2));
}

#game-main .level-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

#game-main .level-btn.completed {
    background: linear-gradient(135deg, var(--cb-green), #81c784);
}

/* --- Écran de jeu --- */
#game-main #game-screen {
    background: var(--cb-bg-dark);
}

#game-main #game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

#game-main .header-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-main .header-item .label {
    font-size: 0.65rem;
    color: var(--cb-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#game-main .header-item .value {
    font-size: clamp(0.9rem, 3.5vw, 1.2rem);
    font-weight: 700;
    color: #fff;
}

/* --- Indice de recette --- */
#game-main .recipe-hint {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.3rem;
    background: rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    z-index: 10;
}

#game-main .recipe-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
}

#game-main .recipe-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

#game-main .recipe-color.cyan { background: var(--cb-cyan); }
#game-main .recipe-color.magenta { background: var(--cb-magenta); }
#game-main .recipe-color.yellow { background: var(--cb-yellow); }
#game-main .recipe-color.green { background: var(--cb-green); }
#game-main .recipe-color.orange { background: var(--cb-orange); }
#game-main .recipe-color.purple { background: var(--cb-purple); }

#game-main .recipe-plus {
    color: var(--cb-text-secondary);
    font-weight: bold;
}

#game-main .recipe-equals {
    color: var(--cb-text-secondary);
}

/* --- Canvas --- */
#game-main #game-canvas {
    width: 100%;
    height: calc(100% - 80px);
    margin-top: 50px;
    touch-action: none;
}

/* --- Contrôles de jeu --- */
#game-main #game-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
}

#game-main .control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
}

#game-main .control-btn:active {
    transform: scale(0.9);
    background: var(--cb-accent);
}

/* --- Modales --- */
#game-main .modal {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    padding: 2rem;
    border-radius: 20px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: cbFadeIn 0.3s ease;
}

#game-main .modal h2 {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, var(--cb-cyan), var(--cb-accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#game-main .modal p {
    margin-bottom: 0.5rem;
    color: #ccc;
}

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

/* --- Règles --- */
#game-main .rules-modal {
    max-width: 400px;
}

#game-main .rules-content {
    text-align: left;
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

#game-main .rule-section {
    margin-bottom: 1.2rem;
}

#game-main .rule-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    color: #b0b0ff;
    font-weight: 600;
}

#game-main .color-examples {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

#game-main .color-block {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

#game-main .color-block.cb-cyan { background: var(--cb-cyan); color: #000; }
#game-main .color-block.cb-magenta { background: var(--cb-magenta); color: #fff; }
#game-main .color-block.cb-yellow { background: var(--cb-yellow); color: #000; }

#game-main .mix-examples {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#game-main .mix {
    font-size: 0.85rem;
}

#game-main .mix .mix-green { color: var(--cb-green); font-weight: 600; }
#game-main .mix .mix-orange { color: var(--cb-orange); font-weight: 600; }
#game-main .mix .mix-purple { color: var(--cb-purple); font-weight: 600; }

/* --- Scores --- */
#game-main .scores-modal {
    max-width: 350px;
}

#game-main #highscores-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

#game-main .score-entry {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    margin: 0.3rem 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 0.85rem;
}

#game-main .score-entry.gold { border-left: 4px solid gold; }
#game-main .score-entry.silver { border-left: 4px solid silver; }
#game-main .score-entry.bronze { border-left: 4px solid #cd7f32; }

/* --- Étoiles --- */
#game-main #stars-container {
    font-size: 2rem;
    margin: 1rem 0;
}

#game-main .star {
    display: inline-block;
    margin: 0 0.2rem;
    transition: all 0.3s ease;
}

#game-main .star.filled {
    color: gold;
    animation: cbStarPop 0.5s ease;
}

#game-main .star.empty {
    color: #555;
}

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

/* --- Combo flash --- */
@keyframes cbComboFlash {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

#game-main .combo-success {
    animation: cbComboFlash 0.5s ease;
}

/* --- Responsive --- */
@media (max-width: 360px) {
    #game-main .game-title {
        font-size: 1.8rem;
    }

    #game-main .menu-btn {
        padding: 0.8rem 1.5rem;
    }
}

@media (min-height: 800px) {
    #game-main .modal {
        padding: 3rem;
    }
}

/* --- Mode paysage --- */
@media (orientation: landscape) and (max-height: 500px) {
    #game-main #game-canvas {
        height: calc(100% - 60px);
        margin-top: 40px;
    }

    #game-main .modal {
        max-width: 60%;
        padding: 1rem;
    }

    #game-main .rules-content {
        display: flex;
        flex-wrap: wrap;
    }

    #game-main .rule-section {
        width: 45%;
        margin-right: 5%;
    }
}

/* --- Safe areas pour notch --- */
@supports (padding-top: env(safe-area-inset-top)) {
    #game-main #game-header {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    #game-main #game-controls {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}
