/* ============================================
   Shape Swap - Feuille de styles
   Design inspiré de Pulse Pattern
   ============================================ */

/* --- 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;
    position: relative;
}

/* --- 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, #00d2ff, #7b2ff7, #ff6fd8);
    -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;
}

/* --- Barre d'informations --- */
#info-bar {
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 6px 10px;
    flex-shrink: 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

/* --- Game Area (Canvas) --- */
.game-area {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 0;
}

#game-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    touch-action: none;
}

/* --- Timer --- */
.timer-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.timer-bar.warning {
    background: linear-gradient(90deg, #ff9800, #ff5252);
    animation: pulse 0.5s ease-in-out infinite;
}

.timer-bar.danger {
    background: #ff5252;
    animation: pulse-fast 0.3s ease-in-out infinite;
}

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

@keyframes pulse-fast {
    0%, 100% { opacity: 1; transform: scaleX(1); }
    50% { opacity: 0.8; transform: scaleX(1.02); }
}

/* --- 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);
}

.game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.btn-play:hover:not(:disabled) {
    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:not(:disabled) {
    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);
}

/* --- Instructions --- */
.instructions {
    text-align: center;
    padding: 4px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

/* --- Modals --- */
.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(123, 47, 247, 0.4);
    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-content.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.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, #00d2ff, #7b2ff7);
    -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;
}

/* --- Example in rules --- */
.example {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 16px 0;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.example-col {
    text-align: center;
    font-size: 0.9rem;
    line-height: 2;
}

.example-col .shape {
    font-size: 1.4rem;
    margin-right: 4px;
}

.example-col mark {
    background: rgba(0, 210, 255, 0.3);
    color: #00d2ff;
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Game Over Modal --- */
.final-score {
    text-align: center;
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(123, 47, 247, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(123, 47, 247, 0.3);
}

.final-score .label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

#final-score-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: #00d2ff;
    text-shadow: 0 0 20px rgba(0, 210, 255, 0.5);
}

.high-scores {
    margin-bottom: 16px;
}

.high-scores h3 {
    font-size: 1rem;
    color: #b0b0ff;
    margin-bottom: 10px;
    text-align: center;
}

#high-scores-list {
    list-style: none;
    counter-reset: score-counter;
}

#high-scores-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    counter-increment: score-counter;
    font-size: 0.85rem;
}

#high-scores-list li::before {
    content: counter(score-counter);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #7b2ff7;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 10px;
    flex-shrink: 0;
}

#high-scores-list li:nth-child(1)::before {
    background: linear-gradient(135deg, #ffd700, #ffed4a);
    color: #333;
}

#high-scores-list li:nth-child(2)::before {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #333;
}

#high-scores-list li:nth-child(3)::before {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    color: #fff;
}

.high-score-name {
    flex: 1;
    margin-left: 10px;
    font-weight: 600;
}

.high-score-value {
    font-weight: 800;
    color: #00d2ff;
}

.name-input {
    margin-bottom: 16px;
    padding: 16px;
    background: rgba(0, 210, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(0, 210, 255, 0.3);
}

.name-input p {
    text-align: center;
    margin-bottom: 12px;
    color: #00d2ff;
    font-size: 0.9rem;
}

#player-name {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 12px;
    text-align: center;
}

#player-name:focus {
    outline: none;
    border-color: #00d2ff;
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.2);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons .game-btn {
    flex: 1;
}

/* --- Utilitaires --- */
.hidden {
    display: none !important;
}

/* --- Animations --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* --- 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;
    }

    #info-bar {
        padding: 4px 8px;
    }

    .info-label {
        font-size: 0.6rem;
    }

    .info-value {
        font-size: 0.85rem;
    }

    .instructions {
        display: none;
    }

    .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;
    }
}
