:root {
    --bg-dark: #0f0c29;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --accent: #00d2ff;
    --accent-glow: rgba(0, 210, 255, 0.5);
    --glass: rgba(255, 255, 255, 0.1);

    /* New Rarity Colors */
    --ssssr-color: linear-gradient(135deg, #ff0000, #ff00cc, #3333ff, #00ffcc, #ffcc00, #ff0000);
    --sssr-color: linear-gradient(135deg, #ff00cc, #3333ff, #00ffcc, #ffcc00);
    --ssr-color: linear-gradient(135deg, #ffd700, #b8860b, #daa520);
    --sr-color: linear-gradient(135deg, #2196f3, #1976d2, #0d47a1);
    --r-color: linear-gradient(135deg, #4caf50, #388e3c, #1b5e20);
    --c-color: linear-gradient(135deg, #a8a8a8, #d3d3d3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: #fff;
    font-family: 'Kanit', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    padding: 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--accent-glow);
}

nav button {
    background: var(--glass);
    border: 1px solid var(--glass);
    color: white;
    padding: 0.5rem 1.5rem;
    margin: 0 0.5rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

nav button:hover {
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

main {
    max-width: 1400px;
    /* Increased to accommodate larger cards */
    margin: 0 auto;
    padding: 2rem;
}

section {
    display: none;
}

section.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pack-container {
    text-align: center;
    margin-bottom: 3rem;
}

.pack-visual {
    width: 200px;
    height: 300px;
    margin: 0 auto 2rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.pack-visual:hover {
    transform: scale(1.05) rotate(2deg);
}

.pack-shaker {
    width: 100%;
    height: 100%;
    position: relative;
    pointer-events: none;
}

.pack-half {
    position: absolute;
    width: 100%;
    height: 50.5%;
    /* Slight overlap to prevent seam */
    overflow: hidden;
    transition: all 0.5s ease-in;
}

.pack-half.top {
    top: 0;
}

.pack-half.bottom {
    bottom: 0;
}

.pack-half img {
    width: 100%;
    height: 300px;
    /* Original height */
    object-fit: cover;
    border-radius: 15px;
    display: block;
}

.pack-half.bottom img {
    margin-top: -150px;
    /* Offset for bottom half */
}

/* Tearing Animation States */
.tearing .pack-shaker {
    animation: shake 0.5s infinite;
}

.tearing.torn .pack-half.top {
    transform: translateY(-150px) rotate(-15deg);
    opacity: 0;
}

.tearing.torn .pack-half.bottom {
    transform: translateY(150px) rotate(15deg);
    opacity: 0;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px) rotate(-1deg);
    }

    75% {
        transform: translateX(5px) rotate(1deg);
    }
}

.pack-glow {
    position: absolute;
    top: -10%;
    left: -10%;
    right: -10%;
    bottom: -10%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    z-index: -1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.3;
        transform: scale(1);
    }
}

.btn-primary {
    background: linear-gradient(to right, #00d2ff, #3a7bd5);
    border: none;
    color: white;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 210, 255, 0.4);
    transition: all 0.3s ease;
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.6);
    filter: brightness(1.1);
}

/* Card Styles */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 2rem;
    justify-items: center;
    padding-top: 2rem;
}

.card {
    width: 230px;
    height: 330px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card:hover {
    transform: translateY(-10px);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: left;
    /* Header is left-aligned */
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card.revealed .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.card-back {
    background: url('assets/back-card.png') no-repeat center center;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #666;
    z-index: 2;
}

.card-back::after {
    content: 'POD';
    font-weight: bold;
    color: rgba(255, 255, 255, 0.2);
    font-size: 3rem;
    transform: rotate(-45deg);
}

.card-front {
    transform: rotateY(180deg);
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Rarity Backgrounds */
.card.ssssr .card-front {
    background: var(--ssssr-color);
    background-size: 600% 600%;
    animation: moveGradient 3s infinite alternate;
}

.card.sssr .card-front {
    background: var(--sssr-color);
    background-size: 400% 400%;
    animation: moveGradient 5s infinite alternate;
}

.card.ssr .card-front {
    background: var(--ssr-color);
}

.card.sr .card-front {
    background: var(--sr-color);
}

.card.r .card-front {
    background: var(--r-color);
}

.card.c .card-front {
    background: var(--c-color);
}

@keyframes moveGradient {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

/* Glossy Effect */
.card-gloss {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(110deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.2) 45%, rgba(255, 255, 255, 0) 50%);
    background-size: 200% 200%;
    z-index: 5;
    pointer-events: none;
    border-radius: 18px;
}

.card:hover .card-gloss {
    animation: shine 1.5s infinite;
}

@keyframes shine {
    0% {
        background-position: 200% 0%;
    }

    100% {
        background-position: -200% 0%;
    }
}

/* Card Content Container */
.card-content {
    background: #fdfdfd;
    height: 100%;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Header: Name and HP */
.card-header {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: #333;
}

.card-header .name {
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
    /* Increased since HP is gone */
}

/* Image Box */
.image-box {
    width: 90%;
    height: 150px;
    margin: 0 auto;
    background: radial-gradient(circle, #eee 20%, #ccc 100%);
    border: 3px solid #777;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.image-box img {
    /* width: 100%;
    height: 100%; */
    object-fit: cover;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
}

/* Card Body */
.card-body {
    padding: 12px;
    flex-grow: 1;
    border-top: 1px solid #ddd;
    margin-top: 10px;
    color: #444;
    overflow-y: auto;
}

.ability {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ability strong {
    font-size: 0.9rem;
    color: #222;
}

.ability p {
    font-size: 0.75rem;
    line-height: 1.3;
}

/* Card Footer */
.card-footer {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid #eee;
    color: #555;
}

.rarity-symbol {
    color: #f39c12;
    font-weight: bold;
}

.rarity-text {
    font-weight: bold;
    color: #333;
}

/* Collection Grid Items */
.card.locked {
    filter: grayscale(1) brightness(0.5);
    pointer-events: none;
}

/* Modal Detail */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-gradient);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--glass);
    width: 80%;
    max-width: 600px;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #fff;
}

.detail-container {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.detail-info h2 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.detail-info p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* God Pack Effect */
.god-pack-effect {
    animation: god-bg 1s infinite alternate;
}

@keyframes god-bg {
    from {
        box-shadow: inset 0 0 100px rgba(255, 235, 59, 0.2);
    }

    to {
        box-shadow: inset 0 0 200px rgba(255, 235, 59, 0.5);
    }
}

@media (max-width: 600px) {
    .detail-container {
        flex-direction: column;
        text-align: center;
    }
}