/* WarHammerHelper — mobile-first dark theme */

:root {
    --bg: #0d0e12;
    --bg-elev: #15171d;
    --bg-elev-2: #1d2028;
    --line: #2a2e3a;
    --text: #e8e8ee;
    --text-dim: #a0a3b0;
    --text-mute: #6e7180;
    --accent: #c8102e;
    --accent-soft: #e63b54;
    --accent-tint: rgba(200, 16, 46, 0.12);
    --gold: #e0b13a;
    --green: #4cb87a;
    --blue: #5cb6ff;

    --topbar-h: 56px;
    --bottombar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.4);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bot: env(safe-area-inset-bottom, 0px);

}

@font-face {
  font-family: 'ConduitITC'; /* The name you choose */
  src: url('fonts/Conduit ITC Regular.otf') format('otf'); /* Modern format */
  font-weight: 700;
  font-style: normal;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "ConduitITC", Roboto, Oxygen,
        Ubuntu, Cantarell, "ConduitITC", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

a {
    color: var(--accent-soft);
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
    font: inherit;
    color: inherit;
}

/* ============ boot splash ============ */
.boot {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}
.boot.fade-out { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.boot-mark {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 44px;
    font-weight: 900;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(200, 16, 46, 0.4);
}
.boot-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.boot-sub { color: var(--text-dim); margin-top: 4px; font-size: 14px; }

/* ============ top bar ============ */
.topbar {
    position: sticky;
    top: 0;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding-top: var(--safe-top);
    background: rgba(13, 14, 18, 0.85);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    z-index: 50;
}
.topbar-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-back, .topbar-action {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 26px;
    border-radius: 10px;
    margin: 0 4px;
}
.topbar-back:active, .topbar-action:active { background: var(--bg-elev); }
.topbar-back[hidden] { visibility: hidden; }

/* ============ screen ============ */
.screen {
    /* Use individual longhands so a wider-viewport rule can change side
       padding without clobbering the bottom-nav clearance. */
    padding-top: 16px;
    padding-right: 16px;
    padding-left: 16px;
    /* Reserve space for the fixed .bottombar (height + iOS safe area) plus a
       comfortable gap so the last element on a long screen never tucks under
       the translucent nav bar. */
    padding-bottom: calc(var(--bottombar-h) + var(--safe-bot) + 32px);
    max-width: 880px;
    margin: 0 auto;
}

/* ============ bottom nav ============ */
.bottombar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottombar-h) + var(--safe-bot));
    padding-bottom: var(--safe-bot);
    background: rgba(13, 14, 18, 0.92);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    display: flex;
    z-index: 40;
}
.navbtn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-mute);
    text-decoration: none;
    font-size: 11px;
    gap: 2px;
    transition: color 0.15s ease;
}
.navbtn .navicon { font-size: 22px; line-height: 1; }
.navbtn.active { color: var(--accent-soft); }
.navbtn:active { background: var(--bg-elev); }

/* ============ home screen ============ */
.hero {
    margin: 8px 0 24px;
    padding: 24px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 30% 20%, rgba(200, 16, 46, 0.25), transparent 50%),
        linear-gradient(160deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
    border: 1px solid var(--line);
}
.hero-title {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.03em;
    margin: 0 0 6px;
}
.hero-sub {
    color: var(--text-dim);
    margin: 0;
    font-size: 15px;
}
.hero-meta {
    color: var(--text-mute);
    font-size: 12px;
    margin-top: 14px;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.tile {
    display: flex;
    flex-direction: column;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    min-height: 110px;
    justify-content: space-between;
    transition: transform 0.12s ease, border-color 0.15s ease;
}
.tile:active { transform: scale(0.98); border-color: var(--accent); }
.tile-icon { font-size: 26px; opacity: 0.85; }
.tile-title { font-weight: 700; font-size: 16px; margin-top: 8px; }
.tile-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.section-h {
    margin: 24px 0 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-mute);
}

/* ============ list (factions, units, etc.) ============ */
.list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    overflow: hidden;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    min-height: 56px;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--bg-elev-2); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 15px; }
.list-item-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.list-item-chev { color: var(--text-mute); font-size: 22px; }

.list-item-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.role-Battleline { background: rgba(92, 182, 255, 0.12); color: var(--blue); }
.role-Characters { background: rgba(224, 177, 58, 0.14); color: var(--gold); }
.role-Other      { background: rgba(160, 163, 176, 0.12); color: var(--text-dim); }

/* search/filter input */
.filter-bar {
    position: sticky;
    top: calc(var(--topbar-h) + var(--safe-top));
    background: var(--bg);
    z-index: 30;
    padding: 8px 0 12px;
    margin: -8px 0 0;
}
.filter-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease;
}
.filter-input::placeholder { color: var(--text-mute); }
.filter-input:focus { border-color: var(--accent); }

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-dim);
}

/* ============ datasheet ============ */
.ds-header {
    margin-bottom: 16px;
}
.ds-name {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.15;
}
.ds-faction {
    color: var(--text-mute);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
}
.ds-role-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text-dim);
}
.chip.kw { background: rgba(255, 255, 255, 0.04); }
.chip.fkw { background: var(--accent-tint); color: var(--accent-soft); border-color: rgba(200, 16, 46, 0.3); }
.chip.weapon-ability {
    background: rgba(92, 182, 255, 0.1);
    color: var(--blue);
    border-color: rgba(92, 182, 255, 0.25);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.04em;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.card-h {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-mute);
    margin: 0 0 10px;
}

/* model stat blocks */
.models-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.model-card {
    background: var(--bg-elev-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.model-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}
.stat-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}
.stat-cell {
    text-align: center;
    background: var(--bg);
    border-radius: 6px;
    padding: 6px 0;
    border: 1px solid var(--line);
}
.stat-label {
    display: block;
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-mute);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.stat-value {
    display: block;
    font-size: 17px;
    font-weight: 800;
    margin-top: 1px;
}
.model-extras {
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 12px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* weapons table */
.weapons-section + .weapons-section { margin-top: 16px; }
.weapons-h {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 0 0 8px;
}
.weapon {
    border-bottom: 1px dashed var(--line);
    padding: 10px 0;
}
.weapon:last-child { border-bottom: none; }
.weapon-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}
.weapon-name .dice-tag {
    font-size: 11px;
    color: var(--text-mute);
    margin-left: 6px;
    font-weight: 500;
}
.weapon-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin: 6px 0;
}
.weapon-stats .stat-cell {
    background: var(--bg);
    padding: 4px 0;
}
.weapon-stats .stat-value { font-size: 13.5px; }
.weapon-abilities {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

/* ability blocks */
.ability {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.ability:last-child { border-bottom: none; }
.ability-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-soft);
}
.ability-type-tag {
    font-size: 10.5px;
    color: var(--text-mute);
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.ability-body {
    font-size: 14px;
    color: var(--text);
    margin-top: 4px;
}
.ability-body p { margin: 6px 0; }
.ability-body ul { padding-left: 22px; margin: 6px 0; }
.ability-body .kwb { font-weight: 700; text-transform: uppercase; font-size: 0.92em; letter-spacing: 0.04em; }
.ability-body .kwb2.bluefont { color: var(--blue); font-weight: 700; font-size: 0.9em; letter-spacing: 0.04em; }
.ability-body .redfont { color: var(--accent-soft); font-weight: 700; }
.ability-body .redExample {
    background: rgba(200, 16, 46, 0.06);
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 13px;
}

.option-list { padding-left: 18px; margin: 0; }
.option-list li { margin: 6px 0; font-size: 14px; }

.cost-grid { display: flex; flex-direction: column; gap: 6px; }
.cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elev-2);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.cost-pts { font-weight: 800; color: var(--gold); }

.kw-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.damaged-card {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
}
.damaged-range {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ============ stratagem detail ============ */
.strat-cp {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    margin-right: 6px;
}
.strat-meta {
    color: var(--text-dim);
    font-size: 12.5px;
    margin: 4px 0 12px;
}

/* ============ dice screen ============ */
.dice-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
}
.dice-result {
    text-align: center;
    font-size: 64px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--accent-soft);
    margin: 8px 0;
    min-height: 64px;
}
.dice-formula {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    margin-bottom: 16px;
    word-break: break-all;
}
.dice-rolls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin: 8px 0;
}
.dice-roll {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-elev-2);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.dice-roll.crit { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-soft); }
.dice-roll.fail { color: var(--text-mute); }

.dice-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.dice-btn {
    padding: 12px 0;
    border-radius: var(--radius-sm);
    background: var(--bg-elev-2);
    border: 1px solid var(--line);
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    transition: transform 0.1s ease;
}
.dice-btn:active { transform: scale(0.95); border-color: var(--accent); }
.dice-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.dice-input {
    flex: 1;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 15px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    outline: none;
}
.dice-input:focus { border-color: var(--accent); }
.dice-roll-btn {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    border: none;
}
.dice-roll-btn:active { background: var(--accent-soft); }

.dice-hint { color: var(--text-mute); font-size: 12px; text-align: center; }

/* ============ search dialog ============ */
.search-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    border: none;
    z-index: 200;
}
.search-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.search-dialog[open] {
    display: flex;
    flex-direction: column;
}
.search-form {
    padding: 8px;
    padding-top: calc(8px + var(--safe-top));
    display: flex;
    gap: 6px;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
}
.search-form input {
    flex: 1;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 16px; /* ≥16 to prevent iOS zoom */
    outline: none;
}
.search-form input:focus { border-color: var(--accent); }
.search-close {
    width: 44px;
    color: var(--text);
    font-size: 20px;
    border-radius: var(--radius-sm);
}
.search-close:active { background: var(--bg-elev-2); }
.search-results { flex: 1; overflow-y: auto; padding: 8px; padding-bottom: calc(16px + var(--safe-bot)); }
.search-section-h {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-mute);
    margin: 12px 8px 6px;
}
.search-result {
    display: block;
    padding: 12px;
    margin-bottom: 6px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
}
.search-result:active { background: var(--bg-elev-2); }
.search-result-title { font-weight: 700; font-size: 15px; }
.search-result-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ============ about screen ============ */
.about-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.about-stat:last-child { border: none; }
.about-stat .label { color: var(--text-dim); }
.about-stat .value { font-weight: 700; }

/* ============ wider screens (tablet & up) ============ */
@media (min-width: 700px) {
    .tile-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-row { grid-template-columns: repeat(6, 80px); }
    .weapon-stats { grid-template-columns: repeat(6, 80px); }
    .topbar-title { font-size: 19px; }
}
@media (min-width: 980px) {
    .topbar { grid-template-columns: 60px 1fr 60px; }
    .screen {
        padding-top: 24px;
        padding-right: 24px;
        padding-left: 24px;
        /* keep the bottom clearance from the base rule — do NOT use the
           `padding` shorthand here or it resets the bottom calc. */
    }
}

/* utility */
.hidden { display: none !important; }
.spacer-12 { height: 12px; }
.text-mute { color: var(--text-mute); }

/* ============ army builder ============ */

/* big home-page army button */
.army-cta {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    margin: 0 0 24px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 100% 0%, rgba(200, 16, 46, 0.5), transparent 55%),
        linear-gradient(140deg, var(--accent) 0%, #7a0a1d 100%);
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 6px 20px rgba(200, 16, 46, 0.35);
    position: relative;
    overflow: hidden;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.army-cta:active { transform: scale(0.985); }
.army-cta-icon {
    flex-shrink: 0;
    font-size: 38px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
.army-cta-text { flex: 1; min-width: 0; }
.army-cta-title { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.army-cta-sub   { font-size: 12.5px; color: rgba(255, 255, 255, 0.85); margin-top: 2px; }
.army-cta-chev  { font-size: 28px; color: rgba(255, 255, 255, 0.85); }

/* wizard progress */
.wiz-steps {
    display: flex;
    gap: 6px;
    margin: 0 0 20px;
}
.wiz-step {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-elev);
    overflow: hidden;
}
.wiz-step.is-done   { background: var(--accent); }
.wiz-step.is-active { background: var(--accent-soft); }

.wiz-h {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 6px;
}
.wiz-sub {
    color: var(--text-dim);
    font-size: 14px;
    margin: 0 0 18px;
}

.wiz-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.btn {
    flex: 1;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    text-decoration: none;
    transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:active { background: var(--accent-soft); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: rgba(200, 16, 46, 0.4); color: var(--accent-soft); }
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
}
.btn-sm { padding: 8px 12px; font-size: 13px; flex: 0 0 auto; }
.btn-lg { padding: 16px; font-size: 16px; }

/* big choice cards (battle size, faction, detachment) */
.choice-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 540px) {
    .choice-grid { grid-template-columns: repeat(2, 1fr); }
}
.choice {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.choice:active { background: var(--bg-elev-2); }
.choice.is-selected { border-color: var(--accent); background: var(--accent-tint); }
.choice.is-peer-pick { border-color: var(--blue); background: rgba(92, 182, 255, 0.06); }
.choice.is-agreed {
    border-color: var(--green);
    background: rgba(76, 184, 122, 0.10);
    box-shadow: 0 0 0 1px var(--green);
}

/* Per-card pick badges (You / peer name) shown on a Match-aware choice card. */
.choice-picks {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
    align-items: flex-end;
}
.choice-pick {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.choice-pick-me   { background: var(--accent); color: #fff; }
.choice-pick-peer { background: var(--blue);   color: #0d1a26; }
.choice.is-agreed .choice-pick-me,
.choice.is-agreed .choice-pick-peer { background: var(--green); color: #08200f; }
.choice-icon { flex-shrink: 0; font-size: 28px; color: var(--accent-soft); width: 36px; text-align: center; }
.choice-main { flex: 1; min-width: 0; }
.choice-title { font-weight: 700; font-size: 15px; }
.choice-sub   { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.choice-meta  { font-weight: 800; color: var(--gold); font-size: 13px; }

/* form fields */
.field { margin-bottom: 14px; }
.field-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mute);
    margin-bottom: 6px;
}
.field-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.field-input:focus { border-color: var(--accent); }
.field-help { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* army editor */
.editor-head {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.editor-name {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
}
.editor-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-dim);
}
.editor-meta b { color: var(--text); }

.points-bar {
    margin: 12px 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
}
.points-bar .label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; }
.points-bar .num { font-weight: 800; font-size: 17px; }
.points-bar .num.over { color: var(--accent-soft); }
.points-bar .bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-elev-2);
    overflow: hidden;
    border: 1px solid var(--line);
}
.points-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--gold));
    transition: width 0.2s ease;
}
.points-bar .fill.over { background: linear-gradient(90deg, var(--gold), var(--accent)); }

/* validation banners */
.banner {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.banner-error  { background: rgba(200, 16, 46, 0.10); border-color: rgba(200, 16, 46, 0.45); color: var(--accent-soft); }
.banner-warn   { background: rgba(224, 177, 58, 0.08); border-color: rgba(224, 177, 58, 0.40); color: var(--gold); }
.banner-ok     { background: rgba(76, 184, 122, 0.08); border-color: rgba(76, 184, 122, 0.30); color: var(--green); }
.banner-info   { background: var(--bg-elev); }
.banner-icon { flex-shrink: 0; font-weight: 900; }

/* unit row in editor */
.unit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-bottom: none;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    min-height: 56px;
}
.unit-row:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.unit-row:last-of-type  { border-bottom: 1px solid var(--line); border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.unit-row:active { background: var(--bg-elev-2); }
.unit-row-main { flex: 1; min-width: 0; }
.unit-row-title { font-weight: 700; font-size: 15px; }
.unit-row-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.unit-row-cost { font-weight: 800; color: var(--gold); flex-shrink: 0; }
.unit-row-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.unit-row-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}
.tag-warlord { background: rgba(224, 177, 58, 0.15); color: var(--gold); }
.tag-leader  { background: rgba(92, 182, 255, 0.15); color: var(--blue); }
.tag-attached{ background: rgba(76, 184, 122, 0.15); color: var(--green); }
.tag-enh     { background: rgba(200, 16, 46, 0.15); color: var(--accent-soft); }
.tag-epic    { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.unit-row + .add-unit-btn { margin-top: 12px; }
.add-unit-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--bg-elev);
    border: 1px dashed var(--line);
    color: var(--accent-soft);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    font-size: 15px;
}
.add-unit-btn:active { background: var(--bg-elev-2); border-color: var(--accent); }

/* unit detail screen sections */
.section-block {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}
.section-block-h {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-mute);
    margin: 0 0 10px;
}
.opt-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.opt-row:last-child { border-bottom: none; }
.opt-row input[type="checkbox"], .opt-row input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    flex-shrink: 0;
    cursor: pointer;
}
.opt-row label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
}
.opt-row-cost {
    font-weight: 800;
    color: var(--gold);
    font-size: 13px;
    flex-shrink: 0;
}
.opt-text { font-size: 14px; color: var(--text); }
.opt-text ul { padding-left: 20px; margin: 4px 0; }

/* import file input shim */
.file-import-label {
    display: inline-block;
    cursor: pointer;
}
.file-import-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* small toolbar (export, delete, etc.) */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}
.toolbar .btn { flex: 0 1 auto; }
/* The view-toggle buttons (Editor / Game-Ready) inside the toolbar — the
   active view stays as .btn-primary; the inactive one is the standard btn. */
.toolbar .btn[aria-current="page"] { cursor: default; }

/* ============ LAN Match (lobby) ============ */

/* Variant of the Army Builder card for the LAN Match entry — slightly more
   subdued so the two CTAs don't both scream for attention. */
.army-cta.lan-cta {
    background:
        radial-gradient(circle at 100% 0%, rgba(92, 182, 255, 0.35), transparent 55%),
        linear-gradient(140deg, #243a52 0%, #122031 100%);
    box-shadow: 0 6px 20px rgba(40, 70, 110, 0.35);
}

/* Tab switcher between QR mode and Manual mode (used both as a "share"
   widget and an "ingest" widget). */
.sig-tabs { margin-top: 4px; }
.sig-tabbar {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}
.sig-tab {
    flex: 1;
    padding: 8px 10px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.sig-tab.is-active {
    background: var(--accent);
    color: #fff;
}
.sig-pane[hidden] { display: none; }

/* QR display: a clean white card so the camera can read it. */
.qr-wrap {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    margin: 0 auto;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    display: block;
}

/* Camera scanner frame — boxed video with a centered reticle. */
.qr-scanner-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 360px;
    margin: 0 auto;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.qr-scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.qr-scanner-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 65%;
    height: 65%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--accent-soft);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* ============ army game-ready view ============ */
.gv-card { padding: 14px 14px 16px; }
.gv-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}
.gv-name {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}
.gv-meta {
    color: var(--text-mute);
    font-size: 13px;
}

/* Game-view abilities collapse to just their title; tap to expand. */
details.gv-ability {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--line);
}
details.gv-ability:last-of-type { border-bottom: none; }
details.gv-ability > summary {
    list-style: none;            /* hide native marker (Chrome/Firefox) */
    cursor: pointer;
    padding: 10px 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    color: var(--accent-soft);
    font-weight: 700;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: background 0.12s ease;
}
details.gv-ability > summary::-webkit-details-marker { display: none; }   /* Safari */
details.gv-ability > summary::before {
    content: "▸";
    color: var(--text-mute);
    font-size: 11px;
    flex-shrink: 0;
    transition: transform 0.18s ease, color 0.12s ease;
}
details.gv-ability[open] > summary::before {
    transform: rotate(90deg);
    color: var(--accent-soft);
}
details.gv-ability > summary:active { background: var(--bg-elev-2); }
@media (hover: hover) {
    details.gv-ability > summary:hover { background: var(--bg-elev-2); }
}
details.gv-ability > .ability-body {
    padding: 0 4px 12px 26px;    /* indent body under the chevron, drop a touch of bottom space */
    margin-top: -4px;
    color: var(--text);
}

/* ============ toast notifications ============ */
.toast-stack {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottombar-h) + var(--safe-bot) + 16px);
    z-index: 250;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-2);
    cursor: pointer;
    animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.is-leaving {
    animation: toast-out 0.22s ease forwards;
}
.toast-success {
    background: var(--green);
    color: #0a1f12;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.toast-error {
    background: var(--accent);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.toast-info {
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--line);
}
.toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    background: rgba(0, 0, 0, 0.18);
}
.toast-error .toast-icon { background: rgba(255, 255, 255, 0.18); }
.toast-info  .toast-icon { background: var(--bg-elev-2); color: var(--accent-soft); }
.toast-msg { flex: 1; line-height: 1.3; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(6px); }
}

/* on small phones — give the toast more room and keep it pinned */
@media (max-width: 480px) {
    .toast-stack { left: 16px; right: 16px; align-items: flex-end; }
    .toast       { width: 100%; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    .toast            { animation: none; }
    .toast.is-leaving { animation: none; opacity: 0; transition: opacity 0.15s; }
}

/* ============ tooltip / glossary popover ============ */
.has-glossary {
    cursor: help;
    border-bottom: 1px dotted currentColor;
    transition: background 0.12s ease;
    border-radius: 3px;
}
.has-glossary:active { background: rgba(255,255,255,0.06); }
.chip.has-glossary,
.weapon-ability.has-glossary {
    border-bottom-style: solid;
    border-bottom-width: 1px;
}

.tooltip {
    position: fixed;
    z-index: 300;
    max-width: min(360px, calc(100vw - 24px));
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-elev);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}
.tooltip.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.tooltip-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--accent-soft);
    margin: 0 0 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.tooltip-name .tooltip-cat {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mute);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 999px;
}
.tooltip-body {
    color: var(--text);
    font-size: 13.5px;
}
.tooltip-body p { margin: 6px 0; }
.tooltip-body ul { padding-left: 20px; margin: 6px 0; }
.tooltip-body .kwb { font-weight: 700; text-transform: uppercase; font-size: 0.92em; letter-spacing: 0.04em; }
.tooltip-body .kwb2.bluefont { color: var(--blue); font-weight: 700; font-size: 0.9em; letter-spacing: 0.04em; }
.tooltip-body .redExample {
    background: rgba(200, 16, 46, 0.06);
    border-left: 3px solid var(--accent);
    padding: 6px 10px;
    border-radius: 4px;
    margin: 6px 0;
    font-size: 12.5px;
}
.tooltip-body .ShowFluff { display: block; color: var(--text-dim); font-style: italic; margin-bottom: 6px; }
.tooltip-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-mute);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tooltip-close:active { background: var(--bg-elev-2); }

/* on hover (desktop), prevent flicker */
@media (hover: hover) {
    .has-glossary:hover { background: rgba(200,16,46,0.08); }
}
