    /* ─── Thème : noir et gris neutres (plus de violet) ─── */
    :root {
      --bg-0: #000000;
      --bg-1: #0a0a0a;
      --panel-bg: rgba(0, 0, 0, 0.82);
      --panel-border: rgba(118, 118, 118, 0.42);
      --panel-radius: 12px;
      --accent: #858585;
      --accent-2: #606060;
      --accent-deep: #333333;
      --text: #ececec;
      --text-dim: #b1b1b1;
      --text-mute: #7d7d7d;
      --ok: #34c77a;
      --danger: #e0476a;
      --hud: #cecece;
      --gap: 8px;
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    /* ─── Roboto Mono (variable 100→700, normal + italique) — self-hostée ─── */
    @font-face {
      font-family: 'Roboto Mono';
      font-style: normal;
      font-weight: 100 700;
      font-display: swap;
      src: url('/assets/fonts/roboto-mono-latin-ext.woff2') format('woff2');
      unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }
    @font-face {
      font-family: 'Roboto Mono';
      font-style: normal;
      font-weight: 100 700;
      font-display: swap;
      src: url('/assets/fonts/roboto-mono-latin.woff2') format('woff2');
      unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }
    @font-face {
      font-family: 'Roboto Mono';
      font-style: italic;
      font-weight: 100 700;
      font-display: swap;
      src: url('/assets/fonts/roboto-mono-italic-latin-ext.woff2') format('woff2');
      unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }
    @font-face {
      font-family: 'Roboto Mono';
      font-style: italic;
      font-weight: 100 700;
      font-display: swap;
      src: url('/assets/fonts/roboto-mono-italic-latin.woff2') format('woff2');
      unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }
    :root {
      --font-mono: 'Roboto Mono', 'Consolas', ui-monospace, monospace;
    }
    html, body { font-family: var(--font-mono); font-weight: 400; color: var(--text); }
    .fw-light  { font-weight: 300; }
    .fw-bold   { font-weight: 700; }
    .fs-italic { font-style: italic; }
    body {
      background:
        radial-gradient(1200px 700px at 50% -10%, #141414 0%, transparent 60%),
        radial-gradient(circle at 50% 30%, var(--bg-1) 0%, var(--bg-0) 78%);
      width: 100vw; height: 100vh; overflow: hidden;
    }
    /* Site = jeu : rien ne se sélectionne (boutons, textes, menus), et pas de
       loupe / menu « copier » à l'appui long sur iPhone/iPad. Les champs de
       saisie de l'éditeur restent sélectionnables. */
    body {
      -webkit-user-select: none; user-select: none;
      -webkit-touch-callout: none;
    }
    input, textarea, select, [contenteditable="true"] {
      -webkit-user-select: text; user-select: text;
      -webkit-touch-callout: default;
    }
    ::-webkit-scrollbar { width: 8px; height: 8px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: rgba(118, 118, 118, 0.5); border-radius: 4px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--accent); }

    /* ─── Stage / canvas ─── */
    #stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
    #viewport { position: relative; line-height: 0; }
    canvas#c {
      image-rendering: pixelated;
      image-rendering: crisp-edges;
      cursor: crosshair;
      box-shadow: 0 0 50px rgba(103, 103, 103, 0.35), 0 0 0 1px #333333;
      background: #000;
    }

    /* ─── Couche de texte (DOM au-dessus du canvas) ─────────────────────────
       Les textes du jeu sont du vrai DOM, pas du texte canvas : typographie
       nette quel que soit le zoom, liens natifs, sélection possible.
       #textLayerInner est en coordonnées monde ; son transform reproduit la caméra. */
    #textLayer {
      position: absolute; inset: 0; overflow: hidden;
      pointer-events: none;
      z-index: 2;
    }
    #textLayerInner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
    .gameText {
      position: absolute;
      font-family: var(--font-mono);
      line-height: 1.5;
      white-space: pre-wrap;
      word-break: break-word;
      -webkit-font-smoothing: antialiased;
    }
    .gameText .glink {
      color: inherit; text-decoration: none;
      border-bottom: 0.08em solid currentColor;
      padding-bottom: 0.05em;
      transition: color 0.12s, opacity 0.12s;
      cursor: pointer;
    }
    .gameText.clickable { pointer-events: auto; }
    .gameText.clickable .glink:hover { opacity: 0.65; }
    body.is-editor .gameText { pointer-events: none !important; }

    /* ─── Panels ─── */
    .panel {
      position: fixed;
      background: var(--panel-bg);
      backdrop-filter: blur(12px) saturate(1.1);
      -webkit-backdrop-filter: blur(12px) saturate(1.1);
      border: 1px solid var(--panel-border);
      border-radius: var(--panel-radius);
      padding: 10px 12px;
      box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255,255,255,0.04);
      z-index: 10;
    }
    .panel h3 {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 1.4px;
      color: var(--accent);
      margin-bottom: 8px;
      font-weight: 700;
      display: flex; align-items: center; gap: 6px;
    }
    .panel h3::before {
      content: ''; width: 3px; height: 12px; border-radius: 2px;
      background: linear-gradient(180deg, var(--accent), var(--accent-2));
    }

    /* ─── Buttons ─── */
    button, .btn {
      background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent-deep) 100%);
      color: #fff;
      border: 1px solid #606060;
      border-radius: 8px;
      padding: 7px 14px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: transform .12s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
      font-family: inherit;
      white-space: nowrap;
    }
    button:hover, .btn:hover {
      background: linear-gradient(180deg, #686868 0%, #414141 100%);
      border-color: var(--accent);
      transform: translateY(-1px);
      box-shadow: 0 4px 14px rgba(103, 103, 103, 0.35);
    }
    button:active, .btn:active { transform: translateY(0); box-shadow: none; }
    button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible {
      outline: 2px solid var(--accent); outline-offset: 1px;
    }
    button.danger {
      background: linear-gradient(180deg, #a82846 0%, #781a30 100%);
      border-color: #c43560;
    }
    button.danger:hover { background: linear-gradient(180deg, #c4365b 0%, #962240 100%); }
    button.success {
      background: linear-gradient(180deg, #2d8b54 0%, #1d6a3e 100%);
      border-color: #3aa86a;
    }
    button.success:hover { background: linear-gradient(180deg, #3ba868 0%, #267a48 100%); }
    button.ghost {
      background: rgba(36, 36, 36, 0.4);
      border: 1px solid #5a5a5a;
    }
    button.ghost:hover { background: rgba(90, 90, 90, 0.3); }
    button.ghost.active {
      background: linear-gradient(180deg, #606060 0%, #474747 100%);
      border-color: #858585;
      box-shadow: 0 0 12px rgba(103, 103, 103, 0.4);
    }
    .btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

    /* ─── Inputs ─── */
    input[type=text], input[type=number], select, textarea {
      background: #161616;
      color: #fff;
      border: 1px solid #474747;
      border-radius: 5px;
      padding: 6px 10px;
      font-size: 13px;
      font-family: inherit;
      width: 100%;
    }
    input[type=text]:focus, input[type=number]:focus, select:focus {
      outline: none; border-color: #858585;
      box-shadow: 0 0 0 2px rgba(133, 133, 133, 0.2);
    }
    label {
      font-size: 11px;
      color: #a4a4a4;
      display: block;
      margin-bottom: 3px;
      letter-spacing: 0.5px;
    }
    input[type=range] {
      width: 100%; accent-color: #858585; background: transparent;
      height: 18px; cursor: pointer;
    }
    input[type=color] {
      width: 100%; height: 30px; padding: 2px; cursor: pointer;
      background: #161616; border: 1px solid #474747; border-radius: 5px;
    }
    .subBox {
      border: 1px solid #262626; border-radius: 7px;
      padding: 9px 10px; margin-bottom: 10px;
      background: rgba(18, 18, 18, 0.5);
    }
    .subBox > .subTitle {
      font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
      color: #a4a4a4; margin-bottom: 8px; font-weight: 700;
    }
    .checkRow {
      display: flex; align-items: center; gap: 7px; cursor: pointer;
      font-size: 12px; color: #cecece; margin-bottom: 7px;
    }
    .checkRow input { width: auto; margin: 0; }
    .choiceRow {
      border: 1px solid #333333; border-radius: 6px; padding: 10px;
      margin-bottom: 8px; background: rgba(36, 36, 36, 0.35);
    }
    .field { margin-bottom: 10px; }
    .field-row { display: flex; gap: 6px; }
    .field-row .field { flex: 1; margin-bottom: 0; }

    /* ─── Main menu ─── */
    #menu {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      background: radial-gradient(circle at 50% 35%, #141414 0%, #000 75%);
      z-index: 50;
    }
    #menu h1 {
      font-size: 72px;
      background: linear-gradient(180deg, #dedede 0%, #6c6c6c 100%);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      letter-spacing: 4px;
      margin-bottom: 6px;
      text-shadow: 0 0 40px rgba(103, 103, 103, 0.3);
    }
    #menu .sub {
      color: #848484;
      font-size: 13px;
      margin-bottom: 38px;
      letter-spacing: 3px;
      text-transform: uppercase;
    }
    #menu .mainBtns { display: flex; flex-direction: column; gap: 12px; min-width: 300px; }
    #menu .mainBtns button { padding: 14px 24px; font-size: 15px; }
    #menu .footer {
      position: absolute; bottom: 14px;
      color: #545454; font-size: 11px;
      letter-spacing: 1px;
    }

    /* ─── Editor toolbar (top) ─── */
    #toolbar {
      top: 12px; left: 12px; right: 12px;
      display: flex; gap: 7px; align-items: center; justify-content: center;
      flex-wrap: wrap;
      padding: 8px 12px;
      max-height: 30vh; overflow-y: auto;
    }
    #toolbar button { padding: 6px 11px; font-size: 12.5px; }
    #toolbar input[type=text] { width: 200px; }
    #toolbar input[type=number] {
      width: 72px; background: rgba(18, 18, 18, 0.8); border: 1px solid #333333;
      color: #cecece; padding: 4px 6px; border-radius: 6px; font: 12px sans-serif;
    }
    #toolbar label { color: #a4a4a4; font-size: 11px; letter-spacing: 0.5px; }
    #toolbar .sep { width: 1px; height: 24px; background: #333333; margin: 0 4px; }

    /* ─── Editor tools (left) ─── */
    #tools {
      left: 14px; top: 50%; transform: translateY(-50%);
      display: flex; flex-direction: column; gap: 6px;
      width: 148px;
      max-height: 86vh; overflow: auto;
    }
    .tool {
      padding: 9px 12px;
      text-align: left;
      font-size: 12px;
      background: rgba(40, 40, 40, 0.45);
      border: 1px solid rgba(118, 118, 118, 0.25);
      border-radius: 8px;
      cursor: pointer;
      color: #fff;
      transition: background .15s, border-color .15s, box-shadow .15s;
      font-family: inherit;
      display: flex; justify-content: space-between; align-items: center;
    }
    .tool:hover { background: rgba(104, 104, 104, 0.35); border-color: rgba(133, 133, 133, 0.5); }
    .tool.active {
      background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent-deep) 100%);
      border-color: var(--accent);
      box-shadow: 0 0 14px rgba(103, 103, 103, 0.45);
    }
    .tool .key {
      font-size: 10px;
      color: #a4a4a4;
      background: rgba(0,0,0,0.35);
      padding: 2px 6px;
      border-radius: 3px;
      letter-spacing: 0.5px;
    }
    .tool.active .key { color: #fff; background: rgba(0,0,0,0.4); }

    /* ─── Editor properties (right) ─── */
    #props {
      right: 14px; top: 50%; transform: translateY(-50%);
      width: 260px;
      max-height: 80vh; overflow: auto;
    }
    #props::-webkit-scrollbar { width: 6px; }
    #props::-webkit-scrollbar-track { background: transparent; }
    #props::-webkit-scrollbar-thumb { background: #474747; border-radius: 3px; }

    /* ─── Editor HUD (bottom) ─── */
    #hud {
      bottom: 12px; left: 50%; transform: translateX(-50%);
      max-width: min(880px, calc(100vw - 320px));
      font-size: 11px;
      color: var(--text-dim);
      letter-spacing: 0.3px;
      display: flex; gap: 6px 12px; align-items: center; justify-content: center;
      flex-wrap: wrap;
      padding: 7px 12px;
    }
    #hud > div { display: inline-flex; align-items: center; white-space: nowrap; }
    .hudKey {
      color: #fff;
      background: rgba(0,0,0,0.32);
      padding: 2px 6px;
      border-radius: 4px;
      margin-left: 4px;
      font-family: 'Consolas', monospace;
      font-size: 10px;
      border: 1px solid rgba(255,255,255,0.06);
    }

    /* ─── Play HUD ─── */
    #playHud {
      top: 14px; left: 14px;
      display: flex; gap: 8px; align-items: center;
      padding: 8px 12px;
    }
    #playLevelName { font-weight: 500; padding-right: 8px; color: #cecece; }
    #playHint {
      bottom: 14px; right: 14px;
      font-size: 11px;
      color: #848484;
      padding: 8px 12px;
    }

    /* ─── Boutons tactiles (mobile) : ◀ · saut · ▶ ───────────────────────────
       Petits, collés au bas de l'écran (flèches dans les coins, saut au centre)
       et presque transparents au repos : ils masquent le moins possible la planche. */
    #touchPad {
      position: fixed; z-index: 20;
      left: max(10px, env(safe-area-inset-left));
      right: max(10px, env(safe-area-inset-right));
      bottom: max(10px, env(safe-area-inset-bottom));
      display: flex; justify-content: space-between; align-items: flex-end;
      pointer-events: none;            /* seuls les boutons captent le toucher */
    }
    #touchPad[hidden] { display: none; }
    /* Tablette (iPad…) : flèches dans les coins = trop loin l'une de l'autre.
       On regroupe ◀ · saut · ▶ en bas au centre, à portée des pouces. */
    @media (min-width: 700px) and (min-height: 600px) {
      #touchPad { justify-content: center; gap: 28px; }
    }
    .tcBtn {
      pointer-events: auto;
      width: 56px; height: 56px; padding: 0;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      color: #fff;
      background: rgba(0, 0, 0, 0.22);
      border: 1.5px solid rgba(255, 255, 255, 0.45);
      opacity: 0.6;
      touch-action: none;
      -webkit-user-select: none; user-select: none;
      -webkit-touch-callout: none;
      -webkit-tap-highlight-color: transparent;
      transition: transform 80ms ease, opacity 80ms ease, background-color 80ms ease;
    }
    .tcBtn svg {
      width: 26px; height: 26px;
      fill: none; stroke: currentColor; stroke-width: 3;
      stroke-linecap: round; stroke-linejoin: round;
      filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));   /* lisible sur planche claire */
    }
    .tcBtn.pressed { opacity: 1; transform: scale(0.92); background: rgba(0, 0, 0, 0.45); }
    /* Le perso passe derrière (paysage) : le bouton s'efface, sans cesser de répondre. */
    .tcBtn.behind, .tcBtn.behind.pressed { opacity: 0.12; transition: opacity 150ms ease; }
    .tcJump { width: 62px; height: 62px; }
    .tcJump svg { width: 30px; height: 30px; }
    #tcUse {
      position: fixed; z-index: 20;
      left: 50%; transform: translateX(-50%);
      bottom: calc(max(10px, env(safe-area-inset-bottom)) + 74px);
      width: 50px; height: 50px;
      font-size: 20px; font-weight: 700;
      color: #ffe44d; opacity: 0.85;
    }
    #tcUse.pressed { transform: translateX(-50%) scale(0.92); }
    #tcUse[hidden] { display: none; }

    /* ─── Ambiance (au-dessus du jeu, sous l'interface) ───────────────────────
       Halo de lumière qui suit le perso, assombrissement des bords qui respire
       et grain de pellicule. Tout passe par transform/opacity, animés en JS
       (cf. js/16-ambiance.js) : rien à repeindre, ça reste fluide sur mobile. */
    #ambiance {
      position: absolute; inset: 0; overflow: hidden;
      pointer-events: none;
      z-index: 3;
    }
    #ambiance[hidden] { display: none; }
    #ambLight, #ambGrain { position: absolute; will-change: transform, opacity; }
    #ambLight { left: -100%; top: -100%; width: 300%; height: 300%; }
    #ambGrain {
      inset: -128px;
      background-size: 128px 128px;
      mix-blend-mode: overlay;
      opacity: 0.05;
    }
    /* Site public : ni menu, ni éditeur, ni barre de jeu — seul le bouton Retour reste
       (#playNav, piloté par refreshPlayNav). Le menu ne clignote pas au chargement. */
    body.is-public #menu,
    body.is-public #editorUI,
    body.is-public #playHud,
    body.is-public #playHint { display: none !important; }
    /* Sur tactile, l'aide clavier n'a pas de sens. */
    body.is-touch #playHint { display: none; }

    /* ─── Navigation en jeu (retour / accueil) ─── */
    #playNav {
      top: 14px; left: 50%; transform: translateX(-50%);
      display: flex; gap: 8px; align-items: center;
      padding: 8px 12px;
    }
    #playNav button { letter-spacing: 0.5px; }
    #playNav[hidden] { display: none !important; }

    /* ─── Menu de sélection en jeu ─── */
    /* ─── Chargement ──────────────────────────────────────────────────────────
       #loader : écran noir tant que les images de la page ne sont pas là.
       #preloadBar : fine barre sur l'accueil pendant que le reste du site se charge. */
    #loader {
      position: fixed; inset: 0; z-index: 90;
      background: #000; color: #fff;
      display: flex; align-items: center; justify-content: center;
      transition: opacity 300ms ease;
    }
    #loader.out { opacity: 0; pointer-events: none; }
    .loaderBox { width: min(220px, 60vw); text-align: center; font-family: 'Roboto Mono', monospace; }
    .loaderTxt { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.7; margin-bottom: 14px; }
    .loaderTrack { height: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
    #loaderBar {
      height: 100%; background: #fff;
      transform: scaleX(0); transform-origin: 0 50%;
      transition: transform 200ms ease;
    }
    #preloadBar {
      position: fixed; z-index: 15; pointer-events: none;
      left: 50%; transform: translateX(-50%);
      top: calc(env(safe-area-inset-top, 0px) + 10px);
      width: min(240px, 60vw);
      font-family: 'Roboto Mono', monospace; text-align: center;
    }
    #preloadBar[hidden] { display: none; }
    #preloadBar .track { height: 2px; background: rgba(0, 0, 0, 0.18); overflow: hidden; }
    #preloadBar .fill {
      height: 100%; background: rgba(0, 0, 0, 0.6);
      transform: scaleX(0); transform-origin: 0 50%;
      transition: transform 300ms ease;
    }
    #preloadBar .pct { margin-top: 5px; font-size: 10px; letter-spacing: 0.08em; color: rgba(0, 0, 0, 0.6); }

    #selectMenu { position: fixed; inset: 0; z-index: 80; }
    #selectMenu .selBackdrop {
      position: absolute; inset: 0;
      background: rgba(4, 4, 4, 0.8);
      backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
      display: flex; align-items: center; justify-content: center;
      animation: fadeIn 0.18s ease-out;
    }
    #selectMenu .selPanel {
      background: linear-gradient(180deg, #111 0%, #000 100%);
      border: 1px solid #5a5a5a; border-radius: 14px;
      padding: 28px 30px; min-width: 420px; max-width: 90vw; max-height: 86vh; overflow: auto;
      box-shadow: 0 18px 70px rgba(0,0,0,0.75);
    }
    #selectMenu .selTitle {
      font-size: 13px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase;
      color: #a4a4a4; margin-bottom: 4px;
    }
    #selectMenu .selSub { font-size: 12px; font-weight: 300; color: #848484; margin-bottom: 20px; }
    #selectMenu .selChoices { display: flex; flex-direction: column; gap: 10px; }
    #selectMenu .selChoice {
      display: flex; align-items: center; gap: 14px;
      padding: 14px 16px; border-radius: 9px; cursor: pointer; text-align: left;
      background: rgba(36, 36, 36, 0.55); border: 1px solid #333333;
      color: #ececec; font-size: 14px; font-family: inherit;
      transition: all 0.15s;
    }
    #selectMenu .selChoice:hover {
      background: rgba(90, 90, 90, 0.35); border-color: #858585;
      transform: translateX(3px);
    }
    #selectMenu .selChoice img {
      width: 52px; height: 52px; object-fit: contain; image-rendering: pixelated;
      border-radius: 5px; background: rgba(0,0,0,0.3); flex: none;
    }
    #selectMenu .selChoice .lbl { font-weight: 700; letter-spacing: 1px; }
    #selectMenu .selChoice .desc { font-size: 11px; font-weight: 300; color: #a4a4a4; margin-top: 2px; }
    #selectMenu .selActions { margin-top: 22px; display: flex; justify-content: flex-end; }

    /* ─── Modal ─── */
    .backdrop {
      position: fixed; inset: 0;
      background: rgba(4, 4, 4, 0.75);
      backdrop-filter: blur(4px);
      z-index: 70;
      display: flex; align-items: center; justify-content: center;
      animation: fadeIn 0.15s ease-out;
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    .modal {
      background: linear-gradient(180deg, #111 0%, #000 100%);
      border: 1px solid #5a5a5a;
      border-radius: 12px;
      padding: 24px;
      min-width: 400px;
      max-width: 560px;
      box-shadow: 0 14px 60px rgba(0,0,0,0.7);
    }
    .modal h2 { margin-bottom: 16px; color: #cecece; font-size: 18px; }
    .modal p { color: #bbbbbb; font-size: 13px; line-height: 1.5; }
    .modal .actions { margin-top: 22px; display: flex; gap: 8px; justify-content: flex-end; }

    /* ─── Level list ─── */
    .levelList { max-height: 50vh; overflow: auto; margin: 0 -8px; padding: 0 8px; }
    .levelList::-webkit-scrollbar { width: 6px; }
    .levelList::-webkit-scrollbar-thumb { background: #474747; border-radius: 3px; }
    .levelItem {
      display: flex; justify-content: space-between; align-items: center;
      padding: 12px 14px; border-radius: 7px;
      cursor: pointer;
      transition: background 0.15s;
      border: 1px solid transparent;
    }
    .levelItem:hover {
      background: rgba(90, 90, 90, 0.18);
      border-color: #474747;
    }
    .levelItem .name { font-weight: 500; }
    .levelItem .meta { font-size: 11px; color: #848484; margin-top: 3px; letter-spacing: 0.3px; }
    .levelItem .btn-row button { padding: 5px 9px; font-size: 11px; }

    /* ─── Hidden ─── */
    [hidden] { display: none !important; }

    /* ─── Indicateur de sauvegarde ─── */
    #saveStatus {
      font-size: 11px; padding: 3px 8px; border-radius: 10px;
      white-space: nowrap; cursor: default; user-select: none;
      border: 1px solid transparent;
    }
    #saveStatus.ok    { color: #7fd6a4; opacity: 0.7; }
    #saveStatus.dirty { color: #f0b35a; border-color: rgba(240,179,90,0.35); }
    #saveStatus.busy  { color: #b4b4b4; }
    #saveStatus.err   { color: #ff7a9c; border-color: rgba(196,53,96,0.6); cursor: pointer; }

    /* ─── Journal ─── */
    .logSummary { margin-bottom: 10px; }
    .logList {
      max-height: 55vh; overflow: auto; background: rgba(0,0,0,0.3);
      border: 1px solid #363636; border-radius: 6px; padding: 6px 8px;
      font-family: 'Roboto Mono', monospace; font-size: 11px; line-height: 1.5;
    }
    .logRow { white-space: pre-wrap; word-break: break-word; color: #a3a3a3; }
    .logRow.warn  { color: #f0b35a; }
    .logRow.error { color: #ff7a9c; }

    /* ─── Toast ─── */
    #toast {
      position: fixed; bottom: 60px; left: 50%;
      transform: translateX(-50%) translateY(20px);
      background: rgba(27, 27, 27, 0.97);
      border: 1px solid #5a5a5a;
      padding: 12px 22px;
      border-radius: 8px;
      font-size: 13px;
      z-index: 100;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s, transform 0.25s;
      box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    }
    #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* ─── Portal image preview ─── */
    .imgPreview {
      width: 100%; height: 90px;
      background: #000;
      border: 1px dashed #5a5a5a;
      border-radius: 5px;
      display: flex; align-items: center; justify-content: center;
      overflow: hidden;
      margin-bottom: 6px;
      position: relative;
    }
    .imgPreview img { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
    .imgPreview .empty {
      color: #646464; font-size: 11px; text-align: center;
      padding: 0 10px; line-height: 1.4;
    }

    /* ─── Help section ─── */
    .help {
      margin-top: 12px; padding-top: 10px;
      border-top: 1px solid #262626;
      font-size: 11px; color: #848484;
      line-height: 1.6;
    }

    /* ─── Modal sizes ─── */
    .modal.wide { min-width: 720px; max-width: 90vw; }
    .modal.huge { min-width: 880px; max-width: 95vw; }

    /* ─── Media library ─── */
    .quotaBar {
      height: 4px; background: #161616; border-radius: 2px; overflow: hidden;
      margin: 4px 0 14px;
    }
    .quotaBar > div { height: 100%; background: linear-gradient(90deg, #474747, #858585); transition: width .2s; }
    .quotaBar.warn > div { background: linear-gradient(90deg, #a82846, #ff7a7a); }
    .quotaLabel { font-size: 11px; color: #848484; display: flex; justify-content: space-between; margin-bottom: 2px; }

    .mediaGrid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 10px;
      max-height: 58vh;
      overflow: auto;
      padding: 4px;
    }
    .mediaGrid::-webkit-scrollbar { width: 6px; }
    .mediaGrid::-webkit-scrollbar-thumb { background: #474747; border-radius: 3px; }
    .mediaCard {
      background: rgba(36, 36, 36, 0.5);
      border: 1px solid #333333;
      border-radius: 7px;
      padding: 8px;
      display: flex; flex-direction: column; gap: 6px;
      transition: border-color .15s;
    }
    .mediaCard:hover { border-color: #858585; }
    .mediaThumb {
      width: 100%; aspect-ratio: 1;
      background: repeating-conic-gradient(#0a0a0a 0% 25%, #101010 0% 50%) 50% / 12px 12px;
      border-radius: 4px;
      display: flex; align-items: center; justify-content: center;
      overflow: hidden;
    }
    .mediaThumb img { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
    .mediaName { font-size: 12px; font-weight: 500; color: #cecece; word-break: break-word; }
    .mediaMeta { font-size: 10px; color: #848484; letter-spacing: .3px; }
    .mediaKindBadge {
      display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 8px;
      letter-spacing: .5px; text-transform: uppercase;
      background: rgba(103, 103, 103, 0.25); color: #aeaeae;
    }
    .mediaKindBadge.sprite { background: rgba(255, 228, 77, 0.18); color: #ffe44d; }
    .mediaKindBadge.tile { background: rgba(58, 255, 144, 0.18); color: #6fffa8; }
    .mediaCard .btn-row { gap: 4px; }
    .mediaCard .btn-row button { padding: 4px 6px; font-size: 10px; flex: 1; }
    .mediaEmpty {
      grid-column: 1/-1;
      padding: 40px 20px; text-align: center; color: #646464; font-size: 13px; line-height: 1.6;
      border: 1px dashed #333333; border-radius: 8px;
    }

    /* ─── Hitbox editor ─── */
    .hbStage {
      position: relative;
      background: repeating-conic-gradient(#0a0a0a 0% 25%, #101010 0% 50%) 50% / 16px 16px;
      border: 1px solid #333333;
      border-radius: 6px;
      overflow: auto;
      max-height: 60vh;
      max-width: 100%;
      display: flex; align-items: center; justify-content: center;
      padding: 16px;
    }
    .hbStage canvas { display: block; cursor: crosshair; image-rendering: pixelated; }
    .hbToolbar {
      display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
      margin-bottom: 10px;
    }
    .hbToolbar .sep { width: 1px; height: 22px; background: #333333; margin: 0 4px; }
    .hbToolbar label { display: inline; color: #a4a4a4; font-size: 11px; margin-right: 4px; }
    .hbToolbar input[type=number] { width: 70px; }
    .hbInfo { font-size: 11px; color: #848484; margin-top: 8px; line-height: 1.5; }
    .hbList { max-height: 18vh; overflow: auto; margin-top: 8px; }
    .hbItem {
      display: flex; justify-content: space-between; align-items: center;
      padding: 5px 10px; border-radius: 5px;
      font-size: 11px; color: #bbbbbb;
      background: rgba(36, 36, 36, 0.4);
      margin-bottom: 4px;
      cursor: pointer;
    }
    .hbItem.active { background: rgba(255, 228, 77, 0.18); color: #ffe44d; border: 1px solid #ffe44d; }
    .hbItem button { padding: 2px 7px; font-size: 10px; }

    /* ─── Armed media chip (next to Objet tool) ─── */
    .armedChip {
      display: flex; align-items: center; gap: 6px;
      padding: 4px 6px;
      background: rgba(255, 228, 77, 0.12);
      border: 1px solid rgba(255, 228, 77, 0.4);
      border-radius: 5px;
      font-size: 10px; color: #ffe44d;
      margin-top: 6px;
    }
    .armedChip img { width: 22px; height: 22px; image-rendering: pixelated; object-fit: contain; }
    .armedChip .x {
      margin-left: auto; background: transparent; border: none; color: #ffe44d;
      cursor: pointer; padding: 0 4px; font-size: 14px;
    }

    /* ─── Responsive ─── */
    @media (max-width: 1180px) {
      #props { width: 232px; }
      #tools { width: 134px; }
      #hud { max-width: calc(100vw - 300px); }
    }
    @media (max-width: 900px) {
      /* Outils en barre horizontale en bas, propriétés à droite, légende masquée. */
      #tools {
        top: auto; bottom: 12px; left: 50%; transform: translateX(-50%);
        flex-direction: row; flex-wrap: wrap; width: auto;
        max-width: calc(100vw - 24px); justify-content: center; gap: 5px;
      }
      #tools h3, #tools .help { display: none; }
      #tools .tool { font-size: 11.5px; padding: 7px 10px; }
      #props { width: 220px; max-height: 62vh; }
      #hud { display: none; }
      #toolbar { max-height: 40vh; }
    }
    @media (max-width: 560px) {
      #toolbar { gap: 5px; padding: 6px 8px; }
      #toolbar button { padding: 5px 9px; font-size: 11.5px; }
      #toolbar input[type=text] { width: 120px; }
      #props {
        left: 12px; right: 12px; top: 64px; bottom: auto; transform: none;
        width: auto; max-height: 38vh;
      }
    }
