  .game-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, calc(var(--gs-u-h) * 16.4));
    gap: calc(var(--gs-u-h) * 1);
    align-items: start;
  }
  .game-card-grid__cell {
    display: flex;
    justify-content: center;
    width: 100%;
  }
  .game-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--gs-u-h) * 0.7);
    align-items: flex-start;
    justify-content: flex-start;
  }
  .game-card-sizing {
    container-type: inline-size;
    container-name: gamecard;
    width: var(--game-card-width, 100%);
    max-width: 100%;
  }

  /* Card face: gamecard cqw only. Shell-scale UI on cards (skill tooltips) uses @container game-stage — not var(--gs-u-*) here. */
  @container gamecard (min-width: 0) {
    .game-card-sizing > .game-card {
      --game-card-fs-a: 11cqw; /* Attack, HP, CD (and stars) */
      --game-card-fs-b: 7.4cqw; /* Title */
      --game-card-fs-c: 6cqw; /* Skills */
    }
  }

  .game-card {
    --game-card-u-min: var(--gs-u-h);
    --game-card-fs-a: 11cqw; /* Attack, HP, CD (and stars) */
    --game-card-fs-b: 7.4cqw; /* Title */
    --game-card-fs-c: 6cqw; /* Skills */
    --game-card-radius: 5cqw;
    --game-card-art-radius: 4.8cqw;
    /* TCG-style inner frame: gutter between outer shell and card face */
    --game-card-frame-inset: 1.85cqw;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-rows: auto 1fr auto;
    width: 100%;
    aspect-ratio: 5 / 7;
    border-radius: var(--game-card-radius);
    overflow: hidden;
    background: var(
      --card-race-surface,
      linear-gradient(165deg, #2c213e 0%, #151022 52%, #0a0610 100%)
    );
    box-shadow:
      0 0 0 1px rgba(255, 200, 140, 0.14),
      0 14px 40px rgba(0, 0, 0, 0.55),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: #f5ebe0;
    font-family: inherit;
    text-align: left;
    /* Cards are game objects, not documents. */
    user-select: none;
  }

  /* Full-view button tooltips use an attribute-trigger pseudo element.
     The card shell intentionally clips most overflow, but for the tooltip we must allow it
     to paint outside the card bounds. */
  .game-card:has(.game-card__full-view[data-tooltip]:hover),
  .game-card:has(.game-card__full-view[data-tooltip]:focus-visible) {
    overflow: visible;
  }

  /* Collector-style finish over race tint (legendary uses transparent shell + frame art). */
  .game-card:not(.legendary-card)::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
    box-shadow:
      inset 0 1px 0 rgba(255, 235, 210, 0.08),
      inset 0 -1px 0 rgba(0, 0, 0, 0.26);
    background:
      radial-gradient(ellipse 125% 52% at 50% -8%, rgba(255, 212, 175, 0.1) 0%, transparent 48%),
      radial-gradient(ellipse 92% 84% at 50% 50%, transparent 38%, rgba(0, 0, 0, 0.17) 100%),
      radial-gradient(118% 72% at 50% 112%, rgba(0, 0, 0, 0.34) 0%, transparent 54%),
      linear-gradient(
        125deg,
        rgba(255, 248, 240, 0.032) 0%,
        transparent 38%,
        transparent 62%,
        rgba(8, 4, 16, 0.065) 100%
      );
  }

  /* Inner rule + matte gutter (non-legendary only; legendary frame is artwork). */
  .game-card:not(.legendary-card)::after {
    content: "";
    position: absolute;
    inset: var(--game-card-frame-inset);
    border-radius: max(2px, calc(var(--game-card-radius) - var(--game-card-frame-inset)));
    pointer-events: none;
    z-index: 0;
    border: 1px solid rgba(255, 212, 175, 0.34);
    box-shadow:
      0 0 0 1px rgba(8, 5, 14, 0.58),
      0 0 0 2px rgba(255, 198, 140, 0.16),
      inset 0 0 0 1px rgba(18, 12, 28, 0.82),
      inset 0 0 0 2px rgba(255, 236, 210, 0.14),
      inset 0 2px 14px rgba(0, 0, 0, 0.14);
  }

  .game-card > * {
    position: relative;
  }
  .game-card__art {
    z-index: 1;
  }
  .game-card__lower {
    z-index: 2;
  }
  .game-card__stats {
    z-index: 4;
  }
  .game-card__race {
    width: 14cqw;
    height: 14cqw;
    display: grid;
    place-items: center;
    z-index: 4;
  }
  .game-card__race--badge {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
  }
  .game-card__race-badge {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.8));
  }
  .game-card__name {
    grid-column: 2;
    font-weight: 800;
    font-size: var(--game-card-fs-b);
    line-height: 0.95;
    letter-spacing: -0.02em;
    text-align: center;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
    max-width: 100%;
    min-width: 0;
    text-wrap: balance;
  }
  .game-card__stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.35cqw;
    width: 100%;
  }
  .game-card__stats .game-card__stars-row {
    justify-self: center;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    gap: 0.12cqw 0.28cqw;
    line-height: 1;
    margin: 0;
    padding: 0 0.25cqw;
    box-sizing: border-box;
  }
  .game-card__star {
    font-size: var(--game-card-fs-a);
    display: inline-block;
    user-select: none;
  }
  .game-card__stats .game-card__star {
    font-size: var(--game-card-fs-a);
  }
  .game-card__star--silver {
    color: #e8eef7;
    text-shadow:
      0 0 0.35em rgba(200, 210, 230, 0.95),
      0 1px 2px rgba(0, 0, 0, 0.85),
      0 0 8px rgba(255, 255, 255, 0.2);
  }
  .game-card__star--gold {
    color: #ffd76a;
    text-shadow:
      0 0 0.45em rgba(255, 200, 90, 0.75),
      0 1px 2px rgba(40, 25, 0, 0.9),
      0 0 10px rgba(255, 220, 120, 0.35);
  }
  .game-card__skills-outer--empty {
    max-height: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
  }
  .game-card__skills-outer--empty .game-card__skills--preview {
    min-height: 0;
    padding: 0;
  }
  .game-card__skills--preview,
  .game-card__skills--full-view {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 1.2cqw 3.2cqw;
    gap: 4.5cqw;
    border: none;
    background: transparent;
    box-shadow: none;
    font-size: var(--game-card-fs-c);
    line-height: 1.2;
    font-weight: 600;
    color: rgba(244, 234, 220, 0.96);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .game-card__full-view {
    position: absolute;
    top: 19.5cqw;
    right: 4.8cqw;
    width: 8.4cqw;
    height: 8.4cqw;
    min-width: 8.4cqw;
    min-height: 8.4cqw;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #ffd78a;
    background: rgba(15, 11, 24, 0.78);
    border: 1px solid rgba(255, 205, 145, 0.4);
    box-shadow:
      inset 0 1px 0 rgba(255, 230, 190, 0.08),
      0 2px 10px rgba(0, 0, 0, 0.45);
    z-index: 6;
  }

  /* `game-tooltip.css` sets `[data-tooltip]{ position: relative }` for pseudo anchoring.
   * `game-card__full-view` must remain absolute (top/right sizing), or it flows into layout and
   * the rest of the card composition (including `game-card__name`) will visually drift.
   */
  .game-card__full-view[data-tooltip] {
    position: absolute;
  }

  .game-card__full-view[data-tooltip]::after {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
  }
  .game-card__full-view:hover {
    color: var(--gs-text-nav-hover);
    background: rgba(24, 18, 36, 0.86);
    border-color: rgba(255, 220, 170, 0.55);
  }
  .game-card__full-view:focus-visible {
    outline: 2px solid #ffd78a;
    outline-offset: 2px;
  }
  .game-card__full-view-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70%;
    height: 70%;
  }
  .game-card__full-view-icon svg {
    width: 100%;
    height: 100%;
    display: block;
  }
  .game-card__fx-val {
    font-weight: 700;
  }
  .game-card__skills .game-card__fx-val,
  .game-card__skills-dialog .game-card__skills .game-card__fx-val {
    color: #9fd9ff;
    text-shadow: 0 0 6px rgba(120, 200, 255, 0.28);
  }
  .game-card__skill-icons {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6cqw;
    width: auto;
    min-height: 0;
    padding: 1cqw 1.2cqw;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: pointer;
    z-index: 6;
  }
  .game-card:not(.legendary-card) > .game-card__skill-icons {
    left: calc(var(--slot-atk-left) + var(--slot-chip-size));
    right: calc(var(--slot-hp-right) + var(--slot-chip-size));
    bottom: var(--slot-chip-bottom);
    height: var(--slot-chip-size);
  }
  .game-card.legendary-card > .game-card__skill-icons {
    left: var(--slot-skills-left);
    right: var(--slot-skills-right);
    bottom: var(--slot-skills-bottom);
    min-height: var(--slot-skills-height);
    z-index: 20;
  }
  .game-card__skill-icon {
    /* Baked-in frame on exported WebP (64×64, ~3px/side) — zoom past it so only art fills the circle. */
    --skill-icon-master-size: 64;
    --skill-icon-art-inset: 3;
    position: relative;
    width: 12cqw;
    height: 12cqw;
    border-radius: 50%;
    border: 1px solid rgba(255, 210, 150, 0.35);
    background: rgba(10, 8, 18, 0.85);
    box-shadow:
      inset 0 1px 0 rgba(255, 240, 210, 0.1),
      0 1px 4px rgba(0, 0, 0, 0.45);
    overflow: visible;
  }
  .game-card__skill-icon-clip {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    pointer-events: none;
  }
  /* Cover + slight zoom: strips intrinsic border; clip keeps circle; badge stays outside this span. */
  .game-card__skill-icon-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transform: scale(
      calc(
        var(--skill-icon-master-size) /
          (var(--skill-icon-master-size) - 2 * var(--skill-icon-art-inset))
      )
    );
    transform-origin: center center;
    pointer-events: none;
  }
  .game-card__skill-icon-badge {
    position: absolute;
    z-index: 1;
    right: -0.6cqw;
    bottom: -0.8cqw;
    min-width: 6cqw;
    height: 4.6cqw;
    border-radius: 2.4cqw;
    padding: 0 0.9cqw;
    background: rgba(6, 6, 12, 0.9);
    border: 1px solid rgba(255, 220, 170, 0.35);
    color: #f3e5c8;
    font-size: 3.6cqw;
    line-height: 4.4cqw;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
  }
  .game-card__skills-outer--icons-ready .game-card__skills--preview {
    display: block;
  }
  .game-card__skills b,
  .game-card__skills-dialog .game-card__skills b {
    font-weight: 800;
    color: #c8b8ff;
    text-shadow: 0 0 10px rgba(180, 160, 255, 0.22);
  }
  .game-card__skill-line {
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .game-card__skill-line + .game-card__skill-line {
    margin-top: 0.2em;
  }
  .game-card__skills-dialog {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    padding: 0;
    border: none;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    display: none;
    background: transparent;
    color: #f5ebe0;
    color-scheme: dark;
    box-sizing: border-box;
  }
  .game-card__skills-dialog[open] {
    display: grid;
    place-items: center;
    align-content: safe center;
    background: rgba(4, 2, 12, 0.72);
    backdrop-filter: blur(4px);
    /* Scroll here so the dialog shell stays `overflow: visible` and does not clip shell shadows. */
    overflow-x: hidden;
    overflow-y: auto;
    padding: calc(var(--gs-u-h) * 1.25);
    box-sizing: border-box;
  }
  .game-card__skills-dialog::backdrop {
    background: rgba(4, 2, 12, 0.72);
    backdrop-filter: blur(4px);
  }
  .game-card__skills-dialog-panel.game-card-sizing--dialog {
    position: relative;
    display: block;
    overflow: visible;
    box-sizing: border-box;
    container-type: inline-size;
    container-name: gamecard;
    --game-card-dialog-pad: calc(var(--gs-u-h) * 1.55);
    --game-card-dialog-content-height: min(
      calc(var(--gs-u-h) * 86),
      calc(100% - var(--game-card-dialog-pad) * 2)
    );
    padding: var(--game-card-dialog-pad);
    height: calc(var(--game-card-dialog-content-height) + var(--game-card-dialog-pad) * 2);
    width: calc((var(--game-card-dialog-content-height) * 5 / 7) + var(--game-card-dialog-pad) * 2);
    max-width: calc(var(--gs-u-w) * 96);
    min-width: 0;
    min-height: 0;
    margin: 0 auto;
    --game-card-width: 100%;
  }

  /* Zoom replica: allow outer shell shadow + legendary decal to paint outside the content box (bleed absorbed by padding on the merged shell). */
  .game-card-sizing--dialog > .game-card.game-card--dialog {
    overflow: visible;
  }

  .game-card__skills-dialog-title {
    margin: 0 0 calc(var(--gs-u-h) * 0.55);
    font-size: var(--gs-text-lg);
    font-weight: 800;
    line-height: 1.15;
    color: #fff8ec;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
    text-align: center;
    text-wrap: balance;
  }

  .game-card__cd-wrap {
    grid-column: 3;
    width: 14cqw;
    height: 14cqw;
    justify-self: center;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    z-index: 4;
  }
  .game-card__cd {
    font-size: var(--game-card-fs-a);
    font-weight: 900;
    line-height: 1;
    color: #fff7cf;
    text-shadow:
      0 2px 2px rgba(0, 0, 0, 0.85),
      0 0 8px rgba(255, 230, 120, 0.45);
  }
  .game-card__art {
    align-self: stretch;
    min-height: 0;
    margin: 0 5cqw;
    border-radius: var(--game-card-art-radius);
    overflow: hidden;
    border: 1px solid rgba(255, 200, 140, 0.12);
    background: #08050c;
  }
  .game-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 18%;
    display: block;
  }

  /* Combat hand: optional 4-frame idle strip (512×128), fills art area like `.game-card__img`. */
  .game-card__sprite-idle {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
    box-sizing: border-box;
    background-color: transparent;
    background-image: var(--game-card-idle-sprite-url);
    background-repeat: no-repeat;
    background-position: 0 18%;
    background-size: 400% 100%;
    image-rendering: auto;
    animation: game-card-idle-sprite-frames 1.5s steps(4) infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .game-card__sprite-idle {
      animation: none;
      background-position: 0 18%;
    }
  }

  @keyframes game-card-idle-sprite-frames {
    from {
      background-position: 0 18%;
    }
    to {
      background-position: 133.333333% 18%;
    }
  }
  /* Dialog large card needs this block to shrink/grow inside the fixed aspect shell. */
  .game-card:not(.game-card--dialog) .game-card__lower {
    flex-shrink: 0;
  }
  .game-card__lower {
    padding: 3.8cqw 5.5cqw 5.2cqw;
    display: flex;
    flex-direction: column;
    gap: 3.2cqw;
    min-height: 0;
    margin-top: auto;
  }
  .game-card__lower .game-card__stats {
    margin-top: auto;
  }
  .game-card__stat {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .game-card__stat--atk {
    justify-self: start;
    align-items: flex-start;
  }
  .game-card__stat--hp {
    justify-self: end;
    align-items: flex-end;
    text-align: right;
  }

  .game-card__stat-value {
    font-weight: 900;
    line-height: 1;
    color: #fff7cf;
    font-size: var(--game-card-fs-a);
    letter-spacing: 0.02em;
    text-shadow:
      0 2px 2px rgba(0, 0, 0, 0.85),
      0 0 8px rgba(255, 230, 120, 0.45);
  }
  .game-card__damage-type-icon {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: calc(var(--game-card-stat-size, 12.5cqw) * 0.92);
    height: calc(var(--game-card-stat-size, 12.5cqw) * 0.92);
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.65));
    z-index: 1;
  }
  .game-card__damage-type-icon--back {
    opacity: 1;
    z-index: 1;
  }
  .game-card__damage-type-icon--front {
    opacity: 0.33;
    z-index: 3;
  }
  .game-card__atk-stack {
    display: inline-grid;
    place-items: center;
  }
  .game-card__atk-stack .game-card__stat-value {
    position: relative;
    z-index: 2;
  }
  .game-card__stat--atk .game-card__stat-value {
    color: #e2eaf5;
    text-shadow:
      0 0 1px rgba(0, 0, 0, 0.75),
      0 -2px 5px rgba(0, 0, 0, 1),
      0 1px 3px rgba(0, 0, 0, 0.75);
  }
  .game-card__stat--hp .game-card__stat-value {
    color: #f0b0b0;
    text-shadow:
      0 0 0.35em rgba(240, 150, 150, 0.35),
      0 1px 3px rgba(0, 0, 0, 0.75);
  }

/* Slot-based composition map: fixed independent anchors. */
.game-card {
  --slot-art-top: 20%;
  --slot-art-left: 6%;
  --slot-art-right: 6%;
  --slot-art-bottom: 15%;

  --slot-title-top: 4%;
  --slot-title-left: 21%;
  --slot-title-right: 21%;

  --slot-stars-top: 11.5%;
  --slot-stars-left: 25%;
  --slot-stars-right: 25%;

  --slot-chip-size: 13%;
  --slot-chip-top: 2%;
  --slot-chip-x: 6%;
  --slot-race-left: var(--slot-chip-x);
  --slot-cd-right: var(--slot-chip-x);
  --slot-atk-left: var(--slot-chip-x);
  --slot-hp-right: var(--slot-chip-x);
  --slot-chip-bottom: 2%;
  --slot-stats-bottom: var(--slot-chip-bottom);

  --slot-skills-left: var(--slot-art-left);
  --slot-skills-right: var(--slot-art-right);
  --slot-skills-bottom: 16%;
  --slot-skills-height: 18%;
}

.game-card__name {
  position: absolute;
  top: var(--slot-title-top);
  left: var(--slot-title-left);
  right: var(--slot-title-right);
  text-align: center;
  transform: translateY(var(--slot-title-translate-y, 0));
}

.game-card:not(.legendary-card) .game-card__name {
  height: calc(var(--slot-stars-top) - var(--slot-title-top));
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
}

.game-card__race {
  position: absolute;
  top: var(--slot-chip-top);
  left: var(--slot-race-left);
  width: var(--slot-chip-size);
  height: var(--slot-chip-size);
}

.game-card__cd-wrap {
  position: absolute;
  top: var(--slot-chip-top);
  right: var(--slot-cd-right);
  width: var(--slot-chip-size);
  height: var(--slot-chip-size);
}

.game-card__art {
  position: absolute;
  top: var(--slot-art-top);
  left: var(--slot-art-left);
  right: var(--slot-art-right);
  bottom: var(--slot-art-bottom);
  margin: 0;
}

.game-card__lower {
  position: absolute;
  inset: 0;
  padding: 0;
  gap: 0;
  pointer-events: none;
}

.game-card__skills-outer {
  position: absolute;
  left: var(--slot-skills-left);
  right: var(--slot-skills-right);
  bottom: var(--slot-skills-bottom);
  height: auto;
  min-height: var(--slot-skills-height);
  border-radius: 3.4cqw;
  border: 1px solid rgba(255, 205, 150, 0.18);
  background: rgba(14, 10, 22, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.07);
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  z-index: 5;
}

/* Surface cards: text overlay over artwork — collapsed overlay must not capture taps (e.g. combat placement through card art). Icons strip toggles open; overlay clicks only dismiss when visible (see game-card.js). */
.game-card:not(.game-card--dialog) > .game-card__skills-outer[data-game-card-skills] {
  top: var(--slot-art-top);
  left: var(--slot-art-left);
  right: var(--slot-art-right);
  bottom: var(--slot-art-bottom);
  min-height: 0;
  border-radius: var(--game-card-art-radius);
  border: none;
  background: linear-gradient(
    180deg,
    rgba(7, 5, 12, 0.78) 0%,
    rgba(7, 5, 12, 0.52) 48%,
    rgba(7, 5, 12, 0.18) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(255, 220, 170, 0.12);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  cursor: default;
  transform: translateY(1.2cqw);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.game-card:not(.game-card--dialog).game-card--skills-preview-pinned
  > .game-card__skills-outer[data-game-card-skills] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

/* Zoom dialog inner card: same overlay pointer rule — collapsed overlay must not steal hits. */
.game-card.game-card--dialog > .game-card__skills-outer {
  top: var(--slot-art-top);
  left: var(--slot-art-left);
  right: var(--slot-art-right);
  bottom: var(--slot-art-bottom);
  min-height: 0;
  border-radius: var(--game-card-art-radius);
  border: none;
  background: linear-gradient(
    180deg,
    rgba(7, 5, 12, 0.78) 0%,
    rgba(7, 5, 12, 0.52) 48%,
    rgba(7, 5, 12, 0.18) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(255, 220, 170, 0.12);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  cursor: default;
  transform: translateY(1.2cqw);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.game-card.game-card--dialog.game-card--skills-preview-pinned > .game-card__skills-outer {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

/* Army / library preview: unowned catalog cards gray in the singleton lightbox. */
.game-card__skills-dialog-panel--catalog-locked > .game-card.game-card--dialog {
  filter: grayscale(0.85) brightness(0.55);
}

/* Missing-units mode: full-size view matches spellbook — art only. */
.game-card__skills-dialog-panel--catalog-missing > .game-card.game-card--dialog .game-card__img {
  filter: grayscale(1) brightness(0.42);
}

/* Overlay / dialog: grid fill + inset padding (shared --preview / --full-view base earlier in file). */
.game-card:not(.game-card--dialog) > .game-card__skills-outer[data-game-card-skills] .game-card__skills--preview,
.game-card.game-card--dialog > .game-card__skills-outer .game-card__skills--full-view {
  display: grid;
  align-content: start;
  height: 100%;
  padding: 3cqw;
  overflow: hidden;
}

.game-card__stats {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.game-card__stat {
  display: grid;
  place-items: center;
}

.game-card__stat--atk {
  position: absolute;
  left: var(--slot-atk-left);
  bottom: var(--slot-chip-bottom);
  width: var(--slot-chip-size);
  height: var(--slot-chip-size);
}

.game-card__stat--hp {
  position: absolute;
  right: var(--slot-hp-right);
  bottom: var(--slot-chip-bottom);
  width: var(--slot-chip-size);
  height: var(--slot-chip-size);
  text-align: center;
}

.game-card__stats .game-card__stars-row {
  position: absolute;
  top: var(--slot-stars-top);
  left: var(--slot-stars-left);
  right: var(--slot-stars-right);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25cqw;
  line-height: 1;
  padding: 0;
}

  /* Race-themed card shell + emblem (shared with `.library-tile--race-*` in card-library.css). */
  .game-card--race-human,
  .library-tile--race-human {
    --card-race-surface:
      radial-gradient(92% 58% at 12% 8%, rgba(255, 220, 185, 0.14) 0%, transparent 52%),
      radial-gradient(90% 68% at 88% 90%, rgba(42, 52, 68, 0.26) 0%, transparent 56%),
      linear-gradient(165deg, #7a6042 0%, #4a3a2a 52%, #1a1d24 100%);
    --card-race-disk: linear-gradient(145deg, #b08a5a 0%, #4c5668 100%);
    --card-race-disk-border: rgba(218, 186, 142, 0.45);
    --card-race-icon-color: #f8efde;
  }
  .game-card--race-elf,
  .library-tile--race-elf {
    --card-race-surface:
      radial-gradient(105% 78% at 18% 12%, rgba(175, 230, 150, 0.22) 0%, rgba(175, 230, 150, 0) 52%),
      radial-gradient(115% 88% at 82% 84%, rgba(110, 170, 95, 0.2) 0%, rgba(110, 170, 95, 0) 58%),
      linear-gradient(154deg, rgba(250, 224, 142, 0) 40%, rgba(250, 224, 142, 0.6) 49%, rgba(250, 224, 142, 0) 58%),
      linear-gradient(171deg, rgba(221, 184, 95, 0) 30%, rgba(221, 184, 95, 0.42) 36%, rgba(221, 184, 95, 0) 44%),
      linear-gradient(165deg, #184c29 0%, #256637 24%, #2f7a3f 46%, #2a6f3a 68%, #163f23 100%);
    --card-race-disk: linear-gradient(145deg, #66b06a 0%, #2e6f39 100%);
    --card-race-disk-border: rgba(222, 192, 108, 0.44);
    --card-race-icon-color: #fff2c8;
  }
  .game-card--race-faefolk,
  .library-tile--race-faefolk {
    --card-race-surface:
      radial-gradient(80% 65% at 14% 8%, rgba(255, 210, 252, 0.34) 0%, rgba(255, 210, 252, 0) 60%),
      radial-gradient(95% 75% at 86% 20%, rgba(190, 228, 255, 0.28) 0%, rgba(190, 228, 255, 0) 64%),
      radial-gradient(110% 92% at 72% 92%, rgba(166, 255, 208, 0.22) 0%, rgba(166, 255, 208, 0) 66%),
      linear-gradient(155deg, rgba(255, 255, 255, 0.24) 4%, rgba(255, 255, 255, 0) 26%),
      linear-gradient(167deg, #7a68d6 0%, #5b4cc0 30%, #3f3f95 55%, #2e7f72 78%, #1a5149 100%);
    --card-race-disk: linear-gradient(145deg, #caa9ff 0%, #8f7be0 42%, #56b39a 100%);
    --card-race-disk-border: rgba(225, 206, 255, 0.5);
    --card-race-icon-color: #fff4ff;
  }
  .game-card--race-undead,
  .library-tile--race-undead {
    --card-race-surface:
      radial-gradient(88% 62% at 16% 10%, rgba(190, 175, 230, 0.14) 0%, transparent 54%),
      radial-gradient(100% 78% at 82% 88%, rgba(18, 16, 32, 0.65) 0%, transparent 58%),
      linear-gradient(165deg, #3b3548 0%, #1b1828 52%, #0a0a12 100%);
    --card-race-disk: linear-gradient(145deg, #7a6aa0 0%, #2f2942 100%);
    --card-race-disk-border: rgba(188, 172, 222, 0.34);
    --card-race-icon-color: #eee8ff;
  }
  .game-card--race-goblin,
  .library-tile--race-goblin {
    --card-race-surface:
      radial-gradient(85% 55% at 14% 12%, rgba(140, 200, 95, 0.13) 0%, transparent 54%),
      radial-gradient(95% 72% at 85% 82%, rgba(120, 80, 18, 0.35) 0%, transparent 58%),
      linear-gradient(165deg, #3a5c28 0%, #61450f 42%, #0e1a0a 100%);
    --card-race-disk: linear-gradient(145deg, #6a9048 0%, #4a3818 100%);
    --card-race-disk-border: rgba(220, 200, 120, 0.4);
    --card-race-icon-color: #f0ecc8;
  }
  .game-card--race-beast,
  .library-tile--race-beast {
    --card-race-surface:
      radial-gradient(88% 56% at 18% 6%, rgba(255, 210, 120, 0.14) 0%, transparent 50%),
      radial-gradient(95% 74% at 78% 88%, rgba(55, 35, 8, 0.48) 0%, transparent 58%),
      linear-gradient(165deg, #685020 0%, #382a10 52%, #1c1408 100%);
    --card-race-disk: linear-gradient(145deg, #d0a040 0%, #785018 100%);
    --card-race-disk-border: rgba(255, 220, 140, 0.42);
    --card-race-icon-color: #fff0c8;
  }
  .game-card--race-monster,
  .library-tile--race-monster {
    --card-race-surface:
      radial-gradient(82% 60% at 22% 8%, rgba(255, 90, 40, 0.14) 0%, transparent 50%),
      radial-gradient(100% 80% at 72% 86%, rgba(20, 10, 70, 0.42) 0%, transparent 56%),
      linear-gradient(165deg, #4d1c00 0%, #080034 52%, #080808 100%);
    --card-race-disk: linear-gradient(145deg, #404040 0%, #202020 100%);
    --card-race-disk-border: rgba(200, 200, 200, 0.42);
    --card-race-icon-color: #f0f0f0;
  }
  .game-card--race-infernal,
  .library-tile--race-infernal {
    --card-race-surface:
      radial-gradient(88% 62% at 50% 28%, rgba(255, 120, 45, 0.22) 0%, transparent 54%),
      radial-gradient(95% 72% at 82% 88%, rgba(30, 8, 8, 0.52) 0%, transparent 58%),
      linear-gradient(165deg, #8a2418 0%, #3a1410 46%, #0c0808 100%);
    --card-race-disk: linear-gradient(145deg, #e87830 0%, #9a2818 52%, #2a1010 100%);
    --card-race-disk-border: rgba(255, 150, 70, 0.46);
    --card-race-icon-color: #ffe8d4;
  }
  .game-card--race-celestial,
  .library-tile--race-celestial {
    --card-celestial-text-color: #8a6418;
    --card-celestial-text-shadow:
      0 1px 0 rgba(255, 244, 210, 0.5),
      0 1px 2px rgba(255, 255, 255, 0.32),
      0 1px 4px rgba(0, 48, 64, 0.52),
      0 2px 5px rgba(0, 0, 0, 0.38);
  }

  .game-card--race-celestial:not(.legendary-card),
  .library-tile--race-celestial:not(.legendary-card) {
    /* White→cerulean→gold: hard stop before gold (no blue↔gold lerp), then metallic sheen overlay. */
    --card-race-surface:
      linear-gradient(
        128deg,
        transparent 40%,
        rgba(228, 250, 255, 0.92) 48%,
        rgba(41, 74, 219, 0.72) 54%,
        transparent 64%
      ),
      radial-gradient(88% 62% at 14% 10%, rgba(255, 255, 255, 0.52) 0%, transparent 54%),
      linear-gradient(
        165deg,
        #ffffff 0%,
        #eefaff 14%,
        #98dcff 53%,
        #30b8e0 58%,
        #0098c0 70%,
        #0098c0 82%,
        #0080c0 100%
      );
    --card-race-disk:
      linear-gradient(
        132deg,
        transparent 36%,
        rgba(255, 250, 220, 0.88) 46%,
        rgba(255, 232, 140, 0.55) 54%,
        transparent 66%
      ),
      linear-gradient(
        240deg,
        #ffffff 0%,
        #48c8e8 30%,
        #0098c0 44%,
        #0098c0 48%,
        #ffc818 56%,
        #fff4c8 68%,
        #ffe878 78%,
        #f0b008 100%
      );
    --card-race-disk-border: rgba(255, 236, 160, 0.62);
    --card-race-icon-color: #fffce8;
  }

  .game-card--race-celestial:not(.legendary-card) .game-card__name {
    color: var(--card-celestial-text-color);
    text-shadow: var(--card-celestial-text-shadow);
  }

  .library-tile--race-celestial:not(.legendary-card) .library-tile__name {
    color: var(--card-celestial-text-color);
    text-shadow: var(--card-celestial-text-shadow);
  }

  .game-card--race-spell,
  .library-tile--race-spell {
    --card-race-surface:
      radial-gradient(85% 62% at 14% 12%, rgba(200, 160, 255, 0.16) 0%, transparent 54%),
      radial-gradient(95% 76% at 88% 72%, rgba(255, 140, 60, 0.12) 0%, transparent 56%),
      linear-gradient(165deg, #403070 0%, #221840 52%, #4a1a05 100%);
    --card-race-disk: linear-gradient(145deg, #8860d8 0%, #483090 100%);
    --card-race-disk-border: rgba(200, 170, 255, 0.45);
    --card-race-icon-color: #ece0ff;
  }
  .game-card--race-other,
  .library-tile--race-other {
    --card-race-surface:
      radial-gradient(88% 60% at 16% 10%, rgba(200, 185, 228, 0.12) 0%, transparent 54%),
      radial-gradient(96% 74% at 84% 88%, rgba(12, 10, 22, 0.55) 0%, transparent 58%),
      linear-gradient(165deg, #383048 0%, #1c1828 52%, #0e0c14 100%);
    --card-race-disk: linear-gradient(145deg, #706080 0%, #383044 100%);
    --card-race-disk-border: rgba(210, 190, 230, 0.35);
    --card-race-icon-color: #ebe4f2;
  }

  /* Shared game-shell checkbox look and feel. */
  .game-shell input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: calc(var(--gs-u-h) * 1.02);
    height: calc(var(--gs-u-h) * 1.02);
    margin: 0;
    flex: 0 0 auto;
    border-radius: calc(var(--gs-u-h) * 0.25);
    border: 1px solid rgba(226, 180, 112, 0.62);
    background:
      radial-gradient(circle at 24% 20%, rgba(255, 229, 178, 0.2) 0%, transparent 58%),
      linear-gradient(160deg, rgba(38, 28, 52, 0.96) 0%, rgba(18, 13, 28, 0.96) 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 229, 178, 0.14),
      inset 0 -1px 0 rgba(0, 0, 0, 0.42),
      0 0 0 1px rgba(0, 0, 0, 0.3);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition:
      border-color 140ms ease,
      box-shadow 140ms ease,
      background 140ms ease,
      transform 90ms ease;
  }

  .game-shell input[type="checkbox"]::before {
    content: "";
    width: calc(var(--gs-u-w) * 0.58);
    height: calc(var(--gs-u-h) * 0.58);
    clip-path: polygon(14% 53%, 0 67%, 39% 100%, 100% 18%, 84% 3%, 38% 66%);
    transform: scale(0);
    transform-origin: center;
    transition: transform 130ms ease-in-out;
    background: linear-gradient(180deg, #fff1d5 0%, #f4c97d 100%);
    filter: drop-shadow(0 0 2px rgba(255, 199, 112, 0.5));
  }

  .game-shell input[type="checkbox"]:hover {
    border-color: rgba(246, 208, 146, 0.92);
    box-shadow:
      inset 0 1px 0 rgba(255, 235, 198, 0.18),
      inset 0 -1px 0 rgba(0, 0, 0, 0.48),
      0 0 0 1px rgba(0, 0, 0, 0.34),
      0 0 12px rgba(255, 171, 74, 0.18);
  }

  .game-shell input[type="checkbox"]:active {
    transform: translateY(1px);
  }

  .game-shell input[type="checkbox"]:checked::before {
    transform: scale(1);
  }

  .game-shell input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(255, 221, 170, 0.92);
    outline-offset: 2px;
  }

  .game-shell input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.55;
  }

/* Card skill tooltips — direct children of .town-field.game-stage (GameCardSkillTooltips.vue).
   Literal 1cqw/1cqh only: var(--gs-u-*) re-resolves against nested gamecard / army-book-cell. */
.town-field.game-stage > .game-card__skill-tooltip.game-tooltip {
  --game-tooltip-gap: calc(0.32 * 1cqh);
  z-index: 620;
  width: max-content;
  max-width: 22cqw;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(0.22 * 1cqh);
  padding: calc(0.36 * 1cqh) calc(0.52 * 1cqw);
  border-radius: calc(0.58 * 1cqh);
  border: max(1px, calc(0.1 * 1cqh)) solid rgba(255, 210, 160, 0.42);
  background: rgba(22, 16, 10, 0.97);
  box-shadow: 0 calc(0.45 * 1cqw) calc(1.25 * 1cqh) rgba(0, 0, 0, 0.58);
  font-size: calc(1.45 * 1cqh);
  color: #f0e4cf;
  line-height: 1.35;
  text-align: left;
  box-sizing: border-box;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: none;
}

.town-field.game-stage > .game-card__skill-tooltip.game-tooltip[hidden] {
  display: none !important;
}

@supports (anchor-name: --a) {
  .town-field.game-stage > .game-card__skill-tooltip.game-tooltip {
    position: fixed;
    left: anchor(center);
    top: anchor(top);
    bottom: auto;
    right: auto;
    transform: translate(-50%, calc(-100% - var(--game-tooltip-gap)));
  }
}

.town-field.game-stage > .game-card__skill-tooltip.game-tooltip .game-tooltip__lines {
  display: flex;
  flex-direction: column;
  gap: calc(0.16 * 1cqh);
  align-items: flex-start;
}

.town-field.game-stage > .game-card__skill-tooltip.game-tooltip .game-tooltip__line {
  margin: 0;
  font-size: calc(1.45 * 1cqh);
  color: #d8ccb8;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

@media (hover: none), (pointer: coarse) {
  .town-field.game-stage > .game-card__skill-tooltip.game-tooltip {
    display: none !important;
  }
}

/* Skill tooltip effect copy — content only, same as card skill region. */
.game-card__skill-tooltip-fx .game-card__fx-val {
  font-weight: 800;
  color: #9fd9ff;
  text-shadow: 0 0 6px rgba(120, 200, 255, 0.28);
}

.game-card__skill-tooltip-fx b {
  font-weight: 800;
  color: #c8b8ff;
  text-shadow: 0 0 10px rgba(180, 160, 255, 0.22);
}

/* Ability overflow chip (+N hidden abilities) — combat board + hand cards. */
.game-card__skill-icon--overflow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 12cqw;
  height: 12cqw;
  max-width: 12cqw;
  min-width: 0;
  overflow: hidden;
}

.game-card__skill-icon-overflow {
  font-weight: 700;
  color: #f3e5c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  line-height: 1;
  font-size: 3.6cqw;
  white-space: nowrap;
}
