/* Ants & Atlases · Flag Match — cinematic dark game UI */

:root {
    --bg-dark: #0a0c10;
    --navy-deep: #0f172a;
    --primary-blue: #3b82f6;
    --accent-gold: #f59e0b;
    --accent-emerald: #10b981;
    --danger: #ef4444;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-display: 'Playfair Display', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background:
        radial-gradient(1200px 700px at 50% -10%, #16223b 0%, transparent 60%),
        var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ---- Header --------------------------------------------------------- */
#fm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 40px;
}
.fm-brand { display: flex; flex-direction: column; gap: 2px; }
.fm-back {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: color 0.2s;
}
.fm-back:hover { color: var(--text-primary); }
.fm-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.fm-scoreboard { display: flex; gap: 26px; }
.fm-stat { display: flex; flex-direction: column; align-items: center; }
.fm-stat-num {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent-gold);
}
.fm-stat-label {
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Level ladder --------------------------------------------------- */
#fm-ladder {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px 40px 4px;
}
.fm-rung {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.fm-rung:hover:not(.locked):not(.active) {
    border-color: var(--primary-blue);
    color: var(--text-primary);
}
.fm-rung-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    font-weight: 700;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.fm-rung-name { font-weight: 600; letter-spacing: 0.3px; }
.fm-rung.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #1a1a1a;
}
.fm-rung.active .fm-rung-num { background: rgba(0,0,0,0.18); color: #1a1a1a; }
.fm-rung.locked { opacity: 0.34; cursor: not-allowed; }
.fm-rung.locked .fm-rung-name::after { content: " 🔒"; font-size: 0.7em; }

/* ---- Stage ---------------------------------------------------------- */
#fm-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 18px 24px 50px;
}
.fm-prompt {
    font-size: 1.05rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* ---- Flag card ------------------------------------------------------ */
.fm-flag-wrap { perspective: 800px; }
.fm-flag-card {
    width: min(380px, 78vw);
    aspect-ratio: 3 / 2;
    border-radius: 14px;
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition: opacity 0.45s ease, transform 0.45s ease;
}
.fm-flag-card.revealed { opacity: 1; transform: translateY(0) scale(1); }
.fm-flag-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---- Choices -------------------------------------------------------- */
.fm-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: min(640px, 92vw);
}
/* With an odd total, let the lone last button span the full row so the
   layout reads as intentional rather than left-stranded. */
.fm-choices > .fm-choice:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}
.fm-choice {
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}
.fm-choice:hover:not(:disabled) {
    border-color: var(--primary-blue);
    background: rgba(59,130,246,0.12);
    transform: translateY(-2px);
}
.fm-choice:disabled { cursor: default; }
.fm-choice.correct {
    border-color: var(--accent-emerald);
    background: rgba(16,185,129,0.22);
    color: #fff;
    animation: pop 0.3s ease;
}
.fm-choice.wrong {
    border-color: var(--danger);
    background: rgba(239,68,68,0.18);
    color: #fecaca;
    animation: shake 0.35s ease;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ---- Feedback ------------------------------------------------------- */
.fm-feedback {
    min-height: 1.6em;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.fm-feedback.good { color: var(--accent-emerald); }
.fm-feedback.bad  { color: var(--danger); }

/* ---- Level-up overlay ----------------------------------------------- */
.fm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 12, 0.82);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.fm-overlay.hidden { display: none; }
.fm-levelup-card {
    background: linear-gradient(160deg, #14213b, #0c1322);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px 48px;
    text-align: center;
    max-width: 90vw;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    animation: pop 0.4s ease;
}
.fm-levelup-emoji { font-size: 3.4rem; margin-bottom: 8px; }
.fm-levelup-card h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-bottom: 6px;
}
.fm-levelup-card p {
    color: var(--text-muted);
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 22px;
}
.fm-btn-primary {
    background: var(--accent-gold);
    color: #1a1a1a;
    border: none;
    padding: 13px 30px;
    border-radius: 50px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}
.fm-btn-primary:hover { background: #fbbf24; transform: translateY(-2px); }

/* ---- Responsive ----------------------------------------------------- */
@media (max-width: 560px) {
    #fm-header { padding: 14px 20px; }
    .fm-title { font-size: 1.5rem; }
    .fm-choices { grid-template-columns: 1fr; }
}
