/* ════════════════════════════════════════════════════════════════
   cards-engine.css — unified card engine styles (all games)
   Themed via CSS variables injected per game:
     --ce-primary  --ce-accent  --ce-surface  --ce-panel
     --ce-border   --ce-text    --ce-muted
   ════════════════════════════════════════════════════════════════ */

.ce-root {
  background: var(--ce-surface, #0d1117);
  color: var(--ce-text, #e6edf3);
  min-height: 100vh;
  padding-bottom: 80px;
}
.ce-wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ── Sticky head (toolbar + filter panel stick together) ── */
.ce-stickyhead {
  position: sticky; top: 0; z-index: 50;
  background: var(--ce-surface, #0d1117);
  display: flex; flex-direction: column;
}

/* ── Toolbar ── */
.ce-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--ce-border, #30363d);
}
.ce-searchwrap {
  position: relative; flex: 1 1 260px; min-width: 200px;
}
.ce-searchwrap i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ce-muted, #8b949e); font-size: .85rem; pointer-events: none;
}
.ce-q {
  width: 100%; padding: 9px 12px 9px 34px;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 8px; color: var(--ce-text, #e6edf3);
  font-size: .9rem; outline: none;
  transition: border-color .15s;
}
.ce-q:focus { border-color: var(--ce-accent, #58a6ff); }
.ce-q::placeholder { color: var(--ce-muted, #8b949e); }

.ce-filter-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  color: var(--ce-text, #e6edf3); font-size: .85rem; cursor: pointer;
  transition: border-color .15s;
}
.ce-filter-toggle:hover { border-color: var(--ce-accent, #58a6ff); }
.ce-filter-count { color: var(--ce-accent, #58a6ff); font-weight: 700; }

.ce-sort {
  padding: 9px 10px; border-radius: 8px;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  color: var(--ce-text, #e6edf3); font-size: .85rem; cursor: pointer;
}
.ce-count {
  margin-left: auto; font-size: .8rem; color: var(--ce-muted, #8b949e);
  white-space: nowrap;
}

/* ── Filter bar (inside sticky head — visible no matter how deep
      the user has scrolled when they hit the Filters button) ── */
.ce-filterbar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 16px;
  padding: 14px;
  margin: 10px 0;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 12px;
  max-height: min(62vh, 520px);
  overflow-y: auto;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
/* display:grid above would defeat the hidden attribute's UA rule —
   restore correct toggle behavior */
.ce-filterbar[hidden] { display: none; }
.ce-f--multi { grid-column: 1 / -1; }
.ce-f__label {
  display: block; font-size: .7rem; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
  color: var(--ce-muted, #8b949e); margin-bottom: 6px;
}
.ce-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ce-chip {
  --chip-c: var(--ce-accent, #58a6ff);
  padding: 5px 12px; border-radius: 999px;
  background: transparent;
  border: 1px solid var(--ce-border, #30363d);
  color: var(--ce-text, #e6edf3);
  font-size: .8rem; cursor: pointer;
  transition: all .12s;
}
.ce-chip:hover { border-color: var(--chip-c); }
.ce-chip.on {
  background: var(--chip-c); border-color: var(--chip-c);
  color: #fff; font-weight: 700;
}
.ce-f__select, .ce-f__text {
  width: 100%; padding: 7px 10px; border-radius: 7px;
  background: var(--ce-surface, #0d1117);
  border: 1px solid var(--ce-border, #30363d);
  color: var(--ce-text, #e6edf3); font-size: .85rem; outline: none;
}
.ce-f__select:focus, .ce-f__text:focus { border-color: var(--ce-accent, #58a6ff); }
/* ── Dual-handle range slider (Piltover-style) ── */
.ce-dualrange { position: relative; height: 40px; padding-top: 18px; }
.ce-dualrange__label {
  position: absolute; top: 0; right: 0;
  font-size: .72rem; color: var(--ce-muted, #8b949e);
  font-family: ui-monospace, monospace;
}
.ce-dualrange__label.on { color: var(--ce-accent, #58a6ff); font-weight: 700; }
.ce-dualrange__track {
  position: absolute; left: 0; right: 0; top: 26px; height: 4px;
  background: var(--ce-border, #30363d); border-radius: 999px;
}
.ce-dualrange__fill {
  position: absolute; top: 0; height: 100%;
  background: var(--ce-accent, #58a6ff); border-radius: 999px;
}
.ce-dualrange input[type="range"] {
  position: absolute; left: 0; right: 0; top: 18px; width: 100%;
  margin: 0; height: 20px;
  -webkit-appearance: none; appearance: none;
  background: none; pointer-events: none; outline: none;
}
.ce-dualrange input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ce-text, #e6edf3);
  border: 3px solid var(--ce-accent, #58a6ff);
  cursor: grab; pointer-events: auto;
  transition: transform .1s;
}
.ce-dualrange input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.ce-dualrange input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }
.ce-dualrange input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ce-text, #e6edf3);
  border: 3px solid var(--ce-accent, #58a6ff);
  cursor: grab; pointer-events: auto;
}
.ce-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .85rem; cursor: pointer; color: var(--ce-text, #e6edf3);
  padding-top: 4px;
}
.ce-toggle input { width: 16px; height: 16px; accent-color: var(--ce-accent, #58a6ff); }
.ce-clear {
  align-self: end; justify-self: start;
  padding: 7px 14px; border-radius: 7px;
  background: transparent; border: 1px dashed var(--ce-border, #30363d);
  color: var(--ce-muted, #8b949e); font-size: .8rem; cursor: pointer;
}
.ce-clear:hover { color: var(--ce-text, #e6edf3); border-color: var(--ce-muted, #8b949e); }

/* ── Card grid ── */
.ce-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 18px 0;
}
.ce-card {
  margin: 0; cursor: pointer; border-radius: 10px; overflow: hidden;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  transition: transform .12s, border-color .12s, box-shadow .12s;
  outline: none;
}
.ce-card:hover, .ce-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--ce-accent, #58a6ff);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.ce-card img { width: 100%; display: block; aspect-ratio: 63/88; object-fit: cover; }
.ce-card__noimg {
  aspect-ratio: 63/88; display: flex; align-items: center; justify-content: center;
  padding: 10px; text-align: center; font-size: .75rem;
  color: var(--ce-muted, #8b949e);
  background: repeating-linear-gradient(45deg,
    var(--ce-panel, #161b22), var(--ce-panel, #161b22) 10px,
    var(--ce-surface, #0d1117) 10px, var(--ce-surface, #0d1117) 20px);
}
.ce-card__cap {
  padding: 5px 8px; font-size: .65rem; text-align: center;
  color: var(--ce-muted, #8b949e);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ce-loading, .ce-empty, .ce-error {
  grid-column: 1 / -1; text-align: center; padding: 60px 0;
  color: var(--ce-muted, #8b949e); font-size: .95rem;
}
.ce-error a { color: var(--ce-accent, #58a6ff); }
.ce-sentinel { height: 1px; }

/* ── Builder layout (grid + deck panel) ── */
.ce-body--builder {
  display: grid; grid-template-columns: 1fr 6px 300px; gap: 8px;
  align-items: start;
}
.ce-split {
  position: sticky; top: 10px;
  width: 6px; height: calc(100vh - 24px); margin-top: 14px;
  border-radius: 3px; cursor: col-resize;
  background: var(--ce-border, #30363d);
  transition: background .12s;
  touch-action: none;
}
.ce-split:hover, .ce-split.dragging { background: var(--ce-accent, #58a6ff); }
/* ── Mobile tab bar (builder) — Piltover-style view switcher ── */
.ce-mobiletabs { display: none; }

@media (max-width: 860px) {
  .ce-body--builder { grid-template-columns: 1fr !important; }
  .ce-split { display: none; }

  .ce-mobiletabs {
    display: flex; gap: 6px; padding: 8px 0 6px;
    /* Tab bar above the search box on small screens (owner request) */
    order: -1;
    border-bottom: 1px solid var(--ce-border, #30363d);
  }
  .ce-mtab {
    flex: 1; padding: 8px 4px; border-radius: 8px;
    border: 1px solid var(--ce-border, #30363d);
    background: transparent; color: var(--ce-muted, #8b949e);
    font-size: .78rem; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  }
  .ce-mtab.on {
    background: var(--ce-accent, #58a6ff); border-color: var(--ce-accent, #58a6ff);
    color: #fff;
  }
  .ce-mtab__count { font-family: ui-monospace, monospace; }

  /* Full-screen view switching driven by root class.
     NOTE: .ce-main holds the sticky head (with the mobile tab bar)
     in builder mode — hide only the grid, never the whole column. */
  .ce-m-deck .ce-grid, .ce-m-stats .ce-grid,
  .ce-m-deck .ce-sentinel, .ce-m-stats .ce-sentinel { display: none; }
  .ce-m-gallery .ce-deck { display: none; }
  .ce-m-deck .ce-deck, .ce-m-stats .ce-deck {
    position: static !important;
    max-height: none; margin-top: 10px;
  }
  .ce-m-deck .ce-deck__list { max-height: calc(100vh - 280px); }
  .ce-m-stats .ce-deck__stats { max-height: calc(100vh - 240px); }
  /* In deck/stats views hide search toolbar + filter panel + the
     panel's own duplicate tab strip (mobile bar drives it) */
  .ce-m-deck .ce-toolbar, .ce-m-stats .ce-toolbar,
  .ce-m-deck .ce-filterbar, .ce-m-stats .ce-filterbar,
  .ce-m-deck .ce-deck__tabs, .ce-m-stats .ce-deck__tabs { display: none; }
}
.ce-deck {
  /* Panel starts at the top of the page — status chip sits level
     with the search input (toolbar pad 14px matches margin-top). */
  position: sticky; top: 10px;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 12px;
  margin-top: 14px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 24px);
}
.ce-deck__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--ce-border, #30363d);
}
.ce-deck__title {
  font-size: .9rem; font-weight: 800; color: var(--ce-text, #e6edf3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ce-deck__title i { color: var(--ce-accent, #58a6ff); margin-right: 4px; }
.ce-deck__status {
  flex-shrink: 0; padding: 2px 9px; border-radius: 999px;
  font-size: .68rem; font-weight: 800; cursor: help; white-space: nowrap;
}
.ce-deck__status.ok   { background: rgba(22,163,74,.18);  color: #4ade80; border: 1px solid rgba(74,222,128,.45); }
.ce-deck__status.warn { background: rgba(245,158,11,.16); color: #fbbf24; border: 1px solid rgba(251,191,36,.45); }
.ce-deck__list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.ce-deck__empty { padding: 28px 12px; text-align: center; font-size: .8rem; color: var(--ce-muted, #8b949e); }
.ce-deck__row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 7px; cursor: pointer;
  font-size: .8rem; color: var(--ce-text, #e6edf3);
  transition: background .1s;
}
.ce-deck__rowimg {
  flex-shrink: 0; width: 34px; height: 47px;
  border-radius: 4px; object-fit: cover;
  border: 1px solid var(--ce-border, #30363d);
  background: var(--ce-surface, #0d1117);
}
.ce-deck__rowimg--none {
  display: inline-block;
  background: repeating-linear-gradient(45deg,
    var(--ce-panel, #161b22), var(--ce-panel, #161b22) 5px,
    var(--ce-surface, #0d1117) 5px, var(--ce-surface, #0d1117) 10px);
}
.ce-deck__row:hover { background: rgba(248, 81, 73, .12); }
.ce-deck__row:hover .ce-deck__rowdel { opacity: 1; }
.ce-deck__rowqty {
  flex-shrink: 0; min-width: 22px; text-align: center;
  font-weight: 800; color: var(--ce-accent, #58a6ff);
  font-family: ui-monospace, monospace;
}
.ce-deck__rowcost {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ce-surface, #0d1117);
  border: 1px solid var(--ce-border, #30363d);
  font-size: .68rem; font-weight: 700;
}
.ce-deck__rowname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-deck__rowdel { flex-shrink: 0; opacity: 0; color: #f85149; font-size: .7rem; transition: opacity .1s; }
.ce-deck__hint {
  padding: 8px 14px; font-size: .68rem; color: var(--ce-muted, #8b949e);
  border-top: 1px solid var(--ce-border, #30363d);
}

/* ── Deck panel tabs + toolbar (status chip lives in the tab row) ── */
.ce-deck__tabs {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--ce-border, #30363d);
}
.ce-deck__tabs .ce-deck__status { margin-left: auto; margin-right: 10px; }
.ce-dtab {
  flex: 0 0 auto; padding: 10px 16px; border: none; cursor: pointer;
  background: transparent; color: var(--ce-muted, #8b949e);
  font-size: .8rem; font-weight: 700;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
}
.ce-dtab.on { color: var(--ce-accent, #58a6ff); border-bottom-color: var(--ce-accent, #58a6ff); }
.ce-dtab:hover { color: var(--ce-text, #e6edf3); }

.ce-deck__toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; font-size: .72rem; color: var(--ce-muted, #8b949e);
  border-bottom: 1px solid var(--ce-border, #30363d);
}
.ce-deck__toolbar .ce-dsort { margin-left: auto; }
.ce-dview { display: inline-flex; gap: 2px; }
.ce-dv, .ce-dc {
  border: 1px solid var(--ce-border, #30363d); background: transparent;
  color: var(--ce-muted, #8b949e); cursor: pointer;
  padding: 3px 8px; border-radius: 6px; font-size: .72rem;
}
.ce-dv.on, .ce-dc.on {
  background: var(--ce-accent, #58a6ff); border-color: var(--ce-accent, #58a6ff);
  color: #fff; font-weight: 700;
}
.ce-dcols { display: inline-flex; align-items: center; gap: 3px; }
.ce-dsort {
  border: 1px solid var(--ce-border, #30363d);
  background: var(--ce-panel, #161b22); color: var(--ce-text, #e6edf3);
  border-radius: 6px; padding: 3px 6px; font-size: .72rem; cursor: pointer;
  max-width: 110px;
}

/* ── Deck zones (Partner / Case / Main) ── */
.ce-deck__zone { margin-bottom: 10px; }
/* Inline zones (Partner + Case) sit side-by-side on one row */
.ce-deck__zonerow { display: flex; gap: 8px; }
.ce-deck__zonerow > .ce-deck__zone { flex: 1; min-width: 0; }
.ce-deck__zonehd {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; margin: 0 2px 4px;
  border-radius: 6px; background: rgba(255, 255, 255, .04);
  font-size: .7rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ce-text, #e6edf3);
}
.ce-deck__zonelabel { flex: 1; }
.ce-deck__zonecount {
  font-weight: 800; font-variant-numeric: tabular-nums;
  padding: 1px 7px; border-radius: 10px; font-size: .72rem;
}
.ce-deck__zonecount.ok   { color: #22c55e; background: rgba(34, 197, 94, .14); }
.ce-deck__zonecount.warn { color: #f59e0b; background: rgba(245, 158, 11, .14); }
.ce-deck__zoneempty {
  margin: 2px; padding: 14px 10px; text-align: center;
  font-size: .74rem; color: var(--ce-muted, #8b949e);
  border: 1px dashed var(--ce-border, #30363d); border-radius: 8px;
}

/* ── Deck grid view ── */
.ce-deck__grid { display: grid; gap: 6px; padding: 2px; }
.ce-deck__grid--c2 { grid-template-columns: repeat(2, 1fr); }
.ce-deck__grid--c3 { grid-template-columns: repeat(3, 1fr); }
.ce-deck__grid--c4 { grid-template-columns: repeat(4, 1fr); }
/* Inline single-card zones (Partner/Case): one card filling its
   half-row, fixed regardless of the column selector. */
.ce-deck__grid--fixed { grid-template-columns: 1fr; }
.ce-deck__cell {
  position: relative; margin: 0; cursor: pointer;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--ce-border, #30363d);
  transition: transform .1s, border-color .1s;
}
.ce-deck__cell:hover { transform: translateY(-2px); border-color: #f85149; }
.ce-deck__cell img { width: 100%; display: block; aspect-ratio: 63/88; object-fit: cover; }
.ce-deck__cellnoimg {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 63/88; padding: 4px; text-align: center;
  font-size: .55rem; color: var(--ce-muted, #8b949e);
  background: var(--ce-surface, #0d1117);
}
.ce-deck__cellqty {
  position: absolute; bottom: 3px; right: 3px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ce-accent, #58a6ff); color: #fff;
  font-size: .7rem; font-weight: 800;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .55);
}

/* ℹ button in deck panel (rows + grid cells) */
.ce-deck__info {
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3); cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: .78rem; font-style: italic; font-weight: 800; font-family: serif;
  display: flex; align-items: center; justify-content: center;
  opacity: .6; transition: opacity .12s, background .12s;
}
.ce-deck__row:hover .ce-deck__info,
.ce-deck__cell:hover .ce-deck__info { opacity: 1; }
.ce-deck__info:hover { background: var(--ce-accent, #58a6ff); border-color: #fff; }
.ce-deck__cell .ce-deck__info {
  position: absolute; top: 3px; right: 3px;
}

/* ── Deck stats ── */
.ce-deck__stats { flex: 1; overflow-y: auto; padding: 12px; }
.ce-statcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(82px, 1fr)); gap: 8px; }
.ce-text__label {
  font-size: .62rem; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; color: var(--ce-accent, #58a6ff);
  margin-bottom: 4px;
}
.ce-statcard {
  background: var(--ce-surface, #0d1117);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 10px; padding: 10px 6px; text-align: center;
}
.ce-statcard__v { font-size: 1.25rem; font-weight: 800; color: var(--ce-text, #e6edf3); }
.ce-statcard__k {
  font-size: .58rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--ce-muted, #8b949e); margin-top: 2px;
}
.ce-statsec { margin-top: 14px; }
.ce-statsec__t {
  font-size: .7rem; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; color: var(--ce-muted, #8b949e); margin-bottom: 8px;
}
.ce-curve {
  display: flex; align-items: flex-end; gap: 4px; height: 110px;
  background: var(--ce-surface, #0d1117);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 10px; padding: 10px 8px 6px;
}
.ce-curve__col { flex: 1; display: flex; flex-direction: column; height: 100%; }
.ce-curve__qty {
  font-size: .6rem; text-align: center; color: var(--ce-muted, #8b949e);
  height: 14px; flex-shrink: 0;
}
.ce-curve__bar {
  flex: 1; display: flex; flex-direction: column-reverse;
  border-radius: 3px; overflow: hidden;
}
.ce-curve__seg { width: 100%; min-height: 2px; }
.ce-curve__x {
  font-size: .6rem; text-align: center; color: var(--ce-muted, #8b949e);
  height: 14px; flex-shrink: 0; font-family: ui-monospace, monospace;
}
.ce-donutwrap { display: flex; align-items: center; gap: 12px; }
.ce-donut { width: 92px; height: 92px; flex-shrink: 0; }
.ce-donut__total { font-size: 22px; font-weight: 800; fill: var(--ce-text, #e6edf3); }
.ce-donut__legend { flex: 1; font-size: .72rem; color: var(--ce-text, #e6edf3); }
.ce-donut__legend div { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.ce-donut__legend b { margin-left: auto; color: var(--ce-muted, #8b949e); }
.ce-donut__dot {
  width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; display: inline-block;
}

/* Card qty badge + info button (builder mode) */
.ce-card { position: relative; }
.ce-card__qty {
  position: absolute; top: 6px; left: 6px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  display: none; align-items: center; justify-content: center;
  background: var(--ce-accent, #58a6ff); color: #fff;
  font-size: .8rem; font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.ce-card__qty.on { display: flex; }
.ce-card__info {
  position: absolute; top: 6px; right: 6px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); cursor: pointer;
  background: rgba(0, 0, 0, .65); color: #fff;
  font-size: 1rem; font-style: italic; font-weight: 800; font-family: serif;
  opacity: .65; transition: opacity .12s, background .12s, transform .12s;
  display: flex; align-items: center; justify-content: center;
}
.ce-card:hover .ce-card__info { opacity: 1; }
.ce-card__info:hover {
  background: var(--ce-accent, #58a6ff);
  border-color: #fff; transform: scale(1.1);
}
@media (max-width: 860px) {
  .ce-card__info { opacity: .85; }  /* no hover on touch — keep visible */
}

/* ── Modal ── */
.ce-modal { position: fixed; inset: 0; z-index: 1000; }
.ce-modal__backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .8);
  backdrop-filter: blur(2px);
}
.ce-modal__frame {
  /* position:relative lifts the whole frame (panel + nav buttons)
     above the absolutely-positioned backdrop — without it the
     static nav buttons paint UNDER the backdrop: invisible, and
     clicks hit the backdrop (closing the modal). */
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  max-width: 992px; margin: 4vh auto; padding: 0 10px;
}
.ce-modal__panel {
  position: relative; flex: 1; min-width: 0;
  max-height: 92vh; overflow-y: auto;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
}
.ce-modal__close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .08); border: none;
  color: var(--ce-text, #e6edf3); font-size: 1rem; cursor: pointer;
}
.ce-modal__close:hover { background: rgba(255, 255, 255, .16); }
.ce-modal__nav {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--ce-panel, #161b22);
  border: 1px solid var(--ce-border, #30363d);
  color: var(--ce-text, #e6edf3); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, transform .1s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
.ce-modal__nav:hover:not(:disabled) {
  background: var(--ce-accent, #58a6ff);
  border-color: var(--ce-accent, #58a6ff);
  color: #fff; transform: scale(1.08);
}
.ce-modal__nav:disabled { opacity: .22; cursor: default; }
@media (max-width: 720px) {
  .ce-modal__frame {
    flex-direction: column; gap: 0;
    margin: 0; max-width: none; padding: 0;
  }
  .ce-modal__nav {
    position: fixed; bottom: 14px; z-index: 3;
  }
  .ce-modal__prev { left: calc(50% - 56px); }
  .ce-modal__next { right: calc(50% - 56px); }
}

.ce-modal__body {
  display: grid; grid-template-columns: 320px 1fr; gap: 22px;
  padding: 24px;
}
@media (max-width: 720px) {
  .ce-modal__body {
    grid-template-columns: 1fr;
    /* the prev/next buttons float at bottom:14px (44px tall) — reserve
       room so the last block (card text / FAQ) can scroll clear of them
       instead of sitting permanently hidden underneath. */
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 24px);
  }
  .ce-modal__panel { max-height: 100vh; border-radius: 0; }
  .ce-modal__nav { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
.ce-modal__img img { width: 100%; border-radius: 10px; }
.ce-card__noimg--big { border-radius: 10px; font-size: 1rem; }
.ce-modal__code { font-size: .75rem; color: var(--ce-muted, #8b949e); font-family: ui-monospace, monospace; }
.ce-modal__name { font-size: 1.3rem; font-weight: 800; margin: 4px 0 2px; color: var(--ce-text, #e6edf3); }
.ce-modal__jp { font-size: .85rem; color: var(--ce-muted, #8b949e); margin-bottom: 8px; }

.ce-stats { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.ce-stat { display: flex; gap: 10px; font-size: .85rem; }
.ce-stat__k {
  flex: 0 0 100px; color: var(--ce-muted, #8b949e);
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding-top: 2px;
}
.ce-stat__v { color: var(--ce-text, #e6edf3); }

.ce-text {
  margin-top: 12px; padding: 12px 14px; border-radius: 8px;
  background: var(--ce-surface, #0d1117);
  border: 1px solid var(--ce-border, #30363d);
  font-size: .85rem; line-height: 1.7; color: var(--ce-text, #e6edf3);
  white-space: normal;
}
.ce-flavor {
  margin-top: 8px; padding: 0 14px; font-size: .8rem; font-style: italic;
  color: var(--ce-muted, #8b949e); line-height: 1.6;
}
.ce-dual {
  margin-top: 16px; padding: 14px; border-radius: 10px;
  border: 1px dashed var(--ce-accent, #58a6ff);
}
.ce-dual__badge {
  font-size: .7rem; font-weight: 800; color: var(--ce-accent, #58a6ff);
  letter-spacing: .6px; margin-bottom: 4px;
}
.ce-dual__name { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }

/* ── Modal: grouped stat rows + colored stat chips + FAQ ──
   Paired rows are a strict 2-column grid and labels keep the SAME
   fixed width as single rows, so all four value columns align:
       COLOR   Blue        LEVEL   3
       AP      2,000       LP      1
       TRAIT   นักคาราเต้ / …
       SET     Promo       RARITY  PR                              */
.ce-statrow {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
.ce-statrow .ce-stat { display: flex; min-width: 0; }

/* Colored value inside a stat row (modal "chip" manifest).
   Owner feedback 2026-06-12: pill backgrounds broke row alignment —
   render as colored bold text instead. */
.ce-vchip {
  --vchip: var(--ce-accent, #58a6ff);
  color: var(--vchip);
  font-weight: 800;
}

.ce-mchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.ce-mchip {
  --mchip: var(--ce-accent, #58a6ff);
  display: inline-flex; align-items: center; overflow: hidden;
  border-radius: 8px; border: 1px solid var(--mchip);
  font-size: .78rem; line-height: 1;
}
.ce-mchip__k {
  background: var(--mchip); color: #fff;
  padding: 5px 8px; font-weight: 700; letter-spacing: .3px;
}
.ce-mchip__v {
  padding: 5px 10px; font-weight: 800;
  color: var(--ce-text, #e6edf3);
  background: var(--ce-surface, #0d1117);
  font-family: ui-monospace, monospace;
}

.ce-faq {
  margin-top: 12px; border-radius: 8px;
  border: 1px solid var(--ce-border, #30363d);
  background: var(--ce-surface, #0d1117);
}
.ce-faq summary {
  padding: 10px 14px; cursor: pointer; font-size: .82rem; font-weight: 700;
  color: var(--ce-accent, #58a6ff); user-select: none;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.ce-faq summary::-webkit-details-marker { display: none; }
.ce-faq summary::after {
  content: '▾'; margin-left: auto; transition: transform .15s;
  color: var(--ce-muted, #8b949e);
}
.ce-faq[open] summary::after { transform: rotate(180deg); }
.ce-faq__body {
  padding: 0 14px 12px; font-size: .85rem; line-height: 1.7;
  color: var(--ce-text, #e6edf3);
  border-top: 1px dashed var(--ce-border, #30363d);
  padding-top: 10px;
}
.ce-faq__count {
  background: var(--ce-accent, #58a6ff); color: #fff;
  border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 800;
}
.ce-faq__header {
  font-size: .72rem; font-weight: 800; letter-spacing: .4px;
  text-transform: uppercase; color: var(--ce-muted, #8b949e);
  margin: 10px 0 6px;
}
.ce-faq__item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--ce-border, #30363d);
}
.ce-faq__item:last-child { border-bottom: none; padding-bottom: 2px; }
.ce-faq__q, .ce-faq__a {
  display: flex; gap: 10px; align-items: flex-start;
}
.ce-faq__q { margin-bottom: 6px; font-weight: 600; }
.ce-faq__a { color: var(--ce-text, #e6edf3); }
.ce-faq__badge {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; color: #fff; margin-top: 1px;
}
.ce-faq__badge--q { background: var(--ce-accent, #58a6ff); }
.ce-faq__badge--a { background: #15803d; }
.ce-faq__note {
  margin: 6px 0 0 32px; font-size: .75rem; font-style: italic;
  color: var(--ce-muted, #8b949e);
}

/* ── Legal notices ── */
.ce-legal {
  margin-top: 10px; font-size: .68rem; line-height: 1.5;
  color: var(--ce-muted, #8b949e); opacity: .85;
}
.ce-legal--trans { font-style: italic; }
.ce-footer {
  padding: 18px 0 26px; text-align: center;
  font-size: .68rem; line-height: 1.7;
  color: var(--ce-muted, #8b949e); opacity: .8;
  border-top: 1px solid var(--ce-border, #30363d);
}
