/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Header */
header {
    background-color: var(--header-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0 40px;
    height: 80px;
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

#logo {
    height: 50px;
    width: auto;
    transition: transform 0.3s ease;
}

#logo:hover {
    transform: scale(1.05);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    background: var(--select-trigger-bg);
    border: 1px solid var(--select-trigger-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--theme-transition);
}

.theme-toggle:hover {
    border-color: var(--accent-color);
}

.toggle-icon {
    width: 20px;
    height: 20px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

[data-theme="dark"] .toggle-icon {
    /* Moon icon for dark theme */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bbb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3E%3C/path%3E%3C/svg%3E");
}

[data-theme="light"] .toggle-icon {
    /* Sun icon for light theme */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'%3E%3C/circle%3E%3Cline x1='12' y1='1' x2='12' y2='3'%3E%3C/line%3E%3Cline x1='12' y1='21' x2='12' y2='23'%3E%3C/line%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3E%3C/line%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3E%3C/line%3E%3Cline x1='1' y1='12' x2='3' y2='12'%3E%3C/line%3E%3Cline x1='21' y1='12' x2='23' y2='12'%3E%3C/line%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3E%3C/line%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3E%3C/line%3E%3C/svg%3E");
}

.controls-container {
    display: flex;
    gap: 15px;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

/* Header Center - Search */
.header-center {
    display: flex;
    justify-content: center;
    width: 100%;
    z-index: 1001;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
}

#searchInput {
    width: 100%;
    height: 40px;
    background: var(--select-trigger-bg);
    border: 1px solid var(--select-trigger-border);
    border-radius: 20px;
    padding: 0 40px 0 20px;
    /* Left padding for search icon if needed, or right for buttons */
    /* Decision: Search Icon LEFT, Clear Icon RIGHT */
    padding-left: 40px;
    padding-right: 40px;
    font-size: 14px;
    color: var(--text-color);
    outline: none;
    transition: all 0.3s;
}

#searchInput:focus {
    border-color: #d32f2f;
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

.search-icon {
    position: absolute;
    left: 15px;
    /* Moved to Left */
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.clear-icon {
    position: absolute;
    right: 15px;
    /* Right for Clear */
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    cursor: pointer;
    transition: opacity 0.2s;
}

.clear-icon:hover {
    opacity: 1;
}

/* Language Hover Styles */
.language-hover-container {
    position: relative;
    cursor: pointer;
    height: 100%;
    display: flex;
    align-items: center;
}

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
    transition: background 0.2s;
}

.lang-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lang-trigger span {
    font-weight: 500;
}

/* Globe Icon SVG */
.globe-icon {
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='2' y1='12' x2='22' y2='12'%3E%3C/line%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

/* Hover Interaction */
.language-hover-container:hover .options-list {
    display: grid;
    animation: fadeIn 0.2s ease-out;
}

/* Custom Select (Remaining mostly for compat if needed, but Language moved out) */
.custom-select {
    position: relative;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    min-width: 160px;
}

.select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--select-trigger-bg);
    border: 1px solid var(--select-trigger-border);
    border-radius: 6px;
    padding: 8px 12px;
    transition: all 0.2s;
    color: var(--select-trigger-text);
    height: 40px;
}

.select-trigger:hover {
    border-color: #b0b0b0;
    background-color: #fafafa;
}

.select-trigger span {
    margin-right: 10px;
    font-weight: 500;
}

.arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-color);
    opacity: 0.6;
    transition: transform 0.2s;
}

.custom-select.active .arrow {
    transform: rotate(180deg);
}

.options-list {
    position: absolute;
    top: 110%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}

/* Hover Bridge to prevent gap closing */
.options-list::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

.custom-select.active .options-list {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* Specific Layout for Language Menu (4x8 Grid) */
#languageBox .options-list {
    grid-template-columns: repeat(4, 1fr);
    width: 600px;
    /* Sufficient width for 4 columns */
    padding: 10px;
    max-height: none;
    /* Remove scroll limitation */
    overflow-y: visible;
}

#languageBox .custom-select.active .options-list {
    display: grid;
    /* Activate grid */
}

.option {
    padding: 10px 15px;
    color: #444;
    transition: background 0.1s;
    cursor: pointer;
}

#languageBox .option {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
    /* Ensure consistent height for alignment */
    text-align: center;
    line-height: 1.2;
    border-radius: 4px;
}

.option:hover {
    background-color: #f5f7fa;
    color: #d32f2f;
}

.option.selected {
    background-color: #ffebee;
    /* Light red bg */
    color: #d32f2f;
    font-weight: 700;
}

/* Filter Tabs */
.filter-tabs-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.tab-item {
    padding: 10px 24px;
    border-radius: 25px;
    background: var(--select-trigger-bg);
    border: 1px solid var(--select-trigger-border);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.tab-item:hover {
    border-color: #d32f2f;
    color: #d32f2f;
}

.tab-item.active {
    background: #d32f2f;
    color: white;
    border-color: #d32f2f;
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.3);
}

/* Gallery Grid */
#thumbs {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    justify-content: center;
    gap: 25px;
    padding: 20px 40px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    align-items: start;
    position: relative;
    z-index: 1;
}


/* Game Card */
.game-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px var(--card-shadow);
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}




.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.card-image-container {
    position: relative;
    width: 100%;
    padding-top: 61.54%;
    /* 325x200 Aspect Ratio (approx 1.625:1) */
    background-color: #eee;
    overflow: hidden;
}

.game-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}

.game-card:hover .game-icon {
    transform: scale(1.1);
}

.game-card.coming-soon .game-icon {
    filter: grayscale(100%);
    opacity: 0.8;
}

.game-card.coming-soon:hover {
    transform: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}


/* Game Type Badge */
.game-type-badge {
    position: absolute;
    top: 0;
    right: 0;
    padding: 3px 8px;
    border-radius: 0;
    border-bottom-left-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    color: white;
    z-index: 5;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    text-transform: uppercase;
}

.game-type-badge.slot {
    background: rgba(255, 193, 7, 0.85);
    /* Yellow */
}

.game-type-badge.crash {
    background: rgba(255, 152, 0, 0.85);
    /* Orange */
}

.game-type-badge.scratch {
    background: rgba(0, 188, 212, 0.85);
    /* Cyan */
}

.game-type-badge.keno {
    background: rgba(33, 150, 243, 0.85);
    /* Blue */
}

.game-type-badge.roulette {
    background: rgba(156, 39, 176, 0.85);
    /* Purple */
}

.game-type-badge.skill {
    background: rgba(63, 81, 181, 0.85);
    /* Indigo */
}

.game-type-badge.other {
    background: rgba(158, 158, 158, 0.85);
    /* Grey */
}

/* Coming Soon Overlay */
/* Coming Soon Label (Tag at top-left of icon) */
.coming-soon-label {
    position: absolute;
    top: 0px;
    left: 0px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 3px 8px;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.5px;
    z-index: 10;
    pointer-events: none;
    border-bottom-right-radius: 6px;
    text-transform: uppercase;
}

/* Multiplier Label (Tag at bottom-left of icon) */
.multiplier-label {
    position: absolute;
    bottom: 0px;
    left: 0px;
    background: rgba(229, 57, 53, 0.85);
    color: white;
    padding: 3px 8px;
    font-weight: 800;
    font-size: 10px;
    z-index: 10;
    border-top-right-radius: 6px;
    text-transform: uppercase;
}

/* Release Date Label (Tag at bottom-center of icon) */
.release-date-label {
    position: absolute;
    bottom: 25px;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-weight: 700;
    font-size: 15px;
    text-transform: none;
    z-index: 10;
    pointer-events: none;
    text-align: center;
    padding: 10px 0;
    border-radius: 0;
    box-shadow: none;
    font-family: 'Roboto', sans-serif;
    white-space: nowrap;
}




/* Hover Overlay */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Initially allow clicks to pass through if needed, but we handle logic */
}

.game-card:hover .card-overlay {
    opacity: 1;
    pointer-events: auto;
}

.game-card.coming-soon:hover .card-overlay {
    display: none !important;
}


/* Coming Soon Hover Text */
.coming-soon-hover-text {
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Mobile specific action buttons (shown by default on small screens) */
.mobile-actions {
    display: none;
    /* Hidden by default on PC */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35%;
    /* Take bottom 1/3 ~ 35% of the image container */
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 5px;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    z-index: 20;
}

.mobile-actions .btn-sm {
    flex: 1;
    padding: 6px 4px;
    font-size: 10px;
    min-width: 0;
    border-radius: 4px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.mobile-actions .btn-primary {
    background: #e53935;
}

.mobile-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    .card-overlay {
        display: none !important;
        /* Hide hover overlay on mobile */
    }

    .mobile-actions {
        display: flex;
    }
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    min-width: 140px;
    text-align: center;
    border: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #e53935 0%, #d32f2f 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4);
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

/* Footer (Card Content) */
.card-footer {
    height: 40px;
    /* 进一步压低固定高度 */
    padding: 2px 8px;
    /* 极致缩减上下边距 */
    background: var(--footer-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--footer-border);
    z-index: 1;
}

.game-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--card-text);
    white-space: normal;
    text-align: center;
    line-height: 1.1;
    word-break: break-word;
    max-height: 100%;
    overflow: hidden;
}

/* Footer Page */
#footer {
    text-align: center;
    padding: 30px;
    color: #999;
    font-size: 13px;
    background: var(--footer-bg);
    margin-top: auto;
    border-top: 1px solid var(--footer-border);
    position: relative;
    z-index: 1;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ruler hidden */
#ruler {
    visibility: hidden;
    position: absolute;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 10px 15px;
        height: auto;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "logo controls"
            "search search";
        padding-bottom: 20px;
        width: 100%;
        /* Removed overflow-x: hidden to allow suggestions to overflow */
    }

    #logo {
        grid-area: logo;
        height: 40px;
        justify-self: start;
        margin-top: 5px;
    }

    .controls-container {
        grid-area: controls;
        justify-self: end;
        width: auto;
        gap: 10px;
    }

    .header-center {
        grid-area: search;
        width: 100%;
        padding: 0;
    }

    .search-container {
        max-width: 100%;
    }

    #thumbs {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        padding: 20px 15px;
        gap: 10px;
    }

    .custom-select {
        min-width: 100px;
    }

    /* Mobile Dropdown Fixes */

    /* Language Menu: Full screen width centered modal-like style */
    #languageBox .options-list {
        position: fixed;
        top: 20%;
        left: 5%;
        width: 90%;
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols for mobile */
        max-height: 60vh;
        overflow-y: auto;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        border: 1px solid var(--select-trigger-border);
        transform: none;
        z-index: 2000;
        background: #fff;
    }

    /* Filter Menu: Centered modal-like style for mobile */
    #filterBox .options-list {
        position: fixed;
        top: 30%;
        left: 50%;
        transform: translateX(-50%);
        width: 60%;
        min-width: 200px;
        max-height: 50vh;
        overflow-y: auto;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        border: 1px solid var(--select-trigger-border);
        z-index: 2005;
        background: #fff;
        right: auto;
    }

    /* Generic override (safety) */
    .options-list {
        position: absolute;
    }
}

/* Side Floating Buttons */
.side-controls {
    position: fixed;
    right: 20px;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.side-btn {
    width: 48px;
    height: 48px;
    background: var(--header-bg);
    border: 1px solid var(--select-trigger-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.side-btn:hover {
    transform: translateY(-3px);
    border-color: #d32f2f;
    box-shadow: 0 6px 16px rgba(211, 47, 47, 0.3);
}

.side-icon {
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
}

.side-btn:hover .side-icon {
    opacity: 1;
}

.icon-up {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'%3E%3C/polyline%3E%3C/svg%3E");
}

.icon-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

[data-theme="dark"] .icon-up {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bbb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .icon-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bbb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

@media (max-width: 768px) {
    .side-controls {
        right: 15px;
        bottom: 20px;
    }

    .side-btn {
        width: 42px;
        height: 42px;
    }
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--select-trigger-border);
    border-radius: 8px;
    margin-top: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    overflow: hidden;
    display: none;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

/* Highlight for search suggestions */
.suggestion-highlight {
    color: #e53935;
    font-weight: 700;
    text-decoration: underline;
}

/* Search suggestion footer */
.suggestion-footer {
    padding: 8px 15px;
    font-size: 12px;
    color: #888;
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid var(--select-trigger-border);
    text-align: right;
    font-style: italic;
}