/* ============================================
   Chroma-Link - Feuille de styles
   Design intégré au style omesjeux (pulsepattern)
   ============================================ */

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

#game-main {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* --- Conteneur principal --- */
#game-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    gap: 8px;
    overflow: hidden;
}

/* --- En-tête --- */
#game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00ffff, #ff00ff, #ffff00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* --- Scores --- */
#scores-container {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.score-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

/* --- Canvas Container --- */
#canvas-container {
    flex: 1;
    width: 100%;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    min-height: 0;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* --- Message Overlay --- */
#message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 12, 41, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.25s ease;
}

#message-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.message-box {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    border: 2px solid rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    animation: slideUp 0.3s ease;
}

#message-title {
    font-size: 1.5rem;
    margin-bottom: 16px;
    background: linear-gradient(90deg, #00ffff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#message-text {
    color: #aaa;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* --- Boutons --- */
#controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 8px 0;
    flex-shrink: 0;
}

.game-btn {
    padding: 12px 36px;
    font-size: 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, opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-play {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-play:hover {
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

.btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}

.btn-stop:hover {
    box-shadow: 0 6px 20px rgba(255, 82, 82, 0.5);
}

.btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

.btn-rules:hover {
    box-shadow: 0 6px 20px rgba(123, 47, 247, 0.5);
}

.hidden {
    display: none !important;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    animation: fadeIn 0.25s ease;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    color: #fff;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
    background: linear-gradient(90deg, #00ffff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

.modal-body h3 {
    font-size: 0.95rem;
    color: #b0b0ff;
    margin: 14px 0 6px;
    font-weight: 600;
}

.modal-body p {
    margin-bottom: 8px;
}

.modal-body ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.modal-body li {
    margin-bottom: 4px;
}

/* --- Shape Examples --- */
.shape-examples {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 16px 0;
}

.shape-circle {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.shape-square {
    display: inline-block;
    width: 28px;
    height: 28px;
}

.shape-triangle {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 26px solid;
}

.cyan {
    background: #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.magenta {
    background: #ff00ff;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.yellow {
    background: #ffff00;
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
    border-bottom-color: #ffff00;
}

/* --- High Scores List --- */
#high-scores-list {
    margin: 16px 0;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    margin-bottom: 4px;
}

.score-entry:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    border: 1px solid gold;
}

.score-entry:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
    border: 1px solid silver;
}

.score-entry:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
    border: 1px solid #cd7f32;
}

.score-entry .rank {
    font-weight: bold;
    width: 30px;
}

.score-entry .player-name {
    flex: 1;
    margin-left: 8px;
}

.score-entry .player-score {
    color: #00ffff;
    font-weight: 600;
}

.no-scores {
    text-align: center;
    color: #888;
    padding: 24px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scoreUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #ffff00; }
    100% { transform: scale(1); }
}

.score-animate {
    animation: scoreUp 0.3s ease-out;
}

/* --- Responsive : petits écrans --- */
@media (max-height: 600px) {
    #game-container {
        padding: 5px 10px;
        gap: 4px;
    }

    #game-title {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .score-number {
        font-size: 1.1rem;
    }

    .game-btn {
        padding: 10px 28px;
        font-size: 0.85rem;
    }
}

/* --- Responsive : grands écrans --- */
@media (min-width: 768px) {
    #game-container {
        padding: 20px;
        gap: 12px;
    }

    #game-title {
        font-size: 2rem;
    }

    .score-number {
        font-size: 1.8rem;
    }
}

/* --- Mode paysage mobile --- */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 5px 10px;
        gap: 4px;
        max-width: 100%;
        justify-content: center;
    }

    #game-header {
        width: 50%;
        order: 1;
    }

    #game-title {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .score-number {
        font-size: 1rem;
    }

    #canvas-container {
        order: 2;
        flex: 1;
        width: auto;
    }

    #controls-container {
        order: 3;
        width: auto;
        flex-direction: column;
        padding: 0 10px;
    }

    .game-btn {
        padding: 8px 20px;
        font-size: 0.8rem;
    }
}
