.game-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 35px 18px;
    align-items: start;
}

.game-card {
    --element-text: #d1d5db;
    --rarity-color: #ffffff;
    --rarity-glow: rgba(255,255,255,0.38);
    --card-image: none;
    --card-overlay: url('/assets/images/card-details/overlay-water.png');

    width: 100%;
    max-width: 285px;
    margin: 0 auto;
    font-size: 16px;
}

.card-not-owned .game-card {
    opacity: 0.25;
    filter: grayscale(45%);
}

.card-not-owned .user_card_stats {
    border-color: rgba(255,255,255,0.04);
    opacity: 0.65;
}

.game-card-element-earth { --element-text: #9bd765; }
.game-card-element-air { --element-text: #9ee7ff; }
.game-card-element-fire { --element-text: #ff5b4f; }
.game-card-element-dark { --element-text: #c084fc; }
.game-card-element-water { --element-text: #4fa3ff; }
.game-card-element-light { --element-text: #f4d06f; }
.game-card-element-non-elemental,
.game-card-element-none,
.game-card-element-neutral { --element-text: #b8bec8; }

.game-card-rarity-common { 
  color: #DDD;
}
.game-card-rarity-uncommon { 
  --rarity-color: #a855f7;
  --rarity-glow: rgba(168,85,247,0.65); 
  color: #a855f7;
}
.game-card-rarity-rare { 
  --rarity-color: #f5c542; 
  --rarity-glow: rgba(245,197,66,0.68);
  color: #f5c542;
}
.game-card-rarity-legendary {
    --rarity-color: #d9f5ff;
    --rarity-glow: rgba(217,245,255,0.95);
    color: #d9f5ff;
}

.game-card-frame {
    position: relative;
    aspect-ratio: 1039 / 1514;
    overflow: hidden;
    border-radius: 14px;
    background: #020812;
    box-shadow: 0 14px 28px rgba(0,0,0,0.46);
}

/* Art sits behind the transparent overlay. */
.game-card-image {
    position: absolute;
    z-index: 1;
    left: 6.1%;
    right: 6.1%;
    top: 3%;
    height: 55%;
    background-image: var(--card-image);
    background-position: top;
    background-size: cover;
    background-repeat: no-repeat;
}

/* Darkens the bottom of the art so title text remains readable. */
.game-card-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.08) 52%, rgba(0,0,0,0.55) 100%),
        radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.25) 100%);
    pointer-events: none;
}

.game-card-overlay {
    position: absolute;
    z-index: 3;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
}

/* Shared stat text */
.game-card-stat {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff7df;
    text-align: center;
    font-weight: 900;
    line-height: 1;
    text-shadow:
        0 2px 4px #000000,
        0 0 4px rgba(0,0,0,0.95);
}

/* Top left: play cost / movement. */
.game-card-stat-cost_movement {
    left: 2.8%;
    top: 5%;
    width: 23%;
    height: 10%;
    display: flex;
    flex-direction: column;
    gap: 0.25em;
}

.game-card-cost-fraction {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.06em;
    width: 78%;
    height: 78%;
    font-size: 1.1em;
}

.game-card-cost-main,
.game-card-movement {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0.72em;
}

.game-card-cost-divider {
    display: inline-block;
    margin: 0 -0.03em;
    color: rgba(255,255,255,0.75);
    font-size: 0.78em;
}

/* Top right: health. */
.game-card-stat-health {
    right: 6%;
    top: 6%;
    width: 18.4%;
    height: 8%;
}

.game-card-stat-health span {
    width: 72%;
    height: 72%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

/* Bottom stats */
.game-card-stat-attack,
.game-card-stat-defense {
    bottom: 7%;
    width: 18.8%;
    height: 8%;
}

.game-card-stat-attack {
    left: 4%;
}

.game-card-stat-defense {
    right: 4.6%;
}

.game-card-stat-attack span,
.game-card-stat-defense span {
    width: 76%;
    height: 76%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

/* Name should sit centered in the overlay title plate. */
.game-card-title-panel {
    position: absolute;
    z-index: 5;
    left: 17.5%;
    right: 17.5%;
    top: 52.8%;
    height: 6.6%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.game-card-title-panel h3 {
    margin: 0;
    color: #f6ead0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.96em;
    font-variant: small-caps;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: 0.035em;
    text-shadow:
        0 2px 4px rgba(0,0,0,0.95),
        0 0 5px rgba(0,0,0,0.90);
}

.game-card-subline {
    margin-top: 0.15em;
    margin-bottom: 0.5em;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.18em;
    color: var(--element-text);
    font-size: 0.43em;
    font-weight: 900;
    letter-spacing: 0.07em;
    line-height: 1;
    text-transform: uppercase;
    text-shadow: 0 2px 4px #000000;
}

.game-card-subline b {
    color: rgba(246,234,208,0.70);
}

/* Lower info panel: abilities above description. */
.game-card-text-panel {
    position: absolute;
    z-index: 5;
    left: 12%;
    right: 12%;
    top: 61.8%;
    height: 15%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    overflow: hidden;
}

.game-card-description-panel {
    position: absolute;
    z-index: 5;
    left: 23%;
    right: 23%;
    top: 77%;
    height: 15%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    overflow: hidden;
    padding: 0.625em;
}

.game-card-abilities {
    display: flex;
    flex-direction: column;
    gap: 0.18em;
    width: 100%;
    margin: 0 0 0.45em;
}

.game-card-ability {
    display: flex;
    align-items: flex-start;
    gap: 0.75em;
    width: 100%;
    color: rgba(246,234,208,0.96);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.6em;
    line-height: 1.08;
    text-align: left;
    text-shadow: 0 2px 3px #000000;
    margin-bottom: 0.3125em;
}

.game-card-ability-cost {
    flex: 0 0 auto;
    width: 1.8em;
    height: 1.8em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0.125em solid #d7a83f;
    border-radius: 999px;
    background: #ffffff;
    color: #1f1300;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.9em;
    font-style: normal;
    font-weight: 900;
    line-height: 1;
    box-shadow:
        0 0 4px rgba(245,197,66,0.75),
        0 2px 3px rgba(0,0,0,0.9);
    text-shadow: none;
}

.game-card-ability-text {
    display: block;
    min-width: 0;
    padding-top: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-ability-text strong {
    color: #fff4d4;
    font-style: normal;
    font-weight: 900;
}

.game-card-ability-separator {
    color: rgba(246,234,208,0.76);
    font-style: normal;
}

.game-card-text-panel p {
    margin: auto 0 0;
    color: rgba(246,234,208,0.90);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.47em;
    line-height: 1.18;
    text-shadow: 0 2px 4px #000000;
}

.game-card-description-panel p {
    margin: auto 0 0;
    color: rgba(246,234,208,0.90);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.47em;
    font-style: italic;
    line-height: 1.18;
    text-shadow: 0 2px 4px #000000;
}

.game-card-rarity-legendary {
    animation: gameCardPlatinumShine 2.8s ease-in-out infinite;
}

.game-card-stat-wrapper .user_card_stats {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;

    width: 100%;
    margin-top: 8px;
    padding: 10px 14px;

    border-radius: 12px;

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,0.06),
            rgba(255,255,255,0.03)
        );

    border: 1px solid rgba(255,255,255,0.08);

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 4px 12px rgba(0,0,0,0.20);

    color: rgba(246,234,208,0.92);
    font-size: 0.9rem;
    font-weight: 600;
}

.game-card-stat-wrapper .user_card_stats > div {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Star cell grows to fill the row so the progress bar takes as much width as
   the weapon/armor icons leave. */
.game-card-stat-wrapper .user_card_stats .card_star {
    flex: 1 1 auto;
    min-width: 0;
}

/* ---- Weapon / armor equip slots ---- */
.card-equip-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 3px;
    border: none;
    border-radius: 8px;
    background: none;
    line-height: 0;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

button.card-equip-slot:hover,
button.card-equip-slot:focus-visible {
    background: rgba(255,255,255,0.10);
    outline: none;
}

button.card-equip-slot:focus-visible {
    box-shadow: 0 0 0 2px rgba(86,184,255,0.55);
}

button.card-equip-slot:active {
    transform: scale(0.92);
}

.card-equip-icon {
    width: 100%;
    height: 100%;
}

.card-equip-icon path {
    fill: currentColor;
}

/* Empty slot: faded, colourless. */
.card-equip-slot.is-empty {
    color: rgba(246,234,208,0.30);
}

button.card-equip-slot.is-empty:hover,
button.card-equip-slot.is-empty:focus-visible {
    color: rgba(246,234,208,0.55);
}

/* Equipped slots get a slot-specific accent + subtle glow. */
.card-equip-slot-weapon.is-equipped {
    color: #ff8a5b;
    filter: drop-shadow(0 0 3px rgba(255,138,91,0.55));
}

.card-equip-slot-armor.is-equipped {
    color: #6db8ff;
    filter: drop-shadow(0 0 3px rgba(109,184,255,0.55));
}

/* Static (non-owned card) icons are never interactive. */
.card-equip-slot.is-static {
    cursor: default;
}

/* ---- Equip popup menu (mirrors the chat name-menu; card-display.css is
   loaded globally, chat.css is not, so the styles live here). ---- */
.card-equip-menu {
    position: fixed;
    z-index: 1000;
    min-width: 168px;
    max-width: 240px;
    padding: 5px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 8px;
    background: rgba(16,22,34,0.98);
    box-shadow: 0 8px 28px rgba(0,0,0,0.6);
    font-family: Arial, Helvetica, sans-serif;
    color: #e4ecf7;
}

.card-equip-menu-head {
    padding: 6px 10px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #d5a85a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-equip-menu-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 2px 10px 8px;
    font-size: 12px;
    color: #b7c4d6;
}

.card-equip-menu-stats.is-empty {
    font-style: italic;
    color: rgba(183,196,214,0.7);
}

.card-equip-menu-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 6px;
    background: none;
    color: #e4ecf7;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.card-equip-menu-item:hover,
.card-equip-menu-item:focus-visible {
    background: rgba(86,184,255,0.18);
    outline: none;
}

.card-equip-menu-item.is-unequip {
    color: #ff9a8b;
}

.card-equip-menu-item .card-equip-menu-item-stats {
    flex: 0 0 auto;
    font-size: 12px;
    color: rgba(183,196,214,0.85);
    white-space: nowrap;
}

.card-equip-menu-status {
    padding: 12px 14px;
    font-size: 13px;
    color: #b7c4d6;
    text-align: center;
}

/* One stat bonus per line in the star-level info popup. */
.card-equip-menu-statlist {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 10px 8px;
    font-size: 12px;
    color: #b7c4d6;
}

@media (prefers-reduced-motion: reduce) {
    .card-equip-slot { transition: none; }
}

/* Star icon acts as a trigger for its bonus popup. */
.card-star-info {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: none;
    background: none;
    line-height: 0;
    cursor: help;
    flex: 0 0 auto;
}

.card-star-info:focus-visible {
    outline: none;
    border-radius: 6px;
    box-shadow: 0 0 0 2px rgba(86,184,255,0.55);
}

/* Star-level progress: [current star] [bar with "5 / 8 (62.5%)"] [next star] */
.card-star-progress {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.card-star-progress-maxed {
    justify-content: flex-end;
}

.card-star-bar {
    position: relative;
    flex: 1 1 auto;
    min-width: 90px;
    height: 20px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
}

.card-star-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #f5c542, #ffe08a);
    box-shadow: 0 0 6px rgba(245,197,66,0.55);
    transition: width 0.3s ease;
}

/* Three readouts pinned along the bar: current at the left, percent centered,
   required at the right. */
.card-star-bar-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: #fff7df;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    text-shadow:
        0 1px 2px #000000,
        0 0 3px rgba(0,0,0,0.9);
}

.card-star-bar-start { left: 6px; }
.card-star-bar-end { right: 6px; }

.card-star-bar-percent {
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Individual star icon */
.card-star-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.card-star-icon svg {
    width: 100%;
    height: 100%;
}

.card-star-icon svg path {
    fill: var(--star-fill, currentColor);
    stroke: var(--star-stroke, none);
    stroke-width: var(--star-stroke-width, 0);
    stroke-linejoin: round;
    paint-order: stroke;
}

.card-star-level-0 {
    --star-fill: transparent;
    --star-stroke: rgba(246,234,208,0.85);
    --star-stroke-width: 1.6;
}

.card-star-level-1 { /* common */
    --star-fill: #DDD;
    --star-stroke: rgba(0,0,0,0.35);
    --star-stroke-width: 0.8;
}

.card-star-level-2 { /* uncommon */
    --star-fill: #a855f7;
    filter: drop-shadow(0 0 2px rgba(168,85,247,0.55));
}

.card-star-level-3 { /* rare */
    --star-fill: #f5c542;
    filter: drop-shadow(0 0 2px rgba(245,197,66,0.55));
}

.card-star-level-4,
.card-star-level-5 { /* legendary */
    --star-fill: #d9f5ff;
    animation: gameCardStarShine 2.8s ease-in-out infinite;
}

.card-star-pair {
    display: inline-flex;
    align-items: center;
}

.card-star-pair .card-star-icon + .card-star-icon {
    margin-left: -4px;
}

.card-star-progress-maxed .card-star-icon {
    width: 24px;
    height: 24px;
}

@keyframes gameCardStarShine {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(217,245,255,0.5));
    }

    50% {
        filter:
            drop-shadow(0 0 5px rgba(255,255,255,0.85))
            drop-shadow(0 0 8px rgba(160,225,255,0.5));
    }
}

@keyframes gameCardPlatinumShine {
    0%, 100% {
        text-shadow:
            0 0 4px rgba(217,245,255,0.45),
            0 2px 4px rgba(0,0,0,0.90);
    }

    50% {
        text-shadow:
            0 0 7px rgba(255,255,255,0.70),
            0 0 10px rgba(160,225,255,0.45),
            0 2px 4px rgba(0,0,0,0.90);
    }
}

/* Keep fullscreen typography proportional to the enlarged card clone. */
.game-card-fullscreen-preview .game-card-title-panel h3 {
    font-size: 0.96em;
}

.game-card-fullscreen-preview .game-card-subline {
    font-size: 0.43em;
}

.game-card-fullscreen-preview .game-card-ability {
    font-size: 0.6em;
    gap: 0.45rem;
}

.game-card-fullscreen-preview .game-card-ability-cost {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.8rem;
    border-width: 2px;
}

.game-card-fullscreen-preview .game-card-description-panel p,
.game-card-fullscreen-preview .game-card-text-panel p {
    font-size: 0.47em;
}

.game-card-fullscreen-preview .game-card-cost-fraction,
.game-card-fullscreen-preview .game-card-stat-health span,
.game-card-fullscreen-preview .game-card-stat-attack span,
.game-card-fullscreen-preview .game-card-stat-defense span {
    font-size: 1.3em;
}
