.onepiece-page {
    padding: 0 var(--space-16) var(--space-64);
}

.onepiece-page .cards-title h1 {
    margin: 0 0 var(--space-8);
}

.onepiece-page-back {
    margin: 0 0 var(--space-16);
}

.onepiece-set-abbrev {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    margin: 0 0 var(--space-8);
    padding: 4px 10px;
    border: 1px solid var(--colour-border);
    border-radius: 6px;
    background: var(--colour-paper);
    color: var(--colour-text-muted);
    font-family: var(--font-header);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-lg);
}

.onepiece-nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--colour-border);
    border-radius: var(--radius-xs);
    background: var(--colour-paper);
    color: var(--colour-text);
    font-family: var(--font-header);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
    text-decoration: none;
}

.onepiece-nav-link:hover {
    border-color: var(--colour-secondary);
}

.onepiece-filter-form {
    width: min(720px, 100%);
}

.onepiece-filter-form .cards-search-field {
    width: min(720px, 100%);
}

.onepiece-set-expansion-header {
    width: 100%;
}

.onepiece-set-logo .onepiece-set-logo-img {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    max-width: 240px;
    max-height: 150px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

.onepiece-set-search {
    min-width: 0;
}

.onepiece-set-search .exp-search-field {
    width: 100%;
}

.onepiece-set-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.onepiece-grandmaster-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid var(--colour-border);
    border-radius: var(--radius-xs);
    background: var(--colour-paper);
    color: var(--colour-text);
    font-family: var(--font-header);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
    white-space: nowrap;
    cursor: pointer;
}

.onepiece-grandmaster-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--colour-secondary);
    cursor: pointer;
}

.onepiece-select-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(132px, 1fr));
    gap: var(--space-8);
    width: 100%;
}

.onepiece-select-grid.onepiece-set-select-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.onepiece-select-grid label {
    display: grid;
    gap: 4px;
    color: var(--colour-text);
    font-family: var(--font-paragraph);
    font-size: 11px;
    font-weight: var(--font-weight-md);
}

.onepiece-select-grid select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--colour-border);
    border-radius: var(--radius-xs);
    background: var(--colour-paper);
    color: var(--colour-text);
    font-family: var(--font-paragraph);
    font-size: 16px;
}

.onepiece-select-grid.onepiece-set-select-grid select {
    min-height: 36px;
    font-size: var(--text-xs);
}

.onepiece-card-image {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.card-name > a {
    display: contents;
    color: inherit;
    text-decoration: none;
}

.card-img[role="link"] {
    cursor: pointer;
}

.onepiece-filter-hidden,
.onepiece-card-tile[hidden],
.series[hidden],
.series-grid > a[hidden] {
    display: none !important;
}

.onepiece-card-image:focus-visible {
    outline: 2px solid var(--colour-primary);
    outline-offset: 4px;
    border-radius: var(--radius-xs);
}

.onepiece-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    top: 0;
    left: 0;
}

.onepiece-card-fallback {
    display: none;
    position: absolute;
    inset: 0;
    place-items: center;
    padding: var(--space-16);
    background: var(--colour-paper);
    color: var(--colour-text-muted);
    font-family: var(--font-header);
    font-size: var(--text-md);
    font-weight: var(--font-weight-lg);
    text-align: center;
}

.onepiece-card-image--missing .onepiece-card-fallback {
    display: grid;
}

.onepiece-card-info {
    height: 100px;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.onepiece-card-info .card-tracking-info {
    height: 45px;
    padding: 0 0 var(--space-4);
}

.onepiece-card-info .card-name {
    font-family: var(--font-header);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-lg);
    line-height: 1.16;
}

.onepiece-rarity {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 20px;
    padding: 2px 6px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--colour-accent) 25%, transparent);
    color: var(--colour-text);
    font-family: var(--font-header);
    font-size: 11px;
    font-weight: var(--font-weight-lg);
}

.card-number .onepiece-rarity {
    position: static;
    flex: 0 0 auto;
}

.onepiece-card-meta-row {
    grid-template-columns: 74px minmax(0, 1fr) 74px;
    gap: 4px;
    height: 50px;
}

.onepiece-card-actions {
    grid-template-columns: 69.5px 139px 69.5px;
}

.onepiece-popup-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--colour-secondary);
    cursor: pointer;
    justify-self: center;
}

.onepiece-popup-open:focus-visible {
    outline: 2px solid var(--colour-primary);
    outline-offset: 2px;
}

.onepiece-print-status {
    width: 69.5px;
    min-height: 44px;
    justify-self: center;
}

.onepiece-print-status__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 24px;
    border: 1px solid var(--colour-border);
    border-radius: 6px;
    color: var(--colour-text-muted);
    font-family: var(--font-header);
    font-size: 12px;
    font-weight: var(--font-weight-lg);
    line-height: 1;
}

.onepiece-print-status.variant-complete .onepiece-print-status__count {
    border-color: color-mix(in srgb, var(--colour-secondary) 70%, transparent);
    background: color-mix(in srgb, var(--colour-secondary) 20%, transparent);
    color: var(--colour-text);
}

.onepiece-meta-pill,
.onepiece-card-set-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 28px;
    padding: 3px 7px;
    border: 1px solid var(--colour-border);
    border-radius: 6px;
    background: var(--colour-bg);
    color: var(--colour-text);
    font-family: var(--font-paragraph);
    font-size: 11px;
    font-weight: var(--font-weight-md);
    line-height: 1.1;
    text-align: center;
}

.onepiece-card-set-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    justify-content: flex-start;
}

.onepiece-expansion .banner {
    width: 286px;
    height: 400px;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: top center;
    opacity: 0.72;
}

.onepiece-expansion .exp-header p {
    font-size: var(--text-md);
    font-weight: var(--font-weight-lg);
}

.onepiece-exp-logo {
    width: 86%;
    height: 128px;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

.onepiece-expansion .exp-body p {
    width: 92%;
    text-align: center;
    line-height: 1.2;
}

.onepiece-exp-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 26px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.58);
    color: #fff;
    font-family: var(--font-header);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-lg);
    text-shadow: none;
}

.onepiece-empty {
    display: grid;
    place-items: center;
    gap: var(--space-8);
    min-height: 260px;
    padding: var(--space-32);
    background: var(--colour-paper);
    border: 1px solid var(--colour-border);
    border-radius: var(--radius-xs);
    text-align: center;
}

.onepiece-empty h2,
.onepiece-empty p {
    margin: 0;
}

body.onepiece-popup-visible {
    overflow: hidden;
}

.onepiece-popup-overlay #card-popup {
    border-color: var(--colour-secondary);
}

.onepiece-popup-overlay .popup-set-hero-logo {
    max-height: 54px;
}

/* The shared popup's desktop height budgets for pokemon's three set-block
   rows; One Piece renders only the hero + Series row, so trim the fixed
   height to match. Media-scoped so the mobile height:auto override in
   cardPopup.css still wins on small screens. */
@media (min-width: 769px) {
    .onepiece-popup-overlay #card-popup {
        height: min(88vh, calc(var(--card-hight-md) + 212px));
    }
}

.onepiece-popup-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-24);
    padding: 0 var(--space-16) var(--space-16);
}

.onepiece-popup-stat {
    display: grid;
    grid-template-columns: minmax(74px, auto) minmax(0, 1fr);
    align-items: center;
    gap: var(--space-12);
    min-height: 55px;
    border-bottom: 1px solid var(--colour-border);
}

.onepiece-popup-stat--wide {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 3px;
    padding: var(--space-16) 0 var(--space-12);
}

.onepiece-popup-stat__label,
.onepiece-popup-text-section h4 {
    color: var(--colour-text);
    font-family: var(--font-header);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-lg);
    line-height: 1.1;
    white-space: nowrap;
}

.onepiece-popup-stat__value {
    min-width: 0;
    margin: 0;
    color: var(--colour-text);
    font-family: var(--font-paragraph);
    font-size: var(--text-sm);
    line-height: 1.45;
    word-break: break-word;
}

.onepiece-popup-stat--wide .onepiece-popup-stat__value {
    font-size: var(--text-sm);
}

.onepiece-popup-stat__value--attribute {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
}

.onepiece-attribute-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 24px;
    min-width: 24px;
    overflow: visible;
    background: transparent;
    color: var(--colour-text);
    font-family: var(--font-header);
    font-size: 13px;
    font-weight: var(--font-weight-lg);
    line-height: 1;
}

.onepiece-attribute-img {
    width: auto;
    height: 100%;
    max-width: 54px;
    object-fit: contain;
}

.onepiece-attribute-img[hidden] {
    display: none !important;
}

.onepiece-attribute-fallback {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 100%;
    border-radius: 50%;
    background: #0a7f9e;
    color: #fff;
}

.onepiece-attribute-fallback[hidden] {
    display: none !important;
}

.onepiece-popup-text-section {
    grid-column: 1 / -1;
    display: grid;
    gap: var(--space-8);
    padding: var(--space-16) 0;
    border-bottom: 1px solid var(--colour-border);
}

.onepiece-popup-text-section h4,
.onepiece-popup-text-section p {
    margin: 0;
}

.onepiece-popup-text-section p {
    color: var(--colour-text);
    font-family: var(--font-paragraph);
    font-size: var(--text-sm);
    font-style: normal;
    font-weight: var(--font-weight-md);
    line-height: 1.5;
    white-space: pre-line;
}

.onepiece-effect-parenthetical {
    font-style: italic;
    font-weight: var(--font-weight-md);
}

.onepiece-effect-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    margin: 0 2px 2px 0;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    font-family: var(--font-header);
    font-size: 13px;
    font-weight: var(--font-weight-lg);
    line-height: 1;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
    vertical-align: baseline;
}

.onepiece-effect-badge--don {
    background: #111;
    border-radius: 8px;
}

.onepiece-effect-badge--turn,
.onepiece-effect-badge--play,
.onepiece-effect-badge--ko,
.onepiece-effect-badge--activate,
.onepiece-effect-badge--opponent,
.onepiece-effect-badge--default {
    background: #1f8fbd;
    border-radius: 6px;
}

.onepiece-effect-badge--once {
    background: #c83f56;
    border-radius: 999px;
}

.onepiece-effect-badge--counter {
    background: #df2432;
    border-radius: 4px;
}

.onepiece-effect-badge--trigger {
    --onepiece-trigger-angle: 22px;
    position: relative;
    z-index: 1;
    background: #f4dc2f;
    color: #161616;
    border-radius: 4px;
    clip-path: polygon(0 0, 100% 0, calc(100% - var(--onepiece-trigger-angle)) 100%, 0 100%);
    text-shadow: none;
}

.onepiece-effect-trigger-wrap {
    display: inline-flex;
    align-items: center;
    margin: 0 2px 2px 0;
    padding-right: 18px;
    border-radius: 4px;
    background: #111;
    vertical-align: baseline;
}

.onepiece-effect-trigger-wrap .onepiece-effect-badge {
    margin: 0;
}

.onepiece-effect-trigger-line {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 2px 2px 0;
    border-radius: 4px;
    background: #111;
    color: #fff;
    font-family: var(--font-paragraph);
    font-size: var(--text-sm);
    font-style: normal;
    font-weight: var(--font-weight-md);
    line-height: 1.35;
    vertical-align: baseline;
}

.onepiece-effect-trigger-line .onepiece-effect-badge--trigger {
    flex: 0 0 auto;
    align-self: stretch;
    margin: 0;
    padding: 3px 16px 3px 7px;
    min-height: 100%;
}

.onepiece-effect-trigger-text {
    min-width: 0;
    padding: 2px 4px 2px 0;
    white-space: normal;
}

.onepiece-effect-badge--rush,
.onepiece-effect-badge--blocker {
    padding: 2px 9px;
    border-radius: 0;
    background: #f06f2f;
    clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 6px 100%, 0 50%);
}

@media (max-width: 1024px) {
    .onepiece-select-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .onepiece-page {
        padding-inline: var(--space-8);
    }

    .onepiece-filter-form {
        align-items: stretch;
    }

    .onepiece-set-logo .onepiece-set-logo-img {
        max-width: 220px;
        max-height: 120px;
    }

    .onepiece-select-grid {
        grid-template-columns: 1fr;
    }

    .onepiece-select-grid.onepiece-set-select-grid {
        grid-template-columns: 1fr;
    }

    .onepiece-expansion-search {
        margin-inline: 0;
        align-self: stretch;
        width: 100%;
    }

    .onepiece-popup-info {
        grid-template-columns: 1fr;
        column-gap: 0;
    }

}
