/* ═══════════════════════════════════════════════════════════
   CHEMISTRY METER — Game-Specific Styles
   Shared styles (buttons, lang dropdown, tools section) → game-shared-style.css
   ═══════════════════════════════════════════════════════════ */

.chem-hero { padding-top: 44px; padding-bottom: 8px; text-align: center; }
.chem-title { font-family: 'Playfair Display', serif; font-size: clamp(1.9rem, 5.5vw, 3.6rem); margin-bottom: 10px; }
.chem-subtitle { max-width: 540px; margin: 0 auto; color: var(--text-secondary); font-size: 1rem; line-height: 1.55; }
.chem-game-section { padding-top: 18px; padding-bottom: 56px; }
@media (max-width: 520px) {
    .chem-hero { padding-top: 24px; padding-bottom: 4px; }
    .chem-title { margin-bottom: 6px; }
    .chem-subtitle { font-size: 0.88rem; }
}

/* Boundary is now the shared .zg-arena-card class (560px, matches every other game) —
   applied directly in the PHP template. #chem-app sits inside it as plain content,
   not a second nested box, so its own border/shadow are intentionally removed here;
   the hue-shift background stays since that's the live "mood color" feedback. */
#chem-app {
    --chem-hue: 200;
    background: var(--bg-card);
    background-image: linear-gradient(160deg, hsla(var(--chem-hue), 80%, 60%, 0.07), transparent 60%);
    border-radius: 14px;
    padding: 6px 2px;
    position: relative;
    min-height: 280px;
    transition: background-image 0.8s ease;
    overflow: hidden;
}

.chem-view { display: none; }
.chem-view-active { display: block; animation: chem-fade-in 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes chem-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chem-view-title { font-family: 'Playfair Display', serif; color: var(--text-primary); font-size: 1.4rem; margin-bottom: 18px; text-align: center; }

/* ===== LANDING CHOICE CARDS (mirrors Cosmic Court pattern) ===== */
.chem-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .chem-choice-grid { grid-template-columns: 1fr; } }
.chem-choice-card {
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
}
.chem-choice-card:hover { border-color: var(--brand-primary-light); transform: translateY(-4px); box-shadow: 0 14px 36px rgba(139, 92, 246, 0.22); }
.chem-choice-icon { font-size: 2.2rem; display: block; margin-bottom: 10px; }
.chem-choice-card h3 { color: var(--text-primary); font-size: 1.02rem; margin-bottom: 6px; font-weight: 600; }
.chem-choice-card p { color: var(--text-secondary); font-size: 0.83rem; margin: 0; }

/* ===== FORM ===== */
.chem-form { display: flex; flex-direction: column; gap: 6px; }
.chem-input-field {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-card); border-radius: 12px;
    padding: 13px 15px; color: var(--text-primary); font-size: 1rem; font-family: inherit; outline: none;
    margin-bottom: 14px;
}
.chem-input-field:focus { border-color: var(--brand-primary-light); box-shadow: 0 0 0 3px rgba(139,92,246,0.1); }
.chem-btn-block { width: 100%; margin-top: 10px; text-align: center; justify-content: center; }

/* ===== LOBBY ===== */
.chem-lobby-code {
    font-family: 'Playfair Display', serif; font-size: 2.8rem; font-weight: 700; letter-spacing: 0.15em;
    color: var(--text-primary); background: rgba(139,92,246,0.1); border: 1px solid var(--brand-primary-light);
    border-radius: 16px; padding: 14px 24px; display: block; text-align: center; margin: 0 auto 18px;
}

/* ===== AURORA CHEMISTRY RIBBON ===== */
.chem-stage-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
.chem-stage-icon { font-size: 1.4rem; }
.chem-stage-label { color: var(--text-primary); font-size: 0.95rem; font-weight: 600; }

.chem-score-number {
    margin-left: 4px;
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: hsl(var(--chem-hue), 90%, 70%);
    text-shadow: 0 0 14px hsla(var(--chem-hue), 90%, 65%, 0.5);
    transition: color 0.6s ease, text-shadow 0.6s ease;
    min-width: 3ch;
    display: inline-block;
    text-align: left;
}
.chem-score-pop { animation: chem-score-pop-anim 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes chem-score-pop-anim {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); text-shadow: 0 0 26px hsla(var(--chem-hue), 95%, 70%, 0.85); }
    100% { transform: scale(1); }
}

.chem-streak-row { text-align: center; margin: -4px 0 14px; }
.chem-streak-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(251,146,60,0.14); border: 1px solid rgba(251,146,60,0.4);
    color: #fdba74; border-radius: 50px; padding: 5px 14px; font-size: 0.78rem; font-weight: 600;
}
.chem-streak-pop { animation: chem-streak-pop-anim 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes chem-streak-pop-anim {
    0% { transform: scale(1); }
    45% { transform: scale(1.18); box-shadow: 0 0 20px rgba(251,146,60,0.5); }
    100% { transform: scale(1); }
}

.chem-ribbon-track {
    position: relative;
    height: 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
    margin-bottom: 18px;
}
.chem-ribbon-fill {
    height: 100%;
    width: 4%;
    border-radius: 20px;
    background: linear-gradient(90deg,
        hsl(calc(var(--chem-hue) - 40), 85%, 60%),
        hsl(var(--chem-hue), 90%, 65%),
        hsl(calc(var(--chem-hue) + 40), 85%, 65%));
    background-size: 200% 100%;
    transition: width 1.1s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 18px hsla(var(--chem-hue), 90%, 65%, 0.55);
}
.chem-pulse .chem-ribbon-fill,
.chem-ribbon-fill { animation: chem-breathe 4s ease-in-out infinite; }
@keyframes chem-breathe { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.chem-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.chem-particle {
    position: absolute; bottom: 40px; width: 5px; height: 5px; border-radius: 50%;
    background: hsl(var(--chem-hue), 90%, 70%);
    box-shadow: 0 0 8px hsla(var(--chem-hue), 90%, 70%, 0.8);
    animation: chem-float-up 1.6s ease-out forwards;
}
@keyframes chem-float-up {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    15% { opacity: 1; }
    100% { transform: translateY(-70px) scale(1.1); opacity: 0; }
}

/* ===== CHAT ===== */
.chem-chat-body { display: flex; flex-direction: column; height: 100%; }
.chem-messages {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 320px; overflow-y: auto; padding: 4px 2px 10px;
    margin-bottom: 10px;
}
.chem-message {
    max-width: 78%; padding: 9px 14px; border-radius: 16px; font-size: 0.9rem; line-height: 1.4;
    word-break: break-word; animation: chem-fade-in 0.25s ease;
}
.chem-message-mine { align-self: flex-end; background: var(--gradient-primary); color: white; border-bottom-right-radius: 4px; }
.chem-message-theirs { align-self: flex-start; background: rgba(255,255,255,0.06); color: var(--text-primary); border-bottom-left-radius: 4px; }

.chem-typing-indicator { height: 18px; font-size: 0.78rem; color: var(--text-muted); opacity: 0; transition: opacity 0.2s ease; margin-bottom: 4px; }
.chem-typing-visible { opacity: 1; }

.chem-input-row { display: flex; gap: 8px; }
.chem-input-row input {
    flex: 1; background: rgba(255,255,255,0.03); border: 1px solid var(--border-card); border-radius: 50px;
    padding: 11px 16px; color: var(--text-primary); font-size: 0.92rem; outline: none;
}
.chem-input-row input:focus { border-color: var(--brand-primary-light); }
.chem-input-row button {
    background: var(--gradient-primary); color: white; border: none; border-radius: 50px;
    padding: 0 20px; font-weight: 600; cursor: pointer; font-family: inherit;
}

.chem-whisper {
    text-align: center; color: var(--text-muted); font-size: 0.8rem; font-style: italic;
    opacity: 0; transform: translateY(4px); transition: all 0.5s ease; margin-top: 8px; min-height: 1.2em;
}
.chem-whisper-visible { opacity: 1; transform: translateY(0); }

/* ===== SYNC / MILESTONE TOASTS ===== */
.chem-toast-layer { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.chem-toast {
    display: flex; align-items: center; gap: 8px;
    background: rgba(16,16,36,0.92); border: 1px solid var(--brand-primary-light); border-radius: 50px;
    padding: 7px 16px; color: var(--text-primary); font-size: 0.82rem; font-weight: 600;
    opacity: 0; transform: translateY(-10px) scale(0.9);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(139,92,246,0.3);
}
.chem-toast-visible { opacity: 1; transform: translateY(0) scale(1); }
.chem-toast-icon { font-size: 1.05rem; }

/* ===== SAVE THIS MOMENT ===== */
.chem-save-moment-btn {
    display: block; margin: 10px auto 4px; background: rgba(139,92,246,0.1);
    border: 1px solid var(--brand-primary-light); border-radius: 50px;
    padding: 7px 18px; color: var(--brand-primary-light); font-size: 0.8rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.25s ease;
}
.chem-save-moment-btn:hover { background: rgba(139,92,246,0.18); transform: translateY(-1px); }
