/* Last Loop — mise en page paysage, mobile d'abord (GDD §14 et §15.3).
   Refonte 0.12 : « le pupitre du mécanicien ». Des plaques de tôle rivetées (pupitre, panneaux, fenêtres),
   des boutons en émail qui s'enfoncent, des listes tenues comme un registre de gare (lignes séparées par
   un filet, pas une carte par ligne). Titres en sérif à empattements carrés, en minuscules.
   Un seul univers visuel, sombre : le jeu ne suit pas le thème clair/sombre de l'appareil.
   Polices système uniquement (GDD). */
:root {
  /* Matières */
  --soot: #18171c;          /* fond, entre les plaques */
  --plate: #25242b;         /* tôle des panneaux */
  --plate-2: #2d2c34;       /* tôle relevée (boutons, lignes actives) */
  --well: rgba(0, 0, 0, 0.22); /* creux dans une plaque (registres, jauges) */
  --line: rgba(239, 230, 207, 0.11);
  --line-2: rgba(239, 230, 207, 0.2);
  --enamel: #efe6cf;        /* texte */
  --dim: #aaa297;           /* texte secondaire */
  --brass: #c4a465;         /* titres, filets et rivets */
  --amber: #e8a33d;         /* action principale, sélection */
  --amber-lip: #9a6420;
  --teal: #3e8e8a;          /* Halte, information */
  --danger: #c8382d;
  --leaf: #8fd17e;          /* santé, gains */
  --gold: #f2c14e;
  /* Anciennes variables (encore lues par quelques styles en ligne) */
  --ink: #2b2a33; --ink-deep: var(--soot); --ash: #6e6a6f; --bone: var(--enamel); --rust: #b5562b;
  --muted: var(--dim); --panel: rgba(37, 36, 43, 0.97);
  /* Typographies */
  --font-display: "Rockwell", "Roboto Slab", "Zilla Slab", "Noto Serif", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  /* Dimensions */
  --top-h: 40px;
  --tabs-w: 60px;
  --bottom-h: 132px;
  --radius: 10px;
  --z-tuto: 45;             /* tutoriel : au-dessus des fenêtres ; le bouton du menu juste au-dessus de lui */
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--soot);
  color: var(--enamel);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#app { position: relative; height: 100%; width: 100%; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.modal-card:focus { outline: none; }   /* la fenêtre reçoit le focus à l'ouverture : pas d'anneau autour d'elle */
.muted { color: var(--dim); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.eyebrow { font-size: 13px; color: var(--dim); margin: 0; }
.warn-text { color: #ffb36b; }
.gain-text { color: #b5dc8c; font-weight: 700; }
.screen { position: absolute; inset: 0; }
/* L'attribut hidden l'emporte toujours (sinon display: flex/grid des écrans le neutralise hors de l'artefact) */
[hidden] { display: none !important; }

/* ---------- La plaque rivetée (signature) ---------- */
.plate, .bottom > .panel, .side-panel, .modal-card {
  --rv: radial-gradient(circle at 45% 40%, #ead39d 0 0.9px, #8a744c 1.7px, #3c3427 2.5px, transparent 3px);
  background:
    var(--rv) 5px 5px / 7px 7px no-repeat,
    var(--rv) calc(100% - 5px) 5px / 7px 7px no-repeat,
    var(--rv) 5px calc(100% - 5px) / 7px 7px no-repeat,
    var(--rv) calc(100% - 5px) calc(100% - 5px) / 7px 7px no-repeat,
    linear-gradient(180deg, #2b2a31 0%, var(--plate) 38%, #222127 100%);
  border: 1px solid #3a3841;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 0 rgba(0, 0, 0, 0.35);
}

/* ---------- Boutons : émail qui s'enfonce ---------- */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #393841, #302f37);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 0 #111015;
  font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 #111015; }
.btn-primary {
  background: linear-gradient(180deg, #f0b452, #e19a2f); border-color: #f5c97f; color: #231b0d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 0 var(--amber-lip);
}
.btn-primary:active:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 0 var(--amber-lip); }
.btn-danger { background: transparent; border-color: var(--danger); color: #f3a59d; box-shadow: none; }
.tr-danger { border-top: 1px dashed var(--line-2); padding-top: 10px; margin-top: 4px; }
.btn-ghost { background: transparent; border-color: var(--line-2); box-shadow: none; color: var(--dim); }
.btn-big { min-height: 52px; padding: 0 34px; font-size: 18px; font-family: var(--font-display); letter-spacing: 0.04em; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
/* Zone de toucher d'au moins 44 × 44 px autour des petits boutons, sans changer leur dessin (ergonomie mobile, WCAG 2.5.8) */
.btn-small, .btn-depart, .chip-speed, .chip-zoom, .chip-auto, .sb-shop-btn { position: relative; }
.btn-small::before, .btn-depart::before, .chip-speed::before, .chip-zoom::before, .chip-auto::before, .sb-shop-btn::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}
/* « Résumé du tour » : sa zone ne s'étend que vers le bas (au-dessus, elle mordait sur « Volontaire » ; « Partir », dessous, garde la sienne) */
.sb-depot-actions .btn-small::before { top: 0; transform: translateX(-50%); }
/* Boutons du Dépôt (en-tête du pupitre) : la place manque pour 44 px ; la zone va du bord du pupitre aux cartes de voie */
.sb-shop-btn::before { left: -3px; right: -3px; top: -6px; bottom: -4px; width: auto; height: auto; transform: none; }
.btn:disabled { opacity: 0.42; cursor: default; box-shadow: none; }
.btn-depart { min-height: 46px; font-family: var(--font-display); letter-spacing: 0.06em; font-size: 17px; text-transform: uppercase; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent;
  display: grid; place-items: center; border-radius: 8px;
}
.icon-btn:active { background: rgba(239, 230, 207, 0.08); }
.icon-btn.small { width: 34px; height: 34px; font-size: 13px; border: 1px solid var(--line-2); background: var(--plate-2); }
.icon-btn.small:disabled { opacity: 0.3; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(37, 36, 43, 0.82);
  font-size: 13px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.chip.on { background: var(--amber); color: #231b0d; border-color: var(--amber); }
.chip-primary { border-color: var(--amber); color: var(--amber); font-weight: 700; }
.chip-danger { border-color: var(--danger); color: #f3a59d; }

/* ---------- Titres ---------- */
.panel-title {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 15px;
  color: #e7d3a4; letter-spacing: 0.01em;
}
.sheet h3 {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 0; font-family: var(--font-display); font-size: 15px; font-weight: 700; color: #e7d3a4;
}
.sheet h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(196, 164, 101, 0.45), transparent); }

/* ---------- Chargement ---------- */
.screen-loading { display: grid; place-items: center; background: var(--soot); padding-inline: 24px; }
.loading-box { display: grid; gap: 14px; width: min(420px, 100%); }
.loading-box .eyebrow { font-family: var(--font-display); font-size: 16px; color: #e7d3a4; }
.loading-track { height: 6px; background: #34323b; border-radius: 3px; overflow: hidden; }
.loading-bar { height: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform 0.2s; }
.loading-tip { margin: 0; color: var(--dim); font-style: italic; line-height: 1.4; }

/* ---------- Écran titre ---------- */
.screen-title canvas { position: absolute; inset: 0; display: block; }
.title-shade {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(24, 23, 28, 0.9) 0%, rgba(24, 23, 28, 0.62) 34%, rgba(24, 23, 28, 0) 58%);
}
.title-content {
  position: absolute; left: max(28px, env(safe-area-inset-left, 0px)); top: 0; bottom: 0;
  width: min(46%, 400px);
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.logo { margin: 0; font-family: var(--font-display); line-height: 0.86; display: grid; text-transform: uppercase; }
.logo-the { font-size: 15px; letter-spacing: 0.5em; color: var(--dim); font-weight: 400; }
.logo-loop {
  font-size: clamp(48px, 15vh, 92px); color: var(--amber); font-weight: 800; letter-spacing: 0.02em;
  text-shadow: 3px 3px 0 var(--rust), 6px 6px 0 rgba(24, 23, 28, 0.7);
}
.logo-loop2 { color: var(--enamel); margin-left: 0.55em; text-shadow: 3px 3px 0 var(--rust), 6px 6px 0 rgba(24, 23, 28, 0.7); }
.logo-express {
  font-size: clamp(20px, 6vh, 34px); letter-spacing: 0.32em; color: var(--enamel); font-weight: 700;
  border-top: 3px solid var(--rust); padding-top: 6px; margin-top: 4px; width: max-content;
}
.title-sub { margin: 4px 0 8px; color: var(--dim); max-width: 32ch; line-height: 1.35; }
.title-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* Boutons secondaires posés sur l'illustration : fond sombre pour rester lisibles */
.title-actions .btn-ghost { background: rgba(24, 23, 28, 0.62); color: var(--enamel); }
.title-confirm { margin: 0; flex-basis: 100%; line-height: 1.35; max-width: 34ch; }
.title-version {
  position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: 10px; margin: 0;
  font-size: 12px; color: rgba(239, 230, 207, 0.6);
}

/* ---------- Jeu : grille paysage ---------- */
.screen-game {
  display: grid;
  grid-template-columns: var(--tabs-w) 1fr;
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--bottom-h);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--soot);
}

/* Barre du haut : jauges du pupitre */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-inline: 10px 2px;
  background: linear-gradient(180deg, #24232a, #1d1c22);
  border-bottom: 1px solid #34323b;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  min-width: 0;
}
.hud-res { display: flex; gap: 14px; align-items: center; min-width: 0; overflow: hidden; }
.res { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.res svg { width: 19px; height: 19px; flex: none; }
.res.low .res-val { color: #ff8a7e; }
.res.full .res-val { color: var(--gold); }
.res.short { border-radius: 6px; animation: res-short 0.9s steps(2) infinite; }
.res.short .res-val { color: #ff8a7e; }
@keyframes res-short { 0% { background: rgba(200, 56, 45, 0.55); } 100% { background: transparent; } }
.hud-hunt { display: flex; align-items: center; gap: 3px; font: 700 12px var(--font-ui, inherit); color: #f0c27a; background: rgba(200, 56, 45, 0.18); border: 1px solid rgba(200, 56, 45, 0.45); border-radius: 10px; padding: 1px 7px 1px 4px; min-height: 22px; cursor: pointer; }
.hud-hunt[hidden] { display: none; }
.hud-hunt svg { width: 16px; height: 16px; }
.hud-hunt.high { color: #ff8a7e; background: rgba(200, 56, 45, 0.35); }
@media (prefers-reduced-motion: reduce) { .res.short { animation: none; background: rgba(200, 56, 45, 0.45); } }
.hud-right { display: flex; align-items: center; gap: 12px; flex: none; }
.hud-route { font-size: 12px; color: var(--dim); white-space: nowrap; }
.hud-time { display: flex; align-items: center; gap: 4px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--dim); white-space: nowrap; }
.hud-time svg { width: 16px; height: 16px; }
.hud-integrity { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; }
.hud-integrity svg { width: 18px; height: 18px; }
.int-bar { display: block; width: 58px; height: 8px; border-radius: 4px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.int-bar b { display: block; height: 100%; width: 100%; background: var(--leaf); border-radius: 4px; transition: width 0.25s; }
.hud-integrity.low .int-bar b { background: var(--danger); }
.hud-integrity.low { color: #ff8a7e; animation: int-blink 1s steps(2) infinite; }
@keyframes int-blink { 50% { opacity: 0.55; } }

/* Rail d'onglets */
.tabs {
  grid-row: 2 / 4; grid-column: 1;
  display: flex; flex-direction: column; gap: 4px; padding: 6px 3px;
  background: linear-gradient(90deg, #1d1c22, #222127);
  border-right: 1px solid #34323b;
}
.tab {
  flex: 1 1 0; max-height: 66px; min-height: 42px; padding: 0 1px;
  border: 0; border-radius: 8px; background: transparent; color: var(--enamel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; line-height: 1.1; min-width: 0;   /* plus grand, « Recherche » ne tient plus dans le rail de 60 px */
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
.tab svg { width: 26px; height: 26px; }
.tab:active:not(:disabled) { background: rgba(239, 230, 207, 0.07); }
.tab.open { background: rgba(232, 163, 61, 0.14); box-shadow: inset 3px 0 0 var(--amber); }
.tab:disabled { opacity: 0.38; cursor: default; }
.tab .tab-badge {
  position: absolute; margin: -26px 0 0 26px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--amber); color: #231b0d; font-size: 10px; font-weight: 800; display: grid; place-items: center;
}

/* ---------- Scène ---------- */
.scene { position: relative; grid-row: 2; grid-column: 2; overflow: hidden; touch-action: none; min-height: 0; }
.scene canvas { position: absolute; inset: 0; display: block; }
.scene-overlay { position: absolute; inset: 0; pointer-events: none; }
.scene-overlay > * { pointer-events: auto; }
.scene-tools { position: absolute; top: 12px; left: 8px; display: flex; gap: 6px; }
.chip-speed, .chip-zoom { min-width: 44px; min-height: 36px; display: grid; place-items: center; }
.chip-zoom svg { width: 20px; height: 20px; }
/* Vitesse ramenée à ×1 automatiquement près d'un site : petit « A » ambré et bord en pointillés */
.chip-speed.auto { position: relative; border-color: var(--amber); border-style: dashed; }
.chip-speed.auto::after { content: 'A'; position: absolute; top: -6px; right: -6px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--amber); color: #231b0d; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.scene.halte canvas { filter: saturate(0.6) brightness(0.92); transition: filter 0.4s; }

/* Progression de l'embranchement : un repère par arrêt */
.leg-progress { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: rgba(24, 23, 28, 0.5); pointer-events: none; }
.leg-progress b { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.25s linear; }
.leg-progress i { position: absolute; top: -2px; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: var(--enamel); border: 2px solid #2b2a33; }
.leg-progress i.done { background: var(--amber); }
.halte-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; background: rgba(42, 101, 98, 0.96); border: 1px solid #63b3ad;
  font-weight: 700; font-size: 12.5px; white-space: nowrap; pointer-events: none;
}

/* Énergie */
.power-pill {
  position: absolute; top: 12px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 10px; border-radius: 999px;
  background: rgba(30, 29, 35, 0.82); border: 1px solid var(--line-2);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.power-pill svg { width: 18px; height: 18px; }
.power-pill .pw-speed { color: var(--dim); font-weight: 600; }
.power-pill.low { border-color: var(--amber); }
.power-pill.low .num { color: #ffb36b; }

/* Capacités du chef de train */
.abilities { position: absolute; right: 8px; top: 54px; display: grid; gap: 8px; }
.ability {
  position: relative; width: 50px; height: 50px; border-radius: 50%; padding: 0;
  border: 2px solid var(--amber); display: grid; place-items: center;
  background: conic-gradient(rgba(232, 163, 61, 0.55) var(--p, 100%), rgba(37, 36, 43, 0.9) 0);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
.ability::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #3a3942, #26252c); }
.ability-ico { position: relative; display: grid; place-items: center; }
.ability-ico svg { width: 26px; height: 26px; }
.ability-cd { position: absolute; bottom: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px;
  background: var(--soot); border: 1px solid var(--amber); font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.ability-cd:empty { display: none; }
.ability.active { border-color: var(--gold); animation: ability-glow 0.6s ease-in-out infinite alternate; }
.ability.dim { border-color: var(--line-2); filter: saturate(0.4); }
@keyframes ability-glow { to { box-shadow: 0 0 14px rgba(242, 193, 78, 0.8); } }

/* ---------- Pupitre du bas ---------- */
.bottom {
  grid-row: 3; grid-column: 2;
  display: grid; grid-template-columns: 2fr 3fr; grid-template-rows: minmax(0, 1fr); gap: 6px;
  padding: 5px 6px 6px;
  background: var(--soot);
  min-width: 0;
}
.panel {
  border-radius: var(--radius);
  padding: 6px 10px;
  display: flex; flex-direction: column; gap: 4px; justify-content: flex-start;
  min-width: 0; min-height: 0; overflow: hidden;
}
.panel-soon { margin: 0; color: var(--dim); font-size: 13px; }

/* Bandeau d'équipage : tout l'équipage, du plus urgent au plus occupé */
.crew-bar.drop-target { border-color: var(--leaf); box-shadow: inset 0 0 0 2px rgba(143, 209, 126, 0.45); }
.crew-head { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 30px; }
.crew-head .panel-title { flex: none; }
.crew-count { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chip-auto { display: flex; align-items: center; gap: 4px; background: var(--amber); color: #231b0d; border-color: #f5c97f; min-height: 30px; flex: none;
  box-shadow: 0 2px 0 var(--amber-lip); }
.chip-auto svg { width: 16px; height: 16px; }
.crew-items {
  display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  touch-action: none; flex: 1; align-items: center; min-height: 0;
}
.crew-items::-webkit-scrollbar { display: none; }
.crew-item {
  position: relative; flex: none; display: grid; justify-items: center; gap: 2px;
  width: 58px; padding: 3px 1px; border: 0; border-radius: 8px; background: transparent;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.crew-item:active { background: rgba(239, 230, 207, 0.06); }
.crew-ring { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.crew-ring canvas { border-radius: 50%; background: #34323b; }
.crew-name { font-size: 12px; font-weight: 650; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-skill {
  position: absolute; right: -6px; bottom: -4px;
  display: flex; align-items: center; gap: 1px; padding: 1px 4px 1px 2px; border-radius: 999px;
  background: var(--soot); border: 1px solid #3d3b45; font-size: 10px; font-weight: 700;
}
.crew-skill svg { width: 13px; height: 13px; }
/* Où il est : une pastille de la couleur du wagon (au travail), une lune (au repos) */
.crew-where {
  position: absolute; left: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--plate);
}
.crew-where.rest { background: #4a5a8a; }
.crew-where.fight { background: var(--danger); }
.crew-item.working { opacity: 0.8; }
.crew-item.working .crew-name { color: var(--dim); }
.crew-item.state-injured { opacity: 0.6; filter: grayscale(0.6); }
.crew-item.blink .crew-ring { animation: crew-blink 0.8s steps(2) infinite; }
@keyframes crew-blink { 50% { box-shadow: 0 0 0 3px var(--danger); } }
.crew-sep { flex: none; width: 1px; align-self: stretch; margin: 8px 3px; background: var(--line-2); }
.crew-empty { margin: 0; font-size: 12px; color: var(--dim); line-height: 1.35; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.45));
}
.drag-ghost canvas { width: 64px; height: 80px; display: block; }

/* Pupitre d'aiguillage */
.switchboard { gap: 4px; padding: 5px 10px 7px; }
.switchboard.pulse { border-color: var(--amber); animation: sb-pulse 1s ease-in-out infinite; }
@keyframes sb-pulse { 50% { box-shadow: inset 0 0 0 2px rgba(232, 163, 61, 0.45), 0 2px 0 rgba(0, 0, 0, 0.35); } }
.switchboard.depot { border-color: rgba(62, 142, 138, 0.8); }
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.sb-head .panel-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sb-site-title svg { width: 18px; height: 18px; flex: none; }
.sb-site-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-timer { font-size: 12.5px; font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-body { display: flex; gap: 8px; flex: 1; min-height: 0; align-items: stretch; }
.sb-lever-wrap { flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) 12px; gap: 6px; min-width: 0; }
.sb-cards { display: flex; gap: 6px; min-width: 0; flex: 1; }
/* Cartes d'embranchement et d'action : des billets à composter */
.sb-card, .sb-action {
  flex: 1 1 0; min-width: 0; display: grid; align-content: center; justify-items: start; gap: 3px;
  padding: 5px 9px; border-radius: 7px; text-align: left; position: relative; overflow: hidden;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, #2f2e36, #29282f);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.sb-card strong, .sb-action strong { font-size: 12.5px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-action strong { white-space: normal; }
.sb-action { align-content: safe center; }
.sb-action span { font-size: 12px; color: var(--dim); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sb-card.selected, .sb-action.selected {
  border-color: var(--amber); background: linear-gradient(180deg, rgba(232, 163, 61, 0.24), rgba(232, 163, 61, 0.1));
  box-shadow: inset 0 0 0 1px rgba(232, 163, 61, 0.5), 0 2px 0 rgba(0, 0, 0, 0.4);
}
.sb-card.locked { opacity: 0.75; border-style: dashed; }
.sb-card.armed { opacity: 1; border-color: var(--gold); border-style: solid; }
.sb-action.pass { flex: 0.7 1 0; }
.sb-action.danger strong { color: #ff8a7a; }
.sb-card-ico svg { width: 20px; height: 20px; }
.sb-card-sub { display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; }
.sb-sites { display: flex; gap: 4px; }
.sb-site { position: relative; display: grid; justify-items: center; gap: 1px; }
.sb-site svg { width: 20px; height: 20px; }
.sb-stock { display: block; width: 18px; height: 3px; border-radius: 2px; background: rgba(239, 230, 207, 0.2); overflow: hidden; }
.sb-stock b { display: block; height: 100%; background: var(--leaf); }
.sb-stock.big { width: 90px; height: 6px; }
.sb-att { display: block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid #2b2a33; }
.att-ally { background: #7ec878; } .att-peaceful { background: #5c9ad6; } .att-wary { background: #e8cf4a; }
.att-suspicious { background: #e8933d; } .att-hostile { background: #c8382d; }
.sb-skulls svg { width: 12px; height: 12px; margin-right: 1px; }
.sb-signal { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #2b2a33; box-shadow: 0 0 6px currentColor; }
.sig-green { background: #7ec878; color: #7ec878; } .sig-orange { background: #e8933d; color: #e8933d; } .sig-red { background: #c8382d; color: #c8382d; }
.sb-card { align-content: start; justify-items: stretch; }
.sb-card-l1 { display: flex; align-items: center; gap: 5px; min-width: 0; }
.sb-card-l1 { align-items: flex-start; }
.sb-card-l1 strong { flex: 1; min-width: 0; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.15; }
.sb-card-l1 .sb-card-ico svg { width: 17px; height: 17px; display: block; }
.sb-card-l1 .sb-signal { flex: none; }
.sb-card-sub { gap: 6px; }
.sb-ago { margin-left: auto; white-space: nowrap; }
.sb-dots { display: flex; gap: 4px; }
.sb-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
/* Levier discret : on choisit surtout en touchant la carte ; il reste pour le geste et le visuel */
.sb-rail { position: relative; height: 12px; border-radius: 6px; background: var(--soot); border: 1px solid #3d3b45; touch-action: none; }
.sb-rail::before { content: ''; position: absolute; left: 10px; right: 10px; top: 4px; height: 2px; background: repeating-linear-gradient(90deg, #6e6a6f 0 8px, transparent 8px 14px); }
.sb-handle {
  position: absolute; top: -6px; width: 28px; height: 20px; border-radius: 6px;
  background: linear-gradient(#c9773f, #8f4426); border: 1px solid #2b2a33; cursor: grab; touch-action: none;
  box-shadow: 0 2px 0 #1a1920;
}
.sb-handle::after { content: ''; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: rgba(239, 230, 207, 0.6); }
.sb-handle.grab { cursor: grabbing; transform: scale(1.06); }
.sb-depot-actions { display: grid; gap: 6px; align-content: center; flex: none; }
.sb-stop { flex-direction: column; gap: 4px; }
.sb-stockline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.sb-actions { display: flex; gap: 6px; flex: 1; min-height: 0; }
.sb-stop-row { display: flex; gap: 10px; align-items: center; flex: 1; }
.sb-stop-col { display: grid; gap: 4px; flex: 1; min-width: 0; }
.sb-info { margin: 0; font-size: 12.5px; line-height: 1.3; }
.sb-progress { height: 8px; border-radius: 4px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.sb-progress b { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.25s linear; }
.sb-progress.boss b { background: var(--danger); }
.sb-shop { display: flex; gap: 6px; margin-left: auto; }
.sb-shop-btn { display: flex; align-items: center; gap: 3px; padding: 0 9px; min-height: 24px; font-size: 12px; justify-content: center; border-radius: 999px; }
.sb-shop-cost { display: inline-flex; align-items: center; gap: 1px; margin-left: 2px; }
.sb-shop-btn svg { width: 16px; height: 16px; }
.sb-shop-cost svg { width: 13px; height: 13px; }
.sb-recruit { border-color: var(--amber); color: var(--amber); }
.att-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }

/* ---------- Notifications : petites plaques sous la barre du haut ---------- */
.toasts {
  position: absolute; top: calc(var(--top-h) + 52px); left: calc(50% + var(--tabs-w) / 2); transform: translateX(-50%);
  display: grid; gap: 5px; justify-items: center; pointer-events: none; z-index: 30;
  width: min(440px, 62%);
}
.toast {
  background: rgba(30, 29, 35, 0.95); border: 1px solid #3d3b45; border-left: 3px solid var(--brass); border-radius: 8px;
  padding: 6px 12px; font-weight: 600; font-size: 13px; text-align: center; line-height: 1.3;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.18s ease-out;
}
.toast-warn { border-left-color: var(--amber); }
.toast.out { opacity: 0; transition: opacity 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Fenêtres ---------- */
.modal-layer {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(14, 13, 17, 0.62);
  display: grid; place-items: center;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
}
.modal-card {
  width: min(520px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); min-height: 0;
  display: flex; flex-direction: column;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 14px 40px rgba(0, 0, 0, 0.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 18px; }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; color: #e7d3a4; }
.modal-body { padding: 8px 18px 18px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.menu-list { display: grid; gap: 8px; }
.menu-list p { margin: 0; line-height: 1.4; }
.code-area {
  width: 100%; box-sizing: border-box; resize: none;
  background: var(--soot); color: var(--enamel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px; font: 12px/1.3 ui-monospace, Menlo, Consolas, monospace;
  -webkit-user-select: text; user-select: text;
}
.form-error { color: #ff8a7e; min-height: 0; }
.form-error:empty { display: none; }
.menu-grid { grid-template-columns: 1fr 1fr; }
.menu-grid .span-2 { grid-column: 1 / -1; }
.version-row { display: flex; justify-content: center; }
.options { display: grid; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.opt-row { display: grid; grid-template-columns: 9.5em 1fr 3.4em; align-items: center; gap: 10px; font-size: 14px; min-height: 36px; }
.opt-row input[type=range] { width: 100%; accent-color: var(--gold); min-height: 32px; }
.opt-val { text-align: right; color: var(--dim); font-size: 13px; }
.opt-toggle { justify-self: start; min-width: 64px; }
.opt-toggle.on { background: var(--gold); color: #231b0d; }
.version-btn { background: none; border: 0; color: var(--dim); font-size: 12px; padding: 6px 12px; min-height: 32px; }
@media (max-width: 420px) { .menu-grid { grid-template-columns: 1fr; } }

/* ---------- Panneaux latéraux ---------- */
.panel-host { position: absolute; inset: 0 0 0 calc(var(--tabs-w) + env(safe-area-inset-left, 0px)); z-index: 35; background: rgba(14, 13, 17, 0.4); }
/* Le rail d'onglets reste utilisable panneau ouvert : on passe d'un panneau à l'autre d'un seul toucher */
.tabs { position: relative; z-index: 36; }
.side-panel {
  position: absolute; top: var(--top-h); right: 0; bottom: 0;
  width: min(60%, 540px); min-width: 300px;
  padding-right: env(safe-area-inset-right, 0px);
  display: flex; flex-direction: column;
  border-radius: 12px 0 0 0; border-right: 0; border-bottom: 0;
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.4);
  animation: panel-in 0.18s ease-out;
}
.side-panel.wide { width: 100%; max-width: none; }
@keyframes panel-in { from { transform: translateX(30px); opacity: 0; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 0 16px; min-height: 42px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-family: var(--font-display); font-size: 19px; color: #e7d3a4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { overflow-y: auto; padding: 10px 18px 16px; min-height: 0; flex: 1; }
/* Sous-onglets du panneau : intercalaires sous le titre, ne défilent pas avec le contenu */
.panel-tabs { flex: none; padding: 0 12px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, 0.14); }
.panel-tabs[hidden] { display: none; }
.subtabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  position: relative; flex: 1 1 auto; min-width: 0; max-width: max-content; min-height: 40px; padding: 0 12px;
  display: flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--dim); font: 600 13px var(--font-ui);
  border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0;
}
.subtab svg { width: 20px; height: 20px; }
.subtab:not(.on) .subtab-ico { opacity: 0.7; filter: saturate(0.6); }
.subtab:active { background: rgba(239, 230, 207, 0.06); }
.subtab.on { color: var(--enamel); border-bottom-color: var(--amber); background: rgba(232, 163, 61, 0.08); }
.subtab-ico { display: grid; place-items: center; flex: none; }
.subtab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtab-badge { flex: none; }
.wagon-desc { color: var(--enamel); line-height: 1.4; }
.tr-detail .wagon-desc { color: var(--dim); }
.subtab-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center;
  background: var(--plate-2); color: var(--enamel); font-size: 10.5px; font-weight: 800; box-shadow: inset 0 0 0 1px var(--line-2);
}
.subtab-badge.hot { background: var(--amber); color: #231b0d; box-shadow: none; }
/* Pied de panneau : les actions principales restent toujours visibles */
.panel-foot {
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  padding: 8px 18px 10px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.18);
}
.panel-foot:empty { display: none; }
.panel-foot .note { margin-right: auto; font-size: 12px; color: var(--dim); }

.sheet { display: grid; gap: 10px; }
.sheet p { margin: 0; line-height: 1.4; }
.sheet-top { display: flex; gap: 12px; align-items: center; }
.sheet-top canvas { border-radius: 12px; background: #34323b; flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.sheet-id { display: grid; gap: 6px; flex: 1; min-width: 0; }
.sheet-status { font-weight: 650; color: var(--amber); }
.stat-row, .skill-row { display: grid; grid-template-columns: 20px 74px 1fr 28px; align-items: center; gap: 6px; font-size: 12.5px; }
.skill-row { grid-template-columns: 20px 1fr 22px 90px; }
.skill-row.main .skill-name { color: var(--amber); font-weight: 700; }
.skill-use { margin: -2px 0 6px 26px; font-size: 12px; opacity: 0.75; line-height: 1.3; }
.skill-help { font-size: 12px; line-height: 1.35; margin: 0 0 6px; }
.stat-ico svg { width: 18px; height: 18px; display: block; }
.bar { height: 8px; border-radius: 4px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--amber); }
.bar-hp .bar-fill { background: var(--leaf); }
.bar-morale .bar-fill { background: var(--amber); }
.bar-xp .bar-fill { background: var(--teal); }
.wagon-info { display: grid; gap: 6px; }

/* Registres : une liste dans un creux de la plaque, lignes séparées par un filet */
.crew-list, .trade-list, .service-list, .ledger {
  display: grid; gap: 0; border-radius: 8px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden;
}
.crew-list > h3 { padding: 0 10px 4px; }
.crew-row, .trade-row, .service-row, .recruit-row, .build-row, .ledger-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; text-align: left;
  background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: inherit;
}
.crew-list > :first-child, .trade-list > :first-child, .service-list > :first-child, .ledger > :first-child { border-top: 0; }
button.crew-row:active { background: rgba(239, 230, 207, 0.05); }
.crew-row canvas, .recruit-row canvas { border-radius: 8px; background: #34323b; flex: none; }
.crew-row-text { display: grid; flex: 1; min-width: 0; font-size: 12.5px; }
.crew-row-text strong { font-size: 13.5px; }
.crew-row-skill { display: flex; align-items: center; gap: 3px; font-size: 13px; min-width: 52px; justify-content: flex-end; }
.crew-row-hp { width: 56px; height: 6px; border-radius: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; flex: none; }
.crew-row-hp i { display: block; height: 100%; }
.panel-back { width: 40px; height: 40px; margin-left: -10px; font-size: 30px; line-height: 1; color: #e7d3a4; }
.panel-head h2 { flex: 1; min-width: 0; }
/* Fiche survivant : flèches précédent / suivant de part et d'autre du nom */
.panel-title-nav { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.panel-title-nav h2 { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.panel-nav { width: 40px; height: 40px; flex: none; font-size: 15px; color: #e8a33d; border-radius: 50%; background: rgba(232, 163, 61, .12); }
.panel-nav:active { background: rgba(232, 163, 61, .3); }

/* Atelier du train : le convoi en vignettes (queue à gauche, locomotive à droite) */
.tr-strip { display: flex; gap: 5px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; align-items: stretch; }
.tr-tile {
  position: relative; flex: none; width: 84px; min-height: 60px; display: grid; align-content: start; gap: 2px; padding: 0 7px 6px;
  text-align: left; border-radius: 7px; border: 1px solid var(--line-2); background: linear-gradient(180deg, #33323a, #2a2930); color: inherit;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); overflow: hidden;
}
.tr-tile strong { font-size: 12px; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tr-sub { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-band { display: block; height: 6px; margin: 0 -7px 4px; background: #6e6a6f; }
.tr-tile.sel { border-color: var(--amber); box-shadow: inset 0 0 0 1px rgba(232, 163, 61, 0.6), 0 2px 0 rgba(0, 0, 0, 0.45); background: linear-gradient(180deg, rgba(232, 163, 61, 0.22), rgba(232, 163, 61, 0.08)); }
.tr-tile.loco { width: 92px; }
.tr-tile.add { width: 64px; place-content: center; justify-items: center; text-align: center; border-style: dashed; padding-top: 6px; }
.tr-tile.add .tr-band { display: none; }
.tr-tile.add strong { font-size: 24px; color: var(--amber); line-height: 1; }
.tr-tile.ghost { opacity: 0.55; border-style: dashed; }
.tr-tile.warn { border-color: var(--danger); }
.tr-badge { position: absolute; top: 9px; right: 4px; font-style: normal; font-size: 9px; font-weight: 800; padding: 0 4px; border-radius: 6px; background: var(--brass); color: #1c1b20; }
.tr-badge.warn { background: var(--danger); color: var(--enamel); right: auto; left: 4px; }
.tr-detail { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.tr-dhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tr-dhead strong { font-family: var(--font-display); font-size: 17px; color: #e7d3a4; }
.tr-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crew-row-skill svg { width: 18px; height: 18px; }
/* Lignes isolées (hors registre) : recrue, wagon, construction */
.recruit-row, .build-row { border: 1px solid var(--line); border-radius: 8px; background: var(--well); }
.build-row { flex-wrap: wrap; }
.trade-row.done { opacity: 0.5; }
.trade-row .btn { margin-left: auto; }
.trade-arrow svg { width: 20px; height: 20px; }
.service-text, .recruit-text, .build-text, .ledger-text { display: grid; gap: 1px; flex: 1; min-width: 0; font-size: 12.5px; }
.service-text strong, .recruit-text strong, .build-text strong, .ledger-text strong { font-size: 13.5px; }
.service-row .btn, .recruit-row .btn { flex: none; }
.rumor-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rumor-list p { width: 100%; margin: 0; }
.recruit-skills { display: flex; gap: 8px; }
.recruit-skill { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; opacity: 0.8; }
.recruit-skill svg { width: 14px; height: 14px; }
.recruit-skill.main { opacity: 1; font-weight: 800; color: var(--amber); }

/* Coûts et ressources */
.cost { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.cost-item, .res-chip { display: inline-flex; align-items: center; gap: 2px; }
.cost-ico { display: inline-flex; }
.cost-ico svg { width: 15px; height: 15px; }
.res-chip { font-size: 14.5px; font-weight: 800; min-width: 52px; }
.res-chip .cost-ico svg { width: 20px; height: 20px; }

/* Gares et camps */
.station-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stars { display: inline-flex; gap: 2px; }
.star svg { width: 16px; height: 16px; opacity: 0.25; }
.star.on svg { opacity: 1; }
.station-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.station-foot .btn-depart { min-height: 40px; }
.panel-foot .station-foot { margin: 0; flex: 1; }
.att-scale { display: flex; gap: 3px; margin: 2px 0; }
.att-step { flex: 1 1 0; text-align: center; font-size: 12px; padding: 5px 2px; color: var(--dim);
  background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.att-step:first-child { border-radius: 6px 0 0 6px; } .att-step:last-child { border-radius: 0 6px 6px 0; }
.att-step.on { color: #1c1b20; font-weight: 800; background: var(--c); box-shadow: none; }

/* Atelier du train */
.build-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wagon-dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #1c1b20; flex: none; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.build-card {
  display: grid; gap: 3px; justify-items: start; text-align: left; padding: 8px 10px; border-radius: 8px;
  background: linear-gradient(180deg, #302f37, #29282f); border: 1px solid rgba(232, 163, 61, 0.45); color: inherit;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.build-card:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.build-card:disabled { border-color: var(--line); opacity: 0.5; box-shadow: none; }
.build-card-head { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.loco-row { border-color: rgba(232, 163, 61, 0.45); }
.caboose-box { display: grid; gap: 6px; }
.recipe-row { display: flex; align-items: center; gap: 6px; }

/* Équipement */
.gear-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.gear-row .stat-ico svg { width: 18px; height: 18px; }
.gear-text { display: grid; flex: 1; min-width: 0; font-size: 12.5px; }
.gear-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 6px 26px; }
.gear-chip { display: grid; justify-items: start; gap: 1px; text-align: left; min-height: 40px; }
.arsenal-list { display: flex; flex-wrap: wrap; gap: 6px; }
.arsenal-item { display: grid; padding: 5px 9px; border-radius: 7px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; }
.arsenal-item.free { box-shadow: inset 0 0 0 1px rgba(143, 209, 126, 0.55); }

/* ---------- Carte : la boucle ferroviaire ---------- */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(210px, 1fr); gap: 14px; align-items: start; }
.rail-map { position: relative; width: 100%; aspect-ratio: 1000 / 440;
  background: radial-gradient(ellipse at 50% 50%, rgba(196, 164, 101, 0.07), transparent 70%), var(--well);
  border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.rail-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tk-bed { fill: none; stroke: #3b342c; stroke-width: 16; stroke-linecap: round; }
.tk-ties { fill: none; stroke: #7d6a52; stroke-width: 12; stroke-dasharray: 2.5 6; }
.tk-rails { fill: none; stroke: #b9afa2; stroke-width: 6.5; stroke-linecap: round; }
.tk-gap { fill: none; stroke: #3b342c; stroke-width: 2.6; stroke-linecap: round; }
.tk-hit { fill: none; stroke: transparent; stroke-width: 34; pointer-events: stroke; cursor: pointer; }
.track.fog { opacity: 0.55; }
.tk-rails.fog { stroke-dasharray: 10 7; }
.tk-rails.locked { stroke: #8f5a4a; }
.tk-rails.chosen { stroke: #5fb7b0; }
.tk-rails.here { stroke: var(--amber); }
.tk-bed.sel { stroke: #5c4e3d; stroke-width: 22; }
.rail-stop, .rail-junction, .rail-depot, .rail-train, .rail-leg, .rail-flag { position: absolute; transform: translate(-50%, -50%); }
.rail-stop {
  width: 26px; height: 26px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: #2b2a31; border: 2px solid var(--brass); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
.rail-stop svg { width: 17px; height: 17px; }
.rail-stop.fog { border-style: dashed; border-color: var(--dim); opacity: 0.8; }
.rail-stop.sel { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.35), 0 2px 0 rgba(0, 0, 0, 0.5); }
.rail-att { position: absolute; right: -3px; bottom: -3px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #2b2a31; }
.rail-stop .map-contract { top: -8px; right: -12px; }
.rail-junction { font-size: 10px; font-weight: 800; color: var(--soot); background: var(--brass); padding: 1px 5px; border-radius: 4px; pointer-events: none; }
.rail-leg { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--dim); pointer-events: none; }
.rail-flag { display: flex; align-items: center; gap: 2px; pointer-events: none; font-size: 12px; font-weight: 800; color: var(--gold); }
.rail-flag.lock { background: #2b2a31; border: 1px solid #8f5a4a; border-radius: 6px; padding: 1px 4px; }
.rail-flag svg { width: 14px; height: 14px; }
.rail-flag.sig-green, .rail-flag.sig-orange, .rail-flag.sig-red { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #2b2a31; box-shadow: 0 0 6px currentColor; }
.rail-depot { display: grid; justify-items: center; gap: 0; pointer-events: none; transform: translate(-50%, -30%); }
.rail-depot svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5)); }
.rail-depot b { font-size: 12px; color: var(--enamel); background: rgba(24, 23, 28, 0.8); padding: 0 5px; border-radius: 4px; }
.rail-depot.here b { color: var(--amber); }
.rail-train {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; pointer-events: none; z-index: 2;
  background: var(--amber); border: 2px solid #f5c97f; box-shadow: 0 0 0 4px rgba(232, 163, 61, 0.3), 0 3px 0 var(--amber-lip);
}
.rail-train svg { width: 20px; height: 20px; }
.map-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.map-detail { display: grid; gap: 8px; }
.map-dhead { display: grid; gap: 1px; }
.map-dhead strong { font-family: var(--font-display); font-size: 17px; color: #e7d3a4; }
.map-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.map-tag { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--amber); color: #231b0d; white-space: nowrap; }
.map-tag.chosen { background: var(--teal); color: var(--enamel); }
.map-tag.lock { background: #5a3a31; color: #f3cdb9; }
.map-tag.sig { color: #1c1b20; }
.map-tag.sig-green { background: #7ec878; } .map-tag.sig-orange { background: #e8933d; } .map-tag.sig-red { background: #c8382d; color: var(--enamel); }
.map-dico svg { width: 22px; height: 22px; display: block; }
.map-contract { position: absolute; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--amber); color: #231b0d; font-size: 9.5px; font-weight: 800; display: grid; place-items: center; font-style: normal; }
.map-legend { margin: 0; font-size: 12px; }
@media (max-width: 700px) { .map-wrap { grid-template-columns: 1fr; } }

/* ---------- Résumé du tour ---------- */
.sum-scroll { overflow-x: auto; }
.sum-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sum-table th { text-align: right; font-size: 12px; color: var(--dim); font-weight: 600; padding: 2px 6px; }
.sum-table th:first-child { text-align: left; }
.sum-table td { padding: 4px 6px; border-top: 1px solid var(--line); }
.sum-res { display: flex; align-items: center; gap: 6px; }
.sum-res svg { width: 18px; height: 18px; }
.sum-table .gain { color: #b5dc8c; }
.sum-table .neg { color: #ff8a7e; }

/* ---------- Contrats et carnet (0.12) ---------- */
.contract {
  display: grid; gap: 6px; padding: 10px 12px; border-radius: 8px;
  background: repeating-linear-gradient(-45deg, rgba(196, 164, 101, 0.05) 0 6px, transparent 6px 12px), var(--well);
  box-shadow: inset 0 0 0 1px rgba(196, 164, 101, 0.35);
}
.contract-head { display: flex; align-items: center; gap: 8px; }
.contract-head strong { font-size: 14px; flex: 1; }
.contract-due { font-size: 12px; font-weight: 700; color: var(--amber); white-space: nowrap; }
.contract-due.late { color: #ff8a7e; }
.contract-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.contract-row .bar { flex: 1; min-width: 90px; }
.contract .btn { flex: none; }
.log-entry { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 7px 10px; border-top: 1px solid var(--line); font-size: 12.5px; }
.log-entry:first-child { border-top: 0; }
.log-lap { color: var(--dim); font-variant-numeric: tabular-nums; }
.empty-note { margin: 0; padding: 10px; color: var(--dim); font-size: 12.5px; }

/* ---------- Événements (0.12) : une carte posée sur la voie ---------- */
.event-card { width: min(640px, 100%); }
.event-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 14px; align-items: start; }
.event-art { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #2a2930; box-shadow: inset 0 0 0 1px var(--line); }
.event-art img, .event-art canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.derail-left p { margin-top: 8px; }
.derail-list { margin: 8px 0; padding-left: 18px; display: grid; gap: 5px; font-size: 0.9em; }
.derail-list li::marker { color: var(--accent, #e8a33d); }
.event-glyph { position: absolute; inset: 0; display: grid; place-items: center; }
.event-glyph svg { width: 34%; height: auto; max-height: 64%; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35)); opacity: 0.9; }
.event-text { margin: 0; line-height: 1.45; font-size: 14px; }
.event-choices { display: grid; gap: 8px; }
.event-choice {
  display: grid; gap: 2px; text-align: left; padding: 9px 12px; border-radius: 8px; color: inherit;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, #34333b, #2c2b33); box-shadow: 0 2px 0 #111015;
}
.event-choice:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.event-choice strong { font-size: 14px; }
.event-choice span { font-size: 12px; color: var(--dim); line-height: 1.3; }
.event-choice:disabled { opacity: 0.45; box-shadow: none; }
.event-choice.first { border-color: rgba(232, 163, 61, 0.65); }
.event-result { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); line-height: 1.45; }
@media (max-height: 360px) { .event-body { grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); } }

/* ---------- Debug ---------- */
.debug-panel {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  display: grid; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--teal); border-radius: var(--radius);
  font-size: 12px; max-width: 70%; max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain;
}
.debug-panel .chip { min-height: 30px; padding: 2px 10px; font-size: 12px; }
.debug-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.debug-fps { font-variant-numeric: tabular-nums; color: var(--gold); }

/* ---------- Écrans de recouvrement ---------- */
.overlay-screen {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding-inline: 24px; text-align: center;
  background: var(--soot);
}
.overlay-screen h2 { margin: 0; font-family: var(--font-display); color: #e7d3a4; }
.overlay-screen p { margin: 0; color: var(--dim); max-width: 40ch; line-height: 1.4; }
.rotate-icon svg { width: 64px; height: 64px; animation: rotate-hint 2.4s ease-in-out infinite; }
@keyframes rotate-hint { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
.screen-error { z-index: 50; }
.error-detail { font-family: ui-monospace, Menlo, monospace; font-size: 11px; opacity: 0.7; }
.error-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Petits écrans ---------- */
/* Téléphones étroits en paysage (iPhone SE, 8…) : on gagne de la place verticale dans les panneaux */
@media (max-width: 760px), (max-height: 380px) {
  .panel-head { min-height: 38px; padding-left: 12px; }
  .panel-head h2 { font-size: 17px; }
  .panel-tabs { padding: 0 6px; }
  .subtab { min-height: 36px; padding: 0 8px; gap: 4px; font-size: 12.5px; }
  .subtab svg { width: 17px; height: 17px; }
  .panel-body { padding: 8px 12px 12px; }
  .panel-foot { padding: 6px 12px 7px; }
  .station-foot .btn-depart { min-height: 38px; font-size: 15px; }
  /* Panneau latéral un peu plus large, et sous-onglets inactifs réduits à leur icône (le nom s'affiche une fois choisi) */
  .side-panel { width: min(72%, 540px); }
  .side-panel:not(.wide) .subtab:not(.on) .subtab-label { display: none; }
  .side-panel:not(.wide) .subtab:not(.on) { min-width: 46px; justify-content: center; }
  .side-panel:not(.wide) .subtab.on { flex: 1 1 auto; }
  /* Pupitre : cartes de voie plus compactes */
  .sb-card-l1 .sb-card-ico { display: none; }
  .sb-card strong, .sb-action strong { font-size: 12px; }
  .sb-shop-btn { padding: 0 7px; }
}
/* Écrans bas (paysage) : le menu tient sans défiler, les réglages sur deux colonnes */
@media (max-height: 430px) {
  .modal-head h2 { font-size: 18px; }
  .modal-body { padding: 6px 14px 12px; }
  .options { grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .opt-row { grid-template-columns: 6.5em 1fr 3em; min-height: 32px; font-size: 13px; }
  .menu-list .btn { min-height: 40px; }
}
@media (max-height: 430px) and (max-width: 700px) { .options { grid-template-columns: 1fr; } }
@media (max-height: 360px) {
  :root { --top-h: 36px; --bottom-h: 122px; }
  .res svg { width: 17px; height: 17px; }
  .sb-depot-actions .btn-small { min-height: 30px; }
  .btn-depart { min-height: 40px; }
  .sb-card { gap: 2px; padding: 4px 8px; }
  .sb-card strong { font-size: 12px; }
  .sb-lever-wrap { grid-template-rows: minmax(0, 1fr); }
  .sb-rail { display: none; }
}
/* La barre du haut se tasse : le temps de jeu part d'abord, puis le compteur de tronçon */
@media (max-width: 920px) { .hud-time { display: none; } }
@media (max-width: 720px) {
  .hud-route { display: none; }
  .hud-res { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-icon svg, .toast, .side-panel, .switchboard.pulse, .ability.active, .hud-integrity.low { animation: none; }
}

/* Atelier de la traverse */
.zone-box { display: grid; gap: 10px; }
.zone-cost { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mat-chip { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; border: 1px dashed var(--line-2); color: var(--dim); }
.mat-chip.on { border-style: solid; border-color: var(--gold); color: var(--gold); }
.zone-kit.soon { opacity: 0.6; filter: grayscale(0.8); }

/* Recherche */
.research-list { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--well); }
.research-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.research-row:first-child { border-top: 0; }
.research-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.research-row.done .research-text strong { color: var(--leaf); }
.research-row.locked { opacity: 0.6; }
.research-done { font-size: 12px; font-weight: 700; color: var(--leaf); }
.research-row .btn { display: inline-flex; align-items: center; gap: 4px; }
.research-row .cost-ico svg { width: 18px; height: 18px; }
.sb-mapico svg { width: 18px; height: 18px; }

/* Bilan des ressources */
.hud-res { cursor: pointer; }
.bal-list { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--well); }
.bal-row { display: grid; gap: 4px; padding: 9px 12px; border-top: 1px solid var(--line); }
.bal-row:first-child { border-top: 0; }
.bal-head { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px; align-items: center; }
.bal-ico svg { width: 20px; height: 20px; }
.bal-net { font-weight: 800; min-width: 84px; text-align: right; }
.bal-net.pos, .bal-detail .pos { color: var(--leaf); }
.bal-net.neg, .bal-detail .neg { color: #f3a59d; }
.bal-detail { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-left: 32px; font-size: 12px; color: var(--dim); }
/* Objectifs */
.obj-box { display: grid; gap: 10px; }
.obj-bar { width: 90px; flex: none; }
/* Rail : le Train s'allume quand on peut y toucher */
.tab.ready svg { filter: drop-shadow(0 0 6px rgba(232, 163, 61, 0.9)); animation: tab-ready 1.6s ease-in-out infinite; }
.tab.ready span { color: var(--amber); }
@keyframes tab-ready { 50% { filter: drop-shadow(0 0 2px rgba(232, 163, 61, 0.4)); } }
@media (prefers-reduced-motion: reduce) { .tab.ready svg { animation: none; } }
.tab { position: relative; }

/* ---------- Tutoriel (Gus) ---------- */
.tuto { position: absolute; inset: 0; z-index: var(--z-tuto); pointer-events: none; }
.tuto.free .tuto-spot, .tuto.free .tuto-pane, .tuto.free .tuto-bubble { display: none; }
.tuto-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(10, 9, 12, 0.62); pointer-events: none; transition: left 0.2s, top 0.2s, width 0.2s, height 0.2s; }
.tuto-spot.pulse { outline: 3px solid var(--gold); outline-offset: 2px; animation: tuto-pulse 1.1s ease-in-out infinite; }
@keyframes tuto-pulse { 50% { outline-color: rgba(242, 193, 78, 0.25); outline-offset: 7px; } }
.tuto-pane { position: fixed; pointer-events: auto; background: transparent; }
/* Le bouton du menu reste touchable au-dessus du tutoriel (pause, Options, retour au hub) */
.tuto-on #btn-menu { position: relative; z-index: calc(var(--z-tuto) + 1); }
.tuto-bubble {
  position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start;
  background: var(--panel, #25242b); border: 1px solid var(--line-2, rgba(255,255,255,0.18)); border-left: 4px solid var(--gold);
  border-radius: 14px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.45); pointer-events: auto;
}
.tuto-bubble.top { bottom: auto; top: max(12px, env(safe-area-inset-top, 0px)); }
.tuto-bubble.left { left: calc(var(--tabs-w, 64px) + 12px); transform: none; width: min(420px, 36vw); grid-template-columns: 48px 1fr; }
.tuto-face { width: 100%; aspect-ratio: 1; display: block; }
.tuto-face svg { width: 100%; height: 100%; display: block; }
.tuto-face { border-radius: 10px; overflow: hidden; background: #3a3238; box-shadow: inset 0 0 0 2px var(--line-2); }
.tuto-face img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 50% 8%; }
.tuto-col { display: grid; gap: 6px; min-width: 0; }
.tuto-col strong { color: var(--gold); font-family: var(--font-display); font-size: 16px; }
.tuto-col p { margin: 0; font-size: 14px; line-height: 1.4; }
.tuto-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tuto-row .btn[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .tuto-spot.pulse { animation: none; } .tuto-spot { transition: none; } }
.gus-tip {
  position: absolute; left: 10px; top: 52px; z-index: 31; display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start;
  width: min(340px, 44%); text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--panel, #25242b); border: 1px solid var(--line-2, rgba(255,255,255,0.18)); border-left: 4px solid var(--gold);
  border-radius: 12px; padding: 8px 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); transition: opacity 0.4s;
}
.gus-tip.out { opacity: 0; }
.gus-tip .tip-text { display: grid; gap: 2px; font-size: 12.5px; line-height: 1.3; }
.gus-tip strong { color: var(--gold); font-family: var(--font-display); }

/* Crédits */
.credits { display: flex; flex-direction: column; gap: 8px; text-align: center; }
.credits-game { font-family: var(--font-display); font-size: 1.6rem; margin: 0; letter-spacing: 0.04em; }
.credits-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.credits-list p { margin: 0; }
.credits p { margin: 0; }
.credits .small { font-size: 0.8rem; }
.credits-thanks { margin-top: 6px !important; font-style: italic; }

/* Logo du studio au lancement (comme les autres jeux Keismey Studio) */
.studio-splash { position: fixed; inset: 0; z-index: 200; background: #000; display: grid; place-items: center; cursor: pointer; transition: opacity .6s ease; }
.studio-splash img { width: min(52vh, 260px, 58vw); height: auto; opacity: 0; animation: studioIn 1s ease-out .15s forwards; }
.studio-splash.out { opacity: 0; pointer-events: none; }
@keyframes studioIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* Nouveautés */
.notes-list { display: flex; flex-direction: column; gap: 14px; }
.notes-list h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.05rem; }
.notes-list h3 small { color: var(--dim, #a99f8f); font-family: var(--font-ui); font-weight: 600; font-size: .8rem; margin-left: 6px; }
.notes-list ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }

/* Nouvelle version en ligne */
.update-bar { position: fixed; left: 50%; top: max(10px, env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 150;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 18px; border-radius: 14px; border: 2px solid #1f1e25;
  background: #e8a33d; color: #1f1e25; font: 600 13px var(--font-ui); box-shadow: 0 4px 0 #8a5a17; cursor: pointer; }
.update-bar b { font-size: 14px; }

/* Onglet Équipage : les quatre compétences sur chaque ligne (les meilleures en grand) */
.crew-row.full .crew-row-text { flex: 0 1 auto; width: clamp(96px, 30%, 190px); }
.crew-row-skills { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding-left: 4px; }
.crew-row-skills .sk { display: inline-flex; align-items: center; gap: 3px; font-size: 13.5px; font-weight: 700; }
.crew-row-skills .sk svg { width: 19px; height: 19px; }
.crew-row-skills .sk.minor { font-size: 12px; font-weight: 600; opacity: .72; }
.crew-row-skills .sk.minor svg { width: 13px; height: 13px; }
@media (max-width: 420px) { .crew-row-skills { gap: 6px; } }

/* Fiche survivant : glisser pour passer au suivant */
.sheet-nav { margin: 2px 0 0; }
.side-panel.slide-next { animation: slide-next .2s ease-out; }
.side-panel.slide-prev { animation: slide-prev .2s ease-out; }
@keyframes slide-next { from { transform: translateX(44px); opacity: .2; } }
@keyframes slide-prev { from { transform: translateX(-44px); opacity: .2; } }

/* Vitesse modifiée par un événement ou la pleine vapeur */
.power-pill .pw-speed.down { color: #ffb36b; }
.power-pill .pw-speed.up { color: #8fd17e; }
.power-pill .pw-fx { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: rgba(232, 163, 61, .18); color: #ffcf8a; white-space: nowrap; }
.power-pill .pw-fx.up { background: rgba(143, 209, 126, .16); color: #b8e6a9; }

/* Arsenal : démanteler un objet libre */
.arsenal-item .dismantle { margin-top: 4px; min-height: 28px; padding: 0 8px; font-size: 12px; }
.arsenal-item .dismantle.armed { color: #ffb36b; box-shadow: inset 0 0 0 1px #e8a33d; }
