/* ============================================
   Color Stack Flow - Feuille de styles
   Design responsive et moderne
   ============================================ */

/* --- Reset et base --- */
#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;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* --- Variables CSS --- */
#game-main {
    --csf-primary: #FF5733;
    --csf-secondary: #33FF57;
    --csf-accent: #3357FF;
    --csf-yellow: #FFD433;
    --csf-purple: #C233FF;
    --csf-bg-dark: #0f0c29;
    --csf-bg-medium: #302b63;
    --csf-bg-light: #24243e;
    --csf-text: #e0e0e0;
    --csf-text-bright: #ffffff;
    --csf-neon: #a855f7;
    --csf-neon-blue: #6e8eff;
}

/* --- Conteneur principal --- */
#game-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* --- Header --- */
#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(15, 12, 41, 0.95);
    border-bottom: 1px solid rgba(168, 85, 247, 0.3);
    flex-shrink: 0;
    z-index: 10;
}

#game-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--csf-primary), var(--csf-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#scores-container {
    display: flex;
    gap: 16px;
}

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

.score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.6;
    letter-spacing: 1px;
}

.score-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--csf-neon);
}

/* --- Info bar --- */
#info-bar {
    display: flex;
    justify-content: space-around;
    padding: 6px 16px;
    background: rgba(36, 36, 62, 0.8);
    border-bottom: 1px solid rgba(168, 85, 247, 0.15);
    flex-shrink: 0;
}

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

.info-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 1px;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--csf-neon-blue);
}

/* --- Message --- */
#message-container {
    text-align: center;
    padding: 6px;
    flex-shrink: 0;
}

#game-message {
    font-size: 0.85rem;
    color: rgba(224, 224, 224, 0.7);
    transition: all 0.3s ease-out;
}

#game-message.active {
    color: var(--csf-yellow);
    font-weight: 600;
}

/* --- Canvas --- */
#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 0;
    touch-action: none;
    -webkit-touch-callout: none;
}

#game-canvas {
    display: block;
    touch-action: none;
}

/* --- Controls --- */
#controls-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(15, 12, 41, 0.95);
    border-top: 1px solid rgba(168, 85, 247, 0.3);
    flex-shrink: 0;
    z-index: 10;
}

.game-btn {
    background: linear-gradient(135deg, #2a2a5a, #1a1a3a);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #c0c0ff;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-out;
    min-width: 80px;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
}

.game-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #3a3a7a, #2a2a5a);
}

.btn-play {
    background: linear-gradient(135deg, var(--csf-primary), var(--csf-purple));
    color: white;
    border: none;
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-play:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

.btn-stop {
    background: linear-gradient(135deg, #ff4444, #cc2222);
    color: white;
    border: none;
}

.btn-discard {
    background: linear-gradient(135deg, #FFD433, #e6b800);
    color: #1a1a2e;
    border: none;
    font-weight: 700;
    min-width: 70px;
}

/* --- Modal --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 20, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: csfFadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a3a, #0a0a2a);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 20px;
    padding: 24px 20px;
    max-width: 340px;
    width: 90%;
    text-align: left;
    box-shadow: 0 10px 40px rgba(168, 85, 247, 0.15);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #a0a0dd;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-title {
    font-size: 1.4rem;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--csf-primary), var(--csf-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.modal-body h3 {
    font-size: 0.95rem;
    margin: 12px 0 6px;
    color: var(--csf-neon);
}

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

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

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

.modal-body strong {
    color: var(--csf-neon-blue);
}

/* --- Game Over overlay --- */
.gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 20, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: csfFadeIn 0.3s ease;
}

.gameover-content {
    background: linear-gradient(135deg, #1a1a3a, #0a0a2a);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(168, 85, 247, 0.15);
}

.gameover-title {
    font-size: 1.8rem;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #ff4444, var(--csf-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gameover-score {
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: #e0e0e0;
}

.gameover-level {
    font-size: 0.9rem;
    margin-bottom: 16px;
    color: #a0a0dd;
}

.gameover-record {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--csf-yellow);
    margin-bottom: 16px;
    animation: csfPulse 0.6s ease-in-out infinite alternate;
}

.gameover-replay-btn {
    margin-top: 8px;
}

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

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

@keyframes csfPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

@keyframes csfShake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 2px); }
    50% { transform: translate(4px, -2px); }
    75% { transform: translate(-2px, -4px); }
}

.csf-shake {
    animation: csfShake 0.15s ease-in-out 3;
}

/* --- Responsive --- */
@media (max-height: 500px) {
    #game-header { padding: 4px 12px; }
    #game-title { font-size: 0.9rem; }
    .score-number { font-size: 1rem; }
    #info-bar { padding: 3px 12px; }
    .info-value { font-size: 0.9rem; }
    #controls-container { padding: 6px 12px; gap: 8px; }
    .game-btn { padding: 8px 14px; font-size: 0.85rem; min-width: 60px; }
}

@media (min-width: 600px) {
    .game-btn { padding: 12px 28px; font-size: 1rem; }
    .modal-content, .gameover-content { max-width: 400px; padding: 32px 28px; }
}

@media (min-width: 900px) {
    #game-container { max-width: 500px; }
}

/* --- Scrollbar hide for mobile --- */
#game-main ::-webkit-scrollbar {
    display: none;
}