/* ═══════════════════════════════════════════════════════════════
   WORLD CONQUEST — Imperial Cartography Design System
   A luxury war room aesthetic: brass, parchment, & military precision
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=&display=swap');

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

:root {
    /* ── Core Palette ── */
    --navy-deep: #070d1a;
    --navy: #0c1629;
    --navy-mid: #121f3a;
    --navy-surface: #182748;
    --navy-light: #1e3258;

    /* ── Brass & Gold ── */
    --brass: #c9a84c;
    --brass-light: #e4cc7a;
    --brass-dark: #8a6f2e;
    --brass-glow: rgba(201, 168, 76, 0.25);
    --brass-subtle: rgba(201, 168, 76, 0.08);

    /* ── Parchment ── */
    --parchment: #f5f0e8;
    --parchment-dim: #d4c9b8;
    --parchment-muted: #9a8e7a;

    /* ── Signal Colors ── */
    --crimson: #9b2335;
    --crimson-light: #c43e52;
    --crimson-glow: rgba(155, 35, 53, 0.3);
    --olive: #4a6741;
    --olive-light: #6b9460;
    --olive-glow: rgba(74, 103, 65, 0.25);
    --azure: #3a7cc8;
    --azure-light: #5a9ce8;
    --azure-glow: rgba(58, 124, 200, 0.25);

    /* ── Text ── */
    --text-primary: #e8e2d6;
    --text-secondary: #a89e8c;
    --text-muted: #6b6155;
    --text-inverse: #0c1629;

    /* ── Surfaces ── */
    --border: rgba(201, 168, 76, 0.12);
    --border-strong: rgba(201, 168, 76, 0.25);
    --glass: rgba(12, 22, 41, 0.92);
    --glass-light: rgba(18, 31, 58, 0.88);

    /* ── Shadows ── */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-brass: 0 0 20px rgba(201, 168, 76, 0.15);

    /* ── Typography ── */
    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Outfit', 'Segoe UI', sans-serif;

    /* ── Spacing ── */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

html, body {
    width: 100%; height: 100%;
    overflow-x: hidden;
    background: var(--navy-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* The guide, breadcrumb and h1 live below the map: with `overflow: hidden`
   they could only be reached with a programmatic scrollTo. Lock again
   while a campaign runs. */
body {
    overflow-y: auto;
}

body:has(#gameScreen:not(.hidden)) {
    overflow: hidden;
}

.hidden { display: none !important; }

/* ── Selection Styling ── */
::selection {
    background: var(--brass);
    color: var(--navy-deep);
}

/* ═══════════════════════════════════════════════════════════════
   START SCREEN
   ═══════════════════════════════════════════════════════════════ */

.start-screen {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--navy-deep);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    /* Subtle radial glow */
    background-image:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(201, 168, 76, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(58, 124, 200, 0.03) 0%, transparent 50%);
}

.start-content {
    background: var(--navy);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 56px 48px;
    max-width: 920px; width: 95%;
    max-height: 90vh; overflow-y: auto;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.03);
    /* Top brass accent line */
    &::before {
        content: '';
        position: absolute; top: 0; left: 20%; right: 20%;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--brass), transparent);
        border-radius: 2px;
    }
}

.game-title {
    font-family: var(--font-display);
    font-size: 4rem; font-weight: 700;
    color: var(--parchment);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 4px;
    text-shadow: 0 2px 20px rgba(201, 168, 76, 0.2);
    line-height: 1.1;
    animation: titleReveal 0.8s ease-out;
}
@keyframes titleReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
        letter-spacing: 8px;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 3px;
    }
}

.game-subtitle {
    font-family: var(--font-body);
    color: var(--brass);
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 40px;
    animation: subtitleReveal 0.8s ease-out 0.2s both;
}
@keyframes subtitleReveal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Section Headers ── */
.selection-section { margin-bottom: 32px; }
.selection-section h2 {
    font-family: var(--font-display);
    color: var(--brass);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
    &::after {
        content: '';
        position: absolute; bottom: -6px; left: 0; right: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--brass-dark), transparent);
    }
}

/* ── Era Buttons ── */
.era-buttons { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

.era-btn {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 36px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    min-width: 220px;
    position: relative;
    overflow: hidden;
    &::before {
        content: '';
        position: absolute; inset: 0;
        background: linear-gradient(135deg, rgba(201, 168, 76, 0.06) 0%, transparent 50%);
        opacity: 0;
        transition: opacity 0.3s;
    }
    &::after {
        content: '';
        position: absolute; bottom: 0; left: 20%; right: 20%;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--brass), transparent);
        opacity: 0;
        transition: opacity 0.3s;
    }
    &:hover {
        border-color: var(--brass);
        transform: translateY(-4px);
        box-shadow: var(--shadow-brass);
        &::before { opacity: 1; }
        &::after { opacity: 1; }
    }
    &.selected {
        border-color: var(--brass);
        background: var(--navy-surface);
        box-shadow: var(--shadow-brass), inset 0 0 30px rgba(201, 168, 76, 0.05);
        &::after { opacity: 1; }
    }
}

.era-icon { font-size: 2.4rem; margin-bottom: 10px; }
.era-name {
    font-family: var(--font-display);
    font-size: 1.3rem; font-weight: 700;
    color: var(--parchment);
}
.era-year {
    color: var(--brass);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-top: 4px;
}
.era-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 6px;
}

/* ── Country Grid ── */
.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.country-card {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
    &::before {
        content: '';
        position: absolute; inset: 0;
        background: radial-gradient(circle at 50% 120%, rgba(201, 168, 76, 0.08) 0%, transparent 60%);
        opacity: 0;
        transition: opacity 0.3s;
    }
    &:hover {
        border-color: var(--azure);
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
        &::before { opacity: 1; }
    }
    &.selected {
        border-color: var(--brass);
        background: var(--navy-surface);
        box-shadow: inset 0 0 24px rgba(201, 168, 76, 0.08), 0 0 16px rgba(201, 168, 76, 0.1);
    }
}

.country-flag {
    width: 42px; height: 42px;
    border-radius: 6px;
    margin: 0 auto 8px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    /* Flag stripes */
    &::after {
        content: '';
        position: absolute;
        inset: 55% 0 0 0;
        background: rgba(255, 255, 255, 0.22);
        border-top: 1px solid rgba(0, 0, 0, 0.25);
    }
    &::before {
        content: '';
        position: absolute;
        top: 0; left: 0;
        width: 45%; height: 50%;
        background: rgba(0, 0, 0, 0.28);
        z-index: 1;
    }
}
.country-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}
.country-leader {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 300;
    margin-top: 2px;
}
.country-provinces {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 300;
}

/* ── Difficulty Buttons ── */
.difficulty-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.diff-btn {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    min-width: 140px;
    position: relative;
    overflow: hidden;
    &::after {
        content: '';
        position: absolute; bottom: 0; left: 20%; right: 20%;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--azure), transparent);
        opacity: 0;
        transition: opacity 0.3s;
    }
    &:hover {
        border-color: var(--azure);
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.4);
        &::after { opacity: 1; }
    }
    &.selected {
        border-color: var(--brass);
        background: var(--navy-surface);
        &::after {
            background: linear-gradient(90deg, transparent, var(--brass), transparent);
            opacity: 1;
        }
    }
}
.diff-name {
    font-family: var(--font-display);
    font-size: 1.1rem; font-weight: 700;
}
.diff-desc {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 300;
}

/* ── Buttons ── */
.btn-primary {
    background: linear-gradient(135deg, var(--brass) 0%, var(--brass-dark) 100%);
    color: var(--navy-deep);
    border: none;
    padding: 16px 40px;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 24px;
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.25);
    &:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 28px rgba(201, 168, 76, 0.35);
        background: linear-gradient(135deg, var(--brass-light) 0%, var(--brass) 100%);
    }
    &:active { transform: translateY(-1px); }
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.25s;
    margin-top: 12px;
    letter-spacing: 0.5px;
    &:hover {
        background: var(--navy-mid);
        color: var(--text-primary);
        border-color: var(--border-strong);
    }
}

.start-btn {
    font-size: 1.2rem;
    padding: 16px 48px;
    display: block;
    width: 100%;
    margin-top: 24px;
}
.back-btn { display: block; margin-top: 16px; }

/* ═══════════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════════ */

.game-screen {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column;
    background: var(--navy-deep);
    z-index: 50;
    overflow: hidden;
}
.game-screen.hidden { display: none !important; }
.game-screen:not(.hidden) { display: flex !important; }

/* ── Top Bar ── */
.top-bar {
    background: var(--navy);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    z-index: 100;
    height: 52px; min-height: 52px; flex-shrink: 0;
    /* Inner glow */
    box-shadow: inset 0 -1px 0 rgba(201, 168, 76, 0.05);
}

.top-stats { display: flex; gap: 20px; align-items: center; }

.stat-item {
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    &:hover { background: rgba(201, 168, 76, 0.05); }
}

.stat-emoji {
    font-size: 1.2rem;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(201, 168, 76, 0.2));
}
.stat-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.stat-label-text {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}
.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--parchment);
}
.stat-rate {
    color: var(--olive-light);
    font-size: 0.62rem;
    font-weight: 400;
}

.top-date {
    display: flex; align-items: center; gap: 8px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    margin: 0 12px;
}
.date-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 300;
}
.date-year {
    font-family: var(--font-display);
    color: var(--brass);
    font-weight: 700;
    font-size: 0.95rem;
}

.top-buttons { display: flex; align-items: center; gap: 8px; }

.top-btn {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    letter-spacing: 0.3px;
    &:hover {
        background: var(--navy-surface);
        border-color: var(--brass);
        color: var(--parchment);
    }
}

.pause-btn {
    background: rgba(155, 35, 53, 0.12);
    border-color: rgba(155, 35, 53, 0.25);
    color: var(--crimson-light);
    &:hover {
        background: rgba(155, 35, 53, 0.2);
        border-color: var(--crimson);
    }
}

.speed-control {
    display: flex; align-items: center; gap: 6px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.speed-label {
    color: var(--text-muted);
    font-size: 0.7rem;
}

#speedSlider {
    width: 56px; height: 3px;
    -webkit-appearance: none;
    background: rgba(201, 168, 76, 0.15);
    border-radius: 2px; outline: none;
    &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 14px; height: 14px;
        border-radius: 50%;
        background: var(--brass);
        cursor: pointer;
        box-shadow: 0 0 8px rgba(201, 168, 76, 0.3);
        transition: box-shadow 0.2s;
        &:hover { box-shadow: 0 0 14px rgba(201, 168, 76, 0.5); }
    }
}
#speedValue {
    color: var(--brass);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 22px;
}

/* ── Map Container ── */
.map-container {
    flex: 1; position: relative; overflow: hidden;
    min-height: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(58, 124, 200, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(201, 168, 76, 0.03) 0%, transparent 50%),
        var(--navy-deep);
}

#gameCanvas {
    display: block;
    width: 100%; height: 100%;
    max-height: none;
    cursor: crosshair;
    image-rendering: auto;
}

/* ═══════════════════════════════════════════════════════════════
   BOTTOM PANEL — Province / Army Info
   ═══════════════════════════════════════════════════════════════ */

/* ── Country Profile Card (bottom panel) ── */
.country-profile {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.06) 0%, var(--navy-mid) 60%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 14px;
}
.country-profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.country-profile-flag {
    width: 44px;
    height: 30px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.15);
    position: relative;
    overflow: hidden;
    /* Double horizontal stripe so it reads as a flag */
    &::after {
        content: '';
        position: absolute;
        inset: 50% 0 0 0;
        background: rgba(255, 255, 255, 0.22);
        border-top: 1px solid rgba(0, 0, 0, 0.25);
    }
    /* Cantón (square) in the corner */
    &::before {
        content: '';
        position: absolute;
        top: 0; left: 0;
        width: 40%; height: 50%;
        background: rgba(0, 0, 0, 0.25);
        z-index: 1;
    }
}
.country-profile-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--parchment);
    line-height: 1.1;
}
.country-profile-rank {
    font-size: 0.72rem;
    font-weight: 500;
    margin-top: 2px;
}
.country-profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   BOTTOM PANEL — Province / Army Info
   ═══════════════════════════════════════════════════════════════ */

.bottom-panel {
    position: absolute; left: 0; bottom: 0;
    width: 500px; height: 55vh; min-height: 360px;
    background: var(--glass);
    border-right: 1px solid var(--border);
    border-top: 1px solid var(--border-strong);
    border-radius: 0 var(--radius-lg) 0 0;
    overflow-y: auto; z-index: 60;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    /* Left brass accent */
    &::before {
        content: '';
        position: absolute; top: 0; left: 0; bottom: 0;
        width: 2px;
        background: linear-gradient(180deg, var(--brass), transparent 80%);
    }
}

#panelContent { padding: 20px; }

/* ── Empty State ── */
.panel-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; min-height: 220px;
    color: var(--text-muted); text-align: center;
}
.panel-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.3;
    filter: grayscale(0.5);
}
.panel-empty-text {
    font-family: var(--font-display);
    font-size: 1rem;
    font-style: italic;
}
.panel-hint {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 10px;
    font-weight: 300;
}

/* ── Province Header ── */
.prov-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.prov-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--brass);
    letter-spacing: 0.5px;
}
.prov-owner {
    font-size: 0.82rem;
    font-weight: 500;
    margin-top: 3px;
}
.prov-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Province Stats Grid ── */
.prov-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.prov-stat {
    background: var(--navy-mid);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.prov-stat-label {
    display: block;
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 3px;
    font-weight: 500;
}
.prov-stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}

/* ── Detail Rows ── */
.prov-detail {
    padding: 8px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(201, 168, 76, 0.06);
}
.prov-detail-label { color: var(--text-secondary); }
.prov-detail-value {
    font-weight: 600;
    color: var(--parchment);
}
.prov-neutral {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

/* ── Action Buttons ── */
.prov-actions { display: flex; gap: 10px; margin-top: 16px; }

.prov-btn {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    text-transform: uppercase;
}
.prov-btn-build {
    background: linear-gradient(135deg, var(--olive) 0%, #3a5a30 100%);
    color: var(--parchment);
    box-shadow: 0 2px 8px rgba(74, 103, 65, 0.3);
    &:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(74, 103, 65, 0.4); }
}
.prov-btn-army {
    background: linear-gradient(135deg, var(--azure) 0%, #2a5a9a 100%);
    color: var(--parchment);
    box-shadow: 0 2px 8px rgba(58, 124, 200, 0.3);
    &:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(58, 124, 200, 0.4); }
}
.prov-btn-back {
    background: var(--navy-mid);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    flex: 0 0 auto;
    padding: 10px 16px;
    &:hover { background: var(--navy-surface); color: var(--parchment); }
}
.prov-btn-move {
    background: linear-gradient(135deg, var(--azure) 0%, #2a5a9a 100%);
    color: var(--parchment);
    font-size: 0.78rem;
    padding: 8px 12px;
    flex: 0 0 auto;
    &:hover { transform: translateY(-1px); }
}
.prov-btn-icon { font-size: 1.1rem; }

/* ═══════════════════════════════════════════════════════════════
   BUILD PANEL
   ═══════════════════════════════════════════════════════════════ */

.build-list { display: flex; flex-direction: column; gap: 10px; }

.build-item {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    &:hover {
        border-color: var(--olive);
        background: var(--navy-surface);
        transform: translateX(4px);
    }
}
.build-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}
.build-item.built-item {
    border-color: var(--brass-dark);
    background: var(--brass-subtle);
    cursor: default;
}

.build-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.build-item-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}
.build-item-cost {
    color: var(--brass);
    font-weight: 600;
    font-size: 0.82rem;
}
.build-item-level {
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: var(--brass);
}
.build-item-desc {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 300;
}
.build-item-status {
    font-size: 0.7rem;
    margin-top: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.build-item-status.built { color: var(--olive-light); }
.build-item-status.queued { color: var(--brass); }
.build-item-status.nok { color: var(--crimson-light); }

/* ═══════════════════════════════════════════════════════════════
   ARMY PANEL
   ═══════════════════════════════════════════════════════════════ */

.section-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--brass);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.army-card {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
    &:hover { border-color: var(--azure); }
}
.army-card-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}
.army-card-size {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 300;
}
.army-card-stats {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin: 6px 0;
}
.army-stat {
    font-size: 0.7rem;
    color: var(--azure-light);
    background: rgba(58, 124, 200, 0.1);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(58, 124, 200, 0.15);
}
.army-card-actions {
    display: flex; gap: 8px;
    margin-top: 8px;
}

/* ── Selected Army Banner ── */
.army-selected-banner {
    background: linear-gradient(135deg, rgba(58, 124, 200, 0.12) 0%, rgba(201, 168, 76, 0.08) 100%);
    border: 1px solid var(--azure);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
    position: relative;
    /* Left accent */
    &::before {
        content: '';
        position: absolute; left: 0; top: 0; bottom: 0;
        width: 3px;
        background: var(--azure);
        border-radius: 3px 0 0 3px;
    }
}
.army-selected-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
}
.army-selected-stat {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
}
.army-selected-stat-label {
    display: block;
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}
.army-selected-stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--parchment);
}
.army-selected-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--azure-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.army-selected-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--parchment);
}
.army-selected-size {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 300;
}
.army-selected-exp {
    font-size: 0.75rem;
    margin-top: 3px;
    color: var(--brass);
}
.army-selected-hint {
    font-size: 0.78rem;
    margin-top: 6px;
    color: var(--azure-light);
    animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.army-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    padding: 14px 0;
    font-weight: 300;
}

/* ── Recruit List ── */
.recruit-list { display: flex; flex-direction: column; gap: 8px; }

.recruit-item {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    &:hover {
        border-color: var(--azure);
        background: var(--navy-surface);
    }
}
.recruit-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.recruit-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.recruit-item-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}
.recruit-item-strength {
    color: var(--azure-light);
    font-size: 0.75rem;
}
.recruit-item-cost {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-top: 3px;
}

/* ── Recruit Slider ── */
.recruit-slider-row {
    display: flex; align-items: center; gap: 10px;
    margin-top: 8px;
}
.recruit-slider {
    flex: 1; height: 4px;
    -webkit-appearance: none;
    background: rgba(201, 168, 76, 0.15);
    border-radius: 2px; outline: none;
    &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px; height: 16px;
        border-radius: 50%;
        background: var(--azure);
        cursor: pointer;
        box-shadow: 0 0 8px rgba(58, 124, 200, 0.3);
    }
}
.recruit-slider-val {
    color: var(--azure-light);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 48px;
    text-align: right;
}
.prov-btn-recruit {
    width: 100%; margin-top: 8px; padding: 10px;
    background: linear-gradient(135deg, var(--azure) 0%, #2a5a9a 100%);
    color: var(--parchment); border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(58, 124, 200, 0.3);
    &:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(58, 124, 200, 0.4); }
}

.prov-btn-upgrade {
    width: 100%; margin-top: 6px; padding: 8px 10px;
    background: linear-gradient(135deg, var(--brass) 0%, var(--brass-dark) 100%);
    color: var(--navy-deep); border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    &:hover { transform: translateY(-1px); }
}

/* ── Recruit Size Controls ── */
.recruit-btn-row {
    display: flex; align-items: center; gap: 6px;
    margin: 8px 0;
}
.recruit-qty-btn {
    background: var(--navy-surface);
    border: 1px solid var(--border);
    color: var(--parchment);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 38px;
    text-align: center;
    &:hover {
        background: var(--azure);
        border-color: var(--azure);
        color: var(--navy-deep);
    }
}
.recruit-size-display {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 55px;
    text-align: center;
    color: var(--parchment);
}

/* ── Recruit Cost Display ── */
.recruit-cost-display {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-top: 4px;
    margin-bottom: 6px;
    font-weight: 300;
}

/* ── Army Extras ── */
.army-card-status {
    color: var(--brass);
    font-size: 0.75rem;
    font-style: italic;
    margin-top: 4px;
}
.army-card-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */

.modal {
    position: fixed; inset: 0;
    background: rgba(7, 13, 26, 0.85);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.modal-content {
    background: var(--navy);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 36px;
    max-width: 720px; width: 92%;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg), var(--shadow-brass);
    /* Top brass accent */
    &::before {
        content: '';
        position: absolute; top: 0; left: 15%; right: 15%;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--brass), transparent);
        border-radius: 2px;
    }
}
.modal-close {
    position: absolute; top: 14px; right: 18px;
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.8rem; cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    &:hover { color: var(--parchment); }
}
.modal h2 {
    font-family: var(--font-display);
    color: var(--brass);
    margin-bottom: 20px;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

/* ── Economy Modal ── */
.economy-section {
    background: var(--navy-mid);
    padding: 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.economy-section h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: var(--parchment);
}
.economy-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 12px;
    font-weight: 300;
}

.slider-group { margin-bottom: 12px; }
.slider-group label {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.slider-group input[type="range"] {
    width: 100%; height: 5px;
    -webkit-appearance: none;
    background: rgba(201, 168, 76, 0.15);
    border-radius: 3px; outline: none;
    &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 18px; height: 18px;
        border-radius: 50%;
        background: var(--brass);
        cursor: pointer;
        box-shadow: 0 0 10px rgba(201, 168, 76, 0.3);
    }
}
.economy-stats {
    display: flex; flex-direction: column; gap: 4px;
    & span {
        font-size: 0.8rem;
        color: var(--text-secondary);
        font-weight: 300;
    }
}

/* ── Game Over ── */
.game-over-stat {
    display: flex; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    & span:last-child {
        font-family: var(--font-display);
        font-weight: 700;
        color: var(--brass);
    }
}
.game-over-buttons {
    display: flex; gap: 12px;
    margin-top: 20px;
    & .btn-primary { flex: 1; margin-top: 0; }
    & .btn-secondary { flex: 1; margin-top: 0; }
}

/* ── Tech Branch Tabs ── */
.tech-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}
.tech-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.tech-tab-icon { font-size: 1.1rem; }
.tech-tab:hover { border-color: var(--border-strong); color: var(--parchment); }
.tech-tab-military.selected {
    background: linear-gradient(135deg, rgba(155, 35, 53, 0.4) 0%, rgba(90, 20, 30, 0.5) 100%);
    border-color: var(--crimson);
    color: #f3c2ca;
    box-shadow: 0 0 18px rgba(155, 35, 53, 0.3);
}
.tech-tab-economic.selected {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.35) 0%, rgba(130, 105, 40, 0.4) 100%);
    border-color: var(--brass);
    color: #f3e2b0;
    box-shadow: 0 0 18px rgba(201, 168, 76, 0.3);
}
.tech-tab-politic.selected {
    background: linear-gradient(135deg, rgba(58, 124, 200, 0.35) 0%, rgba(30, 70, 120, 0.45) 100%);
    border-color: var(--azure);
    color: #bcd6f0;
    box-shadow: 0 0 18px rgba(58, 124, 200, 0.3);
}

/* Branch tinted backgrounds */
.tech-tree-military {
    background: linear-gradient(180deg, rgba(155, 35, 53, 0.10) 0%, rgba(155, 35, 53, 0.03) 100%);
    border: 1px solid rgba(155, 35, 53, 0.25);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.tech-tree-economic {
    background: linear-gradient(180deg, rgba(201, 168, 76, 0.12) 0%, rgba(201, 168, 76, 0.03) 100%);
    border: 1px solid rgba(201, 168, 76, 0.25);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.tech-tree-politic {
    background: linear-gradient(180deg, rgba(58, 124, 200, 0.12) 0%, rgba(58, 124, 200, 0.03) 100%);
    border: 1px solid rgba(58, 124, 200, 0.3);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.tech-empty-branch {
    color: var(--text-muted);
    text-align: center;
    padding: 30px;
    font-style: italic;
    font-weight: 300;
}

/* Tiered tree layout */
.tech-tier {
    display: flex;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
    /* Vertical trunk line */
    position: relative;
    &::before {
        content: '';
        position: absolute;
        left: 22px;
        top: -12px;
        bottom: -12px;
        width: 1px;
        background: repeating-linear-gradient(180deg, var(--brass-dark) 0 4px, transparent 4px 8px);
        opacity: 0.3;
    }
    &:first-of-type::before { top: 0; }
    &:last-of-type::before { bottom: 5px; }
}
.tech-tier-label {
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-secondary);
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    letter-spacing: 1px;
    z-index: 1;
}
.tech-tier-nodes {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.tech-node {
    background: var(--navy);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 12px 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin-left: 18px;
    overflow: hidden;
    /* Connector stub from trunk to node */
    &::before {
        content: '';
        position: absolute;
        left: -18px;
        top: 50%;
        width: 18px;
        height: 1px;
        background: repeating-linear-gradient(90deg, var(--brass-dark) 0 3px, transparent 3px 6px);
        opacity: 0.35;
    }
    /* Status chip */
    .tech-node-status {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.72rem;
        border-radius: 50%;
        border: 1px solid currentColor;
    }
    &[data-state] .tech-node-status { color: var(--text-muted); }
    .tech-node-status[data-state="researched"] { color: var(--olive-light); background: var(--olive-glow); }
    .tech-node-status[data-state="researching"] { color: var(--brass); background: var(--brass-subtle); animation: dotPulse 1.5s infinite; }
    .tech-node-status[data-state="available"] { color: var(--azure-light); background: var(--azure-glow); }
    .tech-node-status[data-state="locked"] { color: var(--text-muted); }
    &:hover {
        border-color: var(--azure);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    &.researched {
        border-color: var(--olive);
        background: linear-gradient(135deg, rgba(74, 103, 65, 0.14) 0%, rgba(74, 103, 65, 0.05) 100%);
        .tech-name { color: var(--olive-light); }
    }
    &.researching {
        border-color: var(--brass);
        background: linear-gradient(135deg, rgba(201, 168, 76, 0.12) 0%, rgba(201, 168, 76, 0.04) 100%);
        animation: techGlow 2.5s ease-in-out infinite;
    }
    &.available {
        border-color: rgba(58, 124, 200, 0.5);
        background: linear-gradient(135deg, rgba(58, 124, 200, 0.08) 0%, transparent 100%);
        .tech-name::after {
            content: '';
        }
    }
    &.locked {
        opacity: 0.4;
        cursor: not-allowed;
        filter: grayscale(0.6);
    }
}
.tech-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--parchment);
    padding-right: 26px;
    line-height: 1.2;
}
.tech-cost {
    color: var(--brass);
    font-size: 0.62rem;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.tech-slots { display: flex; gap: 16px; margin-bottom: 20px; }
.tech-slot {
    flex: 1;
    background: var(--navy-mid);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.tech-slot-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-weight: 500;
}
.tech-slot-content {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--parchment);
}
.progress-bar {
    height: 4px;
    background: rgba(201, 168, 76, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brass-dark), var(--brass));
    border-radius: 2px;
    transition: width 0.4s ease;
}

.tech-tree {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tech-node-progress {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    & .progress-bar { flex: 1; margin-top: 0; }
}
.tech-desc {
    color: var(--text-secondary);
    font-size: 0.68rem;
    margin-top: 4px;
    font-weight: 300;
    line-height: 1.3;
}
.tech-time {
    color: var(--brass);
    font-size: 0.66rem;
    font-weight: 600;
    white-space: nowrap;
}
.tech-prereqs {
    color: var(--crimson-light);
    font-size: 0.62rem;
    margin-top: 4px;
    font-style: italic;
}

@keyframes techGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(201, 168, 76, 0); }
    50% { box-shadow: 0 0 16px rgba(201, 168, 76, 0.25); }
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* ── Score List ── */
.score-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.score-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    &:hover {
        background: var(--navy-surface);
        border-color: var(--border-strong);
    }
}
.score-rank {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    min-width: 32px;
    text-align: center;
    color: var(--brass);
}
.score-color { flex-shrink: 0; }
.score-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    flex: 1;
    color: var(--parchment);
}
.score-provs {
    color: var(--text-secondary);
    font-size: 0.8rem;
    min-width: 95px;
    text-align: right;
}
.score-army {
    color: var(--azure-light);
    font-size: 0.8rem;
    min-width: 85px;
    text-align: right;
}
.score-score {
    color: var(--brass);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 75px;
    text-align: right;
}

/* ── Espionage Modal ── */
.espionage-modal { max-width: 640px; }
.espionage-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.espionage-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    & .espionage-flag {
        width: 30px;
        height: 20px;
        border-radius: 3px;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
    }
    & .espionage-name {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--parchment);
        flex: 1;
    }
    & .espionage-meta {
        color: var(--text-secondary);
        font-size: 0.72rem;
        font-weight: 300;
        text-align: right;
        margin-right: 6px;
    }
    & .prov-btn {
        padding: 7px 10px;
        font-size: 0.72rem;
        border-radius: var(--radius-sm);
        flex: 0 0 auto;
    }
    & .prov-btn-diplo, & .prov-btn-war, & .prov-btn-attack {
        font-family: var(--font-body);
        letter-spacing: 0.2px;
        text-transform: none;
    }
}
.espionage-row-war {
    border-color: rgba(155, 35, 53, 0.5);
    background: linear-gradient(135deg, rgba(155, 35, 53, 0.12) 0%, var(--navy-mid) 70%);
}

/* ── Diplomacy Modal ── */
.diplo-block { margin-bottom: 18px; }
.diplo-block-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.diplo-block-wars .diplo-block-title { color: var(--crimson-light); }
.diplo-block-alliances .diplo-block-title { color: var(--olive-light); }
.diplo-block-coalitions .diplo-block-title { color: var(--azure-light); }
.diplo-empty { color: var(--text-muted); font-size: 0.82rem; font-style: italic; font-weight: 300; padding: 6px 0; }
.diplo-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 6px;
    & .diplo-color {
        width: 26px;
        height: 18px;
        border-radius: 3px;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
    }
    & .diplo-name {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 0.92rem;
        color: var(--parchment);
        flex: 1;
    }
    & .diplo-sub {
        color: var(--text-secondary);
        font-size: 0.76rem;
        font-weight: 300;
        text-align: right;
    }
}
/* ═══════════════════════════════════════════════════════════════
   URGENT ALERT BANNERS (top center)
   ═══════════════════════════════════════════════════════════════ */

.alert-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 250;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 480px;
    width: 90%;
}
.alert-banner {
    background: var(--glass);
    border: 1px solid var(--crimson);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 24px rgba(155, 35, 53, 0.25);
    backdrop-filter: blur(16px);
    opacity: 0;
    transform: translateY(-30px) scale(0.96);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    &::before {
        content: '';
        position: absolute;
        inset: 0 0 auto 0;
        height: 3px;
        background: linear-gradient(90deg, transparent, var(--crimson), transparent);
    }
    & .alert-banner-title {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--crimson-light);
        letter-spacing: 1px;
        text-transform: uppercase;
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    & .alert-banner-title::before { content: '⚠'; font-size: 1.1rem; }
    & .alert-banner-text {
        color: var(--text-primary);
        font-size: 0.88rem;
        font-weight: 300;
        line-height: 1.45;
    }
}
.alert-info { border-color: var(--azure); box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 24px rgba(58, 124, 200, 0.2); }
.alert-info .alert-banner-title { color: var(--azure-light); }
.alert-alliance { border-color: var(--olive); box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 24px rgba(74, 103, 65, 0.25); }
.alert-alliance .alert-banner-title { color: var(--olive-light); }
.alert-alliance .alert-banner-title::before { content: '🤝'; }
.alert-info .alert-banner-title::before { content: 'ⓘ'; }
.alert-show { opacity: 1; transform: translateY(0) scale(1); }
.alert-hide { opacity: 0; transform: translateY(-30px) scale(0.96); }

/* ═══════════════════════════════════════════════════════════════
   INTERACTIVE EVENT MODAL (pauses the game)
   ═══════════════════════════════════════════════════════════════ */

#eventModal {
    z-index: 400;
}
.event-modal-content {
    max-width: 560px;
    text-align: center;
}
.event-modal-icon { font-size: 3rem; margin-bottom: 12px; }
.event-modal-desc {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 300;
    line-height: 1.6;
    margin: 12px 0 20px;
    white-space: pre-line;
}
.event-modal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.event-option {
    background: var(--navy-mid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    cursor: pointer;
    text-align: left;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    & .event-option-label {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 1rem;
        color: var(--brass);
        display: block;
    }
    & .event-option-effect {
        font-size: 0.78rem;
        color: var(--text-secondary);
        font-weight: 300;
        margin-top: 3px;
        display: block;
    }
    &:hover {
        border-color: var(--brass);
        background: var(--navy-surface);
        transform: translateY(-2px);
        box-shadow: var(--shadow-brass);
    }
}

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATIONS — Premium Toast System
   ═══════════════════════════════════════════════════════════════ */

.notif-container {
    position: fixed; top: 80px; right: 18px; z-index: 300;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none; max-width: 380px;
}
.notif {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 0.85rem;
    opacity: 0;
    transform: translateX(60px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    backdrop-filter: blur(16px);
    border-left: 4px solid var(--azure);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.4;
}
.notif-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(58, 124, 200, 0.15);
    color: var(--azure-light);
}
.notif-msg { flex: 1; }
.notif-show { opacity: 1; transform: translateX(0) scale(1); }
.notif-hide { opacity: 0; transform: translateX(60px) scale(0.95); }
.notif-success {
    border-left-color: var(--olive);
    & .notif-icon { background: rgba(74, 103, 65, 0.15); color: var(--olive-light); }
}
.notif-warning {
    border-left-color: var(--brass);
    & .notif-icon { background: rgba(201, 168, 76, 0.15); color: var(--brass); }
}
.notif-war {
    border-left-color: var(--crimson);
    background: rgba(155, 35, 53, 0.12);
    & .notif-icon { background: rgba(155, 35, 53, 0.2); color: var(--crimson-light); }
}
.notif-info {
    border-left-color: var(--azure);
    & .notif-icon { background: rgba(58, 124, 200, 0.15); color: var(--azure-light); }
}

/* ═══════════════════════════════════════════════════════════════
   NEWS FEED — War Room Dispatch
   ═══════════════════════════════════════════════════════════════ */

.news-feed {
    position: absolute; right: 14px; bottom: 14px;
    width: 320px; max-height: 360px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    z-index: 60; overflow: hidden;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    /* Top brass accent */
    &::before {
        content: '';
        position: absolute; top: 0; left: 10%; right: 10%;
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--brass-dark), transparent);
    }
}
.news-header {
    background: var(--brass-subtle);
    padding: 12px 16px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--brass);
    border-bottom: 1px solid var(--border);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}
.news-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}
.news-item {
    padding: 8px 16px;
    display: flex; gap: 10px; align-items: flex-start;
    border-bottom: 1px solid rgba(201, 168, 76, 0.04);
    transition: all 0.2s;
    animation: newsSlideIn 0.3s ease-out;
    &:hover { background: rgba(201, 168, 76, 0.04); }
}
@keyframes newsSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.news-time {
    color: var(--text-muted);
    font-size: 0.62rem;
    white-space: nowrap;
    min-width: 34px;
    font-weight: 500;
}
.news-text {
    color: var(--text-secondary);
    line-height: 1.5;
    font-weight: 300;
    font-size: 0.78rem;
}
.news-empty {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
    font-style: italic;
    font-weight: 300;
}

.news-war_declared .news-text { color: var(--crimson-light); font-weight: 600; }
.news-war_justify .news-text { color: var(--brass); font-weight: 500; }
.news-alliance_request .news-text { color: var(--olive-light); }
.news-peace .news-text { color: var(--azure-light); }
.news-construction .news-text { color: var(--brass-light); }
.news-army .news-text { color: var(--azure-light); }
.news-capture .news-text { color: var(--crimson-light); font-weight: 600; }
.news-alliance_request .news-text { color: var(--olive-light); }
.news-peace .news-text { color: var(--azure-light); }
.news-construction .news-text { color: var(--brass-light); }
.news-army .news-text { color: var(--azure-light); }
.news-capture .news-text { color: var(--crimson-light); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   DIPLOMACY PANEL
   ═══════════════════════════════════════════════════════════════ */

.diplo-section { margin-top: 14px; }
.diplo-status {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    text-transform: uppercase;
}
.diplo-status[data-status="war"] {
    background: var(--crimson-glow);
    color: var(--crimson-light);
}
.diplo-status[data-status="alliance"] {
    background: var(--olive-glow);
    color: var(--olive-light);
}
.diplo-status[data-status="friendly"] {
    background: var(--azure-glow);
    color: var(--azure-light);
}
.diplo-status[data-status="hostile"] {
    background: rgba(201, 168, 76, 0.12);
    color: var(--brass);
}
.diplo-status[data-status="neutral"] {
    background: rgba(107, 97, 85, 0.15);
    color: var(--text-secondary);
}

.diplo-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 10px;
    font-weight: 300;
}
.diplo-progress { margin-top: 10px; }
.diplo-progress-text {
    color: var(--brass);
    font-size: 0.72rem;
    margin-top: 3px;
    display: block;
}

.prov-btn-attack {
    background: linear-gradient(135deg, var(--crimson) 0%, #7a1a2a 100%);
    color: var(--parchment);
    box-shadow: 0 2px 8px rgba(155, 35, 53, 0.3);
    &:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(155, 35, 53, 0.4); }
}
.prov-btn-peace {
    background: linear-gradient(135deg, var(--azure) 0%, #2a5a9a 100%);
    color: var(--parchment);
    &:hover { transform: translateY(-1px); }
}
.prov-btn-diplo {
    background: linear-gradient(135deg, var(--olive) 0%, #3a5a30 100%);
    color: var(--parchment);
    &:hover { transform: translateY(-1px); }
}
.prov-btn-war {
    background: linear-gradient(135deg, var(--brass) 0%, var(--brass-dark) 100%);
    color: var(--navy-deep);
    &:hover { transform: translateY(-1px); }
}
.prov-btn-war-armed {
    background: linear-gradient(135deg, var(--crimson) 0%, #7a1a2a 100%);
    color: var(--parchment);
    animation: gentlePulse 1s ease-in-out infinite;
}
.prov-btn-declare {
    background: linear-gradient(135deg, var(--crimson) 0%, #7a1a2a 100%);
    color: var(--parchment);
    flex: 1 0 100%;
    &:hover { transform: translateY(-2px); }
}

/* ── Build Queue ── */
.build-queue-item {
    background: var(--navy-mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
}
.build-queue-top {
    display: flex; justify-content: space-between;
    margin-bottom: 5px;
}
.build-queue-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--parchment);
}
.build-queue-time {
    color: var(--brass);
    font-size: 0.75rem;
}
.build-item-time {
    color: var(--text-muted);
    font-size: 0.68rem;
    margin-top: 4px;
}
.section-label { margin-top: 12px; }

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR — Brass Accents
   ═══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.12);
    border-radius: 3px;
    transition: background 0.2s;
    &:hover { background: rgba(201, 168, 76, 0.25); }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS — Micro-interactions
   ═══════════════════════════════════════════════════════════════ */

@keyframes warPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.25; }
}

@keyframes armyMove {
    from { transform: translateX(-1px); }
    to { transform: translateX(1px); }
}

.army-moving { animation: armyMove 1s ease-in-out infinite alternate; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Adaptive Layout
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
    .ad-left-fixed { display: none !important; }
}

@media (max-width: 768px) {
    .bottom-panel { width: 340px; height: 50vh; min-height: 320px; }
    .top-stats { gap: 10px; }
    .stat-emoji { display: none; }
    .country-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .game-title { font-size: 2.8rem; }
    .start-content { padding: 40px 28px; }
    .modal-content { padding: 24px; }
    .news-feed { width: 260px; max-height: 280px; }
    .notif-container { max-width: 300px; }
}

/* ═══════════════════════════════════════════════════════════════
   FULL-SCREEN SHELL — floating brand and compact HUD
   ═══════════════════════════════════════════════════════════════ */

body.wc-page .app-header { display: none !important; }
body.wc-page { padding-top: 0 !important; }

/* The game mark floats over the shell, in the top-left gutter. */
.wc-corner-logo {
    position: fixed;
    top: max(7px, env(safe-area-inset-top));
    left: max(7px, env(safe-area-inset-left));
    width: 42px;
    height: 42px;
    z-index: 120;
    display: block;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid rgba(201, 168, 76, 0.5);
    background: #0f1a2e;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.wc-corner-logo img { display: block; width: 100%; height: 100%; }
.wc-corner-logo:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(201, 168, 76, 0.25);
}
.wc-corner-logo:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* Leave room for the floating mark inside the HUD. */
.top-bar { padding-left: 58px; }

/* assets/achievements.css ships generic .stat-value rules; keep the HUD scoped. */
.top-bar .stat-value {
    font-size: 1rem;
    line-height: 1.1;
    margin-bottom: 0;
    color: var(--parchment);
}

/* The minimap canvas has no renderer in this game; keep it out of the HUD. */
.minimap {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 168px;
    height: 104px;
    z-index: 55;
    pointer-events: none;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--navy-mid);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.4));
}

/* The panel bar only exists in the compact layout. */
.panel-bar { display: none; }
.panel-date { display: none; }

/* ── Compact top bar ── */
@media (max-width: 1460px) {
    .top-bar {
        flex-wrap: wrap;
        height: auto;
        min-height: 0;
        padding: 5px 6px 5px 54px;
        gap: 3px 6px;
    }
    .top-stats {
        flex: 1 1 0;
        min-width: 0;
        gap: 2px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .top-stats::-webkit-scrollbar { display: none; }
    .stat-item { min-height: 0; padding: 1px 3px; gap: 2px; }
    .stat-emoji { display: block; font-size: 0.82rem; }
    .stat-label-text, .stat-rate { display: none; }
    .top-bar .stat-value { font-size: 0.8rem; }
    .top-date { margin: 0; padding: 2px 5px; gap: 3px; flex: 0 0 auto; }
    .date-label { display: none; }
    .date-year { font-size: 0.78rem; }
    .top-buttons {
        flex: 1 1 100%;
        order: 3;
        gap: 3px;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 1px;
    }
    .top-buttons::-webkit-scrollbar { display: none; }
    .top-btn {
        width: 38px;
        height: 38px;
        min-width: 0;
        min-height: 0;
        padding: 0;
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .top-btn-label { display: none; }
    .top-btn-icon { font-size: 0.86rem; line-height: 1; }
    .speed-control { padding: 2px 6px; gap: 4px; flex: 0 0 auto; }
    #speedSlider { width: 44px; }
    #speedValue { font-size: 0.7rem; min-width: 18px; }
    .speed-label { display: none; }
    .pause-btn { width: 38px; }
}

/* Narrow phones: the date yields to readable resource values. */
@media (max-width: 600px) {
    .top-date { display: none; }
    .top-bar .stat-value { font-size: 0.85rem; }
    .score-row { gap: 8px; padding: 10px; }
    .score-army, .score-provs { display: none; }
    .score-name { font-size: 0.82rem; }
    .tech-slots { flex-direction: column; gap: 8px; }
    .tech-slot { min-width: 0; padding: 10px; }
    .tech-tree-military, .tech-tree-economic, .tech-tree-politic { padding: 10px; }
    .tech-tabs { gap: 6px; overflow-x: auto; scrollbar-width: none; }
    .tech-tabs::-webkit-scrollbar { display: none; }
    .tech-tab { flex: 0 0 auto; padding: 9px 10px; gap: 5px; font-size: 0.78rem; }
    .tech-tab-icon { font-size: 0.95rem; }
    .tech-tier { gap: 8px; }
    .tech-tier-label { flex-basis: 30px; font-size: 0.8rem; }
    .tech-tier-nodes { grid-template-columns: 1fr; }
    .tech-node { margin-left: 12px; padding: 9px 10px; }
    .panel-date {
        display: inline;
        margin-left: auto;
        flex: 0 0 auto;
        font-family: var(--font-display);
        font-size: 0.66rem;
        letter-spacing: 0.5px;
        color: var(--text-secondary);
        white-space: nowrap;
    }
}

/* ── Phone layout: bottom sheet, compact start screen ── */
@media (max-width: 900px), (max-height: 520px) {
    .minimap { width: 84px; height: 54px; top: 6px; right: 6px; border-radius: 7px; }
    .news-feed { display: none; }

    .bottom-panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: auto;
        max-height: 38vh;
        max-height: 38dvh;
        min-height: 0;
        border-right: 0;
        border-radius: 14px 14px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        transform: translateY(calc(100% - 46px));
        transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
        z-index: 70;
    }
    .bottom-panel.is-open { transform: translateY(0); }

    .panel-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        height: 46px;
        padding: 0 8px 0 12px;
        border-bottom: 1px solid var(--border);
        background: var(--navy-mid);
        position: sticky;
        top: 0;
        z-index: 2;
        cursor: pointer;
    }
    .panel-bar-grab {
        width: 30px;
        height: 4px;
        flex: 0 0 auto;
        border-radius: 2px;
        background: rgba(201, 168, 76, 0.5);
    }
    .panel-bar-title {
        font-family: var(--font-display);
        font-size: 0.72rem;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        color: var(--brass);
    }
    .panel-toggle {
        margin-left: 8px;
        width: 32px;
        height: 32px;
        min-width: 0;
        min-height: 0;
        display: grid;
        place-items: center;
        padding: 0;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text-secondary);
        cursor: pointer;
    }
    .panel-toggle svg { transition: transform 0.2s ease; }
    .bottom-panel.is-open .panel-toggle svg { transform: rotate(180deg); }
    #panelContent { padding: 12px 14px 18px; }
    .prov-name { font-size: 1.15rem; }
    .prov-stats { gap: 6px; }
    .prov-stat { padding: 7px 9px; }

    .start-screen { align-items: stretch; padding: 0; }
    .start-screen .start-content {
        width: 100%;
        max-width: none;
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        padding: 58px 14px 28px;
        box-shadow: none;
    }
    .game-title { font-size: 2.1rem; letter-spacing: 1px; }
    .game-subtitle { font-size: 0.85rem; }
    .selection-section { margin-bottom: 20px; }
    .selection-section h2 { font-size: 0.9rem; letter-spacing: 2px; margin-bottom: 12px; }
    .era-btn { min-width: 0; width: 100%; padding: 14px; }
    .era-icon { font-size: 1.8rem; margin-bottom: 4px; }
    .era-name { font-size: 1.1rem; }
    .country-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        max-height: 38vh;
        max-height: 38dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
    }
    .country-card { padding: 9px 6px; }
    .country-flag { width: 32px; height: 32px; margin-bottom: 5px; }
    .country-name { font-size: 0.78rem; }
    .country-leader, .country-provinces { display: none; }
    .difficulty-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .diff-btn { min-width: 0; padding: 10px 6px; }
    .diff-name { font-size: 0.8rem; }
    .diff-desc { display: none; }
    .start-btn { width: 100%; }
    .back-btn { margin-top: 12px; }
    .modal-content { padding: 18px 14px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
}

/* The narrowest phones keep every modal button visible: speed moves to the pause menu. */
@media (max-width: 360px) {
    .speed-control { display: none; }
    .top-buttons { gap: 4px; }
}

/* Wide compact screens (landscape phones, tablets) fit the HUD in one row. */
@media (min-width: 700px) {
    .top-bar { flex-wrap: nowrap; }
    .top-buttons { flex: 0 0 auto; width: auto; order: 0; overflow: visible; }
}
