@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

:root {
    --dex-red: #dc0a2d;
    --dex-dark-red: #8B0000;
    --dex-blue: #28AAFD;
    --dex-yellow: #FFCB05;
    --dex-green: #4CAF50;
    --dex-bg: #f4f4f4;
    --dex-screen: #E0F7FA;
    --dex-border: #333;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow-card: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-soft: 0 1px 4px rgba(0,0,0,0.06);
    --border-subtle: #ececec;
    --track-bg: #e6e6e6;
    --card-aspect: 2 / 3.2;
    --card-aspect-large: 2 / 3.5;
}

html {
    background: var(--site-gradient, var(--dex-red));
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: transparent;
    color: var(--dex-border);
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
    border-radius: 15px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--site-gradient, var(--dex-red));
    background-size: cover;
    pointer-events: none;
}

h1, h2, h3 {
    margin-top: 25px;
    color: white;
    text-shadow: 2px 2px 0px var(--dex-border);
    text-align: center;
}

.screen-area {
    background-color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-card);
}

.nav-links a {
    text-decoration: none;
    font-weight: bold;
    border: none;
}

@media screen and (min-width: 769px) {
    body {
        max-width: 1180px;
        padding-left: 280px;
        box-sizing: border-box;
        margin-left: max(20px, calc(50vw - 730px));
        margin-right: auto;
    }

    .nav-links {
        position: fixed;
        top: 80px;
        left: max(40px, calc(50vw - 710px));
        width: 240px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 15px;
        z-index: 1000;
        background: transparent;
        padding: 0;
        margin: 0;
        border: none;
    }

    .nav-links a {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 12px 20px;
        width: auto;
        font-size: 20px;
        color: var(--dex-border);
        background: white;
        border-radius: var(--radius-pill);
        box-shadow: var(--shadow-soft);
        transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
        border: none;
    }

    .nav-links a.active {
        color: var(--dex-red);
    }

    .nav-links a:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-card);
        background: #fafafa;
    }

    .nav-links a svg {
        flex-shrink: 0;
    }

    .identity-row {
        margin-left: 0 !important;
        margin-right: auto !important;
    }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.card {
    background: #fff;
    padding: 15px;
    border-radius: var(--radius-md);
    border: 1px solid #ededed;
    position: relative;
    text-align: center;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card.active {
    background: #effaf0;
    border-color: #bfe4c2;
    box-shadow: var(--shadow-card);
}

.card.archived {
    background: #f0f0f0;
    border-color: #e0e0e0;
}

.card.archived.active {
    background: #dcebde;
    border-color: #bcd3be;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--dex-green);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: var(--shadow-soft);
}

.bus-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #888;
}

.active .bus-name {
    color: #333;
}

.bus-details {
    font-size: 13px;
    color: #999;
    line-height: 1.4;
}

.active .bus-details {
    color: #555;
}

.filter-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    background: #fff;
    padding: 12px;
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-card);
}

select, input {
    padding: 11px 16px;
    border: 1px solid var(--border-subtle);
    background: white;
    border-radius: var(--radius-md);
    font-weight: bold;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--dex-blue);
    box-shadow: 0 0 0 3px rgba(40,170,253,0.15);
}

button, .button, .filter-btn {
    padding: 12px 24px;
    text-decoration: none;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: bold;
    box-shadow: var(--shadow-soft);
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-color: var(--dex-blue);
    color: white;
}

button.title-edit-btn,
button.gradient-edit-btn {
    width: auto !important;
    max-width: 32px !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 4px !important;
    border-radius: 8px !important;
    font-size: 0 !important;
    box-shadow: var(--shadow-soft) !important;
}

button.pfp-edit-btn {
    width: 30px !important;
    height: 30px !important;
    max-width: 30px !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    font-size: 0 !important;
    box-shadow: var(--shadow-soft) !important;
}

select {
    cursor: pointer;
}

input {
    cursor: text;
}

button:hover, .button:hover, .filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

button:active, .button:active, .filter-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-soft);
}

.bus-form {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: none;
    box-shadow: var(--shadow-card);
}

.bus-form h3 {
    margin-top: 0;
    color: var(--dex-border);
    text-shadow: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

th, td {
    padding: 12px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

th {
    background-color: var(--dex-blue);
    color: white;
    font-weight: bold;
    text-shadow: none;
}

tr:nth-child(even) {
    background-color: #fafafa;
}

a {
    color: var(--dex-blue);
    font-weight: bold;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.result-card, .bus-header, .overview {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-top: 20px;
    margin-bottom: 20px;
    border: none;
    box-shadow: var(--shadow-card);
}

.leaderboard-table tr td { color: #333; }
.leaderboard-table tr.podium-1 { background-color: #fffac9 !important; }
.leaderboard-table tr.podium-2 { background-color: #e0e0e0 !important; }
.leaderboard-table tr.podium-3 { background-color: #ffe6cc !important; }

.timeline {
    text-align: left;
    margin-top: 20px;
}
.timeline-item {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
}
.timeline-item span.date { color: #888; font-size: 0.9em; float: right; }
.timeline-item h4 { margin: 0 0 5px 0; color: var(--dex-border); text-shadow: none; font-size: 1.1em; }


.mobile-menu-header {
    display: none;
    margin-top: 60px;
    margin-bottom: 5px;
    text-align: right;
}
.burger-btn {
    background-color: var(--dex-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
}
.burger-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0;
}

@media screen and (max-width: 600px) {
    body {
        margin: 5px;
        padding: 5px;
        border-radius: 8px;
        border: none;
    }
    
    h1 { font-size: 1.6em; margin-top: 15px; }
    h2 { font-size: 1.4em; }
    h3 { font-size: 1.2em; }
    
    .mobile-menu-header {
        display: block;
        margin-top: 40px;
    }
    .nav-links {
        display: none;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 0;
        background: transparent;
        padding: 0;
        border: none;
    }
    .nav-links.show {
        display: grid;
    }
    .nav-links a {
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }
    .bus-name { font-size: 16px; }
    .bus-details { font-size: 12px; }
    
    .login-box {
        width: calc(100% - 20px);
        margin: 40px auto;
        padding: 15px;
    }
    
    input, button, #reg-input {
        width: 100% !important;
        box-sizing: border-box;
        margin: 5px 0;
    }

    .duel-card-actions button {
        width: auto !important;
        margin: 0 !important;
        font-size: 0.8em;
        padding: 8px 6px !important;
    }
    
    .filter-container {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .screen-area {
        padding: 10px;
        border: none;
        border-radius: 8px;
        margin-top: 10px;
        overflow-x: auto;
    }
    
    th, td {
        padding: 8px 4px;
        font-size: 0.85em;
    }
    
    .timeline-item span.date {
        float: none;
        display: block;
        margin-bottom: 5px;
    }
    
    .overview {
        font-size: 15px;
        padding: 10px;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 70px;
    }
    .mobile-menu-header, .nav-links {
        display: none !important;
    }
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 15px;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 400px;
        background: rgba(255, 255, 255, 0.45);
        backdrop-filter: blur(12px) saturate(150%);
        -webkit-backdrop-filter: blur(12px) saturate(150%);
        border: 1px solid rgba(255, 255, 255, 0.8);
        box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
        border-radius: 30px;
        height: 60px;
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
    }
    
    .mobile-nav a {
        color: #3f3f3f;
        width: 40px;
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: color 0.2s;
    }
    
    .mobile-nav a:hover, .mobile-nav a:active {
        color: #dc0a2d;
    }

    .mobile-nav a.active {
        background-color: #dc0a2d;
        color: #fff !important;
        border-radius: 50%;
    }

    .mobile-nav .nav-pill {
        position: absolute;
        z-index: -1;
        top: 50%;
        left: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: #dc0a2d;
        transform: translate(0, -50%);
        transition: transform 0.34s cubic-bezier(0.34, 1.4, 0.5, 1);
        pointer-events: none;
        opacity: 0;
    }
    .mobile-nav.nav-pill-ready .nav-pill { opacity: 1; }
    .mobile-nav.nav-pill-ready a.active { background-color: transparent; }

    @media (prefers-reduced-motion: reduce) {
        .mobile-nav .nav-pill { transition: none; }
    }

    .mobile-nav a svg {
        width: 28px;
        height: 28px;
    }
}

@media (min-width: 769px) {
    .mobile-nav {
        display: none !important;
    }
}
. i n s t a l l - c o n t a i n e r   {   b a c k g r o u n d :   w h i t e ;   b o r d e r - r a d i u s :   1 0 p x ;   p a d d i n g :   2 0 p x ;   t e x t - a l i g n :   l e f t ;   m a r g i n :   2 0 p x   a u t o ;   m a x - w i d t h :   4 0 0 p x ;   b o x - s h a d o w :   0   4 p x   6 p x   r g b a ( 0 , 0 , 0 , 0 . 1 ) ;   b o r d e r :   2 p x   s o l i d   v a r ( - - d e x - b o r d e r ) ;   } 
 
 
h1, h2, h3, h4, h5, h6, .modal-title, .title { text-shadow: none !important; }

.install-container {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: left;
    margin: 20px auto;
    max-width: 400px;
    box-shadow: var(--shadow-card);
    border: none;
}

.progress-track {
    height: 9px;
    background: var(--track-bg);
    border-radius: var(--radius-pill);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
}
.progress-fill {
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.30) 0%, rgba(255,255,255,0.05) 55%, rgba(0,0,0,0.06) 100%), var(--dex-green);
    border-radius: var(--radius-pill);
    box-shadow: 0 0 6px rgba(76,175,80,0.55);
    transition: width 0.3s ease;
}
.circle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--dex-blue);
    color: #fff;
    font-weight: bold;
    flex-shrink: 0;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: #f0f0f0;
    color: #555;
    font-size: 0.78em;
    font-weight: bold;
}

.level-rewards { position: relative; margin-top: 6px; text-align: left; }
.reward-row { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.reward-row.last { padding-bottom: 0; }
.reward-row::before {
    content: ""; position: absolute; left: 17px; top: 22px; bottom: -4px;
    width: 2px; background: #e0e0e0;
}
.reward-row.last::before { display: none; }
.reward-marker {
    position: relative; z-index: 1; flex-shrink: 0;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 0.85em; box-sizing: border-box;
    background: #e8e8e8; color: #999; border: 2px solid #e8e8e8;
}
.reward-row.unlocked .reward-marker { background: #36D13C; color: white; border-color: #36D13C; }
.reward-row.next .reward-marker { background: white; color: var(--dex-blue); border-color: var(--dex-blue); }
.reward-content { flex-grow: 1; min-width: 0; padding-top: 2px; }
.reward-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reward-title { font-weight: bold; color: #333; font-size: 1.02em; word-break: break-word; }
.reward-row.locked .reward-title { color: #999; }
.reward-level-badge {
    flex-shrink: 0; font-size: 0.72em; font-weight: bold; color: #777;
    background: #f0f0f0; padding: 2px 8px; border-radius: 999px;
}
.reward-row.next .reward-level-badge { background: #e8f3ff; color: var(--dex-blue); }
.reward-status { font-size: 0.8em; color: #888; margin-top: 3px; }
.reward-status.unlocked-text { color: #2a9d2f; font-weight: bold; }
.reward-progress-track {
    height: 8px; background: #e0e0e0; border-radius: 999px; margin-top: 6px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
}
.reward-progress-fill {
    height: 100%; border-radius: 999px; transition: width 0.3s ease;
    background: linear-gradient(180deg, rgba(255,255,255,0.30) 0%, rgba(255,255,255,0.05) 55%, rgba(0,0,0,0.06) 100%), var(--dex-blue);
    box-shadow: 0 0 6px rgba(40,170,253,0.5);
}
.reward-more {
    position: relative; display: flex; align-items: center; gap: 14px;
    height: 40px; width: 100%; padding: 0; margin: 0;
    background: none; border: none; border-radius: 0; box-shadow: none;
    font-family: inherit; cursor: pointer; text-align: left;
    -webkit-tap-highlight-color: transparent;
}
.reward-more:hover, .reward-more:active {
    transform: none; box-shadow: none;
}
.reward-more::before {
    content: ""; position: absolute; left: 17px; width: 2px;
    background: #e0e0e0; z-index: 0;
}
#rewards-earlier::before { top: 20px; bottom: -4px; }
#rewards-later::before { top: -4px; bottom: 20px; }
.reward-more-node {
    position: relative; z-index: 1; flex-shrink: 0; width: 36px;
    display: flex; align-items: center; justify-content: center;
}
.reward-more-dot {
    width: 24px; height: 24px; border-radius: 50%;
    background: white; border: 2px dashed #cdcdcd; color: #aaa;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.reward-more:hover .reward-more-dot,
.reward-more:focus-visible .reward-more-dot {
    border-color: var(--dex-blue); color: var(--dex-blue); transform: scale(1.1);
}
.reward-more-label {
    font-size: 0.78em; font-weight: bold; color: #aaa; transition: color 0.15s ease;
}
.reward-more:hover .reward-more-label,
.reward-more:focus-visible .reward-more-label { color: var(--dex-blue); }
.reward-soon {
    position: relative; display: flex; align-items: center; gap: 14px;
    height: 40px; width: 100%;
}
.reward-soon::before {
    content: ""; position: absolute; left: 17px; top: -4px; bottom: 20px;
    width: 2px; background: #e0e0e0; z-index: 0;
}

.level-rewards.is-collapsed .reward-row { padding-bottom: 0; }
.level-rewards.is-collapsed .reward-row::before { display: none; }
.rewards-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    margin: 10px auto 0; padding: 6px 16px;
    background: #f1f7ff; border: 1px solid #dbe7fb; border-radius: 999px;
    color: var(--dex-blue); font-family: inherit; font-weight: bold;
    font-size: 0.8em; cursor: pointer; box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}
.rewards-toggle:hover, .rewards-toggle:active {
    transform: none; box-shadow: none; background: #e6f0ff;
}
.rewards-toggle-chevron { transition: transform 0.2s ease; }
.rewards-toggle.is-open .rewards-toggle-chevron { transform: rotate(180deg); }

@keyframes nearby-flair-shift {
    from { background-position: 0% 50%; }
    to   { background-position: 200% 50%; }
}
#unknown-bus-btn {
    border: 3px solid transparent;
    background:
        linear-gradient(90deg, #ffadc6, #ffd6a5, #fdffb6, #c0f5cd, #a8d8ff, #cdb4ff, #ffadc6) padding-box,
        linear-gradient(90deg, #e57a9c, #e8a86a, #d9d35f, #6fc78a, #5aa0e0, #9b78e0, #e57a9c) border-box;
    background-size: 200% 100%;
    background-position: 0% 50%;
    animation: nearby-flair-shift 8s linear infinite;
    box-shadow: 0 4px 16px rgba(160,150,220,0.40);
    color: #444;
}
#unknown-bus-btn:hover {
    animation-duration: 4s;
    box-shadow: 0 6px 22px rgba(160,150,220,0.55);
}
@media (prefers-reduced-motion: reduce) {
    #unknown-bus-btn { animation: none; }
}

.load-more-btn {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 12px auto 0;
    padding: 8px 18px;
    background: #f1f3f5;
    color: #555;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85em;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.load-more-btn:hover,
.load-more-btn:active {
    background: #e7eaee;
    transform: none;
    box-shadow: none;
}
.plus-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.12em;
    line-height: 0;
    flex-shrink: 0;
}
.plus-badge svg {
    width: 1em;
    height: 1em;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.float-field { position: relative; text-align: left; }

.float-field > input,
.float-field > select {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 17px 14px;
    font-size: 16px;
    font-weight: normal;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--dex-border);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.float-field.has-toggle > input { padding-right: 46px; }

.float-field > input:focus,
.float-field > select:focus {
    border-color: var(--dex-blue);
    box-shadow: 0 0 0 3px rgba(40, 170, 253, 0.15);
}

.float-field > label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    max-width: calc(100% - 24px);
    margin: 0;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #fff;
    color: #8a8a8a;
    font-size: 16px;
    font-weight: normal;
    pointer-events: none;
    transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, font-weight 0.15s ease;
}

.float-field > input:focus + label,
.float-field > input:not(:placeholder-shown) + label,
.float-field > select + label {
    top: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--dex-blue);
}
.float-field > input:not(:focus):not(:placeholder-shown) + label,
.float-field > select:not(:focus) + label {
    color: #8a8a8a;
}

.gold-username {
    color: #8a6d0b;
    background: linear-gradient(
        100deg,
        #6b4e00 0%, #8a6d0b 22%, #a67c00 42%,
        #cda12a 50%,
        #a67c00 58%, #8a6d0b 78%, #6b4e00 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gold-username-shimmer 3.5s linear infinite;
    padding-bottom: 0.16em;
    margin-bottom: -0.16em;
}
@keyframes gold-username-shimmer {
    to { background-position: 200% center; }
}
@media (prefers-reduced-motion: reduce) {
    .gold-username { animation: none; }
}

.name-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
    padding-bottom: 0.16em;
    margin-bottom: -0.16em;
}

.tcard {
    position: relative;
    box-sizing: border-box;
    aspect-ratio: var(--card-aspect);
    padding: 0.44em;
    display: flex;
    flex-direction: column;
    border-radius: 0.875em;
    overflow: hidden;
    isolation: isolate;
    text-align: left;
    color: #2a2a2a;
    background: linear-gradient(150deg, #eef1f4 0%, #cdd4db 55%, #e2e7ec 100%);
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: var(--shadow-soft);
    --frame-ring: rgba(255, 255, 255, 0.92);
}
.tcard::before,
.tcard::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.tcard::before { background: var(--liv-l, transparent); }
.tcard::after {
    background: var(--liv-r, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent 28%, #000 70%);
            mask-image: linear-gradient(to right, transparent 28%, #000 70%);
}

.tcard__top { position: relative; flex: 0 0 auto; padding: 0.0625em 0.1875em 0.375em 0.1875em; }
.tcard__top::before {
    content: ""; position: absolute; top: -0.44em; left: -0.44em; right: -0.44em; bottom: -0.875em;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.28) 60%, rgba(0,0,0,0) 100%);
    z-index: 0; pointer-events: none;
}
.tcard__name {
    position: relative; z-index: 1; display: block; min-width: 0; box-sizing: border-box;
    padding-right: 3.9em;
    font-weight: 800; font-size: 0.82em; line-height: 1.12; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.55);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tcard__sub {
    display: none; position: relative; z-index: 1; min-width: 0; margin-top: 0.42em;
    font-weight: 700; font-size: 0.42em; line-height: 1.1; color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tcard--large .tcard__sub { display: block; }

.tcard--large { aspect-ratio: var(--card-aspect-large); padding: 0.6em; }
.tcard--large .tcard__frame { margin-top: 0.4em; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tcard--large .tcard__frame .tcard__img { aspect-ratio: auto; height: 100%; flex: 1 1 auto; min-height: 0; }
.tcard--large .tcard__panel { margin-top: 0.6em; padding: 0.62em 0.82em; gap: 0.4em; }
.tcard--large .tcard__top::before { top: -0.6em; left: -0.6em; right: -0.6em; border-radius: 0.875em 0.875em 0 0; }
.tcard--large .tcard__serial { top: -0.97em; right: -0.97em; padding: 0.5em 0.9em 0.6em 1.1em; }
.tcard__darken { position: absolute; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.32); pointer-events: none; }
.tcard__serial {
    position: absolute; top: -0.7em; right: -0.7em; z-index: 5;
    display: inline-flex; align-items: center; gap: 0.4em;
    padding: 0.4em 0.8em 0.5em; border-radius: 0 0 0 1em;
    background: rgba(0, 0, 0, 0.72); color: #fff;
    font-size: 0.62em; font-weight: 800; letter-spacing: 0.3px; line-height: 1;
    box-shadow: -1px 2px 3px rgba(0, 0, 0, 0.28);
}

.tcard__frame {
    position: relative; flex: 0 0 auto; min-height: 0;
    padding: 0.1875em; border-radius: 0.5625em;
    background: var(--frame-ring);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}
.tcard__img {
    position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 0.375em; overflow: hidden;
    display: flex; align-items: center; justify-content: center; background: #7d828a;
}
.tcard__icon { position: relative; z-index: 1; width: 54%; max-width: 7.5em; filter: brightness(0) invert(1); opacity: 0.9; }
.tcard__photo { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s ease; }
.tcard__photo.is-loaded { opacity: 1; }
.tcard__img.has-photo .tcard__icon { opacity: 0; }
.tcard__img.is-loading::after {
    content: ""; position: absolute; inset: 0; z-index: 3;
    background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.28) 50%, transparent 70%);
    background-size: 220% 100%; animation: tcardShimmer 1.2s linear infinite;
}
@keyframes tcardShimmer { to { background-position: -220% 0; } }
.tcard__holo { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; }

.tcard__retired {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
    padding: 1.4em 0.6em 0.42em; text-align: center; pointer-events: none;
    font-size: 0.5em; font-weight: 800; letter-spacing: 0.5px; line-height: 1.1;
    color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    background: linear-gradient(to top,
        rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.78) 22%, rgba(0, 0, 0, 0.5) 52%,
        rgba(0, 0, 0, 0.2) 78%, rgba(0, 0, 0, 0) 100%);
}
.tcard__panel {
    flex: 0 0 auto; display: flex; flex-direction: column; gap: 0.25em;
    margin-top: auto; padding: 0.5em 0.625em; border-radius: 0.5625em;
    background: rgba(255, 255, 255, 0.92); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.tcard__stat { display: flex; align-items: center; justify-content: space-between; gap: 0.75em; font-size: 0.66em; }
.tcard__stat + .tcard__stat { border-top: 1px solid #eee; padding-top: 0.28em; }
.tcard__stat-k { flex: 0 0 auto; color: #8a8a8a; font-weight: 700; }
.tcard__stat-v { min-width: 0; color: #2a2a2a; font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard--large .tcard__stat-k { font-size: 0.9em; }
.tcard--large .tcard__stat-v { font-size: 0.72em; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }

.tcard--rainbow {
    --frame-ring: linear-gradient(135deg, #ff004c, #ff8a00, #ffe600, #00d26a, #00b3ff, #7a5cff, #ff2fd0);
    border-color: rgba(255, 255, 255, 0.95);
}

.tcard--gold {
    background: linear-gradient(150deg, #fdeeb0 0%, #e9be3d 26%, #b8860b 52%, #f6d873 74%, #c99a2e 100%);
    --frame-ring: linear-gradient(135deg, #7a5a12, #d4af37, #6e4e0f, #e6c15a, #8a6a1f);
    border-color: #b8860b;
}
.tcard--gold::before, .tcard--gold::after { display: none; }
.tcard--gold .tcard__panel { background: rgba(255, 250, 235, 0.94); }

.tcard--shiny {
    background: linear-gradient(115deg, #b8c6db 0%, #f5f7fa 12%, #c1a3ff 28%, #a0e9ff 42%, #ffd1f0 56%, #c8ffd4 70%, #fff1a8 84%, #b8c6db 100%);
    background-size: 220% 220%;
    --frame-ring: linear-gradient(135deg, #c9d2d9, #f6f9fc, #aeb8c2, #eaeff4);
    border-color: rgba(255, 255, 255, 0.95);
    animation: tcardHolo 7s ease-in-out infinite;
}
.tcard--shiny::before, .tcard--shiny::after { display: none; }
.tcard--shiny .tcard__holo {
    opacity: 0.5; mix-blend-mode: color-dodge;
    background: linear-gradient(115deg, transparent 18%, rgba(255,255,255,0.55) 34%, rgba(180,120,255,0.5) 44%, rgba(120,230,255,0.45) 54%, rgba(255,180,240,0.45) 64%, transparent 82%);
    background-size: 250% 250%;
    animation: tcardHolo 7s ease-in-out infinite;
}
@keyframes tcardHolo { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@media (prefers-reduced-motion: reduce) {
    .tcard--shiny, .tcard--shiny .tcard__holo, .tcard__img.is-loading::after { animation: none; }
}

.inv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .inv-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 860px) { .inv-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
.inv-cell { position: relative; min-width: 0; cursor: pointer; transition: transform 0.12s ease; container-type: inline-size; isolation: isolate; }
.inv-cell:active { transform: scale(0.97); }
.inv-cell .tcard { font-size: 9.8cqw; }
.inv-grid:not(.is-stacked) .inv-cell { order: var(--flat, 0); }
.inv-grid.is-stacked .inv-cell:not(.inv-cell--face) { display: none; }
.inv-pile { display: none; position: absolute; top: 0; left: 0; right: 0; aspect-ratio: var(--card-aspect); z-index: -1; pointer-events: none; }
.inv-grid.is-stacked .inv-cell--face.has-stack .inv-pile { display: block; }
.inv-pile__card { position: absolute; inset: 0; }
.inv-pile__card .tcard { width: 100%; height: 100%; }
.inv-pile__card--near { transform: translate(5px, 6px) rotate(3deg); }
.inv-pile__card--far  { transform: translate(10px, 12px) rotate(5.5deg); z-index: -1; }
.inv-stack-label {
    display: none; position: relative; z-index: -1;
    margin-top: -14px; padding: 19px 8px 7px;
    text-align: center; color: #1a1a1a; font-size: 0.78em; font-weight: 800; letter-spacing: 0.2px;
    background: #e3e7ec; border-radius: 0 0 12px 12px;
}
.inv-grid.is-stacked .inv-cell--face .inv-stack-label { display: block; }

.inv-book { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .inv-book { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 860px) { .inv-book { grid-template-columns: repeat(3, 1fr); gap: 18px; } }
.inv-book__cell { position: relative; min-width: 0; container-type: inline-size; isolation: isolate; }
.inv-book__cell .tcard { font-size: 9.8cqw; }
.inv-book__cell--locked { cursor: default; }
.inv-book__cell.has-stack .inv-pile { display: block; }
.inv-book__cell.has-stack .inv-stack-label { display: block; }

.tcard__badge {
    position: absolute; z-index: 5; top: 0.45em; right: 0.45em;
    font-size: 0.62em; font-weight: 800; letter-spacing: 0.3px; color: #fff;
    background: rgba(0, 0, 0, 0.62); border-radius: 999px; padding: 0.18em 0.6em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); pointer-events: none;
}

.tcard--variant-1 .tcard__img { background: linear-gradient(150deg, #2f6fed, #23407e); }
.tcard--variant-2 .tcard__img { background: linear-gradient(150deg, #23a06a, #145c3d); }
.tcard--variant-3 .tcard__img { background: linear-gradient(150deg, #e6a12b, #a6641a); }
.tcard--variant-4 .tcard__img { background: linear-gradient(150deg, #e0578f, #8f2f5c); }
.tcard--variant-5 .tcard__img { background: linear-gradient(150deg, #1ba6b0, #0d5c66); }
.tcard--variant-6 .tcard__img { background: linear-gradient(150deg, #8b5cf6, #542f9e); }

.tcard--locked { opacity: 0.96; }
.tcard--locked .tcard__img { filter: grayscale(1) brightness(0.5); }
.tcard--locked .tcard__icon { opacity: 0.35; }
.tcard--locked .tcard__panel { opacity: 0.72; }
.tcard--locked .tcard__serial { color: #b8bcc4; }
.tcard__lock {
    position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.9);
}
.tcard__lock svg { width: 34%; height: auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }

.inv-search { position: relative; margin-bottom: 14px; }
.inv-search .dex-search { width: 100%; box-sizing: border-box; }
.inv-search__menu {
    display: none; position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; z-index: 300;
    background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    box-shadow: var(--shadow-card); overflow: hidden auto; max-height: 320px;
}
.inv-search__menu.is-open { display: block; }
.inv-search__opt {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100% !important; text-align: left; padding: 11px 15px !important;
    background: #fff; border: none; border-bottom: 1px solid #eee; box-sizing: border-box; cursor: pointer;
}
.inv-search__opt:last-child { border-bottom: none; }
.inv-search__opt:hover { background: #f2f6fc; }
.inv-search__name { font-size: 0.92em; font-weight: 700; color: #2a2f38; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-search__reg { flex: 0 0 auto; font-size: 0.78em; font-weight: 700; color: var(--dex-blue); background: #eef4ff; border-radius: 6px; padding: 2px 7px; }
.inv-search__empty { padding: 14px 15px; color: #6b7480; font-size: 0.9em; }

.card-overlay {
    position: fixed; inset: 0; z-index: 4000; display: none;
    align-items: center; justify-content: center; padding: 24px 16px;
    background: rgba(0, 0, 0, 0.74); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.card-overlay.is-open { display: flex; }
.card-overlay__stage { position: relative; width: min(72vw, 320px); perspective: 1500px; }
.card-flip {
    position: relative; width: 100%; aspect-ratio: var(--card-aspect-large);
    transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.25, 1);
    cursor: pointer;
}
.card-flip.is-flipped { transform: rotateY(180deg); }
.card-flip__face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.card-flip__back {
    transform: rotateY(180deg);
    border-radius: 14px; overflow: hidden; background: var(--dex-red);
    border: 3px solid rgba(255, 255, 255, 0.55); box-shadow: var(--shadow-soft);
    display: flex; align-items: center; justify-content: center;
}
.card-flip__back-icon { width: 58%; max-width: 220px; filter: brightness(0) invert(1); }
.card-flip__back-meta {
    position: absolute; left: 0; right: 0; bottom: 7%; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    color: #fff; text-align: center; pointer-events: none;
}
.card-flip__back-nums { display: flex; gap: 10px; justify-content: center; }
.card-flip__back-stat {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: rgba(0, 0, 0, 0.22); padding: 6px 14px; border-radius: 12px;
}
.card-flip__back-label {
    font-size: 0.58rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.78;
}
.card-flip__back-val { font-size: 0.9rem; font-weight: 800; letter-spacing: 0.5px; line-height: 1; }
.card-flip__back-word { font-size: 1.2rem; font-weight: 900; letter-spacing: 1px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
@media (prefers-reduced-motion: reduce) { .card-flip { transition: none; } }
.card-overlay__hint { margin-top: 14px; text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 0.82em; font-weight: 600; }
.card-overlay__acquired { margin-bottom: 14px; min-height: 1em; text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 0.82em; font-weight: 600; }
.card-overlay__close {
    position: absolute; top: 16px; right: 16px; z-index: 2;
    width: 42px !important; height: 42px !important; flex: 0 0 auto; box-sizing: border-box; padding: 0; margin: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.15); color: #fff; border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%; cursor: pointer;
}
.card-overlay__nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 40px !important; height: 60px !important; flex: 0 0 auto; box-sizing: border-box; padding: 0; margin: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; color: #fff; border: none; cursor: pointer;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}
.card-overlay__nav[disabled] { opacity: 0.25; cursor: default; }
.card-overlay__nav--prev { left: 2px; }
.card-overlay__nav--next { right: 2px; }
.card-overlay__pos { margin-top: 6px; text-align: center; color: rgba(255, 255, 255, 0.7); font-size: 0.78em; font-weight: 700; }
.card-overlay__download {
    margin-top: 12px; display: inline-flex; align-items: center; gap: 8px;
    width: auto !important; padding: 9px 18px !important; box-sizing: border-box;
    background: rgba(255, 255, 255, 0.14); color: #fff; border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 999px; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.card-overlay__download svg { width: 16px; height: 16px; }
.card-overlay__download:hover { background: rgba(255, 255, 255, 0.24); }
.card-overlay__download:disabled { opacity: 0.5; cursor: default; }
.card-overlay__viewbus {
    margin-top: 12px; display: inline-flex; align-items: center; gap: 8px;
    width: auto !important; padding: 9px 18px !important; box-sizing: border-box;
    background: rgba(255, 255, 255, 0.92); color: #111; border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 999px; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.card-overlay__viewbus svg { width: 16px; height: 16px; }
.card-overlay__viewbus:hover { background: #fff; }
