/* Simulateur de mini-sumo : charte des outils Robot Maker (jetons de couleur de Photo Editor et
   Serial Monitor, barre du haut bleu nuit, thèmes clair et sombre par html[data-theme]) et
   organisation du simulateur CFR (barre du haut : onglets soulignés, scores et chronomètre au
   centre, commandes du match ; vue 3D et panneau latéral à sections aux titres en capitales).
   Page en colonne : menu du site (robot-maker.com), puis #app dans toute la hauteur restante.
   Styles préfixés par #app : ceux du site, chargés avec son menu, ne s'appliquent pas à l'outil. */
:root {
  --rm-menu-height: 0px;
  --sumo-color-start: #287351;
  --sumo-color-start-hover: #1d5a3e;
  --sumo-color-on-start: #ffffff;
  --ink: var(--rm-color-text);
  --muted: var(--rm-color-muted);
  --line: var(--rm-color-border);
  --paper: var(--rm-color-bg);
  --white: var(--rm-color-surface);
  --green: var(--rm-color-primary);        /* Bleu d'action Robot Maker (nom historique des outils). */
  --green-dark: var(--rm-color-primary-hover);
  --blue: var(--rm-color-primary-soft);
  --topbar: var(--rm-color-topbar);
  --stage: #e8eff6;
  --control: var(--rm-color-surface-soft);
  --hover: var(--rm-color-hover);
  --active: #e7f2fb;
  --active-line: #91bfe2;
  --secondary: #17263b;
  --on-secondary: #fff;
  --accent-light: #62b4ec; /* Soulignement des onglets, sur la barre du haut. */
  --ok: var(--rm-color-success);
  --ok-bg: #dcefe3;
  --error: var(--rm-color-danger);
  --error-bg: #fff0f1;
  --overlay: rgba(16, 42, 67, .88);
  --shadow: var(--rm-shadow-lg);
  --shadow-small: 0 4px 14px rgba(17, 42, 67, .08);
  --mono: var(--rm-font-mono);
  --radius: var(--rm-radius-md);
}

html[data-theme="dark"] {
  --sumo-color-start: #72c49d;
  --sumo-color-start-hover: #9ad8b8;
  --sumo-color-on-start: #07130e;
  --stage: #0f1b27;
  --control: #1c2c3b;
  --hover: #203346;
  --active: #173957;
  --active-line: #397eb1;
  --secondary: #28445e;
  --on-secondary: #fff;
  --ok: #8ad2a6;
  --ok-bg: #173b2a;
  --error: #ffb4b4;
  --error-bg: #351c21;
  --overlay: rgba(9, 19, 31, .9);
  --shadow: 0 18px 55px rgba(0, 0, 0, .35);
  --shadow-small: 0 4px 14px rgba(0, 0, 0, .3);
}

/* Textes dans les deux langues (aide) : seul celui de la langue de la page est montré. */
html:not([lang="en"]) .l-en, html[lang="en"] .l-fr { display: none !important; }

html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--paper); overflow: hidden; }
#rm-menu-container { position: relative; z-index: 30; }
#rm-fallback { flex: none; padding: 4px 12px; background: var(--topbar); color: #aebdcb; text-align: center; font: 12px/1.4 system-ui, sans-serif; }
#rm-fallback a { color: #fff; }

#app {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  font-size: 14px; line-height: 1.4; text-align: left;
}
#app [hidden] { display: none !important; }
#app h2, #app h3 { font-family: inherit; margin: 0 0 8px; color: var(--ink); }
#app h2 { font-size: 17px; }
#app h3 { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

/* --- Contrôles communs --- */
/* Hors en-tete : la barre superieure suit robot-maker-tool.css. */
#app :is(button:not(.rm-button):not(.rm-icon-action), select, input:not(.rm-number), textarea):not(.rm-tool-header *), dialog button, .tour button { font: inherit; color: var(--ink); }
/* Hors en-tête et hors boutons communs (.rm-button et ses intentions, .rm-icon-action). */
/* Boutons secondaires de Sumo : couleurs du gris commun (.rm-button), taille compacte propre au simulateur. */
#app button:not(.rm-tool-header *):not(.rm-button):not(.rm-icon-action), dialog button:not(.rm-button):not(.rm-icon-action), .tour button:not(.rm-button) {
  background: var(--rm-color-secondary); border: 1px solid var(--rm-color-border); border-radius: var(--rm-radius-sm);
  padding: 5px 11px; min-height: 32px; cursor: pointer; line-height: 1.3; margin: 0; text-transform: none;
  transition: background-color .2s, color .2s, border-color .2s;
}
#app button:hover:not(:disabled):not(.rm-tool-header *):not(.rm-button):not(.rm-icon-action), dialog button:not(.rm-button):hover, .tour button:not(.rm-button):hover { background: var(--rm-color-secondary-hover); border-color: var(--rm-color-border); }
#app button:disabled { opacity: .5; cursor: not-allowed; }
#app button.small { min-height: 26px; padding: 2px 8px; font-size: 12px; }
#app button[aria-pressed="true"], #app button.toggle[aria-pressed="true"] { background: var(--active); border-color: var(--active-line); color: var(--green-dark); font-weight: 700; }
dialog button:focus-visible, .tour button:focus-visible {
  outline: 2px solid var(--rm-color-focus); outline-offset: 2px;
}
#app :is(select, input[type="number"]:not(.rm-number), input[type="text"]):not(.rm-tool-header *) {
  background: var(--control); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; min-height: 32px;
}
#app input[type="color"] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--control); }
#app label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
#app .row { display: flex; gap: 6px; align-items: center; }
#app .row.wrap { flex-wrap: wrap; }
#app .row + .row { margin-top: 8px; }
#app .grow { display: flex; gap: 8px; align-items: center; }
#app .grow input { flex: 1; }
#app .group { display: flex; align-items: center; gap: 6px; }
#app .hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
#app .caption { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
#app .status { min-height: 1.4em; font-size: 13px; }
#app .status.ok { color: var(--ok); }
#app .status.error { color: var(--error); }
#app .section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 4px; }
#app .section-head h3 { margin: 0; }
#app .segmented { display: flex; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#app .segmented button { flex: 1; border: 0; border-radius: 0; min-height: 30px; }
#app .segmented button + button { border-left: 1px solid var(--line); }
#app .segmented button[aria-pressed="true"] { background: var(--green); color: #fff; }
html[data-theme="dark"] #app .segmented button[aria-pressed="true"] { color: #09131f; }

/* --- Barre du haut : marque et onglets, scores et chronomètre, match et préférences --- */
#app #topbar {
  flex: none;
  position: relative; z-index: 5; /* Titre, onglets et commandes : robot-maker-tool.css. */
}
#app #topbar .match-group {
  width: 704px; max-width: 100%; min-width: 0;
}
#app #topbar .match-content { display: grid; grid-template-columns: 160px auto 160px; align-items: center; width: 704px; gap: 8px; }
#app #reset { justify-self: end; }
#app #scores { justify-self: center; }
#app #match-bar { justify-self: start; }
#app #topbar:is([data-rm-header-layout="two"], [data-rm-header-layout="three"]) .match-group {
  display: flex;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  justify-self: stretch;
  justify-content: safe center;
  overflow-x: auto;
}
#app #topbar:is([data-rm-header-layout="two"], [data-rm-header-layout="three"]) .match-content {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: max-content;
  gap: 8px;
}
#app #topbar button[aria-pressed="true"] { background: rgba(98, 180, 236, .28); border-color: var(--accent-light); }
#app #topbar button.primary { background: var(--rm-color-primary); border-color: var(--rm-color-primary); color: var(--rm-color-on-primary); }
#app #topbar button.primary:hover { background: var(--rm-color-primary-hover); border-color: var(--rm-color-primary-hover); }
#app #topbar #start { background: var(--sumo-color-start); border-color: var(--sumo-color-start); color: var(--sumo-color-on-start); }
#app #topbar #start:hover:not(:disabled) { background: var(--sumo-color-start-hover); border-color: var(--sumo-color-start-hover); }
/* Robots et Stratégies : toute la zone du combat (Replacer, scores, chrono, Départ, Pause) est masquée,
   sans changer la mise en page de l'en-tête. */
#app #topbar.editing .match-group { visibility: hidden; }
#app #scores { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
#app .score-chip {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; width: 100px; min-width: 100px; max-width: 100px; padding: 4px 8px;
  border-radius: var(--radius); background: #555; color: #fff; font-variant-numeric: tabular-nums;
}
#app .score-chip .name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#app .score-chip .points { font-size: 20px; font-weight: 800; min-width: 1.6ch; text-align: center; }
#app #match-clock { display: flex; flex-direction: column; align-items: center; min-width: 96px; color: #fff; }
#app #match-clock .caption { color: #aebdcb; }
#app .clock { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
#app .clock.running { color: var(--accent-light); }
#app .clock.countdown { color: #ffd166; }

/* --- Combat : vue 3D et panneau latéral --- */
main.rm-tool-main { flex: 1 1 auto; min-height: 0; display: flex; padding: 0; }
#app .panel { flex: 1; min-height: 0; min-width: 0; }
#app #stage { position: relative; background: var(--stage); overflow: hidden; }
#app #view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#app #loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; background: var(--overlay); color: #fff; font-size: 16px; }
#app #banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); max-width: 90%; pointer-events: none;
  background: var(--overlay); color: #fff; padding: 14px 26px; border-radius: 14px; box-shadow: var(--shadow);
  font-size: 26px; font-weight: 800; text-align: center;
}
#app #banner.count { font-size: 64px; padding: 4px 38px; }
#app #banner small { display: block; margin-top: 4px; font-size: 14px; font-weight: 500; color: #cad6e2; }
#app #view-tools { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; }
#app #view-tools button { background: var(--overlay); border-color: rgba(255, 255, 255, .22); color: #fff; }
#app #view-tools button:hover { background: var(--topbar); }
#app #view-tools button[aria-pressed="true"] { background: #1f6fae; border-color: var(--accent-light); color: #fff; }

#app .drawer-toggle { font-size: 18px; }
#app .drawer > section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#app .drawer .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
#app .drawer .fields label { flex-direction: column; align-items: stretch; gap: 3px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
#app .drawer .fields label.wide { grid-column: 1 / -1; }
#app .drawer .fields select, #app .drawer .fields input:not(.rm-number) { width: 100%; font-size: 13px; font-weight: 400; letter-spacing: 0; }
#app .drawer .fields .rm-number { width: 100%; }
#app .robot-card h3 { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; letter-spacing: .06em; }
#app .swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); flex: none; }
#app .robot-card .segmented { margin-bottom: 6px; }
#app .robot-card .pilot-row select { width: 100%; }
#app .robot-card .error { color: var(--error); font-size: 12px; margin-top: 4px; }
#app .readouts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; font-family: var(--mono); font-size: 11px; }
#app .chip { padding: 1px 7px; border-radius: 999px; background: var(--blue); color: var(--green-dark); border: 1px solid transparent; }
#app .chip.on { background: #1f9d55; color: #fff; }
#app .chip.hit { background: #d93030; color: #fff; }
#app .motors { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-items: center; margin-top: 8px; font-size: 11px; color: var(--muted); }
#app .bar { position: relative; height: 8px; background: var(--blue); border-radius: 4px; overflow: hidden; }
#app .bar span { position: absolute; top: 0; bottom: 0; background: var(--green); }
#app .bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }
#app .bt-state { margin-top: 6px; font-size: 12px; color: var(--muted); }
#app .log { margin: 6px 0 0; max-height: 96px; overflow-y: auto; font: 11px/1.45 var(--mono); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; white-space: pre-wrap; }
#app .log:empty { display: none; }
#app #history-box .section-head { margin-top: 0; }
#app #history { margin: 0; padding-left: 22px; font-size: 13px; max-height: 200px; overflow-y: auto; }
#app #history li { padding: 2px 0; }
#app #history .why { color: var(--muted); }

/* --- Arène --- */
#app #arena-panel { display: flex; flex-direction: column; gap: 8px; }
#app #arena-panel h3, #app #arena-create h3 { margin: 0; }
#app #arena-panel .hint, #app #arena-create .hint { margin: 0; }
#app .arena-champion { display: flex; gap: 10px; align-items: flex-start; }
#app .arena-champion .swatch { width: 22px; height: 22px; margin-top: 2px; }
#app .arena-champion strong { font-size: 15px; }
#app .tag { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--blue); color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
#app #arena-panel .grow span { font-size: 12px; font-weight: 700; }
#app .match-marks { display: flex; align-items: center; gap: 6px; }
#app .match-mark {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 800; font-size: 13px;
  background: var(--control); border: 1px solid var(--line); color: var(--muted);
}
#app .match-mark.current { border-color: var(--green); color: var(--green); box-shadow: 0 0 0 3px var(--active); }
#app .match-mark.win { background: #1f9d55; border-color: #1f9d55; color: #fff; }
#app .match-mark.loss { background: #c0392b; border-color: #c0392b; color: #fff; }
#app .match-mark.draw { background: var(--muted); border-color: var(--muted); color: #fff; }
#app .match-score { margin-left: auto; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
#app .arena-win { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid #1f9d55; border-radius: var(--radius); background: var(--ok-bg); }
#app .arena-link { display: flex; flex-direction: column; gap: 6px; }
#app .arena-link input { width: 100%; font-family: var(--mono); font-size: 12px; }
#app a.button { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 8px; font-size: 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--control); color: var(--ink); text-decoration: none; }
#app a.button:hover { background: var(--hover); border-color: var(--active-line); }
#app .status.warn { color: var(--rm-color-warning); }
#app .arena-board { margin: 0; padding-left: 22px; font-size: 13px; }
#app .arena-board li { padding: 2px 0; }
#app .arena-board li > span, #app .arena-board li > strong { margin-right: 6px; }
#app .arena-board .who { font-weight: 700; }
#app .arena-board strong { float: right; font-variant-numeric: tabular-nums; color: var(--green); }
#app .arena-board li.me { background: var(--active); border-radius: 6px; }
#app .arena-record { margin: 0; padding-left: 20px; font-size: 13px; max-height: 220px; overflow-y: auto; }
#app .arena-record li { padding: 2px 0; }
#app .arena-record .result { font-weight: 800; }
#app .arena-record .cup { text-decoration: none; font-size: 15px; line-height: 1; padding: 1px 3px; border-radius: 6px; }
#app .arena-record a.cup:hover { background: var(--hover); box-shadow: 0 0 0 1px var(--active-line); }
#app .arena-record .cup.locked { opacity: .55; cursor: help; }
#app .arena-record .defended .result { color: var(--ok); }
#app .arena-record .beaten .result { color: var(--error); }
#app #arena-panel > a.hint { color: var(--green); }
#app .drawer.left { background: var(--paper); }
#app .drawer-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .02em; }
#app #championship-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; justify-content: flex-start; background: none; border-color: transparent; font-size: 15px; font-weight: 800; color: var(--ink); }
#app .drawer-title button:hover { background: var(--hover); border-color: var(--active-line); }
#app .pseudo-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#app .pseudo-row > span { color: var(--muted); font-size: 12px; font-weight: 700; }
#app .pseudo-row strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#app .drawer.left > section { border-bottom: 1px solid var(--line); }
#app .cup { margin-right: 6px; }
#app #arena-list, #app #arena-own { display: flex; flex-direction: column; gap: 6px; }
#app .arena-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#app .arena-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--white); }
#app .arena-list li.current { border-color: var(--green); box-shadow: 0 0 0 2px var(--active); }
#app .arena-list a { color: var(--ink); font-weight: 700; text-decoration: none; flex: 1; min-width: 0; }
#app .arena-list a:hover { color: var(--green); }
#app .badge { padding: 1px 7px; border-radius: 999px; background: var(--blue); color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
#app .badge.ok { background: var(--ok-bg); color: var(--ok); }
#app #arena-own h3.locked { color: var(--muted); }
#app #arena-own .grow input { min-width: 0; }
#app a.button.primary { justify-content: center; min-height: 34px; font-size: 14px; font-weight: 750; background: var(--green); border-color: var(--green); color: #fff; }
#app a.button.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
html[data-theme="dark"] #app a.button.primary { color: #09131f; }

/* --- Robots --- */
#app #robots { overflow-y: auto; }
#app .editors { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; padding: 16px; }
#app .editor { background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-small); padding: 16px; }
#app .editor .top { display: grid; grid-template-columns: 1fr 230px; gap: 14px; }
#app .editor .form { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; align-items: center; align-content: start; }
#app .editor .form > span { color: var(--muted); font-size: 13px; }
#app .editor .form input[type="text"] { width: 100%; }
#app .editor .size { color: var(--ink); }
#app .editor svg { width: 230px; height: 230px; background: var(--stage); border: 1px solid var(--line); border-radius: 12px; touch-action: none; color: var(--ink); }
#app .editor svg .draggable { cursor: grab; }
#app .editor svg text { font: 7px system-ui, sans-serif; fill: var(--ink); pointer-events: none; }
#app .gauge-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
#app .gauge-values { font-size: 12px; font-weight: 700; }
#app .derived { font-size: 12px; color: var(--muted); margin: 10px 0; padding: 8px 10px; background: var(--paper); border-radius: 8px; }
#app .derived b { color: var(--ink); }
#app .editor table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
#app .editor th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px; }
#app .editor td { padding: 2px; }
#app .editor td .rm-number { width: 66px; }
#app .editor td.row { gap: 4px; }
#app .outline-box { margin-top: 8px; }
#app .outline-box .section-head { flex-wrap: wrap; }
/* Titre du robot et actions sur la même ligne, l'export en premier. */
#app .editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
#app .editor-head h2 { margin: 0; }

/* --- Stratégies BT --- */
/* Stratégies : volets communs (robot-maker-tool.css) autour de l'éditeur. */
/* Volet replié : seule la ligne du nom (.rm-drawer-clear) se décale ; elle est déjà à 16 px + carte du bord. */
#app .bt-main { display: flex; padding: 16px; --rm-drawer-clear-offset: 29px; }
#app .bt-main .bt-edit { flex: 1; min-width: 0; }
#app .bt-list, #app .bt-edit, #app .bt-reference { min-height: 0; }
#app .bt-list ul { list-style: none; margin: 0 0 10px; padding: 0; }
#app .bt-list li button { width: 100%; text-align: left; border-color: transparent; background: none; }
#app .bt-list li button[aria-current="true"] { background: var(--active); border-color: var(--active-line); font-weight: 700; }
#app .bt-list li .tag { color: var(--muted); font-size: 11px; margin-left: 4px; font-weight: 400; }
#app .bt-edit { display: flex; flex-direction: column; gap: 8px; }
#app #bt-text {
  flex: 1; min-height: 320px; resize: none; font: 13px/1.45 var(--mono); tab-size: 1;
  background: var(--control); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
#app #bt-nodes h4 { margin: 12px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--green); }
#app #bt-nodes button { display: block; width: 100%; text-align: left; margin-bottom: 4px; background: none; }
#app #bt-nodes code { font: 700 12px var(--mono); }
#app #bt-nodes .args { font: 11px var(--mono); color: var(--muted); }
#app #bt-nodes .help { display: block; font-size: 12px; color: var(--muted); }

/* --- Aide et visite guidée --- */
dialog#help {
  max-width: min(760px, calc(100% - 32px)); background: var(--white); color: var(--ink); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 20px 24px; font: 14px/1.45 Inter, system-ui, "Segoe UI", sans-serif;
}
dialog#help::backdrop { background: rgba(9, 19, 31, .55); }
dialog#help h2 { margin: 0 0 8px; font-size: 18px; }
dialog#help h3 { margin: 16px 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--green); }
dialog#help .close { float: right; font-size: 18px; } /* Action carrée commune (.rm-icon-action), placée à droite. */
dialog#help table { border-collapse: collapse; width: 100%; font-size: 13px; }
dialog#help td { border-top: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
dialog#help td:first-child { color: var(--muted); }
dialog#help code { font-family: var(--mono); }
dialog#help .row { margin-top: 16px; }
.tour {
  position: fixed; z-index: 50; width: min(380px, calc(100vw - 16px)); background: var(--white); color: var(--ink);
  border: 1px solid var(--green); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  font: 13px/1.45 Inter, system-ui, "Segoe UI", sans-serif;
}
.tour[hidden] { display: none; }
.tour h3 { margin: 0 0 4px; font-size: 14px; }
.tour p { margin: 0 0 10px; color: var(--muted); }
.tour .actions { display: flex; justify-content: flex-end; gap: 6px; }
.tour-target { outline: 2px solid var(--accent-light) !important; outline-offset: 2px; border-radius: 6px; }

/* --- Fenêtres du championnat : pseudo, victoire --- */
dialog.pseudo-dialog {
  width: min(400px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px;
  background: var(--white); color: var(--ink); box-shadow: var(--shadow); font: 14px/1.45 Inter, system-ui, "Segoe UI", sans-serif;
}
dialog.pseudo-dialog::backdrop, dialog.victory-dialog::backdrop { background: rgba(9, 19, 31, .6); }
dialog.pseudo-dialog h2 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 6px; }
dialog.pseudo-dialog p { margin: 0 0 12px; color: var(--muted); }
dialog.pseudo-dialog input {
  width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--control); color: var(--ink);
}
dialog.pseudo-dialog .status { margin: 6px 0 0; color: var(--error); font-size: 13px; }
dialog.pseudo-dialog .row, dialog.victory-dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog.victory-dialog {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent;
  display: grid; place-items: center; overflow: hidden;
}
dialog.victory-dialog:not([open]) { display: none; }
dialog.victory-dialog .confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
dialog.victory-dialog .victory-card {
  position: relative; width: min(420px, calc(100% - 32px)); padding: 22px 24px; text-align: center; border-radius: 18px;
  background: var(--white); color: var(--ink); border: 2px solid #f7b500; box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
  font: 14px/1.45 Inter, system-ui, "Segoe UI", sans-serif; animation: victory-pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
dialog.victory-dialog h2 { margin: 6px 0; font-size: 22px; }
dialog.victory-dialog p { margin: 0; color: var(--muted); }
dialog.victory-dialog .row { justify-content: center; }
dialog.victory-dialog .trophy { width: 160px; height: 176px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); }
dialog.victory-dialog .trophy-name { font: 800 16px Inter, system-ui, sans-serif; fill: #3b2a12; letter-spacing: .02em; }
@keyframes victory-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* Fenêtres du pseudo et de la victoire : boutons communs (.rm-button, .rm-button--strong). */

/* --- Écrans étroits --- */
@media (max-width: 1420px) {
}
@media (max-width: 760px) {
  body { overflow-y: auto; overflow-x: hidden; }
  #app .editors { grid-template-columns: 1fr; padding: 8px; }
  #app .editor .top { grid-template-columns: 1fr; }
  #app .score-chip { min-width: 0; }
  #app .score-chip .name { max-width: 70px; }
  /* Téléphone : le titre passe sur deux lignes (la grille de l'en-tête est dans robot-maker-tool.css), et
     la barre du combat se replie : scores sur une ligne, boutons dessous, plutôt qu'un défilement latéral. */
  #app #topbar:is([data-rm-header-layout="two"], [data-rm-header-layout="three"]) .match-group { overflow-x: visible; }
  #app #topbar:is([data-rm-header-layout="two"], [data-rm-header-layout="three"]) .match-content {
    flex: 1 1 auto; width: auto; flex-wrap: wrap; justify-content: center; row-gap: 6px;
  }
  #app #topbar #scores { order: -1; flex: 1 0 100%; justify-content: center; padding: 0; }
}

@media (max-width: 760px), (orientation: portrait) {
  body { overflow-y: auto; overflow-x: hidden; }
  #app #stage { min-height: 55vh; }
}

@media (prefers-reduced-motion: reduce) {
  dialog *, .tour * {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --- « Voir tous les champions » : lien du volet Championnat et fenêtre de l'arbre des arènes --- */
#app button.all-champions {
  align-self: flex-start; padding: 0; border: 0; background: none; min-height: 0;
  color: var(--green); font-size: 13px; font-weight: 700; text-decoration: underline; cursor: pointer;
}
#app button.all-champions:hover { color: var(--green-dark); background: none; }
dialog.champions-dialog {
  width: min(640px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); box-shadow: var(--shadow); font: 14px/1.45 Inter, system-ui, "Segoe UI", sans-serif;
}
dialog.champions-dialog::backdrop { background: rgba(9, 19, 31, .6); }
.champions-card { padding: 18px 20px; }
.champions-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.champions-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.champions-card .hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.champions-summary { margin: 0 0 8px; font-weight: 700; }
.champions-tree, .champions-tree ul { list-style: none; margin: 0; padding: 0; }
.champions-tree ul { margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--line); }
.champions-tree li { margin: 6px 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.champions-tree li.locked { background: var(--white); }
.champion-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.champion-line a { color: var(--ink); font-weight: 800; }
.champion-line a:hover { color: var(--green); }
.champion-line strong { color: var(--muted); }
.champion-line .badge { padding: 1px 7px; border-radius: 999px; background: var(--blue); color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.champion-line .badge.ok { background: var(--ok-bg); color: var(--ok); }
.champion-facts, .champion-lock { margin: 2px 0 0 26px; font-size: 12px; color: var(--muted); }
.champion-lock { color: var(--ink); font-weight: 600; }
.champion-beaten-by { margin: 6px 0 0 26px; }
.champion-beaten-by > span { font-size: 12px; color: var(--muted); }
.champions-card .status.error { color: var(--error); }
.champions-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.champions-copied { color: var(--muted); font-size: 12px; word-break: break-all; }
