.team-sheet,
.team-sheet *,
.team-sheet *::before,
.team-sheet *::after {
    box-sizing: border-box;
}

.team-sheet {
    --format-accent: #3467b8;
    --format-contrast: #b33758;
    width: 100%;
    min-width: 0;
    container-type: inline-size;
    padding: 0.9rem;
    background: #f1f3f6;
    color: #182230;
    font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.team-sheet--swsh {
    --format-accent: #0b7f91;
    --format-contrast: #c33b50;
    background: #eef3f4;
}

.team-sheet--sv {
    --format-accent: #5b4ca6;
    --format-contrast: #c1414d;
    background: #f2f1f5;
}

.team-sheet--champions {
    --format-accent: #16734f;
    --format-contrast: #b88a19;
    background: #ecefed;
}

.team-sheet__overview {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
    padding: 0.15rem 0.25rem 0.85rem;
    border-bottom: 2px solid var(--format-accent);
}

.team-sheet__identity {
    min-width: 0;
}

.team-sheet__kicker {
    display: block;
    margin-bottom: 0.25rem;
    color: #687386;
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}

.team-sheet__title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    min-width: 0;
}

.team-sheet__title-row h2 {
    min-width: 0;
    margin: 0;
    color: #111927;
    font-size: 1.5rem;
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.team-sheet__format-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.team-sheet__format-tags span,
.team-sheet__format-tags strong {
    padding: 0.2rem 0.42rem;
    border-radius: 3px;
    font-size: 0.68rem;
    line-height: 1.2;
}

.team-sheet__format-tags span {
    background: var(--format-accent);
    color: #fff;
    font-weight: 850;
}

.team-sheet__format-tags strong {
    border: 1px solid #cfd5df;
    background: #fff;
    color: #334054;
    font-weight: 800;
}

.team-sheet__issues {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin: 0 0 0.8rem;
    padding: 0.55rem 0.65rem;
    border-left: 3px solid #b76b16;
    background: #fff7e8;
    color: #70430d;
    font-size: 0.72rem;
    font-weight: 700;
}

.team-sheet__status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.48rem;
    border: 1px solid #cfd5df;
    border-radius: 999px;
    color: #526071;
    font-size: 0.68rem;
    font-weight: 750;
}

.team-sheet__status .rzi {
    font-size: 0.85rem;
}

.team-sheet__count {
    display: grid;
    grid-template-columns: auto auto;
    align-items: baseline;
    flex: 0 0 auto;
    min-width: 4.5rem;
    color: #111927;
    text-align: right;
}

.team-sheet__count strong {
    font-size: 1.65rem;
    font-weight: 900;
    line-height: 1;
}

.team-sheet__count > span {
    color: #7b8797;
    font-size: 0.82rem;
    font-weight: 700;
}

.team-sheet__count small {
    grid-column: 1 / -1;
    margin-top: 0.2rem;
    color: #687386;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0;
}

.team-sheet__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.pokemon-loadout {
    --pokemon-accent: #687386;
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 17.6rem;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #d7dce5;
    border-top: 3px solid var(--pokemon-accent);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 7px 20px rgba(25, 34, 48, 0.08);
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.pokemon-loadout:hover {
    transform: translateY(-2px);
    border-color: #b9c1ce;
    border-top-color: var(--pokemon-accent);
    box-shadow: 0 11px 24px rgba(25, 34, 48, 0.12);
}

.pokemon-loadout__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    min-height: 3.35rem;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid #e5e8ee;
    background: #f8f9fb;
}

.pokemon-loadout__number {
    display: grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border: 1px solid var(--pokemon-accent);
    border-radius: 50%;
    color: var(--pokemon-accent);
    font-size: 0.68rem;
    font-weight: 900;
}

.pokemon-loadout__name {
    min-width: 0;
}

.pokemon-loadout__name h3 {
    margin: 0;
    color: #111927;
    font-size: 0.98rem;
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pokemon-loadout__markers {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
    color: #7b8797;
    font-size: 0.65rem;
    font-weight: 700;
}

.pokemon-loadout__shiny {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    color: #9a6500;
}

.pokemon-loadout__shiny .rzi {
    font-size: 0.78rem;
}

.pokemon-loadout__mechanic {
    display: grid;
    max-width: 4.8rem;
    justify-items: end;
    color: var(--format-contrast);
    line-height: 1.12;
}

.pokemon-loadout__mechanic small {
    color: #8e98a7;
    font-size: 0.57rem;
    font-weight: 750;
}

.pokemon-loadout__mechanic strong {
    max-width: 100%;
    font-size: 0.76rem;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pokemon-loadout__mechanic--gmax {
    color: #0b7f91;
}

.pokemon-loadout__mechanic--points {
    color: #16734f;
}

.pokemon-loadout__main {
    display: grid;
    grid-template-columns: minmax(6.7rem, 0.88fr) minmax(7.2rem, 1.12fr);
    min-height: 9.8rem;
}

.pokemon-loadout__visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid #e5e8ee;
    background: #f3f5f8;
}

.pokemon-loadout__visual::after {
    position: absolute;
    inset: 0.55rem;
    border: 1px solid color-mix(in srgb, var(--pokemon-accent) 22%, transparent);
    border-radius: 50%;
    content: "";
}

.pokemon-loadout__visual img {
    position: relative;
    z-index: 2;
    display: block;
    width: 6.6rem;
    height: 6.6rem;
    object-fit: contain;
    image-rendering: auto;
    filter: drop-shadow(0 8px 5px rgba(25, 34, 48, 0.16));
}

.pokemon-loadout__watermark {
    position: absolute;
    top: -0.35rem;
    left: 0.2rem;
    z-index: 0;
    color: #e2e6ec;
    font-size: 4.5rem;
    font-weight: 950;
    line-height: 1;
}

.pokemon-loadout__types {
    position: absolute;
    right: 0.4rem;
    bottom: 0.4rem;
    left: 0.4rem;
    z-index: 3;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pokemon-loadout__types span {
    min-width: 2.65rem;
    padding: 0.16rem 0.38rem;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 999px;
    background: var(--type-color);
    box-shadow: 0 1px 4px rgba(25, 34, 48, 0.18);
    color: #fff;
    font-size: 0.59rem;
    font-weight: 850;
    line-height: 1.2;
    text-align: center;
}

.pokemon-loadout__moves {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 0.55rem;
    background: #fff;
}

.pokemon-loadout__points {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem 0.55rem;
    padding: 0.5rem 0.65rem;
    border-top: 1px solid #e2e7e4;
    background: #f4f7f5;
}

.pokemon-loadout__points > div {
    display: grid;
    grid-template-columns: 1.8rem minmax(0, 1fr) 1.25rem;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.pokemon-loadout__points span,
.pokemon-loadout__points strong {
    font-size: 0.56rem;
    font-weight: 800;
}

.pokemon-loadout__points span {
    color: #647068;
}

.pokemon-loadout__points strong {
    color: #173d2f;
    text-align: right;
}

.pokemon-loadout__points i {
    display: block;
    height: 0.25rem;
    overflow: hidden;
    background: #d8dfdb;
}

.pokemon-loadout__points b {
    display: block;
    height: 100%;
    background: #16734f;
}

.pokemon-loadout__stat-values {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border-top: 1px solid #e2e7e4;
    background: #f4f7f5;
}

.pokemon-loadout__stat-values > div {
    min-width: 0;
    padding: 0.45rem 0.3rem;
    text-align: center;
}

.pokemon-loadout__stat-values > div + div {
    border-left: 1px solid #e2e7e4;
}

.pokemon-loadout__stat-values span,
.pokemon-loadout__stat-values strong,
.pokemon-loadout__stat-values em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0;
}

.pokemon-loadout__stat-values span {
    color: #647068;
    font-size: 0.57rem;
    font-weight: 850;
}

.pokemon-loadout__stat-values strong,
.pokemon-loadout__stat-values em {
    margin-top: 0.12rem;
    color: #173d2f;
    font-size: 0.64rem;
    font-style: normal;
    font-weight: 850;
}

.pokemon-loadout__stat-values em {
    color: #647068;
    font-weight: 750;
}

.pokemon-loadout__stat-values small {
    font-size: 0.48rem;
    font-weight: 750;
}

.team-sheet--swsh .pokemon-loadout {
    border-top-color: #0b7f91;
}

.team-sheet--swsh .pokemon-loadout:nth-child(even) {
    border-top-color: #c33b50;
}

.team-sheet--champions .pokemon-loadout {
    border-top-color: #16734f;
    box-shadow: 0 7px 20px rgba(20, 50, 38, 0.1);
}

.team-sheet--champions .pokemon-loadout__header {
    border-bottom-color: #d8dfdb;
    background: #f1f5f2;
}

.pokemon-loadout__section-label {
    margin-bottom: 0.3rem;
    color: #8a95a5;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0;
}

.pokemon-loadout__move {
    --move-color: #687386;
    display: grid;
    grid-template-columns: 1.05rem minmax(0, 1fr);
    align-items: center;
    gap: 0.38rem;
    min-width: 0;
    min-height: 1.85rem;
    border-bottom: 1px solid #edf0f4;
}

.pokemon-loadout__move:last-child {
    border-bottom: 0;
}

.pokemon-loadout__move > span {
    display: grid;
    place-items: center;
    width: 0.95rem;
    height: 0.95rem;
    border: 1px solid var(--move-color);
    border-radius: 3px;
    color: var(--move-color);
    font-size: 0.53rem;
    font-weight: 900;
}

.pokemon-loadout__move strong {
    min-width: 0;
    color: #334054;
    font-size: 0.69rem;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pokemon-loadout__move--empty {
    opacity: 0.45;
}

.pokemon-loadout__details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 3.35rem;
    margin-top: auto;
    border-top: 1px solid #e5e8ee;
    background: #fbfcfd;
}

.pokemon-loadout__details--nature-hidden {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pokemon-loadout__details > div {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 0.12rem;
    padding: 0.5rem 0.55rem;
    border-right: 1px solid #e5e8ee;
}

.pokemon-loadout__details > div:last-child {
    border-right: 0;
}

.pokemon-loadout__details span {
    color: #8a95a5;
    font-size: 0.57rem;
    font-weight: 750;
}

.pokemon-loadout__details strong {
    min-width: 0;
    color: #273447;
    font-size: 0.66rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pokemon-loadout__item-detail {
    padding-right: 1.45rem !important;
}

.pokemon-loadout__item-icon {
    position: absolute;
    right: 0.25rem;
    bottom: 0.28rem;
    transform: scale(0.8);
    transform-origin: bottom right;
}

.team-sheet__image {
    margin: 0.9rem 0 0;
    overflow: hidden;
    border: 1px solid #d7dce5;
    border-radius: 8px;
    background: #fff;
}

.team-sheet__image figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #e5e8ee;
    background: #f8f9fb;
}

.team-sheet__image figcaption .team-sheet__kicker {
    margin-bottom: 0.1rem;
}

.team-sheet__image figcaption strong {
    color: #182230;
    font-size: 0.86rem;
}

.team-sheet__image figcaption a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #245bb0;
    font-size: 0.74rem;
    font-weight: 800;
    text-decoration: none;
}

.team-sheet__image figcaption a .rzi {
    font-size: 0.92rem;
}

.team-sheet__image > a {
    display: block;
    padding: 0.8rem;
}

.team-sheet__image img {
    display: block;
    width: 100%;
    max-height: 26rem;
    margin: 0 auto;
    object-fit: contain;
}

.team-sheet__source {
    margin-top: 0.85rem;
    border: 1px solid #d7dce5;
    border-radius: 8px;
    background: #fff;
}

.team-sheet__source summary {
    padding: 0.7rem 0.85rem;
    color: #334054;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 800;
}

.team-sheet__source textarea {
    width: calc(100% - 1.5rem) !important;
    margin: 0 0.75rem 0.75rem;
    resize: vertical;
    font-family: Consolas, monospace;
    font-size: 0.76rem;
}

.team-sheet__empty,
.team-sheet__loading {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 12rem;
    place-content: center;
    border: 1px dashed #c7ced9;
    border-radius: 8px;
    background: #f8f9fb;
    color: #687386;
    text-align: center;
}

.team-sheet__empty .rzi {
    color: #8793a4;
    font-size: 2rem;
}

.team-sheet__empty strong {
    color: #273447;
    font-size: 0.9rem;
}

.team-sheet__empty span,
.team-sheet__loading {
    font-size: 0.76rem;
}

.team-sheet__loading-mark {
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid #d7dce5;
    border-top-color: #3467b8;
    border-radius: 50%;
    animation: team-sheet-spin 800ms linear infinite;
}

@keyframes team-sheet-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 800px) {
    .team-sheet__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container (max-width: 800px) {
    .team-sheet__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container (max-width: 540px) {
    .team-sheet {
        padding: 0.55rem;
    }

    .team-sheet__title-row h2 {
        font-size: 1.25rem;
    }

    .team-sheet__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 540px) {
    .team-sheet {
        padding: 0.55rem;
    }

    .team-sheet__overview {
        align-items: center;
    }

    .team-sheet__title-row h2 {
        font-size: 1.25rem;
    }

    .team-sheet__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pokemon-loadout {
        min-height: 17.4rem;
    }

    .pokemon-loadout__main {
        grid-template-columns: minmax(7rem, 0.85fr) minmax(8rem, 1.15fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pokemon-loadout {
        transition: none;
    }

    .team-sheet__loading-mark {
        animation: none;
    }
}
