@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Noto+Sans+TC:wght@400;500;700&display=swap');

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-abyss: #050510;
    --bg-dark: #08081a;
    --bg-card: #0c0c20;
    --bg-card-hover: #10102a;
    --bg-surface: #111128;
    --bg-modal: #0a0a1c;

    --silver-bright: #e8ecf4;
    --silver: #b8c4d4;
    --silver-dim: #7888a0;
    --steel: #4a5a70;

    --accent: #3a8aff;
    --accent-glow: #5ea8ff;
    --accent-pale: #a0ccff;
    --accent-deep: #1a5acc;
    --accent-rgb: 58, 138, 255;

    --gold: #c8a030;
    --gold-bright: #e8c850;
    --gold-dim: #806018;

    --red-warn: #cc3333;
    --green: #3cb868;
    --green-dim: #287848;

    --text: #d0d4e0;
    --text-dim: #6878a0;
    --border: #1a1a3a;
    --border-light: #252550;

    --radius: 6px;
    --radius-lg: 10px;

    --glow-accent: 0 0 20px rgba(var(--accent-rgb), 0.15);
    --glow-accent-strong: 0 0 30px rgba(var(--accent-rgb), 0.25), 0 0 60px rgba(var(--accent-rgb), 0.1);
    --glow-gold: 0 0 15px rgba(200, 160, 48, 0.2);
}

html {
    scroll-behavior: smooth;
}
body {
    font-family: 'Noto Sans TC', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-abyss);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(var(--accent-rgb), 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(var(--accent-rgb), 0.02) 0%, transparent 50%);
}

/* === Header === */
header {
    background: linear-gradient(180deg, #0a0a20 0%, #080818 100%);
    border-bottom: 1px solid var(--border);
    padding: 2.5rem 1rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 80%, rgba(var(--accent-rgb), 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 0%, rgba(200, 160, 48, 0.04) 0%, transparent 40%);
    pointer-events: none;
}
header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.4;
}
.header-content { position: relative; z-index: 1; }
.header-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.4));
}
header h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--silver-bright);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.2);
}
header h1 .en,
header h1 .page-title-alt {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--accent-pale);
    letter-spacing: 0.5em;
    margin-top: 0.4rem;
    opacity: 0.7;
}
.subtitle {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 0.6rem;
    letter-spacing: 0.08em;
}

/* === Navigation === */
nav {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 0.6rem 1rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.6rem 1.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    letter-spacing: 0.03em;
}
.nav-btn:hover { color: var(--silver); }
.nav-btn.active {
    color: var(--accent-pale);
}
.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    border-radius: 2px;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem;
}
.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.3rem 1rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.2s;
    letter-spacing: 0.05em;
}
.filter-btn:hover { color: var(--silver); border-color: var(--steel); }
.filter-btn.active {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent-pale);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.1);
}

/* === Sections === */
main { max-width: 1400px; margin: 0 auto; padding: 0.5rem 1rem 2rem; }
.section { display: none; }
.section.active { display: block; }

/* === Units Grid === */
.units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}
.unit-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}
.unit-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    opacity: 0;
    transition: opacity 0.3s;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}
.unit-card:hover {
    transform: translateY(-3px);
    border-color: rgba(var(--accent-rgb), 0.4);
    box-shadow: var(--glow-accent);
}
.unit-card:hover::before { opacity: 1; }

.unit-card-img {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #0e0e24 0%, #0a0a18 100%);
}
.unit-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.unit-card:hover .unit-card-img img {
    transform: scale(1.05);
}
.unit-card-img .fallback-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    opacity: 0.6;
}
.unit-card-img .unit-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(5, 5, 16, 0.85);
    color: var(--accent-pale);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    backdrop-filter: blur(4px);
    z-index: 2;
}
.unit-card-img .unit-points {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(5, 5, 16, 0.85);
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 2px;
    border: 1px solid rgba(60, 184, 104, 0.2);
    backdrop-filter: blur(4px);
    z-index: 2;
}
.unit-card-img .epic-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(204, 51, 51, 0.9);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    z-index: 2;
}
/* Image credit badge */
.unit-card-img .img-credit {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(5, 5, 16, 0.75);
    color: var(--text-dim);
    font-size: 0.5rem;
    padding: 2px 6px;
    border-radius: 2px;
    backdrop-filter: blur(4px);
    z-index: 2;
    letter-spacing: 0.03em;
}
/* Modal image credit */
.modal-img-credit {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
    text-align: center;
}
/* Image gradient overlay */
.unit-card-img::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(transparent, rgba(12, 12, 32, 0.8));
    pointer-events: none;
    z-index: 1;
}

.unit-card-info {
    padding: 0.8rem 0.9rem;
    position: relative;
}
.unit-card-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}
.unit-card-info h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--silver-bright);
    margin-bottom: 0.15rem;
}
.unit-card-info .unit-name-en {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.unit-card-info .unit-quick-stats {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.unit-card-info .qs {
    font-size: 0.68rem;
    color: var(--steel);
    background: rgba(var(--accent-rgb), 0.04);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 2px;
}
.unit-card-info .qs span {
    color: var(--accent-pale);
    font-weight: 600;
}

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 10, 0.92);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 920px;
    position: relative;
    animation: modalIn 0.3s ease-out;
    box-shadow: var(--glow-accent-strong);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: rgba(10, 10, 26, 0.8);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    color: var(--silver-bright);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    transition: color 0.2s, background 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}
.modal-close:hover { color: var(--red-warn); background: rgba(200, 40, 40, 0.2); }
.modal-content { padding: 1.5rem; padding-right: 3.5rem; }

/* Modal - Unit Header */
.modal-header {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.modal-icon {
    width: 90px;
    height: 90px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-surface);
}
.modal-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.modal-icon .fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}
.modal-title-block { flex: 1; min-width: 200px; }
.modal-title-block h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--silver-bright);
}
.modal-title-block .en-name {
    font-family: 'Cinzel', serif;
    color: var(--accent-pale);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    opacity: 0.7;
}
.modal-title-block .unit-meta {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}
.modal-title-block .meta-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 2px;
    border: 1px solid;
    letter-spacing: 0.03em;
}
.meta-tag.points { border-color: var(--green-dim); color: var(--green); background: rgba(60, 184, 104, 0.06); }
.meta-tag.type { border-color: var(--border-light); color: var(--silver-dim); background: rgba(120, 136, 160, 0.06); }
.meta-tag.invuln { border-color: rgba(var(--accent-rgb), 0.3); color: var(--accent-pale); background: rgba(var(--accent-rgb), 0.06); }
.meta-tag.epic { border-color: rgba(204, 51, 51, 0.4); color: var(--red-warn); background: rgba(204, 51, 51, 0.08); }

/* Modal - Stat Line */
.stat-line {
    display: flex;
    gap: 2px;
    margin-bottom: 1.2rem;
}
.stat-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 0.5rem 0.3rem;
    text-align: center;
    flex: 1;
    min-width: 0;
}
.stat-box:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.stat-box:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.stat-box .stat-label {
    font-size: 0.55rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}
.stat-box .stat-value {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-pale);
    text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.2);
}

/* Modal - Weapons Table */
.weapons-section { margin-bottom: 1.2rem; }
.weapons-section h3, .abilities-section h3, .keywords-section h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--silver-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.weapons-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.weapons-table th {
    background: var(--bg-surface);
    color: var(--text-dim);
    padding: 0.45rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}
.weapons-table th:first-child { text-align: left; }
.weapons-table td {
    padding: 0.45rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(26, 26, 58, 0.5);
    color: var(--silver);
}
.weapons-table td:first-child {
    text-align: left;
    color: var(--silver-bright);
    font-weight: 500;
}
.weapons-table tr:hover { background: rgba(var(--accent-rgb), 0.03); }
.weapon-abilities {
    font-size: 0.68rem;
    color: var(--accent);
    font-style: normal;
    opacity: 0.85;
}
.weapon-psychic { color: var(--accent-glow) !important; }

/* Modal - Abilities */
.abilities-section { margin-bottom: 1.2rem; }
.ability-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-deep);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.4rem;
}
.ability-name {
    color: var(--silver-bright);
    font-weight: 600;
    font-size: 0.85rem;
}
.ability-desc {
    color: var(--silver-dim);
    font-size: 0.8rem;
    margin-top: 0.2rem;
    line-height: 1.5;
}
.core-abilities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}
.core-ability-tag {
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    color: var(--accent-pale);
    padding: 2px 10px;
    border-radius: 2px;
    font-size: 0.72rem;
    font-weight: 500;
}

/* Modal - Keywords */
.keywords-section { margin-bottom: 1rem; }
.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.keyword-tag {
    background: rgba(200, 160, 48, 0.04);
    border: 1px solid rgba(200, 160, 48, 0.15);
    color: var(--gold);
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
}

/* === Detachments === */
.detachments-container { display: flex; flex-direction: column; gap: 1rem; }
.detachment-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.detachment-header {
    background: var(--bg-surface);
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.detachment-header:hover { background: var(--bg-card-hover); }
.detachment-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--silver-bright);
    letter-spacing: 0.05em;
}
.detachment-header .det-rule-name {
    color: var(--accent);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}
.detachment-header .toggle-icon {
    color: var(--steel);
    font-size: 0.9rem;
    transition: transform 0.3s;
}
.detachment-body {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.3s;
}
.detachment-body.open {
    padding: 1rem 1.2rem;
    max-height: 5000px;
}

.det-rule-box {
    background: rgba(var(--accent-rgb), 0.04);
    border: 1px solid rgba(var(--accent-rgb), 0.15);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.8rem;
    margin-bottom: 1rem;
}
.det-rule-box h4 {
    color: var(--accent-pale);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}
.det-rule-box p { color: var(--text); font-size: 0.83rem; line-height: 1.6; }

.enhancements-grid, .stratagems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.enhancement-item, .stratagem-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem;
}
.enhancement-item h5, .stratagem-item h5 {
    color: var(--silver-bright);
    font-size: 0.83rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.enhancement-pts { color: var(--green); font-size: 0.72rem; font-weight: 600; }
.stratagem-cp {
    color: var(--accent-pale);
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(var(--accent-rgb), 0.1);
    padding: 1px 8px;
    border-radius: 2px;
}
.stratagem-phase { color: var(--text-dim); font-size: 0.65rem; margin-top: 0.15rem; }
.enhancement-item p, .stratagem-item p {
    color: var(--silver-dim);
    font-size: 0.78rem;
    margin-top: 0.3rem;
    line-height: 1.5;
}

.sub-heading {
    font-family: 'Cinzel', serif;
    color: var(--silver-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 1.2rem 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

/* === Rules section === */
.rules-container { display: flex; flex-direction: column; gap: 1rem; }
.rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
}
.rule-card h2 {
    font-family: 'Cinzel', serif;
    color: var(--silver-bright);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.05em;
}
.rule-card h2 .en {
    font-family: 'Cinzel', serif;
    color: var(--accent);
    font-size: 0.75rem;
    opacity: 0.7;
}
.rule-text { color: var(--text); font-size: 0.88rem; line-height: 1.65; }
.rule-text p { margin-bottom: 0.6rem; }
.rule-rituals {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--border);
    display: grid;
    gap: 0.7rem;
}
.rule-ritual {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    padding: 0.7rem 0.9rem;
}
.rule-ritual h3 {
    font-family: 'Cinzel', serif;
    color: var(--silver-bright);
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    letter-spacing: 0.04em;
}
.rule-ritual-cost {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0;
}
.rule-ritual-when {
    color: var(--accent-pale);
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
}
.rule-ritual-desc { color: var(--text); font-size: 0.85rem; line-height: 1.6; }
.rule-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}
.rule-table th, .rule-table td {
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border);
    font-size: 0.83rem;
}
.rule-table th { background: var(--bg-surface); color: var(--accent-pale); font-weight: 600; }
.rule-table td { color: var(--silver); }

.keywords-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.3rem;
}
.keyword-item {
    font-size: 0.78rem;
    padding: 0.3rem 0;
    color: var(--silver-dim);
}
.keyword-item .kw {
    display: inline-block;
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    color: var(--accent-pale);
    padding: 1px 8px;
    border-radius: 2px;
    font-size: 0.68rem;
    font-weight: 600;
    margin-right: 4px;
}
.keyword-item .kw.psychic {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
}

/* === Lore Section === */
.lore-container { max-width: 800px; margin: 0 auto; }
.lore-hero {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}
.lore-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.06) 0%, transparent 70%);
    pointer-events: none;
}
.lore-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.3;
}
.lore-hero-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.3));
}
.lore-hero h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: var(--silver-bright);
    letter-spacing: 0.2em;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.15);
}
.lore-hero h2 .lore-hero-alt {
    font-family: 'Cinzel', serif;
    font-size: 0.55em;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    margin-left: 0.5em;
    vertical-align: middle;
    text-transform: uppercase;
}
.lore-hero-sub {
    color: var(--accent-pale);
    font-size: 0.9rem;
    margin-top: 0.3rem;
    letter-spacing: 0.1em;
    position: relative;
    z-index: 1;
    opacity: 0.7;
}
.lore-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 0.8rem;
}
.lore-section h3 {
    font-family: 'Cinzel', serif;
    color: var(--silver);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.08em;
}
.lore-section p {
    color: var(--silver-dim);
    font-size: 0.88rem;
    line-height: 1.85;
    white-space: pre-line;
}

/* === Footer === */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-dim);
    font-size: 0.7rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    letter-spacing: 0.03em;
}

/* === Wargear, composition, damaged, transport, leader === */
.wargear-section { margin-bottom: 1rem; }
.wargear-section h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem !important;
    color: var(--silver-dim) !important;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.wargear-section p {
    color: var(--silver-dim);
    font-size: 0.78rem;
    padding: 0.15rem 0;
}

.composition-text {
    color: var(--silver-dim);
    font-size: 0.8rem;
    margin-bottom: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.8rem;
}

.damaged-box {
    background: rgba(204, 51, 51, 0.05);
    border: 1px solid rgba(204, 51, 51, 0.2);
    border-left: 3px solid var(--red-warn);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.5rem 0.8rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--red-warn);
}

.transport-box {
    background: rgba(60, 184, 104, 0.04);
    border: 1px solid rgba(60, 184, 104, 0.15);
    border-left: 3px solid var(--green);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.5rem 0.8rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--green);
}

.leader-box {
    background: rgba(200, 160, 48, 0.04);
    border: 1px solid rgba(200, 160, 48, 0.15);
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.5rem 0.8rem;
    margin-bottom: 1rem;
}
.leader-box h4 { color: var(--gold); font-size: 0.8rem; margin-bottom: 0.2rem; }
.leader-box p { color: var(--silver-dim); font-size: 0.78rem; }

/* === Responsive — Large Tablet / iPad Pro (≤1024px) === */
@media (max-width: 1024px) {
    main { padding: 0.5rem 0.8rem 2rem; }
    .units-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* === Responsive — Tablet / iPad / Z Fold Inner (≤900px) === */
@media (max-width: 900px) {
    .enhancements-grid, .stratagems-grid { grid-template-columns: 1fr; }
    .keywords-legend { grid-template-columns: 1fr; }
}

/* === Responsive — Small Tablet / Z Fold Inner (≤768px) === */
@media (max-width: 768px) {
    header { padding: 1.8rem 1rem 1.4rem; }
    header h1 { font-size: 1.6rem; }
    .subtitle { font-size: 0.72rem; }
    main { padding: 0.4rem 0.6rem 1.5rem; }
    .units-grid { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
    .modal { max-width: 95vw; }
    .modal-content { padding: 1.2rem; }
    .lore-hero { padding: 2.5rem 1rem; }
    .lore-hero h2 { font-size: 1.5rem; }
}

/* === Responsive — Mobile (≤600px) === */
@media (max-width: 600px) {
    /* Base font bump for readability */
    body { font-size: 16px; -webkit-text-size-adjust: 100%; }

    /* Header */
    header { padding: 1.5rem 0.8rem 1.2rem; }
    .header-icon { font-size: 1.6rem; }
    header h1 { font-size: 1.4rem; letter-spacing: 0.08em; }
    header h1 .en,
    header h1 .page-title-alt { font-size: 0.6rem; letter-spacing: 0.2em; }
    .subtitle { font-size: 0.7rem; }

    /* Nav — scrollable horizontally */
    nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        gap: 0;
        padding: 0.4rem 0.5rem;
    }
    .nav-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.82rem;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 44px;
    }

    /* Main */
    main { padding: 0.3rem 0.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); }

    /* Filter bar */
    .filter-bar { gap: 0.3rem; padding: 0.6rem 0.2rem; }
    .filter-btn { font-size: 0.78rem; padding: 0.35rem 0.8rem; min-height: 36px; }

    /* Units Grid — 2 columns */
    .units-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .unit-card-info { padding: 0.6rem; }
    .unit-card-info h3 { font-size: 0.85rem; }
    .unit-card-info .unit-name-en { font-size: 0.58rem; }
    .unit-card-info .unit-quick-stats { gap: 0.3rem; margin-top: 0.4rem; }
    .unit-card-info .qs { font-size: 0.68rem; }
    .unit-card-img .unit-type-badge { font-size: 0.58rem; padding: 2px 6px; }
    .unit-card-img .unit-points { font-size: 0.72rem; padding: 2px 8px; }
    .unit-card-img .epic-badge { font-size: 0.5rem; }

    /* Modal — full screen on mobile */
    .modal-overlay { padding: 0; overflow: hidden; }
    .modal {
        border-radius: 0;
        border: none;
        min-height: 0;
        max-height: 100vh;
        max-height: 100dvh;
        max-width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-close {
        position: fixed;
        top: max(10px, env(safe-area-inset-top, 0px));
        right: max(10px, env(safe-area-inset-right, 0px));
        margin: 0;
        font-size: 1.6rem;
        width: 44px;
        height: 44px;
        z-index: 1100;
    }
    .modal-content { padding: 1rem 0.8rem; padding-top: 3.5rem; }
    .modal-header { gap: 0.8rem; }
    .modal-icon { width: 64px; height: 64px; }
    .modal-title-block h2 { font-size: 1.15rem; }
    .modal-title-block .en-name { font-size: 0.7rem; }
    .modal-title-block .meta-tag { font-size: 0.65rem; padding: 2px 8px; }

    /* Stat line */
    .stat-line { gap: 1px; }
    .stat-box { padding: 0.4rem 0.15rem; }
    .stat-box .stat-value { font-size: 1.05rem; }
    .stat-box .stat-label { font-size: 0.48rem; }

    /* Weapons table — horizontal scroll */
    .weapons-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .weapons-table { font-size: 0.72rem; min-width: 560px; }
    .weapons-table th { font-size: 0.6rem; padding: 0.35rem 0.3rem; }
    .weapons-table td { padding: 0.35rem 0.3rem; }
    .weapon-abilities { font-size: 0.62rem; }

    /* Abilities */
    .ability-item { padding: 0.5rem 0.6rem; }
    .ability-name { font-size: 0.82rem; }
    .ability-desc { font-size: 0.78rem; }
    .core-ability-tag { font-size: 0.7rem; }

    /* Keywords */
    .keyword-tag { font-size: 0.65rem; }

    /* Composition, damaged, transport, leader boxes */
    .composition-text { font-size: 0.78rem; }
    .damaged-box, .transport-box { font-size: 0.78rem; }
    .leader-box h4 { font-size: 0.78rem; }
    .leader-box p { font-size: 0.75rem; }
    .wargear-section p { font-size: 0.75rem; }

    /* Rules section */
    .rule-card { padding: 0.8rem; }
    .rule-card h2 { font-size: 0.9rem; }
    .rule-text { font-size: 0.82rem; }
    .rule-table th, .rule-table td { padding: 0.35rem 0.5rem; font-size: 0.78rem; }
    .keyword-item { font-size: 0.75rem; }
    .keyword-item .kw { font-size: 0.65rem; }

    /* Detachments */
    .detachment-header { padding: 0.8rem; }
    .detachment-header h2 { font-size: 0.9rem; }
    .detachment-header h2 span { font-size: 0.72rem !important; }
    .detachment-header .det-rule-name { font-size: 0.72rem; }
    .detachment-body.open { padding: 0.8rem; }
    .det-rule-box { padding: 0.6rem; }
    .det-rule-box h4 { font-size: 0.8rem; }
    .det-rule-box p { font-size: 0.78rem; }
    .enhancement-item, .stratagem-item { padding: 0.6rem; }
    .enhancement-item h5, .stratagem-item h5 { font-size: 0.8rem; }
    .enhancement-item p, .stratagem-item p { font-size: 0.75rem; }
    .enhancements-grid, .stratagems-grid { grid-template-columns: 1fr; }
    .sub-heading { font-size: 0.72rem; }

    /* Lore */
    .lore-hero { padding: 2rem 0.8rem; }
    .lore-hero h2 { font-size: 1.3rem; }
    .lore-hero-sub { font-size: 0.8rem; }
    .lore-section { padding: 1rem; }
    .lore-section h3 { font-size: 0.9rem; }
    .lore-section p { font-size: 0.82rem; line-height: 1.75; }

    /* Footer */
    footer { padding: 1.5rem 0.5rem calc(0.65rem + env(safe-area-inset-bottom, 0px)); font-size: 0.65rem; }
}

/* === Responsive — Large Phone (≤480px) === */
@media (max-width: 480px) {
    header { padding: 1.2rem 0.6rem 1rem; }
    header h1 { font-size: 1.2rem; letter-spacing: 0.05em; }
    header h1 .en { font-size: 0.55rem; }
    .subtitle { font-size: 0.65rem; }
    .nav-btn { padding: 0.4rem 0.7rem; font-size: 0.78rem; }
    .filter-btn { font-size: 0.72rem; padding: 0.3rem 0.6rem; }
    .unit-card-info h3 { font-size: 0.8rem; }
    .unit-card-info .unit-name-en { font-size: 0.52rem; }
    .unit-card-info .qs { font-size: 0.62rem; }
    .modal-icon { width: 52px; height: 52px; }
    .modal-title-block h2 { font-size: 1.05rem; }
    .stat-box .stat-value { font-size: 0.95rem; }
    .stat-box .stat-label { font-size: 0.44rem; }
    .weapons-table { min-width: 500px; }
    .ability-name { font-size: 0.78rem; }
    .ability-desc { font-size: 0.74rem; }
    .rule-card h2 { font-size: 0.85rem; }
    .rule-text { font-size: 0.78rem; }
    .detachment-header h2 { font-size: 0.85rem; }
    .lore-hero h2 { font-size: 1.15rem; }
    .lore-section p { font-size: 0.78rem; }
}

/* === Responsive — Very Small Phone / Z Fold Outer (≤360px) === */
@media (max-width: 360px) {
    header { padding: 1rem 0.5rem 0.8rem; }
    .header-icon { font-size: 1.3rem; }
    header h1 { font-size: 1.05rem; letter-spacing: 0.03em; }
    header h1 .en { font-size: 0.5rem; letter-spacing: 0.1em; }
    .subtitle { font-size: 0.6rem; }
    nav { padding: 0.3rem 0.3rem; }
    .nav-btn { padding: 0.35rem 0.5rem; font-size: 0.72rem; }
    main { padding: 0.2rem 0.3rem 1.5rem; }
    .filter-bar { padding: 0.4rem 0.1rem; }
    .filter-btn { font-size: 0.68rem; padding: 0.25rem 0.5rem; }

    /* Units Grid — single column for very small screens */
    .units-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    .unit-card-info { padding: 0.5rem; }
    .unit-card-info h3 { font-size: 0.82rem; }

    /* Modal */
    .modal-content { padding: 0.8rem 0.5rem; padding-top: 3rem; }
    .modal-header { gap: 0.5rem; flex-direction: column; align-items: flex-start; }
    .modal-icon { width: 48px; height: 48px; }
    .modal-title-block h2 { font-size: 0.95rem; }
    .modal-title-block .en-name { font-size: 0.6rem; }
    .stat-box { padding: 0.3rem 0.1rem; }
    .stat-box .stat-value { font-size: 0.88rem; }
    .stat-box .stat-label { font-size: 0.4rem; }
    .weapons-table { min-width: 440px; font-size: 0.65rem; }
    .weapons-table th { font-size: 0.55rem; padding: 0.25rem 0.2rem; }
    .weapons-table td { padding: 0.25rem 0.2rem; }
    .ability-item { padding: 0.4rem 0.5rem; }
    .ability-name { font-size: 0.75rem; }
    .ability-desc { font-size: 0.7rem; }
    .rule-card { padding: 0.6rem; }
    .rule-card h2 { font-size: 0.82rem; }
    .rule-text { font-size: 0.75rem; }
    .detachment-header { padding: 0.6rem; }
    .detachment-header h2 { font-size: 0.8rem; }
    .det-rule-box { padding: 0.5rem; }
    .lore-hero { padding: 1.5rem 0.5rem; }
    .lore-hero h2 { font-size: 1rem; }
    .lore-section { padding: 0.8rem; }
    .lore-section h3 { font-size: 0.82rem; }
    .lore-section p { font-size: 0.75rem; }
    footer { font-size: 0.6rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-abyss); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--steel); }

/* Selection */
::selection {
    background: rgba(var(--accent-rgb), 0.3);
    color: var(--silver-bright);
}

/* ============================================
   ARMY BUILDER / POINTS CALCULATOR
   ============================================ */

.builder-container { max-width: 1200px; margin: 0 auto; }

/* Top bar: settings + points display */
.builder-top {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}
.builder-settings {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 240px;
}
.builder-setting {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.builder-setting label {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.builder-setting select {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--silver);
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.82rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
.builder-setting select:focus { border-color: var(--accent); }

.builder-custom-pts {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
}
.builder-custom-pts input {
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    color: var(--accent-pale);
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    width: 120px;
    outline: none;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.1);
}
.builder-custom-pts input:focus {
    box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.2);
}
.builder-custom-pts span {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.builder-points-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 220px;
}
.builder-points-numbers {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}
.builder-total {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent-pale);
    text-shadow: 0 0 15px rgba(var(--accent-rgb), 0.3);
}
.builder-total.over { color: var(--red-warn); text-shadow: 0 0 15px rgba(204, 51, 51, 0.3); }
.builder-slash { color: var(--steel); font-size: 1.2rem; }
.builder-limit { color: var(--silver-dim); font-size: 1.2rem; font-weight: 600; }
.builder-pts { color: var(--text-dim); font-size: 0.75rem; margin-left: 0.2rem; }
.builder-remaining {
    font-size: 0.78rem;
    color: var(--green);
    margin-top: 0.2rem;
}
.builder-remaining.negative { color: var(--red-warn); }

.builder-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.builder-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

/* Validation messages */
.builder-validation { margin-bottom: 0.8rem; }
.val-error, .val-warning {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    margin-bottom: 0.3rem;
}
.val-error {
    background: rgba(204, 51, 51, 0.08);
    border: 1px solid rgba(204, 51, 51, 0.25);
    border-left: 3px solid var(--red-warn);
    color: var(--red-warn);
}
.val-warning {
    background: rgba(200, 160, 48, 0.06);
    border: 1px solid rgba(200, 160, 48, 0.2);
    border-left: 3px solid var(--gold);
    color: var(--gold);
}

/* Summary bar */
.builder-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.bsb-item {
    font-size: 0.72rem;
    color: var(--text-dim);
    padding: 2px 10px;
    border-right: 1px solid var(--border);
}
.bsb-item:last-child { border-right: none; }
.bsb-item b { color: var(--accent-pale); font-weight: 600; }

/* Two column layout */
.builder-columns {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1rem;
    align-items: start;
}

.builder-section-title {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--silver-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

/* === Roster (left) === */
.builder-roster {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 300px;
}
.builder-empty {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-align: center;
    padding: 3rem 1rem;
    opacity: 0.6;
}

.roster-category-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem 0 0.2rem;
    border-bottom: 1px solid rgba(26, 26, 58, 0.5);
    margin-bottom: 0.3rem;
}

.roster-entry {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    margin-bottom: 0.3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}
.roster-entry:hover { border-color: var(--border-light); }

.roster-entry-img {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-card);
}
.roster-entry-img img { width: 100%; height: 100%; object-fit: cover; }
.roster-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.roster-entry-info { flex: 1; min-width: 0; }
.roster-entry-name {
    font-size: 0.82rem;
    color: var(--silver-bright);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.roster-epic {
    font-size: 0.5rem;
    background: rgba(204, 51, 51, 0.8);
    color: #fff;
    padding: 1px 5px;
    border-radius: 2px;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.roster-entry-en {
    font-size: 0.62rem;
    color: var(--text-dim);
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.roster-size-select, .roster-enh-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--silver-dim);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    margin-top: 0.2rem;
    cursor: pointer;
    outline: none;
    max-width: 100%;
}
.roster-size-select:focus, .roster-enh-select:focus {
    border-color: var(--accent);
}

.roster-enh-badge {
    display: inline-block;
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    color: var(--accent-pale);
    font-size: 0.62rem;
    padding: 1px 6px;
    border-radius: 2px;
    margin-top: 0.2rem;
}

.roster-entry-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
    flex-shrink: 0;
}
.roster-entry-pts {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--green);
}
.roster-remove {
    background: none;
    border: 1px solid rgba(204, 51, 51, 0.2);
    color: var(--red-warn);
    width: 22px;
    height: 22px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.5;
}
.roster-remove:hover { opacity: 1; background: rgba(204, 51, 51, 0.1); }

/* === Picker (right) === */
.builder-picker {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 70vh;
    overflow-y: auto;
    position: sticky;
    top: 60px;
}

.picker-cat-label {
    font-size: 0.62rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem 0 0.2rem;
    border-bottom: 1px solid rgba(26, 26, 58, 0.5);
    margin-bottom: 0.2rem;
}

.picker-unit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 1px;
}
.picker-unit:hover { background: rgba(var(--accent-rgb), 0.06); }
.picker-unit.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.picker-unit.disabled:hover { background: transparent; }

.picker-unit-img {
    width: 34px;
    height: 34px;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-surface);
}
.picker-unit-img img { width: 100%; height: 100%; object-fit: cover; }
.picker-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.picker-unit-info { flex: 1; min-width: 0; }
.picker-unit-name {
    font-size: 0.75rem;
    color: var(--silver);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.picker-unit-en {
    font-size: 0.55rem;
    color: var(--text-dim);
    font-family: 'Cinzel', serif;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-unit-right {
    text-align: right;
    flex-shrink: 0;
}
.picker-unit-pts {
    font-size: 0.72rem;
    color: var(--green);
    font-weight: 600;
}
.picker-unit-count {
    font-size: 0.6rem;
    color: var(--text-dim);
}

/* Detachment info at bottom */
.builder-det-info {
    background: rgba(var(--accent-rgb), 0.03);
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    border-radius: var(--radius);
    padding: 0.8rem;
    margin-top: 1rem;
}
.builder-det-info-header {
    font-size: 0.78rem;
    color: var(--accent-pale);
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.builder-det-info p {
    font-size: 0.78rem;
    color: var(--silver-dim);
    line-height: 1.5;
}

/* === Builder Responsive === */
@media (max-width: 800px) {
    .builder-columns {
        grid-template-columns: 1fr;
    }
    .builder-picker {
        position: static;
        max-height: none;
    }
    .builder-top {
        flex-direction: column;
    }
    .builder-points-display {
        min-width: unset;
    }
}
@media (max-width: 600px) {
    .builder-container { padding: 0; }
    .builder-top { gap: 0.6rem; }
    .builder-setting label { font-size: 0.7rem; }
    .builder-setting select { font-size: 0.82rem; padding: 0.5rem; min-height: 44px; }
    .builder-custom-pts input { font-size: 1rem; width: 100px; padding: 0.4rem 0.6rem; min-height: 44px; }

    .builder-points-display { padding: 0.8rem 1rem; }
    .builder-total { font-size: 1.8rem; }
    .builder-slash { font-size: 1rem; }
    .builder-limit { font-size: 1rem; }
    .builder-remaining { font-size: 0.75rem; }

    .builder-summary-bar { padding: 0.4rem 0.5rem; gap: 0.15rem; }
    .bsb-item { font-size: 0.7rem; padding: 2px 6px; }

    .builder-roster { padding: 0.6rem; min-height: 200px; }
    .builder-empty { padding: 2rem 0.5rem; font-size: 0.82rem; }
    .roster-category-label { font-size: 0.65rem; }
    .roster-entry { gap: 0.5rem; padding: 0.4rem; }
    .roster-entry-img { width: 38px; height: 38px; }
    .roster-entry-name { font-size: 0.8rem; }
    .roster-entry-en { font-size: 0.58rem; }
    .roster-size-select, .roster-enh-select { font-size: 0.72rem; min-height: 36px; }
    .roster-enh-badge { font-size: 0.6rem; }
    .roster-entry-pts { font-size: 0.82rem; }

    .builder-picker { padding: 0.6rem; }
    .picker-cat-label { font-size: 0.62rem; }
    .picker-unit { padding: 0.35rem 0.4rem; gap: 0.4rem; min-height: 44px; }
    .picker-unit-img { width: 30px; height: 30px; }
    .picker-unit-name { font-size: 0.75rem; }
    .picker-unit-en { font-size: 0.52rem; }
    .picker-unit-pts { font-size: 0.72rem; }
    .picker-unit-count { font-size: 0.58rem; }

    .builder-det-info { padding: 0.6rem; margin-top: 0.8rem; }
    .builder-det-info-header { font-size: 0.75rem; }
    .builder-det-info p { font-size: 0.75rem; }

    .builder-section-title { font-size: 0.72rem; }
}

/* === Builder — Large Phone (≤480px) === */
@media (max-width: 480px) {
    .builder-points-display { padding: 0.6rem 0.8rem; }
    .builder-total { font-size: 1.5rem; }
    .builder-remaining { font-size: 0.7rem; }
    .roster-entry-img { width: 34px; height: 34px; }
    .roster-entry-name { font-size: 0.75rem; }
    .picker-unit-img { width: 26px; height: 26px; }
    .picker-unit-name { font-size: 0.7rem; }
}

/* === Builder — Very Small Phone / Z Fold Outer (≤360px) === */
@media (max-width: 360px) {
    .builder-top { gap: 0.4rem; }
    .builder-setting select { font-size: 0.78rem; }
    .builder-custom-pts input { width: 80px; font-size: 0.9rem; }
    .builder-points-display { padding: 0.5rem 0.6rem; }
    .builder-total { font-size: 1.3rem; }
    .builder-slash, .builder-limit { font-size: 0.85rem; }
    .bsb-item { font-size: 0.62rem; padding: 1px 4px; }
    .builder-roster { padding: 0.4rem; }
    .roster-entry { gap: 0.3rem; padding: 0.3rem; }
    .roster-entry-img { width: 28px; height: 28px; }
    .roster-entry-name { font-size: 0.7rem; }
    .roster-entry-en { font-size: 0.5rem; }
    .roster-entry-pts { font-size: 0.72rem; }
    .builder-picker { padding: 0.4rem; }
    .picker-unit { padding: 0.3rem; gap: 0.3rem; }
    .picker-unit-img { width: 24px; height: 24px; }
    .picker-unit-name { font-size: 0.65rem; }
    .picker-unit-pts { font-size: 0.65rem; }
}

/* === Combat Patrol Available Tag === */
.cp-available-tag {
    display: inline-block;
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    color: var(--gold);
    background: rgba(200, 160, 48, 0.1);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    padding: 0.15rem 0.5rem;
    margin: 0.25rem 0;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}
.cp-available-tag:hover {
    background: rgba(200, 160, 48, 0.2);
    color: var(--gold-bright);
}

/* === Unit Card Highlight Pulse (scroll-to navigation) === */
@keyframes highlight-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6); }
    50%  { box-shadow: 0 0 20px 4px rgba(var(--accent-rgb), 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}
.unit-card.highlight-pulse {
    animation: highlight-pulse 1s ease 2;
    border-color: var(--accent) !important;
}

/* === Iframe-embedded mode: compact header === */
body.in-iframe header {
    padding: 1rem 1rem 0.8rem;
}
body.in-iframe .header-icon {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}
body.in-iframe header h1 {
    font-size: 1.4rem;
}
body.in-iframe .subtitle {
    font-size: 0.7rem;
    margin-top: 0.3rem;
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Keyboard focus — visible gold outline for keyboard users only */
:focus-visible {
    outline: 2px solid var(--gold, #c9a227);
    outline-offset: 2px;
    border-radius: 3px;
}
