﻿body{
    background-color: lightskyblue;
    min-height: 100vh;
    background-image: url('../img/themes/body.png');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    /*border: 10px solid lime !important;*/
}

.head{
    background-image: url('../img/themes/head.png');
    height: 350px;
    background-size: cover;
    background-position: top center;
    text-align: center;
    font-size: 40px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px black;
    padding: 20px;
    position: relative;
    /*box-shadow:  20px 20px 20px rgba(0, 0, 0, 1.5);*/
    /*border-bottom: 2px solid rgba(255, 255, 255, 0.5);*/
    /*border-bottom: 2px solid rgba(255, 255, 255, 0.7);*/
    border-bottom: 2px solid gold;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 1);
}

.head::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: top center;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
    pointer-events: none;
}

.head.theme-changing::before {
    opacity: 1;
}

#card-master-section{
   /*background-color: GrayText;*/
   background-color: rgba(95, 102, 106, 0.95);
   min-height: 850px;
   position: relative;
    /*border-bottom: 2px solid darkgray;*/
    border-bottom: 2px solid gold;
    box-shadow: 0 2px 0 rgba(0, 0, 0, .3);
}

.loading-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Hide series selector and card container until loaded */
#series-selector-wrapper,
#card-container {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#series-selector-wrapper.loaded,
#card-container.loaded {
    visibility: visible;
    opacity: 1;
}

/* Stats section is always visible with pre-loaded zeros */
#account-stats {
    visibility: visible;
    opacity: 1;
}


.loading-text {
    color: white;
    font-size: 24px;
    font-weight: 500;
    text-align: center;
    margin: 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.empty-section {
    /*background-color: lightskyblue;*/
    /*background-color: rgba(51, 51, 51, 0.9);*/
    /*background-color: rgba(135, 206, 250, 0.8);*/
    background-color: rgba(255, 255, 255, 0.2);
    min-height: 200px;
    padding: 50px;
}

.footer {
    background-color: #303030;
    color: white;
    text-align: center;
    padding: 30px 20px;
    margin: 0;
    /*border-top: 1px solid greenyellow;*/
}

.footer p {
    margin: 0;
    font-size: 16px;
}

.card{
    width: 150px;
    height: 220px;
    box-shadow: black 2px 2px 5px;
    flex-shrink: 0;
    order: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    background-color: transparent;
    border-radius: 10px;

    /*border: 1px solid black;*/
    /*border: 1px solid #fff;*/
    background-size: 102% 102%;
    /*background-size: cover;*/
    background-position: center;
    position: relative;
    touch-action: manipulation; /* Eliminate 300ms tap delay on mobile */
}

/* Grayscale filter for cards with 0 count */
.card.zero-count {
    filter: grayscale(100%) brightness(0.8);
    opacity: 0.7;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

/* Only apply hover effects on non-touch devices */
body:not(.touch-device) .card:hover{
    transform: scale(1.10);
    transition: transform 0.3s ease;
    box-shadow: 0 6px 20px rgba(118, 207, 249, 0.9);
}

.card-counter{
    margin-top: 15px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    user-select: none;
}

.count {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

/* Force card 13 to column 7, row 1 */
#card-container .card-wrapper:nth-child(13) {
    grid-column: 7;
    grid-row: 1;
    margin-left: 20px;
}

/* Card 14 naturally goes to column 7, row 2 */
#card-container .card-wrapper:nth-child(14) {
    grid-column: 7;
    grid-row: 2;
    margin-left: 20px;
}

/* Special cards styling */
.card-special {
    box-shadow: black 2px 2px 5px;
    color: white;
    font-weight: bold;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    /*border: 2px solid gold;*/
    /*border: 2px solid black;*/
}

/* Special cards gold glow on desktop hover */
body:not(.touch-device) .card-special:hover {
    transform: scale(1.1) rotate(2deg);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.6);
}

.card-grid-6 {
    display: grid;
    grid-template-columns: repeat(7, 150px);
    gap: 30px;
    justify-content: center;
    margin-left: -20px; /* Offset to compensate for special card right shift */
}

/* Account Stats Section */
.stats-section {
    background-color: rgba(50, 50, 50, 0.7);
    min-height: 265px;
    padding: 50px 0;
    border-bottom: 2px solid rgba(255, 215, 0, 0.69);
}

.account-stats {
    text-align: center;
    color: #fff;
    font-size: 18px;
}

.account-stats h2 {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 700px;
    margin: 0 auto;
}

.stat-item {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #2c5aa0;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.series-selector-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: calc(7 * 150px + 6 * 30px + 20px); /* Match card grid width + special card offset */
    margin: 0 auto;
}

.series-selector-inner {
    display: flex;
    align-items: center;
}

#series-selector {
    width: 300px;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

#login-btn {
    padding: 8px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: none; /* Hidden until auth check completes */
}

#login-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    border-color: #007bff;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
    right: 5px;
    display: none; /* Hidden until auth check completes */
}

.username-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.username-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    border-color: #007bff;
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.username-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu-custom {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    display: none;
    z-index: 1000;
}

.dropdown-menu-custom.show {
    display: block;
}

.dropdown-item-custom {
    width: 100%;
    padding: 10px 20px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 16px;
    color: #333;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-item-custom:hover {
    background-color: #f8f9fa;
}

.dropdown-item-custom.logout-btn {
    color: #dc3545;
    background-color: #fdd;
}

.dropdown-item-custom.logout-btn:hover {
    background-color: #fcc;
    color: #c82333;
}







/* Responsive: smaller screens */
@media (max-width: 1350px) {
    .card-grid-6 {
        grid-template-columns: repeat(4, 150px);
        margin-left: 0; /* Reset offset on smaller screens */
        min-height: 1255px; /* Reserve space for 4 rows of cards (200px cards + counters + gaps) */
    }
    .series-selector-wrapper {
        width: calc(4 * 150px + 3 * 30px);
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .card-grid-6 {
        grid-template-columns: repeat(3, 150px);
        margin-left: 0; /* Reset offset on smaller screens */
    }
    .series-selector-wrapper {
        width: calc(3 * 150px + 2 * 30px);
        margin: 0 auto;
    }
}

@media (max-width: 576px) {
    .user-dropdown {
        right: 0;
    }

    .card-grid-6 {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-left: 0; /* Reset offset on smaller screens */
    }

    .card {
        width: 90%;
        max-width: 300px;
        height: 400px;
        margin: 0 auto;
    }

    .card-counter {
        width: 90%;
        max-width: 300px;
        margin: 10px auto 0;
    }

    .series-selector-wrapper {
        width: 100%;
        max-width: 400px;
        padding: 0 20px;
        flex-direction: column-reverse; /* Auth section on top, series below */
        gap: 15px;
        align-items: stretch;
    }

    .auth-section {
        justify-content: center;
    }

    .series-selector-inner {
        width: 100%;
    }

    #series-selector {
        width: 100%;
    }
}

/* Remove special positioning on smaller screens */
@media (max-width: 1350px) {
    .card-wrapper-special {
        grid-column: auto;
        margin-left: 0;
        order: 1;
    }

    /* Reset forced positioning for cards 13 and 14 */
    #card-container .card-wrapper:nth-child(13),
    #card-container .card-wrapper:nth-child(14) {
        grid-column: auto;
        grid-row: auto;
        margin-left: 0;
    }
}