:root {
    --bg: #14181c;
    --panel: #1e252b;
    --panel-2: #263038;
    --line: #33414c;
    --ink: #e6ebef;
    --muted: #90a0ad;
    --rust: #c1440e;
    --rust-soft: #d9673a;
    --ok: #3fa66a;
    --ko: #c1440e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

.app-shell { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.app-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.app-titles { flex: 1; min-width: 0; }
.lang-switch select {
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 6px; padding: .35rem .5rem; font-size: .85rem;
}
.app-header .mark {
    width: 44px; height: 44px; flex: none; border-radius: 50%;
    border: 3px solid var(--rust);
    box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 6px var(--rust-soft);
}
.app-header h1 { font-size: 1.4rem; margin: 0; letter-spacing: .5px; }
.subtitle { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }

.loading { color: var(--muted); padding: 2rem; text-align: center; }

/* Filtres */
.filters {
    display: flex; flex-wrap: wrap; gap: 1rem;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 1rem; margin-bottom: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 170px; }
.field.grow { flex: 1; }
.field label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.field select, .field input {
    background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; font-size: .95rem;
}
.field select:focus, .field input:focus { outline: 2px solid var(--rust-soft); }

/* Recherche : conditions sur les stats reconnues, ou rappel de la syntaxe */
.query-help { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; min-height: 1.6rem; }
.query-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: var(--panel-2); border: 1px solid var(--rust-soft); border-radius: 999px;
    padding: .1rem .2rem .1rem .55rem; font-size: .78rem; font-weight: 600;
}
.query-chip .icon { width: .85rem; height: .85rem; background-color: var(--ink); }
.chip-remove {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: .75rem; padding: 0 .3rem; line-height: 1;
}
.chip-remove:hover { color: var(--rust-soft); }
.hint { font-size: .72rem; color: var(--muted); }
.hint code {
    font-family: Consolas, monospace; font-size: .72rem; color: var(--ink);
    background: var(--panel-2); border-radius: 3px; padding: 0 .25rem;
}

/* Slots */
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 820px) { .slots { grid-template-columns: minmax(0, 1fr); } }

.slot { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .9rem; }
.slot-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.rank-badge { color: var(--rust-soft); font-size: 1rem; letter-spacing: 1px; }
.rank-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.clear {
    margin-left: auto; background: transparent; border: none; color: var(--muted);
    cursor: pointer; font-size: 1rem; padding: .1rem .3rem;
}
.clear:hover { color: var(--rust-soft); }

.picker { display: flex; flex-direction: column; gap: .4rem; max-height: 340px; overflow-y: auto; }
.cog-option {
    display: flex; flex-direction: column; text-align: left; gap: .1rem;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
    padding: .5rem .6rem; cursor: pointer; color: var(--ink);
}
.cog-option:hover { border-color: var(--rust-soft); }
.cog-name { font-weight: 600; }
.cog-title { font-size: .82rem; color: var(--muted); }
.cog-min { font-size: .72rem; color: var(--rust-soft); }
.cog-via { font-size: .72rem; color: var(--muted); font-style: italic; }
.empty { color: var(--muted); font-size: .85rem; font-style: italic; }

.cog-card { display: flex; flex-direction: column; gap: .7rem; }

/* Icônes du livre de règles teintées via mask-image (stats LDR p.15, pictogrammes LDR p.20) */
.icon {
    display: inline-block; flex: none; width: 1.15rem; height: 1.15rem; background-color: var(--muted);
    -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat;
}
.icon.active        { -webkit-mask-image: url("../img/icons/active.png");        mask-image: url("../img/icons/active.png"); }
.icon.permanent     { -webkit-mask-image: url("../img/icons/permanent.png");     mask-image: url("../img/icons/permanent.png"); }
.icon.freq-planning { -webkit-mask-image: url("../img/icons/freq-planning.png"); mask-image: url("../img/icons/freq-planning.png"); }
.icon.freq-cycle    { -webkit-mask-image: url("../img/icons/freq-cycle.png");    mask-image: url("../img/icons/freq-cycle.png"); }
.icon.freq-game     { -webkit-mask-image: url("../img/icons/freq-game.png");     mask-image: url("../img/icons/freq-game.png"); }

/* Caractéristiques (composant StatLine) */
.stat-line { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.stat {
    display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center;
    column-gap: .35rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
    padding: .3rem .2rem .2rem;
}
.stat-icon.tech   { -webkit-mask-image: url("../img/stats/tech.png");   mask-image: url("../img/stats/tech.png"); }
.stat-icon.melee  { -webkit-mask-image: url("../img/stats/melee.png");  mask-image: url("../img/stats/melee.png"); }
.stat-icon.ranged { -webkit-mask-image: url("../img/stats/ranged.png"); mask-image: url("../img/stats/ranged.png"); }
.stat-icon.dodge  { -webkit-mask-image: url("../img/stats/dodge.png");  mask-image: url("../img/stats/dodge.png"); }
.stat-value { font-weight: 700; font-size: 1.05rem; line-height: 1; }
.stat-abbr {
    grid-column: 1 / -1; text-align: center; font-size: .62rem; letter-spacing: .8px;
    color: var(--muted); margin-top: .15rem;
}
.stat.zero .stat-value, .stat.zero .icon { opacity: .4; }

.stat-line.compact { display: flex; gap: .8rem; margin-top: .2rem; }
.stat-line.compact .stat { background: none; border: none; padding: 0; column-gap: .25rem; }
.stat-line.compact .icon { width: .9rem; height: .9rem; }
.stat-line.compact .stat-value { font-size: .85rem; font-weight: 600; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.life-line { display: flex; flex-wrap: wrap; gap: 4px; }
.pip { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #0000; }
.pip.s { background: var(--rust); }
.pip.r { background: #8a97a1; }
.pip.t { background: #10151a; border-color: var(--rust); }

.equipment-zone { display: flex; flex-direction: column; gap: .3rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.equipment-zone label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.equip-stepper { display: flex; align-items: center; gap: .35rem; }
.equip-stepper select { flex: 1; }
.equip-stepper .step { width: 2.2rem; height: 2.2rem; font-size: 1.3rem; }
.equip-position { font-size: .72rem; color: var(--muted); text-align: center; }

.equipment-zone select {
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 6px; padding: .45rem .5rem; font-size: .9rem;
    width: 100%; min-width: 0; text-overflow: ellipsis;
}

/* Légalité */
.legality { margin-top: 1.5rem; border-radius: 10px; padding: 1rem 1.2rem; border: 1px solid var(--line); }
.legality h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.legality.ok { border-color: var(--ok); background: rgba(63, 166, 106, .1); }
.legality.ok h2 { color: var(--ok); }
.legality.ko { border-color: var(--ko); background: rgba(193, 68, 14, .08); }
.legality.ko h2 { color: var(--rust-soft); }
.legality ul { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.legality li { margin: .15rem 0; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #7a2a10; color: #fff; padding: .6rem 1rem; z-index: 1000;
}
#blazor-error-ui a { color: #fff; margin-left: 1rem; }

/* Capacités (AbilityList) : colonne de pictogrammes puis nom et effet de jeu */
.abilities { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.ability { display: flex; gap: .55rem; align-items: flex-start; font-size: .82rem; line-height: 1.4; }
.ability-picts {
    display: flex; flex-direction: column; align-items: center; gap: .25rem; flex: none;
    width: 1.3rem; padding-top: .1rem;
}
.ability-picts .icon { background-color: var(--ink); }
.ability-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ability-name { font-weight: 600; text-transform: uppercase; letter-spacing: .3px; font-size: .78rem; }
.game-effect { color: var(--muted); }
.game-effect .icon { width: .95em; height: .95em; vertical-align: -.12em; background-color: var(--ink); margin: 0 .1em; }
.pict-img { width: 1.05rem; height: 1.05rem; vertical-align: -.15em; }
.game-effect .pict-img { width: .95em; height: .95em; margin: 0 .1em; }

/* Fréquences : silhouette du livre, chiffre superposé (au-dessus de la couronne) */
.freq { position: relative; display: inline-flex; justify-content: center; align-items: center; }
.freq .freq-n {
    position: absolute; inset: 0; display: flex; justify-content: center; align-items: center;
    font-size: .68rem; font-weight: 800; color: var(--bg); line-height: 1;
}
.freq.freq-planning .freq-n { color: var(--ink); align-items: flex-start; top: -.45rem; }
.freq.freq-planning { margin-top: .35rem; }
.game-effect .freq .freq-n { font-size: .58em; }
.game-effect .freq.freq-planning .freq-n { top: -.4em; }

.pict-unknown { font-family: Consolas, monospace; font-size: .75rem; color: var(--rust-soft); }

/* Texte d'une carte non traduit : affiché dans la langue de référence */
.untranslated { font-style: italic; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }

/* Export (texte au format bwaaaanegamesdb.fr, ou JSON) */
.export { margin-top: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; }
.export h2 { margin: 0 0 .7rem; font-size: 1.05rem; }
.export-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: .8rem; }
.export-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.export-modes button {
    background: var(--panel-2); color: var(--muted); border: none; padding: .5rem .9rem;
    font-size: .9rem; cursor: pointer;
}
.export-modes button + button { border-left: 1px solid var(--line); }
.export-modes button.active { background: var(--rust); color: #fff; }
.export-warning { color: var(--rust-soft); font-size: .85rem; margin: 0 0 .5rem; }
.export-output {
    width: 100%; resize: vertical; background: var(--bg); color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; padding: .6rem .7rem;
    font-family: Consolas, "Cascadia Mono", monospace; font-size: .85rem; line-height: 1.45;
}
.export-actions { display: flex; gap: .6rem; margin-top: .6rem; }
.btn {
    display: inline-block; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 6px; padding: .45rem .9rem; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--rust-soft); }

.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.primary { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--rust-soft); }
.btn.danger { color: var(--rust-soft); border-color: var(--rust); background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .8rem; }

/* Planche des cartes (/builder/cards) : A4 paysage, cartes à taille réelle, positions en % de la page */
.cards-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .8rem 1.2rem; margin-bottom: 1rem; }
.cards-titles { flex: 1 1 18rem; min-width: 0; }
.cards-titles h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.cards-titles .hint { margin: 0; font-size: .8rem; }
.cards-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.card-sheet {
    position: relative; width: 100%; aspect-ratio: 297 / 210; background: #fff;
    border-radius: 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, .45); overflow: hidden;
}
.card-sheet-card, .card-sheet-empty { position: absolute; display: block; }
.card-sheet-card { object-fit: fill; }
.card-sheet-empty { border: 1px dashed #c8c8c8; box-sizing: border-box; }
.card-sheet { page: cards; }
@page cards { size: A4 landscape; margin: 0; }
@media print {
    html, body { background: #fff !important; }
    .app-header, .cards-toolbar, #blazor-error-ui { display: none !important; }
    .app-shell { max-width: none; margin: 0; padding: 0; }
    .card-sheet { width: 297mm; height: 210mm; aspect-ratio: auto; border-radius: 0; box-shadow: none; break-inside: avoid; }
    .card-sheet-empty { display: none; }
}

/* Constructeur ouvert depuis l'inscription à un tournoi */
.tournament-notice {
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: 0 0 .8rem; padding: .55rem .8rem;
    border: 1px solid var(--ok); border-radius: 8px; background: rgba(63, 166, 106, .1); font-size: .88rem;
}
.tournament-notice a { color: var(--ok); font-weight: 600; }

/* Cabales sauvegardées sur l'appareil */
.builder-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.builder-tools .count {
    display: inline-block; min-width: 1.3rem; margin-left: .3rem; padding: 0 .35rem; border-radius: 999px;
    background: var(--rust); color: #fff; font-size: .75rem; font-weight: 700; text-align: center;
}
.load-notice {
    display: flex; align-items: center; gap: .5rem; margin: 0; padding: .35rem .6rem; border-radius: 8px;
    border: 1px solid var(--rust); background: rgba(193, 68, 14, .1); color: var(--rust-soft); font-size: .85rem;
}
.export-controls > .btn { min-width: 9.5rem; text-align: center; }   /* « Sauvegardée ✓ » sans décalage */
.saved-cabals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.saved-cabal {
    display: flex; flex-direction: column; gap: .35rem;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem;
}
.saved-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem; }
.saved-meta { font-size: .75rem; color: var(--muted); }
.saved-slots { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.saved-slots .stars { display: inline-block; width: 2.6em; color: var(--rust); font-size: .75rem; }
.saved-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.library-import { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.library-import input[type="file"] { display: none; }
.library-import .export-warning { margin: 0; }

/* Lancement du mode partie (constructeur) */
.play-launch { margin-top: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; }
.play-launch h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.play-launch-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.play-launch-intro { margin: 0 0 .6rem; color: var(--muted); font-size: .88rem; }

/* Mode partie : pensé pour un téléphone ou une tablette posé sur la table */
.play-empty { text-align: center; padding: 2rem 0; }
.play-bar {
    position: sticky; top: 0; z-index: 10;
    display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: .6rem .8rem; margin-bottom: .8rem;
}
.play-ident { display: flex; align-items: center; gap: .6rem; flex: 1 1 12rem; min-width: 0; }
.play-back {
    flex: none; width: 2.4rem; height: 2.4rem; display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 1.1rem;
}
.play-back:hover { border-color: var(--rust-soft); }
.play-names { display: flex; flex-direction: column; min-width: 0; }
.play-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-faction { font-size: .78rem; color: var(--muted); }
.play-counters { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.counter { display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.counter-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.counter-value { font-size: 1.3rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter-value small { font-size: .8rem; color: var(--muted); font-weight: 600; }
.counter-track { display: flex; align-items: center; gap: .35rem; }
.counter.lost .counter-label { color: var(--rust-soft); }
.vp-value { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.play-commands { display: flex; gap: .5rem; flex-wrap: wrap; }
.play-commands .btn { min-height: 2.4rem; }


.play-cogs { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; }
@media (min-width: 1000px) { .play-cogs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.play-cog {
    display: flex; flex-direction: column; gap: .65rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .8rem;
}
.play-cog.ooa { opacity: .6; border-style: dashed; }
.play-cog-head { display: flex; align-items: center; gap: .55rem; }
.play-cog-names { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.status-badge {
    flex: none; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.status-badge.tainted { border-color: #8c6bb1; color: #b89ad6; }
.status-badge.corrupted { border-color: #7b3fb8; background: #7b3fb8; color: #fff; }
.status-badge.outOfAction { border-color: var(--rust); background: var(--rust); color: #fff; }

.play-hp { display: flex; align-items: center; gap: .6rem; }
.life-line.play { gap: 5px; flex: 1; }
.life-line.play .pip { width: 24px; height: 24px; padding: 0; cursor: pointer; position: relative; }
.pip.fortified { box-shadow: 0 0 0 2px var(--ok); }
.pip.marked { opacity: .35; }
.pip.marked::after {
    content: "✕"; position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1;
}
.hp-count { font-size: 1.25rem; font-weight: 700; white-space: nowrap; min-width: 3.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.hp-count small { font-size: .8rem; color: var(--muted); }

.play-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.play-row .btn { min-height: 2.3rem; }
.amount { display: flex; align-items: center; gap: .5rem; }
.amount-value { font-size: 1.4rem; font-weight: 700; min-width: 2ch; text-align: center; }
.amount-label { color: var(--muted); font-size: .85rem; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--rust); }
.check.disabled { opacity: .45; }
.play-preview { margin: 0; font-size: .85rem; color: var(--muted); }

.step {
    width: 2.3rem; height: 2.3rem; flex: none; border-radius: 8px; cursor: pointer;
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); font-size: 1.15rem; line-height: 1;
}
.step:hover:not(:disabled) { border-color: var(--rust-soft); }
.step:disabled { opacity: .35; cursor: default; }

.play-tracks { display: flex; flex-direction: column; gap: .4rem; }
.track { display: flex; align-items: center; gap: .45rem; }
.track-label { width: 5.5rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.token-track { display: inline-flex; gap: .25rem; min-width: 0; }
.token { width: 1.5rem; height: 1.5rem; }
.token.off { opacity: .18; filter: grayscale(1); }
.counter .token { width: 1.25rem; height: 1.25rem; }

.toggle {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; min-height: 2.3rem;
    background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
    padding: .3rem .8rem; font-size: .85rem;
}
.toggle .pict-img { width: 1.1rem; height: 1.1rem; opacity: .5; }
.toggle .pip { width: 13px; height: 13px; }
.toggle.on { color: var(--ink); border-color: var(--rust-soft); background: rgba(193, 68, 14, .18); font-weight: 600; }
.toggle.on .pict-img { opacity: 1; }

.play-abilities { list-style: none; margin: 0; padding: .5rem 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .4rem; }
.play-abilities li { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.ability-picts.row { flex-direction: row; width: auto; min-width: 1.3rem; padding: 0; }
.play-ability-name { flex: 1; min-width: 0; font-weight: 600; }
.uses-left { font-weight: 700; font-variant-numeric: tabular-nums; }
.uses-left.none { color: var(--rust-soft); }

.play-card-text { border-top: 1px solid var(--line); padding-top: .4rem; }
.play-card-text summary { cursor: pointer; font-size: .8rem; color: var(--muted); padding: .2rem 0; }
.play-card-text h4 { margin: .7rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
.play-card-text .abilities { margin-top: .4rem; }

.play-footer { margin-top: 1.5rem; text-align: center; }

/* Fin de partie, à la place du bouton de fin de cycle */
.play-over {
    display: inline-flex; align-items: center; min-height: 2.4rem; padding: .3rem .8rem; border-radius: 8px;
    border: 1px solid var(--ok); background: rgba(63, 166, 106, .12); font-size: .85rem; font-weight: 600;
}
.play-over.lost { border-color: var(--ko); background: rgba(193, 68, 14, .15); color: var(--rust-soft); }
/* Même case pour tous : elle prend la taille du plus grand, l'élément courant la remplit */
.play-end { display: grid; }
.play-end > * { grid-area: 1 / 1; justify-content: center; text-align: center; }
.play-end > .off { visibility: hidden; }

/* Carte supplémentaire (Medic Ruzicka) */
.play-extra { display: flex; flex-direction: column; gap: .3rem; }
.play-extra label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.play-extra select {
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 6px; padding: .45rem .5rem; font-size: .9rem; width: 100%; min-width: 0;
}

/* Fenêtre superposée (Sheet) : panneau en bas sur téléphone, centré sur grand écran */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 10, .6);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
    width: 100%; max-width: 28rem; max-height: 90vh; overflow-y: auto; outline: none;
    display: flex; flex-direction: column; gap: .7rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 0 0;
    padding: .9rem 1rem calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .45);
}
@media (min-width: 600px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: 14px; }
}
.sheet-head { display: flex; align-items: center; gap: .5rem; }
.sheet-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.sheet-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.sheet-actions .btn { min-height: 2.6rem; min-width: 6.5rem; }

/* Notification : compte rendu de la dernière action, par-dessus la page */
.toast {
    position: fixed; z-index: 90; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
    width: max-content; max-width: min(32rem, calc(100vw - 1.5rem));
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--rust-soft); border-radius: 10px;
    display: flex; align-items: center; gap: .8rem;
    padding: .55rem .6rem .55rem .9rem; font-size: .88rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); cursor: pointer;
    animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, .6rem); } }

/* Téléphone : en-tête compact, pour laisser la place aux rouages */
@media (max-width: 600px) {
    .app-shell { padding: .8rem .75rem 3rem; }
    .app-header { gap: .6rem; margin-bottom: .8rem; }
    .app-header .mark { width: 30px; height: 30px; border-width: 2px; }
    .app-header h1 { font-size: 1.02rem; }
    .subtitle { font-size: .78rem; }
    /* Barre trop haute pour rester fixée : « Annuler » est aussi dans les notifications. */
    .play-bar { position: static; padding: .5rem .6rem; gap: .5rem .8rem; }
    .play-bar .step { width: 2rem; height: 2rem; }
    .play-counters { gap: .45rem .8rem; }
    .play-back { width: 2.1rem; height: 2.1rem; }
    .play-cog { padding: .7rem; }
}

/* Navigation entre les apps (en-tête) */
.app-header a.mark { display: block; }
.app-nav a {
    color: var(--ink); text-decoration: none; font-size: .85rem; white-space: nowrap;
    border: 1px solid var(--line); border-radius: 6px; padding: .35rem .65rem;
}
.app-nav a:hover { border-color: var(--rust-soft); }

/* ---- Tournois (/pairings/) ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.panel h2 { margin: 0 0 .7rem; font-size: 1.1rem; }
.panel h3 { margin: 0 0 .7rem; font-size: 1rem; }
.panel h4 { margin: .9rem 0 .4rem; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tn-intro { margin: 0 0 .8rem; color: var(--muted); font-size: .88rem; }
.tn-inline { display: flex; gap: .5rem; flex-wrap: wrap; }
.tn-inline input {
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
    padding: .5rem .6rem; font-size: 1rem; width: 14rem; max-width: 100%;
}
.tn-join .tn-inline input { text-transform: uppercase; letter-spacing: 2px; width: 10rem; }
.tn-form { display: flex; flex-direction: column; gap: .9rem; }
.tn-fields { display: flex; flex-wrap: wrap; gap: .8rem 1rem; }
.tn-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tn-actions .btn { min-height: 2.4rem; }
.tn-modes { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.tn-modes legend { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 0 .3rem; }
.tn-modes label { display: flex; gap: .5rem; align-items: baseline; font-size: .88rem; cursor: pointer; }
.tn-modes .tn-sub { margin-left: 1.6rem; color: var(--muted); }
.tn-modes .tn-sub.off { opacity: .45; }
.tn-problems { margin: 0; padding-left: 1.2rem; color: var(--rust-soft); font-size: .85rem; }
.tn-legal { margin: 0; color: var(--ok); font-size: .85rem; }

.tn-mine { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.tn-mine li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .45rem .6rem; background: var(--panel-2); border-radius: 8px; }
.tn-mine-name { color: var(--ink); font-weight: 700; text-decoration: none; }
.tn-mine-name:hover { color: var(--rust-soft); }
.tn-code-small { font-family: Consolas, monospace; font-size: .8rem; color: var(--muted); letter-spacing: 1px; }
.tn-role { font-size: .7rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; color: var(--muted); }
.tn-mine-actions { margin-left: auto; display: flex; gap: .4rem; }

.tn-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .6rem 1rem; }
.tn-head-main { flex: 1 1 16rem; min-width: 0; }
.tn-head h2 { margin: 0; }
.tn-meta { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
.tn-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.tn-code { font-family: Consolas, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: 3px; }
.tn-phase { font-size: .72rem; border-radius: 999px; padding: .1rem .55rem; border: 1px solid var(--line); color: var(--muted); }
.tn-phase.registration { border-color: var(--ok); color: var(--ok); }
.tn-phase.started { border-color: var(--rust-soft); color: var(--rust-soft); }
.tn-head-tools { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.tn-head-tools .tn-share { flex: 1 1 16rem; }
.tn-share code { flex: 1; }
.tn-share .btn { flex: none; }
.tn-share { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }
.tn-share code {
    font-family: Consolas, monospace; font-size: .8rem; background: var(--panel-2); border-radius: 4px; padding: .2rem .4rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; user-select: all;
}
.tn-links { display: flex; flex-direction: column; gap: .8rem; }
.panel.tn-danger { border-color: var(--rust); }
.panel.tn-keep { border-color: var(--ok); }
.panel.tn-keep h3 { color: var(--ok); }
.tn-keep-body { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.tn-keep-link { flex: 1 1 16rem; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; }
.tn-keep-link .tn-share { width: 100%; }
.tn-qr { display: block; background: #fff; padding: 6px; border-radius: 6px; image-rendering: pixelated; max-width: 100%; height: auto; }
.panel.tn-danger h3 { color: var(--rust-soft); }

.tn-faction { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.tn-alignment { font-size: .66rem; text-transform: uppercase; letter-spacing: .5px; border-radius: 999px; padding: 0 .4rem; border: 1px solid; }
.tn-alignment.light { color: #e2c46b; border-color: #8a7536; }
.tn-alignment.dark { color: #9fb0c8; border-color: #4d5b70; }
.tn-player-name { font-weight: 700; }

.tn-picker { display: flex; flex-direction: column; gap: .5rem; padding: .7rem .8rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.tn-picker-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.tn-picker-title { font-weight: 700; margin-right: auto; }
.tn-picker select {
    background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
    padding: .35rem .5rem; font-size: .85rem; max-width: 100%; min-width: 0;
}
.tn-picker input[type="file"] { display: none; }
.tn-picker .export-warning { margin: 0; }
.tn-paste {
    width: 100%; box-sizing: border-box; resize: vertical; background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem;
    font-family: Consolas, "Cascadia Mono", monospace; font-size: .85rem; line-height: 1.45;
}
.tn-paste:focus { outline: 2px solid var(--rust-soft); }

.tn-cabals { display: flex; flex-wrap: wrap; gap: .6rem; }
.tn-cabal { min-width: 0; }
.tn-cabals .tn-cabal { flex: 1 1 14rem; }        /* côte à côte dans une liste de cabales seulement */
.tn-cabal-name { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.tn-cabal ul { list-style: none; margin: 0; padding: 0; font-size: .85rem; display: flex; flex-direction: column; gap: .1rem; }
.tn-cabal .stars { display: inline-block; width: 2.6em; color: var(--rust); font-size: .72rem; }
.tn-equipment { color: var(--muted); }
.tn-player-card { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .8rem; }

.tn-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.tn-players li { padding: .45rem .6rem; background: var(--panel-2); border-radius: 8px; }
.tn-players li.mine { box-shadow: inset 3px 0 0 var(--rust); }
.tn-players li.dropped .tn-player-name { text-decoration: line-through; color: var(--muted); }
.tn-player-line { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.tn-player-actions { margin-left: auto; }
.tn-dropped { font-size: .7rem; color: var(--rust-soft); }
.tn-player-lists summary, .tn-history summary { cursor: pointer; font-size: .8rem; color: var(--muted); padding: .3rem 0; }
.tn-player-lists .tn-cabals { padding-top: .4rem; }
.tn-history { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .3rem; }

/* Tables d'une ronde : même grille en lecture et en saisie, rien ne bouge d'une ligne à l'autre */
.tn-tables, .tn-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.tn-table, .tn-result {
    display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .5rem;
    padding: .45rem .6rem; background: var(--panel-2); border-radius: 8px;
}
.tn-result { grid-template-columns: 4.2rem minmax(0, 1fr) auto minmax(0, 1fr) 6.2rem; }
.tn-table.mine { box-shadow: inset 3px 0 0 var(--rust); }
.tn-table-number { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tn-side { display: flex; flex-direction: column; min-width: 0; }
.tn-side .tn-player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-side.tn-right { align-items: flex-end; text-align: right; }
.tn-score { font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; min-width: 4.5rem; }
.tn-bye { color: var(--muted); font-weight: 400; font-style: italic; }
.tn-inputs { display: inline-flex; align-items: center; gap: .3rem; }
.tn-inputs input {
    width: 3.6rem; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
    padding: .35rem .3rem; font-size: 1rem; text-align: center; font-variant-numeric: tabular-nums;
}
.tn-result-save { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.tn-result-state { width: 1rem; text-align: center; font-weight: 700; }
.tn-result-state.saved { color: var(--ok); }
.tn-result-state.dirty { color: var(--rust-soft); }
.tn-result-state.error { color: var(--ko); }

/* Statistiques : barres en CSS seul (libellé, barre, %, détail), estompées si l'échantillon est petit */
.stat-row {
    display: grid; grid-template-columns: minmax(8rem, 15rem) minmax(4rem, 1fr) 3.2rem minmax(5rem, 11rem);
    align-items: center; gap: .3rem .7rem; padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: .88rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row.muted { opacity: .55; }
.stat-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar { height: .7rem; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.stat-bar > span { display: block; height: 100%; background: var(--rust); border-radius: 999px; }
.stat-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-detail { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.tn-home-links { margin: 0 0 1rem; text-align: right; }
.hint a { color: var(--rust-soft); }
#stats-faction { max-width: 24rem; }
.tn-home-links a { color: var(--rust-soft); font-weight: 600; }
.tn-check { display: flex; gap: .5rem; align-items: baseline; font-size: .88rem; cursor: pointer; }
.tn-played { display: block; font-size: .72rem; color: var(--muted); }
.tn-cabal-choice { display: inline-flex; gap: .25rem; margin-top: .2rem; }
.tn-cabal-choice button {
    width: 2.4rem; padding: .15rem 0; font-size: .75rem; cursor: pointer;
    background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 5px;
}
.tn-cabal-choice button.on { background: var(--rust); border-color: var(--rust); color: #fff; }
.tn-cabal-choice button:disabled { cursor: default; }
@media (max-width: 600px) {
    .stat-row { grid-template-columns: minmax(0, 1fr) 3.2rem; }
    .stat-bar { grid-column: 1 / -1; grid-row: 2; }
    .stat-detail { grid-column: 1 / -1; }
}

.tn-scroll { overflow-x: auto; }
.tn-standings { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tn-standings th { font-size: .7rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.tn-standings th, .tn-standings td { padding: .4rem .45rem; text-align: center; border-bottom: 1px solid var(--line); }
.tn-standings .tn-left { text-align: left; }
.tn-standings td.tn-left .tn-faction { margin-left: .4rem; }
.tn-standings .tn-strong { font-weight: 700; }
.tn-standings tr.mine td { background: rgba(193, 68, 14, .1); }
.tn-standings tr.dropped .tn-player-name { text-decoration: line-through; color: var(--muted); }

@media (max-width: 600px) {
    .panel { padding: .8rem; }
    .app-nav a { padding: .3rem .5rem; font-size: .8rem; }
    .tn-table, .tn-result { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); row-gap: .2rem; }
    .tn-table-number, .tn-result-save { grid-column: 1 / -1; }
    .tn-faction { font-size: .72rem; }
    .tn-head-side { align-items: flex-start; flex-direction: row; }
}
