/* 修改 game-page 布局为上下布局 */
.game-page {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

.game-page__mainblock.mainblock-game {
    display: block !important;
    width: 100% !important;
    max-width: 1000px !important;
    margin: 0 auto !important;
}

.mainblock-game__content {
    display: block !important;
}

.mainblock-game__main {
    display: block !important;
    width: 100% !important;
}

.game-page__content {
    display: block !important;
    width: 100% !important;
    max-width: 1000px !important;
    margin: 20px auto 0 !important;
}

/* 强制显示游戏预览区域的所有层级 */
.screen,
.screen__main,
.screen__body,
.screen__window,
.NewPlayGames,
.screen__preview,
.preview-screen,
.NewGameInfo {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    width: 100% !important;
}

.screen__window {
    aspect-ratio: 16 / 9 !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    background: #000 !important; /* 背景黑，防止 iframe 加载时闪烁 */
}

/* 固定 preview-screen__content 样式，PC 和移动端统一 */
.preview-screen {
    width: 100% !important;
    height: 100% !important;
    background: var(--candy-gradient) !important;
    margin-bottom: 0 !important;
}

.screen__gamebox {
    width: 100% !important;
    height: 100% !important;
}

.preview-screen__bg-ibg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0.3 !important;
    z-index: 1 !important;
    overflow: hidden !important;
}

.preview-screen__bg-ibg img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.preview-screen__content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    position: relative !important;
    z-index: 10 !important;
    width: 100% !important;
    height: 100% !important;
}

.preview-screen__image-ibg {
    width: 120px !important;
    height: 120px !important;
    margin-bottom: 15px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
}

.preview-screen__image-ibg img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.preview-screen__title {
    font-size: 24px !important;
    font-weight: 700 !important;
    color: #fff !important;
    margin-bottom: 15px !important;
    text-align: center !important;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
}

.preview-screen__button {
    padding: 10px 35px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    background: #fff !important;
    color: var(--candy-primary) !important;
    border: none !important;
    border-radius: 30px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
}

.preview-screen__button:hover {
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3) !important;
}

/* 移动端隐藏 mobileblock，统一使用 preview-screen */
.mobileblock {
    display: none !important;
}

/* 移动端适配 preview-screen */
@media (max-width: 768px) {
    .screen__window {
        aspect-ratio: 4 / 3 !important;
    }

    .preview-screen__content {
        padding: 15px !important;
    }

    .preview-screen__image-ibg {
        width: 100px !important;
        height: 100px !important;
    }

    .preview-screen__title {
        font-size: 20px !important;
    }

    .preview-screen__button {
        padding: 8px 25px !important;
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .screen__window {
        aspect-ratio: 1 / 1 !important;
        border-radius: 15px !important;
    }

    .preview-screen__content {
        padding: 10px !important;
    }

    .preview-screen__image-ibg {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 10px !important;
    }

    .preview-screen__title {
        font-size: 18px !important;
        margin-bottom: 10px !important;
    }

    .preview-screen__button {
        padding: 8px 20px !important;
        font-size: 14px !important;
    }
}

/* 修改 apps-sidebar 布局为多列网格 */
.apps-sidebar {
    margin-top: 30px !important;
}

.apps-sidebar__title {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: var(--candy-primary) !important;
    text-align: center !important;
    margin-bottom: 20px !important;
}

.apps-sidebar__items {
    display: grid !important;
    grid-template-columns: repeat(8, 1fr) !important;
    gap: 15px !important;
}

@media (max-width: 1600px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(7, 1fr) !important;
    }
}

@media (max-width: 1400px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

@media (max-width: 1200px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

@media (max-width: 900px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px !important;
    }
}

@media (max-width: 600px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
}

@media (max-width: 450px) {
    .apps-sidebar__items {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}

/* PWA 安装按钮样式 - Candy Bounce */
.pwa-install-btn {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    padding: 14px 24px;
    background: linear-gradient(135deg, #ff5c8a 0%, #5cc8ff 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(255, 92, 138, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    touch-action: none;
    white-space: nowrap;
    min-width: max-content;
    animation: candyInstallBounce 2s ease-in-out infinite;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 92, 138, 0.5);
    animation-play-state: paused;
}

@keyframes candyInstallBounce {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 0 6px 20px rgba(255, 92, 138, 0.4);
    }
    50% {
        transform: translateY(-8px);
        box-shadow: 0 12px 30px rgba(255, 92, 138, 0.5);
    }
}

.pwa-install-btn svg {
    width: 24px;
    height: 24px;
}

/* PWA 弹窗样式 */
.pwa-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.pwa-modal.active {
    display: flex;
}

.pwa-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease;
}

.pwa-modal-wrapper {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 480px;
    animation: modalEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnter {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9) rotateX(-10deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
    }
}

.pwa-modal-content {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 32px;
    padding: 48px 40px 40px;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    overflow: hidden;
}

.pwa-modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 183, 77, 0.08) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pwa-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #718096;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.pwa-modal-close:hover {
    background: #fff;
    color: #2d3748;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pwa-modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-visual {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.app-icon-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.icon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 183, 77, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

.app-icon {
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 8px 24px rgba(255, 183, 77, 0.4));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.app-name {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #FFB74D 0%, #FF8A65 50%, #F06292 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 8px;
    letter-spacing: -1px;
}

.app-tagline {
    font-size: 16px;
    color: #718096;
    margin: 0;
    font-weight: 500;
}

.modal-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.feature-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px 16px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid #FFF3E0;
}

.feature-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 35px rgba(255, 183, 77, 0.25);
    border-color: #FFE0B2;
}

.feature-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.gradient-1 {
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%);
}

.gradient-2 {
    background: linear-gradient(135deg, #F06292 0%, #E91E63 100%);
}

.gradient-3 {
    background: linear-gradient(135deg, #4DD0E1 0%, #00BCD4 100%);
}

.feature-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 6px;
}

.feature-card p {
    font-size: 12px;
    color: #718096;
    margin: 0;
    line-height: 1.4;
}

.modal-stats {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: linear-gradient(135deg, rgba(255, 183, 77, 0.08) 0%, rgba(255, 138, 101, 0.08) 100%);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #e2e8f0, transparent);
}

.modal-actions {
    position: relative;
    z-index: 1;
}

.install-button {
    width: 100%;
    padding: 20px 32px;
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 50%, #FF8A65 100%);
    border: none;
    border-radius: 18px;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 30px rgba(255, 152, 0, 0.4);
}

.button-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.button-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

.install-button:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 45px rgba(255, 152, 0, 0.5);
}

.install-button:active {
    transform: translateY(-2px) scale(1);
}

.install-button svg {
    width: 24px;
    height: 24px;
}

.cancel-button {
    width: 100%;
    padding: 16px;
    margin-top: 12px;
    background: transparent;
    border: 2px solid #e2e8f0;
    border-radius: 18px;
    color: #718096;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cancel-button:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    color: #4a5568;
    transform: translateY(-2px);
}

@media (max-width: 600px) {
    .pwa-install-btn {
        right: 1rem;
        bottom: 1rem;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .pwa-install-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .pwa-modal-wrapper {
        width: 95%;
        max-width: none;
    }
    
    .pwa-modal-content {
        padding: 40px 28px 32px;
        border-radius: 28px;
    }
    
    .app-icon-container {
        width: 100px;
        height: 100px;
    }
    
    .app-icon {
        width: 100px;
        height: 100px;
    }
    
    .icon-glow {
        width: 120px;
        height: 120px;
    }
    
    .app-name {
        font-size: 26px;
    }
    
    .app-tagline {
        font-size: 14px;
    }
    
    .modal-features {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .feature-card {
        padding: 16px 14px;
    }
    
    .feature-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 10px;
    }
    
    .feature-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .feature-card h3 {
        font-size: 14px;
    }
    
    .feature-card p {
        font-size: 12px;
    }
    
    .modal-stats {
        padding: 16px;
        border-radius: 16px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .stat-divider {
        height: 30px;
    }
    
    .install-button {
        padding: 18px 24px;
        font-size: 16px;
        border-radius: 16px;
    }
    
    .button-content svg {
        width: 20px;
        height: 20px;
    }
    
    .cancel-button {
        padding: 14px;
        font-size: 14px;
    }
}

/* Categories Modal Styles */
.candy-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.candy-modal.candy-modal--active {
    display: flex;
}

.candy-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease;
}

.candy-modal-wrapper {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    animation: candyModalEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes candyModalEnter {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.candy-modal-content {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #fff5f8 100%);
    border-radius: 28px;
    padding: 40px 36px 36px;
    box-shadow:
        0 20px 60px rgba(255, 92, 138, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.8) inset;
    overflow: hidden;
    max-height: calc(80vh - 40px);
    overflow-y: auto;
}

.candy-modal-content::-webkit-scrollbar {
    width: 8px;
}

.candy-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.candy-modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ff5c8a 0%, #ffb8d0 100%);
    border-radius: 4px;
}

.candy-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #718096;
    z-index: 10;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.candy-modal-close:hover {
    background: #fff;
    color: #ff5c8a;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 92, 138, 0.3);
}

.candy-modal-close svg {
    width: 18px;
    height: 18px;
}

.candy-modal-header {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #fff0f5;
}

.candy-modal-header h2 {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #ff5c8a 0%, #ff8a9b 50%, #ffb8d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
}

.candy-modal-body .candy-categories {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 0;
    animation: candyFadeIn 0.4s ease-out 0.1s both;
}

.candy-modal-body .candy-category-pill {
    padding: 14px 28px;
    font-size: 15px;
}

@media (max-width: 600px) {
    .candy-modal-wrapper {
        width: 95%;
        max-width: none;
    }

    .candy-modal-content {
        padding: 32px 24px 28px;
        border-radius: 24px;
    }

    .candy-modal-header h2 {
        font-size: 22px;
    }

    .candy-modal-body .candy-category-pill {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Random Game Button */
.candy-random-game-container {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    padding: 20px 0;
}

.candy-random-game-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #ff5c8a 0%, #ff8a9b 50%, #ffb8d0 100%);
    color: #fff;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 8px 25px rgba(255, 92, 138, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.candy-random-game-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 35px rgba(255, 92, 138, 0.5);
}

.candy-random-game-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.candy-random-game-btn svg {
    width: 24px;
    height: 24px;
    animation: diceShake 2s ease-in-out infinite;
}

@keyframes diceShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: rotate(-10deg);
    }
    20%, 40%, 60%, 80% {
        transform: rotate(10deg);
    }
}

@media (max-width: 600px) {
    .candy-random-game-btn {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    .candy-random-game-btn svg {
        width: 22px;
        height: 22px;
    }
}
