
  :root {
    --bg: #0B0E14; --surface: #12151C; --surface-2: #171B23;
    --ink: #F2F3F5; --ink-soft: #9AA0AC; --border: rgba(255,255,255,.10);
    --field: #F4F8F4; --field-line: #C7D2C9; --los-color: #2C5FA8;
    --accent: #FF5A1F; --accent-text: #FF5A1F; --accent-ink: #0B0E14; --danger: #FF6B6B; --focus: #FF5A1F;
    --route-end: #9B4FCC;
  }
  :root[data-theme="light"] {
    --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #F1F2F4;
    --ink: #12151C; --ink-soft: #5B616B; --border: #E2E4E8;
    --field: #F4F8F4; --field-line: #C7D2C9; --los-color: #2C5FA8;
    --accent: #FF5A1F; --accent-text: #C24518; --accent-ink: #12151C; --danger: #C4453B;
    --route-end: #9B4FCC;
  }
  @media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
      --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #F1F2F4;
      --ink: #12151C; --ink-soft: #5B616B; --border: #E2E4E8;
      --field: #F4F8F4; --field-line: #C7D2C9; --los-color: #2C5FA8;
      --accent: #FF5A1F; --accent-text: #C24518; --accent-ink: #12151C; --danger: #C4453B;
      --route-end: #9B4FCC;
    }
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0; background: var(--bg); color: var(--ink);
    font-family: 'Barlow Condensed', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100%;
  }
  .app-nav {
    display: flex; align-items: center; gap: .1rem; padding: 0 1.1rem; min-height: 3.2rem; flex-wrap: wrap;
    background: var(--surface); font-size: .85rem; border-bottom: 1px solid var(--border);
  }
  .app-nav a { color: var(--ink); text-decoration: none; opacity: .65; padding: 0 .85rem; height: 3.2rem; display: flex; align-items: center; text-transform: uppercase; font-weight: 600; letter-spacing: .04em; font-size: .78rem; border-bottom: 3px solid transparent; }
  .app-nav a.current { opacity: 1; background: none; color: var(--accent-text); border-bottom-color: var(--accent); }
  .new-badge { display:inline-block; background:var(--accent); color:var(--accent-ink); font-size:.6rem; font-weight:700; padding:.12rem .4rem; margin-left:.4rem; text-transform:uppercase; letter-spacing:.02em; vertical-align:middle; }
  .app-nav a:hover { opacity: 1; }
  .nav-dropdown { position: relative; display: inline-block; }
  .nav-dropdown-toggle { font-family: inherit; background: none; border: none; color: var(--ink); opacity: .65; padding: 0 .85rem; height: 3.2rem; text-transform: uppercase; font-weight: 600; letter-spacing: .04em; font-size: .78rem; border-bottom: 3px solid transparent; cursor: pointer; }
  .nav-dropdown-toggle:hover { opacity: 1; }
  .nav-dropdown-toggle.current, .nav-dropdown.open .nav-dropdown-toggle { opacity: 1; color: var(--accent-text); border-bottom-color: var(--accent); }
  .nav-dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--surface); border: 1px solid var(--border); min-width: 170px; box-shadow: 0 10px 24px rgba(0,0,0,.35); z-index: 60; padding: .35rem; margin-top: 0; flex-direction: column; gap: .1rem; }
  .nav-dropdown.open .nav-dropdown-menu { display: flex; }
  .nav-dropdown-menu a { color: var(--ink); text-decoration: none; opacity: .85; padding: .5rem .7rem; height: auto; border-bottom: none; text-transform: none; font-weight: 500; letter-spacing: 0; font-size: .85rem; white-space: nowrap; }
  .nav-dropdown-menu a:hover { opacity: 1; background: var(--surface-2); }
  .nav-dropdown-menu a.current { opacity: 1; background: var(--surface-2); font-weight: 600; border-bottom: none; }
  .theme-toggle-btn { background: transparent; color: var(--ink); border: 1px solid var(--border); padding: .3rem .7rem; border-radius: 0; font-size: .72rem; cursor: pointer; font-family: inherit; text-transform: uppercase; letter-spacing: .03em; }
  .global-search-input { margin-left: auto; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink); padding: .35rem .7rem; border-radius: 0; font-size: .78rem; width: 9rem; font-family: inherit; }
  .global-search-input::placeholder { color: var(--ink-soft); }
  .global-search-input:focus { outline: none; border-color: var(--accent); }
  .theme-toggle-btn:hover { border-color: var(--accent); color: var(--accent-text); }
  #helpBtn + #themeToggleBtn { margin-left: .35rem; }
  .update-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; background: var(--surface); color: var(--ink); padding: .7rem 1rem; display: flex; align-items: center; justify-content: center; gap: .9rem; font-size: .85rem; box-shadow: 0 -4px 14px rgba(0,0,0,.4); border-top: 1px solid var(--border); }
  .update-banner button { background: var(--accent); color: var(--accent-ink); border: none; padding: .35rem .8rem; border-radius: 0; font-family: inherit; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; cursor: pointer; font-size: .8rem; }

  .help-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; align-items: center; justify-content: center; padding: 1rem; }
  .help-overlay.open { display: flex; }
  .help-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 1.2rem 1.3rem; max-width: 480px; width: 100%; max-height: 82vh; overflow-y: auto; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
  .help-panel h2 { font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; font-size: 1.15rem; margin: 0 0 .8rem; display: flex; align-items: center; justify-content: space-between; color: var(--ink); }
  .help-panel h3 { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .8rem; color: var(--accent-text); margin: 1rem 0 .4rem; text-transform: uppercase; letter-spacing: .05em; }
  .help-panel h3:first-of-type { margin-top: 0; }
  .help-panel ul { margin: 0; padding-left: 1.1rem; font-size: .85rem; line-height: 1.65; color: var(--ink); }
  .help-panel kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: .05rem .4rem; font-family: inherit; font-size: .8rem; }
  .help-panel .close-x { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--ink); line-height: 1; }


  .app { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 3rem; }
  header.top {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem;
    margin-bottom: .9rem; border-bottom: 1px solid var(--border); padding-bottom: .75rem;
  }
  header.top h1 {
    font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase;
    font-size: 1.5rem; letter-spacing: .01em; margin: 0; flex: 0 0 auto;
  }
  header.top .subtitle { color: var(--ink-soft); font-size: .8rem; flex: 1 1 100%; order: 3; }

  select, button, input { font-family: inherit; }
  select, input[type="text"] {
    background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
    padding: .38rem .55rem; font-size: .82rem; border-radius: 0;
  }
  button {
    background: transparent; color: var(--ink); border: 1px solid var(--border);
    padding: .4rem .8rem; font-size: .74rem; cursor: pointer;
    border-radius: 0; font-family: 'Barlow Condensed', sans-serif; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em;
    transition: border-color .1s ease, color .1s ease, background .1s ease;
  }
  button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
  button:active:not(:disabled) { opacity: .85; }
  button:disabled { opacity: .35; cursor: not-allowed; }
  button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
  button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  button.primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--accent-ink); border-color: var(--accent); }
  button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
  button.danger:hover:not(:disabled) { background: var(--danger); color: var(--bg); }
  button.favorites-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .tag-chip { padding: .3rem .7rem; font-size: .74rem; }
  .saved-filter-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem .3rem .7rem; font-size: .74rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; }
  .saved-filter-chip:hover { border-color: var(--accent); }
  .saved-filter-chip .remove-x { background: none; border: none; box-shadow: none; padding: 0; font-size: .8rem; line-height: 1; color: var(--ink-soft); cursor: pointer; }
  .saved-filter-chip .remove-x:hover { color: var(--danger); }
  .tag-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .favorite-star { background: none; border: none; box-shadow: none; padding: 0 .3rem; font-size: 1.05rem; cursor: pointer; line-height: 1; }
  .favorite-star:hover { filter: brightness(1.2); }

  .toolbar {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0;
    padding: .6rem .7rem; margin-bottom: 1rem;
  }
  .toolbar input[type="text"] { flex: 1 1 auto; min-width: 9rem; }
  #fileInput { display: none; }

  .section-title {
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .82rem; color: var(--accent-text);
    margin: 1.1rem 0 .5rem; text-transform: uppercase; letter-spacing: .06em;
  }
  .play-list { display: flex; flex-direction: column; gap: .5rem; }
  .play-card {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0;
    padding: .65rem .8rem; transition: border-color .12s ease;
  }
  @keyframes highlightFlash { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: 0 0 0 3px var(--accent); } }
  .play-card.highlight-flash { animation: highlightFlash 1.6s ease-in-out 2; }
  .play-card input[type="checkbox"] { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
  .play-card:hover { border-color: var(--accent); }
  .play-card-main { min-width: 8rem; flex: 1 1 auto; }
  .play-card-thumb { width: 3.4rem; height: 2.55rem; flex: 0 0 auto; background: var(--field); border: 1px solid var(--border); border-radius: 0; overflow: hidden; }
  .play-card-thumb svg { width: 100%; height: 100%; display: block; }
  .play-card-main strong { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; display: block; }
  .play-card-meta { font-size: .74rem; color: var(--ink-soft); }
  .type-badge {
    display: inline-block; font-size: .65rem; text-transform: uppercase; letter-spacing: .03em;
    padding: .1rem .4rem; border-radius: 0; margin-right: .4rem; font-weight: 700;
  }
  .type-badge.attaque { background: rgba(255,90,31,.16); color: var(--accent-text); }
  .type-badge.defense { background: rgba(255,107,107,.16); color: var(--danger); }
  .play-card-actions { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1 1 auto; justify-content: flex-end; }
  .play-card-actions button { font-size: .68rem; padding: .3rem .55rem; }

  .empty-state {
    text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft);
    background: var(--surface); border: 1px dashed var(--border); border-radius: 0; font-size: .88rem;
  }

  .present-overlay {
    display: none; position: fixed; inset: 0; background: var(--bg); z-index: 60;
    flex-direction: column; align-items: center; justify-content: center; padding: 1rem;
  }
  .present-overlay.open { display: flex; }
  .present-top {
    position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center;
    justify-content: space-between; padding: .8rem 1rem; gap: .6rem;
  }
  .present-title { font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase; font-size: 1.15rem; text-align: center; flex: 1 1 auto; }
  .present-field-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 1rem; }
  svg.present-svg { width: 100%; max-width: 480px; height: auto; display: block; }

  @media print {
    .app-nav, .help-btn, #themeToggleBtn, #presentCloseBtn, #presentPrintBtn, .present-nav,
    .help-overlay, .mini-dialog-overlay, #gridOverlay, .quiz-overlay, .compare-overlay, .legend { display: none !important; }
    body * { visibility: hidden; }
    .present-overlay.open, .present-overlay.open * { visibility: visible; }
    .present-overlay { position: absolute; inset: 0; background: #FFFFFF !important; display: block !important; padding-top: 0 !important; }
    .present-title { position: static; text-align: left; font-size: 1.4rem; padding: 0 0 .6rem; }
    .present-meta { position: static !important; display: block; margin-bottom: .6rem; }
    .present-field-wrap { border: none; box-shadow: none; padding: 0; }
    svg.present-svg { max-width: 100%; }
    .present-notes-wrap { border: 1px solid #999; }
  }
  .present-notes { max-width: 480px; text-align: center; font-size: .84rem; color: var(--ink-soft); margin: 0; padding: 0 .5rem; }
  .present-notes-wrap { margin-top: .8rem; }

  .quiz-overlay { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 65; flex-direction: column; align-items: center; padding: 1rem; overflow-y: auto; }
  .quiz-overlay.open { display: flex; }
  .quiz-top { width: 100%; max-width: 640px; display: flex; align-items: center; justify-content: space-between; padding: .3rem 0 1rem; gap: .6rem; }
  .quiz-progress { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .9rem; text-align: center; flex: 1 1 auto; }
  .quiz-body { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding-bottom: 2rem; }
  .quiz-prompt-card { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 1.2rem; width: 100%; text-align: center; box-sizing: border-box; }
  .quiz-prompt-card h3 { font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase; margin: 0 0 .7rem; font-size: 1.05rem; }
  .quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; width: 100%; }
  .quiz-option { background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; padding: .7rem; cursor: pointer; font-family: inherit; font-size: .85rem; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 3rem; }
  .quiz-option:hover { border-color: var(--accent); }
  .quiz-option.correct { border-color: #3A9247; background: rgba(58,146,71,.16); }
  .quiz-option.incorrect { border-color: var(--danger); background: rgba(255,107,107,.16); }
  .quiz-option svg { width: 100%; height: auto; display: block; pointer-events: none; }
  .quiz-score { font-size: 1.4rem; font-weight: 700; font-family: 'Anton', sans-serif; text-transform: uppercase; }

  .compare-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 70; align-items: center; justify-content: center; padding: 1rem; }
  .compare-overlay.open { display: flex; }
  .compare-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 1.2rem; width: 100%; max-width: 760px; height: min(640px, 90vh); display: flex; flex-direction: column; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
  .compare-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; flex: 0 0 auto; }
  .compare-header h2 { font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase; font-size: 1.1rem; margin: 0; }
  .compare-selects { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; flex: 0 0 auto; }
  .compare-selects select { flex: 1 1 240px; padding: .5rem .6rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: 0; font-size: .85rem; font-family: inherit; }
  .compare-preview { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; overflow-y: auto; min-height: 0; }
  .compare-preview-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; padding: .8rem; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .compare-preview-cell strong { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; }
  .compare-preview-cell .compare-meta { font-size: .75rem; color: var(--ink-soft); margin-bottom: .5rem; }
  .compare-preview-cell.empty { color: var(--ink-soft); font-size: .85rem; }
  .compare-preview-cell svg { width: 100%; height: auto; }
  .present-notes-label { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-text); text-align: center; margin-bottom: .25rem; }
  .present-meta { font-size: .78rem; color: var(--ink-soft); text-align: center; margin-top: .2rem; }
  .legend { display: flex; flex-wrap: wrap; gap: .7rem; font-size: .72rem; color: var(--ink-soft); margin-top: .8rem; justify-content: center; align-items: center; max-width: 480px; }
  .legend span { display: inline-flex; align-items: center; gap: .3rem; }
  .swatch { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; border: 1px solid var(--ink); }
  .tri-swatch { width: 0; height: 0; border-left: .4rem solid transparent; border-right: .4rem solid transparent; border-bottom: .65rem solid; display: inline-block; }
  .ring-swatch { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; border: 2px solid var(--route-end); }
  .line-swatch { display: inline-block; width: 1.1rem; height: 0; border-top: 2px solid var(--ink-soft); vertical-align: middle; }
  .line-swatch.dashed { border-top-style: dashed; }
  .zone-swatch { width: .8rem; height: .65rem; display: inline-block; border: 1px solid var(--ink-soft); background: var(--ink-soft); opacity: .5; }
  .present-nav { display: flex; align-items: center; gap: 1.2rem; margin-top: 1rem; }
  .present-nav button { font-size: 1.1rem; padding: .5rem .9rem; }
  .present-counter { font-size: .78rem; color: var(--ink-soft); }
  .legend.wide { max-width: 1100px; }

  .grid-overlay {
    display: none; position: fixed; inset: 0; background: var(--bg); z-index: 60;
    flex-direction: column; align-items: center; overflow-y: auto; padding: 4.2rem 1rem 1.5rem;
  }
  .grid-overlay.open { display: flex; }
  .grid-container {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem;
    max-width: 1100px; width: 100%;
  }
  @media (max-width: 900px) { .grid-container { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 520px) { .grid-container { grid-template-columns: 1fr; } }
  .grid-cell {
    background: var(--surface); border: 1px solid var(--border); border-radius: 0;
    padding: .5rem; display: flex; flex-direction: column; align-items: center;
  }
  .grid-cell svg { width: 100%; height: auto; display: block; }
  .grid-cell .cell-title {
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .74rem;
    text-align: center; margin-top: .35rem; line-height: 1.25;
  }
  .grid-cell .cell-meta { font-size: .64rem; color: var(--ink-soft); text-align: center; margin-top: .1rem; }

  .mini-dialog-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 90; align-items: center; justify-content: center; padding: 1rem;
  }
  .mini-dialog-overlay.open { display: flex; }
  .mini-dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 1.1rem; max-width: 340px; width: 100%; box-shadow: 0 10px 28px rgba(0,0,0,.5); }
  .mini-dialog p { margin: 0 0 .9rem; font-size: .88rem; color: var(--ink); line-height: 1.4; }
  .mini-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }

  footer.note { margin-top: 2rem; font-size: .72rem; color: var(--ink-soft); text-align: center; line-height: 1.5; }

  @media (max-width: 560px) {
    .toolbar { flex-direction: column; align-items: stretch; }
  }
  .toast-container { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
  .toast { background: var(--accent); color: var(--accent-ink); padding: .55rem 1rem; border-radius: 0; font-size: .8rem; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.4); opacity: 0; transform: translateY(12px); transition: opacity .22s ease, transform .22s ease; max-width: 86vw; text-align: center; }
  .toast.show { opacity: 1; transform: translateY(0); }
  body.drag-over::after {
    content: "📂 Dépose le fichier JSON ici pour l'importer";
    position: fixed; inset: 0; z-index: 200;
    background: rgba(255,90,31,.18);
    border: 5px dashed var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.5rem; font-weight: 700; text-transform: uppercase;
    color: var(--ink); text-align: center; padding: 2rem;
    pointer-events: none;
  }
