:root {
    --am-primary: #02d0bd;
    --am-primary-dark: #01a08f;
    --am-ink: #0d1f38;
    --am-ink-2: #12304f;
    --am-primes: #3b82f6;
    --am-sinistres: #f59e0b;
    --am-danger: #ef4444;
    --am-ok: #10b981;
    --am-warn: #f59e0b;
}

.am-game {
    background: #0b1727;
    background-image: radial-gradient(circle, rgba(255, 255, 255, .04) 1px, transparent 1px);
    background-size: 26px 26px;
    color: #e6edf5;
    min-height: 100vh;
    padding: 12px;
    font-size: 14px;
}

/* En plein ecran : occuper tout l'ecran avec defilement interne */
.am-game:fullscreen,
.am-game:-webkit-full-screen,
.am-game:-ms-fullscreen {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    padding: 16px;
}

/* ---------- Topbar ---------- */
.am-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--am-ink) 0%, var(--am-ink-2) 100%);
    border-radius: 14px;
    padding: 12px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

.am-logo {
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.am-logo i { color: var(--am-primary); }

.am-kpi {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    padding: 0 10px;
    border-left: 1px solid rgba(255, 255, 255, .08);
}

.am-kpi-lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; color: rgba(255, 255, 255, .55); }
.am-kpi-val { font-size: 1.15rem; font-weight: 800; color: #fff; }
.am-kpi-val.is-good { color: var(--am-ok); }
.am-kpi-val.is-warn { color: var(--am-warn); }
.am-kpi-val.is-bad { color: var(--am-danger); }

.am-actions { margin-left: auto; display: flex; gap: 8px; }

/* Chrono de reaction au scenario */
.am-kpi-timer[hidden] { display: none; }
.am-kpi-timer {
    border-left: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    animation: none;
}
.am-kpi-timer .am-kpi-val { color: var(--am-primary); }
.am-kpi-timer.is-urgent {
    background: rgba(239, 68, 68, .15);
    padding: 2px 10px;
    animation: am-pulse 1s ease-in-out infinite;
}
.am-kpi-timer.is-urgent .am-kpi-val { color: var(--am-danger); }
@keyframes am-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

.am-btn {
    background: var(--am-primary);
    color: var(--am-ink);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform .15s ease, filter .15s ease;
}

.am-btn:hover { transform: translateY(-1px); filter: brightness(1.05); color: var(--am-ink); }
.am-btn-ghost { background: rgba(255, 255, 255, .1); color: #fff; }
.am-btn-ghost:hover { color: #fff; }
.am-btn-ghost.is-active {
    background: var(--am-primary);
    color: var(--am-ink);
    box-shadow: 0 0 0 2px rgba(2, 208, 189, .35);
    animation: am-sound-pop .25s ease;
}
@keyframes am-sound-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ---------- Board ---------- */
.am-board {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 12px;
    margin-top: 12px;
}

.am-left { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Branch cards ---------- */
.am-branches { display: flex; flex-direction: column; gap: 10px; }
.am-levers { display: flex; flex-direction: column; gap: 10px; }

/* Cartes leviers (Reassurance, ALM) */
.am-lever {
    background: #13233a;
    border: 1px solid rgba(2, 208, 189, .25);
    border-radius: 14px;
    padding: 12px 14px;
}
.am-lever .am-branch-head { align-items: flex-start; }
.am-lever-desc { font-size: .72rem; color: rgba(255, 255, 255, .5); margin: 6px 0 4px; }

.am-branch {
    background: #13233a;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 14px;
    padding: 12px 14px;
    transition: opacity .2s ease;
}

.am-branch.is-off { opacity: .5; }

.am-branch-head { display: flex; align-items: center; gap: 10px; }

.am-branch-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; color: #fff;
}

.am-branch-name { font-weight: 700; flex: 1; }
.am-branch-primes { font-size: .8rem; color: var(--am-primary); font-weight: 700; }

/* toggle */
.am-toggle { position: relative; width: 42px; height: 22px; }
.am-toggle input { opacity: 0; width: 0; height: 0; }
.am-toggle .track {
    position: absolute; inset: 0; border-radius: 22px;
    background: rgba(255, 255, 255, .2); transition: background .2s;
}
.am-toggle .track::before {
    content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .2s;
}
.am-toggle input:checked + .track { background: var(--am-ok); }
.am-toggle input:checked + .track::before { transform: translateX(20px); }

.am-branch-meta {
    display: flex; justify-content: space-between;
    font-size: .72rem; color: rgba(255, 255, 255, .55);
    margin: 8px 0 4px;
}

.am-branch-meta b { color: #e6edf5; font-weight: 700; }

/* slider */
.am-slider { width: 100%; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px; outline: none; }
.am-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; border: 2px solid var(--am-primary); cursor: pointer;
}
.am-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; background: #fff;
    border: 2px solid var(--am-primary); cursor: pointer;
}
.am-slider-row { display: flex; align-items: center; gap: 8px; }
.am-slider-val { font-size: .8rem; font-weight: 700; width: 38px; text-align: right; }

/* ---------- Center ---------- */
.am-center { display: flex; flex-direction: column; gap: 12px; }

.am-status {
    display: flex; align-items: center; gap: 12px;
    background: #13233a; border-radius: 14px; padding: 12px 16px;
    border-left: 4px solid var(--am-ok);
}
.am-status.is-warn { border-left-color: var(--am-warn); }
.am-status.is-bad { border-left-color: var(--am-danger); }
.am-status-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--am-ok); box-shadow: 0 0 12px var(--am-ok); }
.am-status.is-warn .am-status-dot { background: var(--am-warn); box-shadow: 0 0 12px var(--am-warn); }
.am-status.is-bad .am-status-dot { background: var(--am-danger); box-shadow: 0 0 12px var(--am-danger); }
.am-status-title { font-weight: 700; }
.am-status-sub { font-size: .8rem; color: rgba(255, 255, 255, .55); }

.am-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .am-panels { grid-template-columns: 1fr; } }

.am-panel {
    background: #13233a; border-radius: 14px; padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, .06);
}
.am-panel h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; color: rgba(255, 255, 255, .6); margin-bottom: 10px; }
.am-scenario-title { font-weight: 700; color: var(--am-primary); margin-bottom: 4px; }
.am-scenario-text { font-size: .85rem; color: rgba(255, 255, 255, .7); margin: 0; }

/* gauges */
.am-gauges { display: flex; flex-direction: column; gap: 10px; }
.am-gauge-row { }
.am-gauge-row .lbl { display: flex; justify-content: space-between; font-size: .78rem; margin-bottom: 3px; }
.am-gauge-row .lbl b { color: #fff; }
.am-gauge-bar { height: 7px; border-radius: 7px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.am-gauge-fill { height: 100%; border-radius: 7px; background: var(--am-primary); transition: width .3s ease; }

/* balance meter */
.am-balance { display: flex; align-items: center; justify-content: space-around; gap: 12px; }
.am-balance-side { text-align: center; font-size: .8rem; color: rgba(255, 255, 255, .7); }
.am-balance-side .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-primes { background: var(--am-primes); }
.dot-sinistres { background: var(--am-sinistres); }
.am-balance-val { font-size: 1.05rem; font-weight: 800; color: #fff; margin-top: 4px; }

.am-gauge-meter { text-align: center; }
.am-gauge-arc {
    width: 130px; height: 66px; margin: 0 auto;
    border-radius: 130px 130px 0 0;
    background: conic-gradient(from 270deg at 50% 100%, var(--am-danger) 0deg, var(--am-warn) 45deg, var(--am-ok) 90deg, var(--am-ok) 180deg);
    position: relative; overflow: hidden;
}
.am-gauge-arc::after {
    content: ""; position: absolute; left: 15px; right: 15px; bottom: 0; top: 15px;
    background: #13233a; border-radius: 130px 130px 0 0;
}
.am-gauge-needle {
    position: absolute; left: 50%; bottom: 0; width: 3px; height: 58px;
    background: #fff; transform-origin: bottom center; transform: rotate(0deg);
    border-radius: 3px; z-index: 2; transition: transform .4s ease;
}
.am-gauge-net { font-size: 1.2rem; font-weight: 800; margin-top: 6px; }
.am-gauge-net.is-good { color: var(--am-ok); }
.am-gauge-net.is-bad { color: var(--am-danger); }

.am-chart-wrap .am-chart { height: 220px; position: relative; }

/* ---------- End modal ---------- */
.am-modal {
    position: fixed; inset: 0; z-index: 1050;
    background: rgba(4, 12, 22, .82);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}
.am-modal[hidden] { display: none; }
.am-modal-card {
    background: #13233a; border-radius: 20px; padding: 34px; max-width: 440px; width: 92%;
    text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.am-modal-icon { font-size: 2.6rem; color: var(--am-primary); margin-bottom: 8px; }
.am-modal-icon.is-bad { color: var(--am-danger); }
.am-modal-card h2 { font-weight: 800; }
.am-end-score { font-size: 3.2rem; font-weight: 900; color: var(--am-primary); line-height: 1; margin: 10px 0; }
.am-end-detail { font-size: .85rem; color: rgba(255, 255, 255, .65); margin-bottom: 16px; }
.am-modal-actions { display: flex; gap: 10px; justify-content: center; }
.am-end-note { font-size: .78rem; color: rgba(255, 255, 255, .55); margin-top: 12px; margin-bottom: 0; }

/* Aide / regles */
.am-help-card { max-width: 560px; text-align: left; position: relative; }
.am-help-card > .am-modal-icon,
.am-help-card > h2 { text-align: center; }
.am-help-card > p.text-muted { text-align: center; }
.am-help-close {
    position: absolute; top: 14px; right: 16px;
    background: transparent; border: none; color: rgba(255, 255, 255, .6);
    font-size: 1.1rem; cursor: pointer;
}
.am-help-close:hover { color: #fff; }
.am-help-list { list-style: none; padding: 0; margin: 18px 0 6px; }
.am-help-list li { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; font-size: .88rem; color: rgba(255, 255, 255, .8); }
.am-help-list li b { color: #fff; }
.am-help-ic {
    flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .9rem;
}

@media (max-width: 800px) {
    .am-board { grid-template-columns: 1fr; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .am-game { padding: 8px; font-size: 13px; }

    .am-topbar {
        justify-content: center;
        padding: 10px;
        gap: 8px;
    }
    .am-logo { flex: 0 0 100%; justify-content: center; margin-bottom: 4px; }
    .am-kpi {
        border-left: none;
        padding: 2px 8px;
        align-items: center;
    }
    .am-actions {
        margin-left: 0;
        flex: 0 0 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .am-actions .am-btn span { display: none; }
    .am-actions .am-btn { padding: 8px 10px; }

    .am-branch, .am-lever, .am-panel { padding: 10px 12px; }

    .am-balance { flex-wrap: wrap; }
    .am-gauge-arc { width: 110px; height: 56px; }
    .am-gauge-needle { height: 48px; }

    .am-chart-wrap .am-chart { height: 180px; }

    .am-modal-card { padding: 22px 18px; }
    .am-end-score { font-size: 2.4rem; }
    .am-modal-actions { flex-wrap: wrap; }
}
