/* ============================================
   Atom Bubble - Feuille de styles
   Design responsive 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;
}

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

.score-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #00d2ff;
}

/* --- Info bar --- */
#info-bar {
    display: flex;
    justify-content: center;
    gap: 24px;
    width: 100%;
    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;
    opacity: 0.6;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #b48cff;
}

/* --- Message --- */
#message-container {
    width: 100%;
    text-align: center;
    min-height: 1.4rem;
    flex-shrink: 0;
}

#game-message {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* --- Canvas --- */
#canvas-wrap {
    position: relative;
    width: 100%;
    flex: 1;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

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

/* --- Overlay (start screen) --- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(15, 12, 41, 0.92);
    backdrop-filter: blur(4px);
    padding: 20px;
    text-align: center;
    z-index: 5;
}

.overlay.hidden { display: none; }

.overlay-title {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-subtitle { opacity: 0.85; font-size: 0.95rem; }

.hint {
    font-size: 0.8rem;
    opacity: 0.55;
    font-style: italic;
}

/* --- Top 10 --- */
.top10-panel {
    width: 100%;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px 16px;
}

.top10-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #ffd66e;
}

.top10-list {
    list-style-position: inside;
    font-size: 0.85rem;
    text-align: left;
    max-height: 160px;
    overflow-y: auto;
}

.top10-list li {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.top10-list li .rank { color: #00d2ff; font-weight: 700; margin-right: 6px; }
.top10-list li .name { flex: 1; }
.top10-list li .pts { font-weight: 700; color: #ffd66e; }

.top10-empty { opacity: 0.5; font-size: 0.8rem; }

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

.game-btn {
    flex: 1;
    max-width: 130px;
    min-height: 44px;
    border: none;
    border-radius: 22px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: transform 0.12s, opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.game-btn:active { transform: scale(0.94); }
.game-btn:disabled { opacity: 0.35; cursor: default; }

.btn-play     { background: linear-gradient(135deg, #2ecc71, #159c52); }
.btn-stop     { background: linear-gradient(135deg, #e74c3c, #b03a2e); }
.btn-solution { background: linear-gradient(135deg, #f39c12, #c87f0a); }
.btn-rules    { background: linear-gradient(135deg, #3498db, #2471a3); }

.hidden { display: none !important; }

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 20;
    padding: 16px;
}

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

.modal-content {
    position: relative;
    background: linear-gradient(160deg, #22355e, #141d36);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 22px;
    max-width: 400px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    animation: pop-in 0.25s ease;
}

@keyframes pop-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
}

.modal-close:hover { opacity: 1; }

.modal-title {
    margin-bottom: 12px;
    color: #00d2ff;
    font-size: 1.2rem;
}

.modal-body p {
    margin-bottom: 10px;
    line-height: 1.45;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* --- Solution list --- */
.solution-list {
    list-style: none;
    margin-bottom: 6px;
}

.solution-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.solution-list .formula {
    font-weight: 800;
    font-size: 1.1rem;
    color: #ffd66e;
    min-width: 56px;
}

.solution-list sub { font-size: 0.7em; }
.solution-list .mol-name { font-size: 0.85rem; opacity: 0.9; }

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

/* --- Toast --- */
.toast {
    position: fixed;
    top: 18%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: rgba(20, 30, 55, 0.95);
    border: 1px solid #00d2ff;
    color: #fff;
    padding: 12px 22px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 30;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.toast .bonus { color: #ffd66e; }
