  /* =================================================================
     COLOR PALETTE
     ================================================================= */
  :root {
    --wood-darkest: #0d0703;
    --wood-dark:    #1a0e04;
    --wood:         #2a1606;
    --wood-mid:     #4a2a0e;
    --parchment:    #f4e9c4;
    --parchment-dk: #d4be8a;
    --parchment-hi: #faf3d8;
    --gold:         #c9a45e;
    --gold-hi:      #f0c75e;
    --gold-dk:      #8b6f3a;
    --ink:          #3a1f00;
    --ink-soft:     #5d3a1a;
    --crimson:      #8b1a1a;
    --emerald:      #2f6f3f;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: 'EB Garamond', Georgia, serif;
    color: var(--ink);
    background:
      radial-gradient(at 50% 0%, #3a1e08 0%, #1a0e04 60%, #0d0703 100%),
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/></svg>");
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.4;
  }

  /* =================================================================
     LAYOUT
     ================================================================= */
  .page {
    max-width: 1400px;
    min-width: 820px;            /* fits the troops section (96px label + 4×135px cards + gaps + paddings) */
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
  }

  /* =================================================================
     LOGO CONCEPTS (mockup-only section)
     ================================================================= */
  .logo-concepts {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(240,199,94,0.15), 0 6px 20px rgba(0,0,0,0.5);
  }
  .logo-concepts-title {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold-dk);
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  }
  .logo-concepts-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 1.25rem;
  }
  .logo-card {
    background: linear-gradient(135deg, var(--parchment), var(--parchment-dk));
    border: 2px solid var(--gold-dk);
    border-radius: 6px;
    padding: 1rem 1rem 0.85rem;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold),
      inset 0 0 25px rgba(139,111,58,0.2),
      0 3px 10px rgba(0,0,0,0.4);
    text-align: center;
  }
  .logo-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(255,250,230,0.7), rgba(212,190,138,0.5));
    border: 1px solid rgba(139,111,58,0.4);
    border-radius: 4px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    min-height: 140px;
  }
  .logo-stage.tall {
    min-height: 250px;
    padding: 1rem;
  }
  .logo-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
  }
  .logo-note {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--ink-soft);
    font-style: italic;
    line-height: 1.35;
  }

  /* =================================================================
     PAGE TITLE (banner scroll)
     ================================================================= */
  .page-title-wrap {
    text-align: center;
    margin-bottom: 1.75rem;
    padding: 1.5rem 1rem 1.25rem;
  }
  .page-title {
    font-family: 'Cinzel', serif;
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    background: linear-gradient(180deg, #fce8a3 0%, #f0c75e 50%, #b8842c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 0 rgba(0,0,0,0.4);
    margin: 0;
    filter: drop-shadow(0 2px 8px rgba(240,199,94,0.25));
  }
  .page-title-rule {
    display: flex; align-items: center; justify-content: center;
    gap: 3rem;              /* clear space in the middle, below the crest */
    margin-top: -0.75rem;   /* sits higher, tucked up under the crest */
    color: var(--gold);
  }
  .page-title-rule::before,
  .page-title-rule::after {
    content: '';
    flex: 1 1 0;
    max-width: 300px;
    min-width: 30px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
  }
  /* Crest sits above the gold rule, which stays a plain divider now that
     the text title is gone. */
  .page-title-crest {
    display: block;
    margin: 0 auto 0.5rem;
    width: 100%;
    max-width: 250px;
    height: auto;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.5));
  }
  .page-title-rule span {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    letter-spacing: 4px;
    color: var(--gold);
    text-transform: uppercase;
    white-space: nowrap;          /* keep the swords on the same line as the title */
  }

  /* =================================================================
     PRESETS BAR — parchment tab strip with gold-trimmed action buttons
     ================================================================= */
  .presets-bar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    padding: 0.9rem 1rem;
    margin-bottom: 1.5rem;
    background:
      linear-gradient(180deg, rgba(50,30,10,0.85), rgba(30,18,4,0.95));
    border: 1px solid var(--gold-dk);
    border-radius: 8px;
    box-shadow:
      inset 0 1px 0 rgba(240,199,94,0.15),
      0 4px 14px rgba(0,0,0,0.5);
  }
  .preset-tabs {
    display: flex; gap: 0.5rem; flex-wrap: wrap; flex: 1; min-width: 0;
  }
  .preset-tab {
    padding: 0.45rem 1rem;
    background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    color: var(--wood-mid);
    border: 1.5px solid var(--gold-dk);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s;
    min-width: 100px;
  }
  .preset-tab:hover {
    background: linear-gradient(180deg, var(--parchment-hi), var(--parchment));
    border-color: var(--gold);
  }
  .preset-tab.active {
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 100%);
    color: var(--wood-dark);
    border-color: var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 6px rgba(240,199,94,0.4);
  }
  .preset-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;   /* the tab strip wraps instead of squashing these */
  }

  /* "+" tile at the end of the tab strip. Reads as a slot waiting to be
     filled - dashed and translucent - so it is clearly not itself a preset,
     while matching the tabs in height and radius so the row stays even. */
  .preset-tab-add {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.45rem 1rem;
    min-width: 44px;
    background: rgba(240,199,94,0.06);
    color: var(--gold);
    border: 1.5px dashed var(--gold-dk);
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
  }
  .preset-tab-add:hover {
    background: rgba(240,199,94,0.16);
    border-color: var(--gold);
    color: var(--gold-lt, var(--gold));
  }
  .preset-btn {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--gold-dk);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 2px 4px rgba(0,0,0,0.4);
    transition: all 0.15s;
  }
  .preset-btn.add, .preset-btn.dup {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
  }
  .preset-btn.import {
    background: linear-gradient(180deg, #4a8a4a, #2f6f3f);
    color: #f0f7e8;
  }
  .preset-btn.export {
    background: linear-gradient(180deg, #a82a2a, var(--crimson));
    color: #fce8d8;
  }
  .preset-btn:hover { filter: brightness(1.15); }

  /* =================================================================
     INPUT CONTAINER — three-column layout
     ================================================================= */
  .input-container {
    display: grid;
    grid-template-columns: 16fr 38.5fr 38.5fr;
    gap: 2.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background:
      linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow:
      inset 0 1px 0 rgba(240,199,94,0.15),
      0 6px 20px rgba(0,0,0,0.5);
  }
  .input-section h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: left;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold-dk);
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  }
  .tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--gold);
    font-size: 0.8rem;
    cursor: help;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
  }
  .tooltip:hover {
    color: var(--gold-hi);
    transform: scale(1.1);
  }

  /* =================================================================
     PARCHMENT CARD — base style, title INSIDE
     ================================================================= */
  .parchment-card {
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 2px solid var(--gold-dk);
    border-radius: 4px;
    padding: 0.45rem 0.85rem 0.6rem;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold),
      inset 0 0 25px rgba(139,111,58,0.25),
      0 3px 10px rgba(0,0,0,0.4);
    position: relative;
    transition: all 0.2s;
  }
  .parchment-card::before,
  .parchment-card::after {
    content: '❖';
    position: absolute;
    color: var(--gold-dk);
    font-size: 9px;
    top: 1px;
  }
  .parchment-card::before { left: 6px; }
  .parchment-card::after { right: 6px; }
  .parchment-card:focus-within {
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold-hi),
      inset 0 0 28px rgba(180,140,60,0.4),
      0 4px 14px rgba(240,199,94,0.4);
  }
  .parchment-card-title {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
    padding-bottom: 0.3rem;
    margin-bottom: 0.45rem;
    border-bottom: 1px solid rgba(139,111,58,0.4);
  }
  /* RPG Awesome glyph that prefixes the title text in Special Bonuses cards. */
  .card-icon {
    color: var(--gold-dk);
    font-size: 1.1rem;
    vertical-align: -2px;
    margin-right: 0.4rem;
    text-shadow: none;
  }
  /* "Epic Monster Hunters" is the longest title and wraps to 2 lines at the
     default size — shrink only that card's title to keep it on one line. */
  .parchment-card:has(#bonusEpicMonsterHunter) .parchment-card-title {
    font-size: 0.9rem;
  }

  /* =================================================================
     ARMY LIMITS — large parchment cards
     ================================================================= */
  .army-limits {
    display: flex; flex-direction: column; gap: 1rem;
  }
  .limit-card {
    padding: 1rem 1.1rem 1.1rem;
  }
  .limit-card-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
    padding-bottom: 0.55rem;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid rgba(139,111,58,0.4);
  }
  .limit-field {
    position: relative;
  }
  .limit-field input {
    width: 100%;
    padding: 0.25rem 0.9rem;
    border: 1px solid var(--gold-dk);
    border-radius: 3px;
    background: rgba(255,250,230,0.7);
    color: var(--ink);
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  }
  .limit-field input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(255,252,240,0.95);
  }
  .limit-used-pill {
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(74, 42, 14, 0.88);
    color: var(--gold-hi);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 12px;
    letter-spacing: 0.3px;
    pointer-events: none;
  }

  /* =================================================================
     BONUS CARDS GRID
     ================================================================= */
  .bonus-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  .span-2 { grid-column: 1 / -1; }

  .sub-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }
  .sub-inputs.single { grid-template-columns: 1fr; }
  .sub {
    display: flex; align-items: center; gap: 0.4rem; min-width: 0;
  }
  .sub-label {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--ink-soft);
    font-weight: 700;
    flex-shrink: 0;
  }
  .sub input {
    width: 100%; min-width: 0;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--gold-dk);
    border-radius: 3px;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
    background: rgba(255,250,230,0.7);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
    text-align: center;
  }
  .sub input:focus {
    outline: none;
    border-color: var(--gold-hi);
    background: rgba(255,252,240,0.95);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 6px rgba(240,199,94,0.5);
  }
  input[type=number] { -moz-appearance: textfield; }
  input[type=number]::-webkit-outer-spin-button,
  input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
  }

  /* =================================================================
     TROOPS SELECTION — checkbox grid
     ================================================================= */
  .selection-section {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background:
      linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow:
      inset 0 1px 0 rgba(240,199,94,0.15),
      0 6px 20px rgba(0,0,0,0.5);
  }
  .selection-section h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: left;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold-dk);
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .troop-class-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }
  .troop-class-label {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
    width: 130px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .troop-tiers {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
  }
  .tier-chip {
    min-width: 50px;
    padding: 0.3rem 0.55rem;
    background: linear-gradient(180deg, rgba(40,24,8,0.7), rgba(20,12,4,0.7));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    color: var(--parchment-dk);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
  }
  .tier-chip:hover {
    border-color: var(--gold);
    color: var(--gold-hi);
  }
  .tier-chip.selected {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 4px rgba(240,199,94,0.4);
  }

  /* =================================================================
     KILL ORDER — drag list
     ================================================================= */
  .kill-order-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
  }
  .kill-order-col {
    flex: 1;
    min-width: 240px;
  }
  .kill-order-col h3 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0 0 0.6rem;
    padding-bottom: 0.3rem;
    display: flex; align-items: center; gap: 0.5rem;
    /* Reserve enough height for the tier-mode-toggle (~28px) so the Category Order
       header stays the same height — keeps both columns' items vertically aligned. */
    min-height: 32px;
  }
  .mode-toggle {
    display: inline-flex;
    margin-left: auto;
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    /* No overflow:hidden — needs to be visible so segment hover tooltips
       (rendered as ::after pseudo-elements outside the segment box) aren't
       clipped. Rounded corners are handled per-segment via :first/:last-child. */
    background: rgba(20,12,4,0.6);
  }
  .mode-toggle span {
    padding: 0.2rem 0.55rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--parchment-dk);
    cursor: pointer;
  }
  .mode-toggle span + span { border-left: 1px solid var(--gold-dk); }
  .mode-toggle span.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    font-weight: 800;
  }
  .order-list {
    display: flex; flex-direction: column; gap: 0.4rem;
  }
  .order-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    cursor: grab;
    color: var(--wood-mid);
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 3px rgba(0,0,0,0.3);
  }
  .order-item .handle {
    color: var(--gold-dk);
    font-size: 0.85rem;
  }
  .order-item .rank {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--wood-mid);
    color: var(--gold-hi);
    font-size: 0.75rem;
    font-weight: 700;
  }

  /* =================================================================
     CALCULATE BUTTON
     ================================================================= */
  /* Calculate button hidden — results auto-recalc on every input change. */
  .calculate-btn {
    display: none !important;
    margin: 1.5rem auto;
    padding: 0.9rem 3.5rem;
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-dk) 100%);
    color: var(--wood-dark);
    border: 2px solid var(--wood-dark);
    border-radius: 6px;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.5),
      inset 0 -2px 0 rgba(0,0,0,0.2),
      0 0 0 1px var(--gold),
      0 4px 12px rgba(240,199,94,0.4),
      0 6px 16px rgba(0,0,0,0.5);
    transition: all 0.15s;
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  }
  .calculate-btn:hover {
    transform: translateY(-1px);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.5),
      inset 0 -2px 0 rgba(0,0,0,0.2),
      0 0 0 1px var(--gold-hi),
      0 6px 16px rgba(240,199,94,0.55),
      0 8px 20px rgba(0,0,0,0.5);
  }

  /* =================================================================
     RESULTS SECTION
     ================================================================= */
  .result-section {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background:
      linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow:
      inset 0 1px 0 rgba(240,199,94,0.15),
      0 6px 20px rgba(0,0,0,0.5);
  }
  .result-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold-dk);
  }
  .result-section h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 0;
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
    display: flex; align-items: center; gap: 0.5rem;
  }
  .multiplier-bar {
    display: flex; align-items: center; gap: 0.4rem;
    margin-bottom: 1rem;
  }
  .multiplier-bar .label {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    color: var(--gold);
    margin-right: 0.5rem;
  }
  .multiplier-btn {
    min-width: 38px;
    padding: 0.3rem 0.55rem;
    background: linear-gradient(180deg, rgba(40,24,8,0.7), rgba(20,12,4,0.7));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    color: var(--parchment-dk);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
  }
  .multiplier-btn.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
  }

  .tier-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: flex-start;
  }
  .tier-group-label {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gold-hi);
    font-weight: 700;
    min-width: 60px;
    text-align: center;
    padding-top: 1rem;
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  }
  .troop-row {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
  }
  .troop-card {
    position: relative;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 2px solid var(--gold-dk);
    border-radius: 4px;
    padding: 0.6rem;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold),
      inset 0 0 25px rgba(139,111,58,0.2),
      0 3px 10px rgba(0,0,0,0.4);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
  }
  .troop-card:hover {
    transform: translateY(-2px);
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold-hi),
      inset 0 0 28px rgba(180,140,60,0.3),
      0 6px 16px rgba(240,199,94,0.3);
  }
  .troop-card.disabled {
    opacity: 0.55;
    filter: sepia(60%) grayscale(40%);
  }
  .troop-card .portrait {
    width: 96px; height: 96px;
    margin: 0 auto 0.4rem;
    background: linear-gradient(135deg, var(--wood-mid), var(--wood));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
    box-shadow: inset 0 0 12px rgba(0,0,0,0.5);
    overflow: hidden;
  }
  .troop-card .portrait img {
    width: 100%; height: 100%;
    object-fit: contain;
    padding: 1px;
  }
  .troop-card .name {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--wood-mid);
    margin-bottom: 0.1rem;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
  }
  .troop-card .count {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--wood-dark);
  }
  .troop-card .copy-btn {
    position: absolute;
    top: 6px; right: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20,12,4,0.7);
    border: 1px solid var(--gold);
    border-radius: 3px;
    color: var(--gold-hi);
    font-size: 0.75rem;
    opacity: 0; transition: opacity 0.2s;
    cursor: pointer;
  }
  .troop-card:hover .copy-btn { opacity: 1; }
  .troop-card .copy-btn:hover {
    background: var(--gold-hi);
    color: var(--wood-dark);
  }

  /* =================================================================
     DYNAMIC DOM OVERRIDES (calculator.js-generated content)
     Loaded AFTER styles.css so these rules win.
     ================================================================= */

  /* ---- TOOLTIP POPUP (live .tooltip-wrapper structure) ---- */
  .tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    color: var(--gold);
    font-size: 1rem;
    cursor: help;
    transition: all 0.2s;
    line-height: 1;
    background: none;
    border: none;
  }
  .tooltip-icon:hover {
    color: var(--gold-hi);
    transform: scale(1.1);
  }
  .tooltip-text {
    visibility: hidden; opacity: 0;
    position: absolute;
    top: 125%; left: 50%;
    transform: translateX(-50%);
    background: var(--wood-dark);
    color: var(--parchment);
    padding: 0.75rem 1rem;
    border: 1px solid var(--gold-dk);
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'EB Garamond', serif;
    line-height: 1.5;
    width: 495px;
    max-width: 90vw;
    z-index: 1000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    text-align: left;
  }
  .tooltip-text strong {
    display: block;
    font-family: 'Cinzel', serif;
    color: var(--gold-hi);
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }
  .tooltip-text::after {
    content: '';
    position: absolute;
    bottom: 100%; left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--gold-dk);
  }
  /* Screenshot image embedded inside a tooltip — keeps it scaled to the
     tooltip width and gives the tooltip a wider min-width so the picture
     isn't squished. */
  .tooltip-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-top: 0.5rem;
    display: block;
    border: 1px solid var(--gold-dk);
  }
  .tooltip-icon:hover + .tooltip-text,
  .tooltip-text:hover {
    visibility: visible; opacity: 1;
  }

  /* ---- TROOPS SELECTION (populated by JS) ---- */
  #troopSelection h3 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin: 0 0 0.55rem;
    padding-bottom: 0.3rem;
    display: flex; align-items: center; gap: 0.5rem;
  }
  /* Hide per-section tooltips inside h3 — only the section-level h2 tooltip stays */
  .troop-selection-section h3 .tooltip-wrapper { display: none; }
  .troop-selection-row {
    display: flex; gap: 1.5rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
  }
  .troop-selection-row:last-child { margin-bottom: 0; }
  .troop-selection-section {
    flex: 1; min-width: 220px;
  }
  .troop-checkboxes {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
  }
  .checkbox-wrapper {
    display: inline-flex; align-items: stretch;
    background: linear-gradient(180deg, rgba(40,24,8,0.7), rgba(20,12,4,0.7));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    /* Padding moved to the label below so the WHOLE chip is clickable; with
       padding on the wrapper the gap between border and label was dead space. */
    padding: 0;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--parchment-dk);
    user-select: none;
  }
  .checkbox-wrapper:hover {
    border-color: var(--gold);
    color: var(--gold-hi);
  }
  .checkbox-wrapper input[type="checkbox"] {
    position: absolute; opacity: 0; pointer-events: none;
  }
  .checkbox-wrapper:has(input:checked) {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    border-color: var(--wood-dark);
    color: var(--wood-dark);
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  }
  .checkbox-wrapper label {
    cursor: pointer;
    margin: 0;
    padding: 0.3rem 0.65rem;            /* fill the whole chip so any click toggles */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-family: inherit;
    color: inherit;
    font-weight: inherit;
  }

  /* ---- KILL ORDER LISTS ---- */
  #killOrderSection h3 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin: 0 0 0.6rem;
    padding-bottom: 0.3rem;
  }
  .kill-order-container {
    display: flex; gap: 1.5rem; flex-wrap: wrap;
  }
  .kill-order-tiers, .kill-order-categories {
    flex: 1; min-width: 240px;
  }
  #killOrderContainer, #categoryOrderContainer {
    display: flex; flex-direction: column; gap: 0.4rem;
  }
  .kill-order-item, .category-order-item {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    cursor: grab;
    color: var(--wood-mid);
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 1.05rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 3px rgba(0,0,0,0.3);
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  }
  .kill-order-item:hover, .category-order-item:hover {
    border-color: var(--gold-hi);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 8px rgba(0,0,0,0.35);
  }
  .kill-order-item:active, .category-order-item:active { cursor: grabbing; }
  /* While being dragged — the source item gets ghosted and slightly scaled */
  .kill-order-item.dragging, .category-order-item.dragging {
    opacity: 0.4;
    transform: scale(0.98);
    border-color: var(--gold-hi);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.4),
      0 0 0 1px var(--gold-hi),
      0 6px 14px rgba(240,199,94,0.35);
    cursor: grabbing;
  }
  /* Slide-into-position animation for siblings as the dragged item reorders.
     Quadratic Bezier easing for that "soft snap" feel. */
  #killOrderContainer .kill-order-item:not(.dragging),
  #categoryOrderContainer .category-order-item:not(.dragging) {
    transition:
      transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1),
      box-shadow 0.18s ease,
      border-color 0.18s ease;
  }
  .order-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--wood-mid);
    color: var(--gold-hi);
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
  }
  .drag-handle {
    color: var(--gold-dk);
    font-size: 1.1rem;
    flex-shrink: 0;
  }
  .group-name, .category-name { flex: 1; }
  /* Category-order warrior icons (RPG Awesome: sword/cavalry/archer/pegasus) —
     pinned to the order number so the label still flexes freely. */
  .category-icon {
    width: 22px;
    text-align: center;
    color: var(--wood-mid);
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
  }
  /* Arrow move-buttons removed from template — drag handle + numbering are enough */
  .move-buttons { display: none; }

  /* ---- EPIC MONSTER: squads toggle + expected damage ----
     Both belong to Epic Monster fights (PvE and M); calculator.js sets
     .epic-hidden on #killOrderSection in PvP and FR. */
  #killOrderSection.epic-hidden #epicSquadsToggle,
  #killOrderSection.epic-hidden .expected-damage { display: none; }

  /* ---- TROOP TYPES LEFT OUT (no bonuses entered, or their cap is 0) ----
     calculator.js refreshOffState / updateKillOrderUI; the desktop tab's
     TroopsOffVeil / KillOrderItem[off="true"] / TroopsSectionNote. */
  .troop-checkboxes { position: relative; }
  .troop-checkboxes .off-veil { display: none; }
  .troop-checkboxes.is-off .off-veil {
    display: flex; align-items: center; justify-content: center;
    position: absolute; inset: -2px;
    background: rgba(11, 11, 13, 0.93);
    border: 1px solid var(--gold-dk);
    border-radius: 6px;
    color: var(--parchment);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    padding: 0 0.75rem;
    z-index: 2;
  }
  .troop-checkboxes.is-off .checkbox-wrapper { pointer-events: none; }
  .parchment-card.is-unused { opacity: 0.4; }
  .parchment-card.is-unused input { cursor: not-allowed; }
  .kill-order-item.is-off {
    background: rgba(60, 52, 40, 0.55);
    border: 1.5px dashed rgba(138, 106, 61, 0.7);
    color: #9a917f;
    cursor: default;
    box-shadow: none;
  }
  .kill-order-item.is-off:hover { border-color: rgba(138, 106, 61, 0.7); box-shadow: none; }
  .kill-order-item.is-off .order-number { background: rgba(40, 34, 26, 0.9); color: #9a917f; }
  .kill-order-note {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--wood-mid);
    flex-shrink: 0;
  }
  .kill-order-item.is-off .kill-order-note { color: #c9bd9f; }
  /* The Mercenaries row: always last, never dragged. */
  .kill-order-item.is-fixed, .kill-order-item.is-fixed:active { cursor: default; }
  /* Rows that are not dragged keep the handle's room so their numbers line up. */
  .drag-handle.is-placeholder { visibility: hidden; }
  .section-notes:empty { display: none; }
  .section-notes { margin: 0.2rem 0 0.6rem; }
  .section-note {
    margin: 0.15rem 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--parchment-dk);
  }
  /* Both toggles sit together at the right of the Kill Order h2; the
     wrapper carries the auto margin so hiding the squads toggle (PvP, FR)
     leaves the mode toggle where it is. */
  .kill-order-toggles { display: inline-flex; align-items: center; gap: 0.6rem; margin-left: auto; }
  .kill-order-toggles .tier-mode-toggle, .kill-order-toggles .squads-toggle { margin-left: 0; }
  .squads-toggle { cursor: pointer; }
  .squads-segment { position: relative; }
  .expected-damage {
    margin-top: 0.9rem;
    padding: 0.65rem 0.9rem 0.75rem;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 3px rgba(0,0,0,0.3);
  }
  .expected-damage-head {
    display: flex; align-items: center; gap: 0.4rem;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--wood-mid);
  }
  .expected-damage-head .tooltip-icon { font-size: 0.85rem; }
  .expected-damage-value {
    font-family: 'Cinzel', serif;
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--wood-dark);
    margin-top: 0.15rem;
  }
  .expected-damage-detail {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    color: var(--wood-mid);
  }
  .expected-damage.is-empty .expected-damage-value { opacity: 0.55; }

  /* ---- TIER MODE TOGGLE ----
     calculator.js puts a SINGLE click handler on the whole toggle and tracks
     state with .is-pvp / .is-manual classes on the parent (no class = PvE).
     Highlight the right segment via parent-class selectors below. */
  .tier-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    /* overflow:visible by default — keeps the hover tooltip ::after pseudo
       (positioned below each segment) from being clipped. */
    background: rgba(20,12,4,0.6);
    margin-left: auto;
    cursor: pointer;
  }
  .tier-mode-segment {
    padding: 0.3rem 0.75rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--parchment-dk);
    letter-spacing: 0.5px;
    transition: background 0.15s, color 0.15s;
  }
  .tier-mode-segment + .tier-mode-segment { border-left: 1px solid var(--gold-dk); }

  /* Hover preview — non-active segments brighten when the toggle is hovered */
  .tier-mode-toggle:hover .tier-mode-segment {
    color: var(--gold-hi);
  }

  /* Active segment (gold gilded). Parent-class selectors mirror calculator.js's
     state: no class → PvE; .is-pvp → PvP; .is-manual → M; .is-fr → FR. */
  .tier-mode-toggle:not(.is-pvp):not(.is-manual):not(.is-fr) .tier-mode-segment[data-seg="pve"],
  .tier-mode-toggle.is-pvp .tier-mode-segment[data-seg="pvp"],
  .tier-mode-toggle.is-manual .tier-mode-segment[data-seg="manual"],
  .tier-mode-toggle.is-fr .tier-mode-segment[data-seg="fr"] {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    font-weight: 800;
  }

  /* Without overflow:hidden on the parent, first/last segments need their
     own border-radius to follow the toggle's rounded corners (3px = 4px - 1px border). */
  .tier-mode-segment:first-child,
  .category-mode-segment:first-child,
  .mode-toggle > span:first-child {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
  }
  .tier-mode-segment:last-child,
  .category-mode-segment:last-child,
  .mode-toggle > span:last-child {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
  }

  /* Hover tooltip rendered from data-tooltip attribute on each mode segment.
     Plain CSS — appears below the segment on hover, no JS needed. */
  .tier-mode-segment, .category-mode-segment { position: relative; }
  .tier-mode-segment[data-tooltip]:hover::after,
  .squads-segment[data-tooltip]:hover::after,
  .category-mode-segment[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem 0.55rem;
    background: rgba(20,12,4,0.96);
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    color: var(--parchment);
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
    z-index: 120;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  }

  /* Category Order Mode toggle: Ordered (default) vs All Equal.
     Same pattern as tier-mode-toggle — single click handler + .is-equal on parent. */
  .category-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    background: rgba(20,12,4,0.6);
    margin-left: auto;
    cursor: pointer;
  }
  .category-mode-segment {
    padding: 0.3rem 0.75rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--parchment-dk);
    letter-spacing: 0.5px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
  }
  .category-mode-segment + .category-mode-segment { border-left: 1px solid var(--gold-dk); }
  .category-mode-toggle:hover .category-mode-segment { color: var(--gold-hi); }
  .category-mode-toggle:not(.is-equal) .category-mode-segment[data-seg="ordered"],
  .category-mode-toggle.is-equal .category-mode-segment[data-seg="equal"] {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    font-weight: 800;
  }

  /* When All Equal is active, dim the category list to show ordering is ignored. */
  .kill-order-categories.is-equal #categoryOrderContainer {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.4);
  }

  /* ---- WELCOME MESSAGE ---- */
  .welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(240,199,94,0.15), 0 6px 20px rgba(0,0,0,0.5);
    color: var(--parchment-dk);
    backdrop-filter: none;
  }
  .welcome-message h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold-hi);
    font-size: 1.3rem;
    letter-spacing: 1px;
    margin: 0 0 1rem;
    text-align: left;
    text-shadow: 0 2px 0 rgba(0,0,0,0.4);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: var(--gold-hi);
    font-weight: 700;
    text-transform: uppercase;
  }
  .welcome-message p {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto;
    color: var(--parchment-dk);
  }

  /* ---- MULTIPLIER BAR ---- */
  .multiplier-bar {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    background: none;
    border: none;
    box-shadow: none;
  }
  .multiplier-bar .label,
  .multiplier-label {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--gold);
    margin-right: 0.5rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }
  .multiplier-buttons {
    display: flex; gap: 0.3rem; flex-wrap: wrap;
  }
  .multiplier-btn {
    min-width: 40px;
    padding: 0.35rem 0.7rem;
    background: linear-gradient(180deg, rgba(40,24,8,0.7), rgba(20,12,4,0.7));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    color: var(--parchment-dk);
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
  }
  .multiplier-btn:hover {
    border-color: var(--gold);
    color: var(--gold-hi);
  }
  .multiplier-btn.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
  }

  /* ---- RESULT SECTION ---- */
  .result-section {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9));
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(240,199,94,0.15), 0 6px 20px rgba(0,0,0,0.5);
  }
  .result-section h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-hi);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold-dk);
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
    display: flex; align-items: center; gap: 0.5rem;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: var(--gold-hi);
  }
  .troops-display {
    display: flex; flex-direction: column; gap: 0.75rem;
  }

  /* "X / Y used" pill in each result-section header — moved here from the
     Army Limits cards so the usage data sits next to the troops it controls. */
  .header-used-pill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    background: rgba(20, 12, 4, 0.72);
    color: var(--gold-hi);
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--gold-dk);
    border-radius: 999px;
    -webkit-text-fill-color: var(--gold-hi);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
    box-shadow: inset 0 1px 0 rgba(240, 199, 94, 0.15), 0 2px 4px rgba(0, 0, 0, 0.4);
  }

  /* ---- RESULT COLUMN HEADERS ---- */
  .column-headers-row {
    display: flex; gap: 1rem;
    padding: 0.5rem 0;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .group-label-space { width: 96px; flex-shrink: 0; }
  .column-headers-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
  .column-header { text-align: center; }

  /* ---- TIER GROUP ---- */
  .group-display {
    display: flex; gap: 1rem; align-items: center;
    margin-bottom: 1rem;
  }
  .group-label-container {
    width: 96px; flex-shrink: 0;
    text-align: center;
  }
  .group-label {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--gold-hi);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
    line-height: 1.15;
  }
  /* Mercenaries: label is direct child of .group-display (no container) */
  .group-display > .group-label {
    width: 96px;
    flex-shrink: 0;
    text-align: center;
  }
  .group-label-partial {
    font-family: 'EB Garamond', serif;
    font-size: 0.7rem;
    color: var(--parchment-dk);
    font-style: italic;
  }
  .troop-columns {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
  .troop-column {
    display: flex; flex-direction: column; gap: 1rem;
  }
  .extra-categories-container,
  .engineer-corps-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
  }

  /* ---- TROOP CARD (in results) ---- */
  .troop-item {
    position: relative;
    display: flex; flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 2px solid var(--gold-dk);
    border-radius: 4px;
    padding: 0.55rem;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 3px var(--gold),
      inset 0 0 25px rgba(139,111,58,0.2),
      0 3px 10px rgba(0,0,0,0.4);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    overflow: visible;
  }
  @media (hover: hover) {
    .troop-item:hover {
      transform: translateY(-2px);
      box-shadow:
        0 0 0 1px var(--wood-dark),
        0 0 0 3px var(--gold-hi),
        inset 0 0 28px rgba(180,140,60,0.3),
        0 6px 16px rgba(240,199,94,0.3);
    }
  }
  /* A troop left out: the card dims, its switch stays bright. */
  .troop-item-disabled > :not(.troop-toggle) {
    opacity: 0.55;
    filter: sepia(60%) grayscale(40%);
  }
  .troop-category-label {
    display: none;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: var(--gold-dk);
    text-transform: uppercase;
  }
  .troop-image,
  .troop-image-placeholder {
    width: 96px; height: 96px;
    background: linear-gradient(135deg, var(--wood-mid), var(--wood));
    border: 1.5px solid var(--gold-dk);
    border-radius: 3px;
    margin-bottom: 0.4rem;
    object-fit: contain;
    padding: 1px;
    color: var(--gold);
    font-size: 0.7rem;
    box-shadow: inset 0 0 12px rgba(0,0,0,0.5);
  }
  .troop-image-placeholder {
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 6px;
    line-height: 1.1;
  }
  .troop-image.merc-image,
  .troop-image-placeholder.merc-placeholder {
    width: 80px;
    height: 105px;
    aspect-ratio: 200 / 263;
  }
  .troop-info { width: 100%; }
  .troop-name {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wood-mid);
    margin-bottom: 0.1rem;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
    line-height: 1.2;
    min-height: 2.4em;          /* reserve 2 lines so all cards are uniform height */
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .troop-count {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--wood-dark);
  }

  /* ---- THE SWITCH ON A TROOP CARD (2026-10-31) ---- */
  /* Sends the troop (gold track, green knob right) or leaves it out (dark
     track, red knob left): the desktop's RpgToggleSwitch. Shown at all
     times; it replaced the card-wide click and the hover-only Copy button. */
  .troop-toggle {
    position: absolute;
    top: 6px; right: 6px;
    width: 36px; height: 20px;
    padding: 0;
    border: 1px solid var(--wood-dark);
    border-radius: 10px;
    background: #232228;
    cursor: pointer;
    z-index: 2;
    transition: background 0.2s ease;
  }
  .troop-toggle::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--crimson);
    border: 1px solid var(--wood-dark);
    box-sizing: border-box;
    transition: left 0.2s ease, background 0.2s ease;
  }
  .troop-toggle[aria-checked="true"] {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold-dk));
  }
  .troop-toggle[aria-checked="true"]::after {
    left: 18px;
    background: var(--emerald);
  }
  .troop-toggle:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }

  /* ---- COPY AND RESET ON A TROOP CARD (2026-11-03) ---- */
  /* One row under the name: a reset slot, the count, a Copy slot. The slots
     are always there, so the number never moves when a button comes or
     goes. Quiet icons, gold under the mouse; with a mouse they show only
     while it is over the card (Barak: three controls crowding the top of
     the card "look very messy"). A touch screen has no hover, so there they
     are always shown. troops_tab.py _TroopResultTile. */
  .troop-count-row { display: flex; align-items: center; justify-content: center; gap: 4px; }
  .troop-count-slot { flex: 0 0 22px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
  .troop-count-row .troop-count-input { margin: 0; max-width: 6.8rem; }
  .troop-copy-btn, .troop-reset-btn {
    width: 22px; height: 22px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--wood-mid);
    opacity: 0.7;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  .troop-copy-btn:hover, .troop-reset-btn:hover { opacity: 1; background: var(--gold-hi); border-color: var(--gold); color: var(--wood-dark); }
  .troop-copy-btn:focus-visible, .troop-reset-btn:focus-visible { opacity: 1; outline: 2px solid var(--gold-hi); outline-offset: 1px; }
  @media (hover: hover) {
    .troop-item:not(:hover) .troop-copy-btn:not(:focus-visible),
    .troop-item:not(:hover) .troop-reset-btn:not(:focus-visible) { opacity: 0; }
  }

  /* A mercenary's count is a boxed field in the count's font, so it reads
     as something to type into (2026-10-31). Once the player set it, the
     count is brown and a reset sits beside the switch. */
  .troop-count-input {
    width: 100%;
    max-width: 7.5rem;
    margin: 0.1rem auto 0;
    display: block;
    text-align: center;
    color: inherit;
    font: inherit;
    font-family: 'Cinzel', serif;
    font-weight: 800;
    background: var(--parchment-hi);
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    box-shadow: inset 0 1px 3px rgba(74, 42, 14, 0.25);
    padding: 0.05rem 0.4rem;
    cursor: text;
  }
  .troop-count-input:hover { border-color: var(--gold); }
  .troop-count-input:focus {
    outline: none;
    background: #fffaf0;
    border: 2px solid var(--gold);
    padding: calc(0.05rem - 1px) calc(0.4rem - 1px);
  }
  .troop-count-input.is-set { color: #8a4b12; }
  /* .troop-reset-btn: with .troop-copy-btn above. */

  /* ---- COPY ALL FLOATING BUTTON ---- */
  .copy-all-btn {
    position: fixed;
    bottom: 30px; right: 30px;
    padding: 0.75rem 1.3rem;
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-dk) 100%);
    border: 2px solid var(--wood-dark);
    border-radius: 6px;
    color: var(--wood-dark);
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.5),
      0 0 0 1px var(--gold),
      0 4px 14px rgba(0,0,0,0.5);
    display: flex; align-items: center; gap: 0.5rem;
    z-index: 100;
  }
  .copy-all-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

  /* ---- TOAST NOTIFICATION ---- */
  .toast-notification {
    position: fixed;
    bottom: 30px; left: 50%;
    transform: translateX(-50%);
    padding: 0.7rem 1.5rem;
    background: var(--wood-dark);
    color: var(--gold-hi);
    border: 1px solid var(--gold);
    border-radius: 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    z-index: 200;
  }

  /* ---- PRESET TABS (live class names) ---- */
  .presets-container {
    /* override styles.css: remove the white panel */
    background: linear-gradient(180deg, rgba(50,30,10,0.85), rgba(30,18,4,0.95));
    backdrop-filter: none;
    border: 1px solid var(--gold-dk);
    box-shadow: inset 0 1px 0 rgba(240,199,94,0.15), 0 4px 14px rgba(0,0,0,0.5);
  }
  .presets-tabs {
    display: flex; gap: 0.5rem; flex-wrap: wrap; flex: 1; min-width: 0;
  }
  .preset-tab {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 1rem;
    background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    color: var(--wood-mid);
    border: 1.5px solid var(--gold-dk);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s;
    min-width: 100px;
    position: relative;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
  }
  .preset-tab:hover {
    background: linear-gradient(180deg, var(--parchment-hi), var(--parchment));
    border-color: var(--gold);
  }
  .preset-tab.active {
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 100%);
    color: var(--wood-dark);
    border-color: var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 6px rgba(240,199,94,0.4);
  }
  .preset-tab-name {
    font-family: 'Cinzel', serif;
    color: inherit;
    font-weight: inherit;
  }
  .preset-tab-name-input {
    background: transparent; border: none;
    font-family: 'Cinzel', serif;
    color: inherit;
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    min-width: 80px;
  }
  .preset-tab-delete,
  .preset-tab-rename-btn,
  .preset-tab-checkmark {
    padding: 0;
    width: 22px; height: 22px;
    border: none;
    background: rgba(74,42,14,0.18);
    cursor: pointer;
    color: inherit;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 3px;
    flex-shrink: 0;
  }
  .preset-tab-delete:hover { background: var(--crimson); color: #fff; }
  .preset-tab-rename-btn:hover { background: var(--gold); color: var(--wood-dark); }
  .preset-tab-checkmark:hover { background: var(--emerald); color: #fff; }
  .preset-tab-insert-before {
    width: 3px;
    background: var(--gold-hi);
    border-radius: 2px;
    align-self: stretch;
    box-shadow: 0 0 6px var(--gold-hi);
  }

  /* ---- PRESET ACTION BUTTONS (live class names) ---- */
  .preset-action-btn {
    /* base styling already comes from .preset-btn; this stays in sync */
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--gold-dk);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 2px 4px rgba(0,0,0,0.4);
    transition: all 0.15s;
  }
  .preset-action-btn:not(.preset-action-btn-import):not(.preset-action-btn-export) {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
  }
  .preset-action-btn-import {
    background: linear-gradient(180deg, #4a8a4a, #2f6f3f);
    color: #f0f7e8;
  }
  .preset-action-btn-export {
    background: linear-gradient(180deg, #a82a2a, var(--crimson));
    color: #fce8d8;
  }
  .preset-action-btn:hover { filter: brightness(1.15); }

  /* ---- ENSURE OUR INPUT-CONTAINER OVERRIDES WIN OVER styles.css ---- */
  .input-container {
    background: linear-gradient(180deg, rgba(60,40,18,0.85), rgba(40,24,8,0.9)) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(240,199,94,0.15), 0 6px 20px rgba(0,0,0,0.5);
  }

  /* ---- CONTAINER OVERRIDE (styles.css may set container styles) ---- */
  .container {
    background: none;
  }
  .main-content {
    background: none;
  }

  /* ---- HIDE OLD PAGE TITLE H1 (we use logo now) ---- */
  .page-title {
    display: none;
  }

  /* =================================================================
     RESPONSIVE
     ================================================================= */
  @media (max-width: 1100px) {
    .input-container { grid-template-columns: 1fr !important; }
    .troop-row { grid-template-columns: repeat(2, 1fr); }
    .kill-order-container { flex-direction: column; }
    .troop-selection-row { flex-direction: column; }
  }

  /* Desktop (>820px viewport): tier label gets a wider, larger column so
     longer names like "Jungle Guardians" sit comfortably. */
  @media (min-width: 821px) {
    .group-label-space         { width: 150px; }
    .group-label-container     { width: 150px; }
    .group-display > .group-label { width: 150px; }
    .group-label               { font-size: 1.2rem; line-height: 1.5em; }
  }

  /* Mobile (≤820px viewport): tighten the layout for the forced-width mobile
     view. */
  @media (max-width: 820px) {
    /* Army Limits: side-by-side 3-column row. */
    .army-limits {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 0.75rem;
    }
    .limit-card {
      width: 100%;
    }

    /* Kill Order: keep Tier Order + Category Order side-by-side (60/40 split)
       instead of stacking them as the 1100px breakpoint would otherwise do. */
    .kill-order-container {
      flex-direction: row;
      gap: 1rem;
    }
    .kill-order-tiers,
    .kill-order-categories {
      min-width: 0;          /* allow children to shrink past their min-content */
    }
    .kill-order-tiers      { flex: 0 0 55%; }
    .kill-order-categories { flex: 0 0 calc(45% - 1rem); }
  }

  /* ---- CONFIRM MODAL ---- */
  .modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 6, 2, 0.72);
    backdrop-filter: blur(3px);
    animation: modalFade 0.18s ease-out;
  }
  .modal-overlay.closing { animation: modalFade 0.18s ease-in reverse; }
  @keyframes modalFade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  .modal-dialog {
    min-width: 320px;
    max-width: min(480px, 90vw);
    padding: 1.5rem 1.75rem;
    background: linear-gradient(180deg, var(--parchment-hi) 0%, var(--parchment) 60%, var(--parchment-dk) 100%);
    border: 2px solid var(--gold-dk);
    border-radius: 8px;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 4px var(--gold),
      inset 0 0 30px rgba(139, 111, 58, 0.25),
      0 16px 40px rgba(0, 0, 0, 0.6);
    color: var(--ink);
    animation: modalRise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @keyframes modalRise {
    from { transform: translateY(12px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
  }
  .modal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35);
    margin: 0 0 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(139, 111, 58, 0.4);
  }
  .modal-body {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.05rem;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 0 0 1.25rem;
    text-align: center;
  }
  .modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
  }
  .modal-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.55rem 1.4rem;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  }
  .modal-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
  .modal-btn:active { transform: translateY(0); filter: brightness(0.95); }
  .modal-btn:focus { outline: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 0 2px var(--gold-hi), 0 2px 6px rgba(0,0,0,0.35); }
  .modal-btn-cancel {
    background: linear-gradient(180deg, var(--parchment-hi) 0%, var(--parchment) 60%, var(--parchment-dk) 100%);
    color: var(--wood-mid);
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
  }
  .modal-btn-confirm {
    background: linear-gradient(180deg, #b53535 0%, var(--crimson) 60%, #5e1010 100%);
    color: #fce8d8;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  }

  /* =================================================================
     MONSTERS BOOST PRESET BAR
     Sits between the 4 category cards and the 4 type cards inside Special
     Bonuses. The buttons rewrite all 8 type-bonus inputs at once.
     ================================================================= */
  /* The Adjust All Troops bar (Troops Bonuses column) shares this rule on
     purpose -- one rule, two names -- so the two bars never drift apart. */
  .monsters-boost-bar,
  .adjust-all-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0 1rem;
    padding: 0.55rem 0.85rem;
    background: linear-gradient(180deg, rgba(40, 24, 8, 0.75), rgba(20, 12, 4, 0.85));
    border: 1px solid var(--gold-dk);
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(240, 199, 94, 0.15);
    flex-wrap: wrap;
  }
  .mb-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--gold-hi);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  }
  .mb-label i { color: var(--gold-dk); }
  .mb-options {
    display: inline-flex;
    border: 1px solid var(--gold-dk);
    border-radius: 5px;
    overflow: hidden;
    background: rgba(20, 12, 4, 0.55);
    margin-left: auto;
  }
  .mb-btn {
    padding: 0.4rem 0.85rem;
    background: transparent;
    color: var(--parchment-dk);
    border: none;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
  }
  .mb-btn small {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.85;
  }
  .mb-btn + .mb-btn { border-left: 1px solid var(--gold-dk); }
  .mb-btn:hover { color: var(--gold-hi); }
  .mb-btn.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  }
  .mb-btn.active small { color: var(--wood-mid); opacity: 1; }

  /* =================================================================
     ADJUST ALL TROOPS
     Two gilded chips (H / S) inside a Monsters-Boost-style bar, each with
     round dark +/- discs. The chips wear the ACTIVE Monsters Boost gold on
     purpose: across the row, gilded already means "the live control".
     Mirrors the desktop app's bar exactly.
     ================================================================= */
  .adjust-all-bar { margin: 0.9rem 0 0; }
  .aa-chips {
    display: inline-flex;
    gap: 0.6rem;
    margin-left: auto;
  }
  .aa-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem 0.25rem 0.65rem;
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    border: 1px solid var(--wood-dark);
    border-radius: 4px;
  }
  .aa-chip .sub-label {
    color: var(--ink-soft);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: none;
  }
  .aa-btn {
    width: 24px; height: 24px;
    padding: 0;
    border-radius: 50%;
    background: var(--wood-mid);
    color: var(--gold-hi);
    border: 1px solid var(--gold-dk);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
  }
  .aa-btn:hover { color: #f3eee0; border-color: var(--gold-hi); }
  .aa-btn:active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
  }

  /* =================================================================
     PRESET WIZARD (multi-step modal)
     ================================================================= */
  .wizard-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 6, 2, 0.78);
    backdrop-filter: blur(4px);
    animation: modalFade 0.18s ease-out;
    padding: 1rem;
  }
  .wizard-overlay.closing { animation: modalFade 0.18s ease-in reverse; }
  .wizard-dialog {
    width: min(720px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--parchment-hi) 0%, var(--parchment) 60%, var(--parchment-dk) 100%);
    border: 2px solid var(--gold-dk);
    border-radius: 10px;
    box-shadow:
      0 0 0 1px var(--wood-dark),
      0 0 0 4px var(--gold),
      inset 0 0 35px rgba(139, 111, 58, 0.25),
      0 18px 50px rgba(0, 0, 0, 0.65);
    color: var(--ink);
    animation: modalRise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
    overflow: hidden;
  }

  .wizard-header {
    padding: 1rem 1.5rem 0.85rem;
    border-bottom: 1px solid rgba(139, 111, 58, 0.4);
    background: linear-gradient(180deg, rgba(255, 250, 230, 0.4), transparent);
  }
  .wizard-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .wizard-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
  }
  .wizard-title i { color: var(--gold-dk); }
  .wizard-close {
    background: transparent;
    border: 1px solid transparent;
    color: var(--wood-mid);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, border-color 0.15s;
  }
  .wizard-close:hover { background: rgba(139,111,58,0.18); border-color: var(--gold-dk); }

  .wizard-step-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 1rem 0 0.6rem;
  }
  .wizard-step-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(74, 42, 14, 0.18);
    border: 1.5px solid var(--gold-dk);
    color: var(--wood-mid);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .wizard-step-dot.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    border-color: var(--wood-dark);
    color: var(--wood-dark);
    box-shadow: 0 0 0 2px rgba(240, 199, 94, 0.4);
  }
  .wizard-step-dot.done {
    background: var(--wood-mid);
    border-color: var(--gold-dk);
    color: var(--gold-hi);
  }
  .wizard-step-conn {
    flex: 1;
    height: 2px;
    background: rgba(74, 42, 14, 0.3);
    border-radius: 1px;
  }
  .wizard-step-conn.done { background: var(--gold-dk); }
  .wizard-sub-title {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--wood-mid);
    font-weight: 600;
    letter-spacing: 0.5px;
  }

  .wizard-content {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
  }
  .wizard-step { display: flex; flex-direction: column; gap: 1rem; }

  /* ---- Form atoms ---- */
  .wz-field { display: flex; flex-direction: column; gap: 0.4rem; }
  .wz-label {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--wood-mid);
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }
  /* Army-Limits step only: 3-column field grid → center the labels above each input. */
  .wz-grid-3 .wz-label { text-align: center; justify-content: center; }

  /* Compact wizard tooltip (Step 2 cap labels). Inline pill that pops ABOVE
     the icon — positioning above keeps it out of the wizard-content overflow
     box so we never trigger horizontal/vertical scrollbars on the dialog. */
  .wz-tip-wrap { position: relative; display: inline-flex; }
  .wz-tip {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: nowrap;
    padding: 0.3rem 0.7rem;
    background: var(--wood-dark);
    color: var(--gold-hi);
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    text-shadow: none;
    line-height: 1.2;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    top: auto;
    z-index: 2100;
  }
  /* Arrow points DOWN (since the tooltip sits above the icon). Overrides the
     default :has-image / tooltip-text::after triangle. */
  .wz-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    bottom: auto;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gold-dk);
  }
  .wz-tip-wrap:hover .wz-tip,
  .wz-tip-wrap .tooltip-icon:focus + .wz-tip {
    visibility: visible;
    opacity: 1;
  }
  .wz-label small {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink-soft);
    margin-left: 0.3rem;
    font-size: 0.7em;
  }
  .wz-input {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    background: rgba(255, 250, 230, 0.85);
    color: var(--ink);
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    font-weight: 600;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
  }
  .wz-input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(255, 252, 240, 0.95);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.08), 0 0 6px rgba(240,199,94,0.5);
  }
  .wz-num { text-align: center; }
  .wz-hint {
    margin: 0;
    font-family: 'EB Garamond', Georgia, serif;
    color: var(--ink-soft);
    font-style: italic;
    line-height: 1.45;
    font-size: 0.95rem;
  }

  /* ---- Mode toggle ---- */
  .wz-mode-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  .wz-mode-group-2 { grid-template-columns: repeat(2, 1fr); }
  .wz-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
  /* Quick-pick row: full-width chips so a player can spot their tier fast. */
  .wz-tier-quick .wz-chip { min-width: 48px; font-size: 0.95rem; }
  .wz-mode-btn {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.6rem 0.5rem;
    border: 1.5px solid var(--gold-dk);
    border-radius: 5px;
    background: rgba(74, 42, 14, 0.12);
    color: var(--wood-mid);
    cursor: pointer;
    transition: all 0.15s;
  }
  .wz-mode-btn:hover { border-color: var(--gold); color: var(--wood-dark); }
  .wz-mode-btn.active {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 6px rgba(240,199,94,0.35);
  }

  /* ---- Tier chips ---- */
  .wz-chip-group { display: flex; gap: 0.35rem; flex-wrap: wrap; }
  .wz-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 0.35rem 0.55rem;
    border: 1.5px solid var(--gold-dk);
    border-radius: 4px;
    background: rgba(74, 42, 14, 0.12);
    color: var(--wood-mid);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
  }
  .wz-chip:hover { border-color: var(--gold); color: var(--wood-dark); }
  .wz-chip input { position: absolute; opacity: 0; pointer-events: none; }
  .wz-chip.checked {
    background: linear-gradient(180deg, var(--gold-hi), var(--gold));
    color: var(--wood-dark);
    border-color: var(--wood-dark);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  }

  /* ---- Class / category bonus cards ---- */
  .wz-card {
    background: linear-gradient(180deg, rgba(255, 250, 230, 0.55), rgba(244, 233, 196, 0.4));
    border: 1px solid rgba(139, 111, 58, 0.5);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
  }
  .wz-card-title {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--wood-mid);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    text-align: center;
    padding-bottom: 0.3rem;
    margin-bottom: 0.45rem;
    border-bottom: 1px solid rgba(139, 111, 58, 0.4);
  }
  .wz-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .wz-pair-item {
    display: flex; align-items: center; gap: 0.35rem;
  }
  .wz-pair-item.full { grid-column: 1 / -1; }
  .wz-sub-label {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    color: var(--ink-soft);
    font-weight: 700;
    width: 1em;
  }
  .wz-section + .wz-section { margin-top: 0.4rem; }
  .wz-section-title {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--wood-mid);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
  }
  .wz-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }

  /* ---- Review summary ---- */
  .wz-summary {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: linear-gradient(180deg, rgba(255, 250, 230, 0.55), rgba(244, 233, 196, 0.35));
    border: 1px solid rgba(139, 111, 58, 0.45);
    border-radius: 6px;
    padding: 0.85rem 1rem;
  }
  .wz-summary-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .wz-summary-section + .wz-summary-section {
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(139, 111, 58, 0.4);
  }
  .wz-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
  }
  .wz-summary-label { color: var(--ink-soft); }
  .wz-summary-value { color: var(--wood-mid); font-weight: 700; text-align: right; }

  /* ---- Footer / buttons ---- */
  .wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.5rem;
    border-top: 1px solid rgba(139, 111, 58, 0.4);
    background: linear-gradient(180deg, transparent, rgba(74, 42, 14, 0.08));
  }
  .wizard-btn {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 0.55rem 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid var(--wood-dark);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 2px 5px rgba(0,0,0,0.35);
    transition: transform 0.12s ease, filter 0.12s ease;
  }
  .wizard-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
  .wizard-btn:active:not(:disabled) { transform: translateY(0); filter: brightness(0.95); }
  .wizard-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .wizard-btn-cancel {
    background: linear-gradient(180deg, var(--parchment-hi) 0%, var(--parchment) 60%, var(--parchment-dk) 100%);
    color: var(--wood-mid);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.4);
    margin-right: auto;
  }
  .wizard-btn-prev {
    background: linear-gradient(180deg, var(--parchment-dk), #c4a878);
    color: var(--wood-mid);
  }
  .wizard-btn-next {
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-dk) 100%);
    color: var(--wood-dark);
  }

  /* Magic-wand preset action button (matches the existing gold-on-dark style) */
  .preset-action-btn-wizard,
  .preset-btn.wizard {
    background: linear-gradient(180deg, #6a4ca8, #4a2e7e);
    color: #f0c75e;
  }

  /* ---- FOOTER ---- */
  .site-footer {
    margin-top: 3rem;
    padding: 1.5rem 1rem;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 1px;
    color: var(--gold-dk);
    border-top: 1px solid var(--gold-dk);
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%);
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  }
