/* ── Design tokens from agenda21 theme.json ───────────────────────── */
.a21-emg {
    --a21-green:      #85ad69;
    --a21-blue:       #5c6a99;
    --a21-white:      #ffffff;
    --a21-text:       #2d3a2d;
    --a21-bg:         #f4f7f0;
    --a21-border:     #d0dbc8;

    --a21-red:        #c0392b;
    --a21-yellow:     #e67e22;
    --a21-tile-bg:    #ffffff;
    --a21-tile-hover: #eef4e8;

    font-family: inherit;
    max-width: 780px;
    margin: 0 auto;
    color: var(--a21-text);
}

/* ── Intro overlay ─────────────────────────────────────────────────── */
.a21-emg__intro-overlay {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 1rem 0.5rem;
}

.a21-emg__intro-dialog {
    background: var(--a21-white);
    border: 1px solid var(--a21-border);
    border-radius: 12px;
    max-width: 480px;
    width: 100%;
    padding: 2rem 1.5rem 1.5rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    text-align: center;
}

.a21-emg__intro-slide { display: none; }
.a21-emg__intro-slide.active { display: block; }

.a21-emg__intro-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.a21-emg__intro-dialog h2 {
    font-size: 1.2rem;
    color: var(--a21-green);
    margin: 0 0 0.75rem;
}

.a21-emg__intro-dialog p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

.a21-emg__intro-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    gap: 0.5rem;
}

.a21-emg__intro-dots {
    display: flex;
    gap: 6px;
}

.a21-emg__intro-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--a21-border);
    transition: background 0.2s;
}

.a21-emg__intro-dots span.active { background: var(--a21-green); }

.a21-emg__intro-skip {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}

.a21-emg__intro-next {
    background: var(--a21-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.a21-emg__intro-next:hover { background: #6e9358; }

/* ── Header ────────────────────────────────────────────────────────── */
.a21-emg__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.a21-emg__scenarios {
    display: flex;
    gap: 0.4rem;
}

.a21-emg__scenario-btn {
    background: var(--a21-white);
    border: 2px solid var(--a21-border);
    border-radius: 8px;
    padding: 0.35rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.a21-emg__scenario-btn.active,
.a21-emg__scenario-btn:hover {
    border-color: var(--a21-green);
    background: var(--a21-tile-hover);
}

.a21-emg__clock {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--a21-blue);
    letter-spacing: 1px;
}

/* ── Gauge row ─────────────────────────────────────────────────────── */
.a21-emg__gauge-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.a21-emg__gauge-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

.a21-emg__gauge-svg {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

.a21-emg__gauge-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #888;
    padding: 0 4px;
    margin-top: -6px;
}

.a21-emg__storage-bars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 130px;
}

.a21-emg__storage-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 6px;
}

.a21-emg__storage-label {
    font-size: 0.78rem;
    grid-column: 1;
}

.a21-emg__bar-pct {
    font-size: 0.78rem;
    font-weight: 700;
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    color: var(--a21-blue);
}

.a21-emg__bar-track {
    position: relative;
    height: 10px;
    background: var(--a21-border);
    border-radius: 5px;
    overflow: visible;
    grid-column: 1;
}

.a21-emg__bar-fill {
    height: 100%;
    background: var(--a21-green);
    border-radius: 5px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 0%;
}

.a21-emg__bar-fill--low {
    background: var(--a21-red);
}

.a21-emg__bar-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: #333;
    border-radius: 1px;
    pointer-events: none;
}

.a21-emg__bar-marker::after {
    content: '';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
}

/* ── Chart ─────────────────────────────────────────────────────────── */
.a21-emg__chart-wrap {
    height: 160px;
    margin-bottom: 0.75rem;
    background: var(--a21-white);
    border: 1px solid var(--a21-border);
    border-radius: 8px;
    padding: 0.5rem;
}

/* ── Controls ──────────────────────────────────────────────────────── */
.a21-emg__controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

@media (min-width: 500px) {
    .a21-emg__controls { grid-template-columns: repeat(4, 1fr); }
}

.a21-emg__tile {
    background: var(--a21-tile-bg);
    border: 1px solid var(--a21-border);
    border-radius: 10px;
    padding: 0.65rem 0.5rem;
    text-align: center;
    transition: border-color 0.2s;
}

.a21-emg__tile-icon { font-size: 1.5rem; }

.a21-emg__tile-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--a21-blue);
    margin: 0.2rem 0 0.4rem;
    line-height: 1.2;
}

.a21-emg__tile-modes {
    display: flex;
    gap: 3px;
    justify-content: center;
    flex-wrap: wrap;
}

.a21-emg__mode-btn {
    background: var(--a21-bg);
    border: 1px solid var(--a21-border);
    border-radius: 5px;
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.a21-emg__mode-btn.active {
    background: var(--a21-green);
    border-color: var(--a21-green);
    color: #fff;
    font-weight: 700;
}

.a21-emg__mode-btn:hover:not(.active) {
    background: var(--a21-tile-hover);
    border-color: var(--a21-green);
}

/* ── Help text ─────────────────────────────────────────────────────── */
.a21-emg__help-text {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
    transition: background 0.3s;
}

.a21-emg__help-text--ok       { background: #eef6e8; color: #3a6b2a; }
.a21-emg__help-text--info     { background: #fff8e1; color: #7a5c00; }
.a21-emg__help-text--tip      { background: #e8f0fb; color: #2a3f7a; }
.a21-emg__help-text--warn     { background: #fff0e0; color: #a04000; }
.a21-emg__help-text--critical { background: #fde8e8; color: #8b0000; animation: a21-pulse 0.5s ease-in-out infinite alternate; }

/* ── Brownout warning ──────────────────────────────────────────────── */
.a21-emg__brownout-warning {
    background: var(--a21-red);
    color: #fff;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-weight: 700;
    text-align: center;
    animation: a21-pulse 0.6s ease-in-out infinite alternate;
    margin-bottom: 0.75rem;
}

@keyframes a21-pulse {
    from { opacity: 1; }
    to   { opacity: 0.7; }
}

/* ── Details ───────────────────────────────────────────────────────── */
.a21-emg__details {
    border: 1px solid var(--a21-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.a21-emg__details summary {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--a21-blue);
    background: var(--a21-bg);
    list-style: none;
}

.a21-emg__details summary::-webkit-details-marker { display: none; }
.a21-emg__details summary::before { content: '▶ '; font-size: 0.7rem; }
.a21-emg__details[open] summary::before { content: '▼ '; }

.a21-emg__details-content {
    padding: 0.75rem 1rem;
    background: var(--a21-white);
}

.a21-emg__details-content h3 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem;
    color: var(--a21-green);
}

.a21-emg__details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.a21-emg__details-table th,
.a21-emg__details-table td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--a21-border);
    text-align: left;
    vertical-align: top;
}

.a21-emg__details-table th {
    font-weight: 700;
    color: var(--a21-blue);
}

.a21-emg__details-note {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* ── Dev config panel ──────────────────────────────────────────────── */
.a21-emg__dev-panel {
    position: relative;
    margin-top: 0.75rem;
}

.a21-emg__dev-panel-inner {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
}

.a21-emg__dev-panel-inner h3 {
    margin: 0 0 0.25rem;
    color: #cba6f7;
    font-size: 1rem;
}

.a21-emg__dev-hint {
    color: #6c7086;
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
}

.a21-emg__dev-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.a21-emg__dev-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.a21-emg__dev-field label {
    font-weight: 600;
    color: #89dceb;
    font-size: 0.78rem;
}

.a21-emg__dev-field input {
    background: #313244;
    border: 1px solid #45475a;
    color: #cdd6f4;
    border-radius: 5px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    width: 100%;
}

.a21-emg__dev-hint-inline {
    color: #6c7086;
    font-size: 0.72rem;
}

.a21-emg__dev-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.a21-emg__dev-actions button {
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 600;
}

.a21-emg__dev-apply  { background: #a6e3a1; color: #1e1e2e; }
.a21-emg__dev-reset  { background: #f9e2af; color: #1e1e2e; }
.a21-emg__dev-close  { background: #45475a; color: #cdd6f4; }

/* ── End screen overlay ────────────────────────────────────────────── */
.a21-emg__game { position: relative; }

.a21-emg__end {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
}
.a21-emg__end[hidden] { display: none; }

/* ── Score breakdown table ─────────────────────────────────────────── */
.a21-emg__score-breakdown {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.75rem 0;
    text-align: left;
}
.a21-emg__score-breakdown td {
    padding: 0.25rem 0.4rem;
    vertical-align: middle;
}
.a21-emg__score-breakdown td:first-child { width: 38%; white-space: nowrap; }
.a21-emg__score-breakdown td:last-child  { width: 3rem; text-align: right; color: #555; white-space: nowrap; }

.a21-emg__score-bar {
    background: #e8ede4;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
}
.a21-emg__score-bar-fill {
    height: 100%;
    background: var(--a21-green);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.a21-emg__end-total {
    font-size: 1rem;
    margin: 0.5rem 0;
    color: var(--a21-text);
}
.a21-emg__end-co2 {
    font-size: 0.85rem;
    color: #666;
    margin: 0.5rem 0 0.75rem;
}

/* ── End screen card ───────────────────────────────────────────────── */
.a21-emg__end-card {
    background: var(--a21-white);
    border: 1px solid var(--a21-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.a21-emg__end-card h2 {
    margin: 0 0 1rem;
    color: var(--a21-green);
}

.a21-emg__end-score {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    background: var(--a21-bg);
}

.a21-emg__end-pct {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.grade-great .a21-emg__end-pct { color: var(--a21-green); }
.grade-good  .a21-emg__end-pct { color: var(--a21-blue); }
.grade-ok    .a21-emg__end-pct { color: var(--a21-yellow); }

.a21-emg__end-label { font-size: 0.85rem; color: #888; }

.a21-emg__end-grade {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.a21-emg__end-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.a21-emg__end-stats > div {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.a21-emg__end-stats span {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--a21-blue);
}

.a21-emg__end-stats small {
    font-size: 0.78rem;
    color: #888;
}

.stat-good { color: var(--a21-green) !important; }
.stat-ok   { color: var(--a21-yellow) !important; }
.stat-bad  { color: var(--a21-red) !important; }

.a21-emg__commute-note {
    background: #fff8e1;
    border-left: 3px solid var(--a21-yellow);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    text-align: left;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.a21-emg__commute-note strong { display: block; margin-bottom: 0.3rem; }

.a21-emg__wind-note {
    background: #eef4fb;
    border-left: 3px solid var(--a21-blue);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}
.a21-emg__wind-note strong { display: block; margin-bottom: 0.3rem; }
.a21-emg__wind-note p { margin: 0; line-height: 1.5; }

.a21-emg__winter-note {
    background: #eef4fb;
    border-left: 3px solid var(--a21-blue);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    text-align: left;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.a21-emg__winter-note strong { display: block; margin-bottom: 0.3rem; }

.a21-emg__restart-btn {
    background: var(--a21-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.a21-emg__restart-btn:hover { background: #6e9358; }

.a21-emg__end-card--gameover h2 {
    color: var(--a21-red);
}
.a21-emg__gameover-time {
    font-size: 1rem;
    margin: 0.25rem 0 1rem;
    color: var(--a21-text);
}
.a21-emg__gameover-tip {
    background: #fff8e1;
    border-left: 3px solid var(--a21-yellow);
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin: 0.75rem 0;
    text-align: left;
}

/* ── Start button overlay (sits on top of the gauge) ──────────────── */
.a21-emg__start-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(244, 247, 240, 0.75);
    border-radius: 8px;
    z-index: 10;
}
.a21-emg__start-overlay[hidden] { display: none; }

.a21-emg__start-btn {
    background: var(--a21-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.1s;
}
.a21-emg__start-btn:hover  { background: #6e9358; }
.a21-emg__start-btn:active { transform: scale(0.97); }
