/* =========================================================
   Home redesign v3 — dark theme, modern UI
   Dark purple palette, Inter + Montserrat, accent #8b5cf6
   Scoped to #main-screen.new-design
   ========================================================= */

@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiA.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fAZ9hiA.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYAZ9hiA.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuFuYAZ9hiA.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Hw5aXo.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCuM73w5aXo.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCu173w5aXo.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCsn73w5aXo.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- Background & decor --- */
#main-screen.new-design {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a0b2e 50%, #0f0f0f 100%) !important;
    padding: 24px;
}

#main-screen.new-design .home-decor {
    position: absolute;
    border-radius: 100%;
    pointer-events: none;
    z-index: 0;
}
#main-screen.new-design .home-decor-1 {
    width: 240px;
    height: 240px;
    background: #8b5cf6;
    opacity: 0.15;
    top: -80px;
    right: -80px;
    animation: decorFloat 8s ease-in-out infinite;
}
#main-screen.new-design .home-decor-2 {
    width: 280px;
    height: 280px;
    background: #7c3aed;
    opacity: 0.25;
    bottom: -100px;
    left: -100px;
    animation: decorFloat 10s ease-in-out infinite reverse;
}
#main-screen.new-design .home-decor-3 {
    width: 56px;
    height: 56px;
    background: #c4b5fd;
    opacity: 0.3;
    top: 200px;
    left: 24px;
    animation: decorFloat 6s ease-in-out infinite;
}

@keyframes decorFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.05); }
}

#main-screen.new-design .home-container {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    padding: 24px 20px 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 40px rgba(139, 92, 246, 0.1);
    backdrop-filter: blur(10px);
}

/* --- Mobile: full-bleed --- */
@media (max-width: 599.98px) {
    #main-screen.new-design { padding: 0; }
    #main-screen.new-design .home-container {
        min-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding: 16px 16px 32px;
    }
    #main-screen.new-design .home-decor-1 { width: 200px; height: 200px; top: -60px; right: -60px; }
    #main-screen.new-design .home-decor-2 { width: 220px; height: 220px; bottom: -80px; left: -80px; }
    #main-screen.new-design .home-decor-3 { display: none; }
}

/* --- Header --- */
#main-screen.new-design .home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}
#main-screen.new-design .user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
#main-screen.new-design .user-circle {
    width: 40px;
    height: 40px;
    border-radius: 100%;
    background: linear-gradient(135deg, #8b5cf6, #c4b5fd);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(.215,.61,.355,1);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}
#main-screen.new-design .user-circle:hover { transform: scale(1.05); }
#main-screen.new-design .username {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#main-screen.new-design .user-buttons { display: flex; gap: 8px; }
#main-screen.new-design .home-header .btn {
    width: auto;
    margin: 0;
    padding: 8px 16px;
    border-radius: 100%;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    animation: none;
    transition: opacity 0.15s ease, transform 0.2s cubic-bezier(.215,.61,.355,1);
}
#main-screen.new-design .home-header .btn::before { display: none; }
#main-screen.new-design .home-header .btn:hover { transform: none; box-shadow: none; opacity: 0.85; }
#main-screen.new-design .home-header .btn.auth-btn { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #ffffff; }
#main-screen.new-design .home-header .btn.secondary-btn { background: rgba(139, 92, 246, 0.1); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.3); }

/* --- Brand --- */
#main-screen.new-design .home-brand { text-align: center; margin-bottom: 24px; }
#main-screen.new-design .home-brand h1 {
    font-family: 'Inter', sans-serif;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    background: linear-gradient(135deg, #8b5cf6, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    animation: none;
    margin-bottom: 8px;
}
#main-screen.new-design .home-brand h1 .char {
    display: inline-block;
    animation: charReveal 0.4s cubic-bezier(.215,.61,.355,1) both;
}
#main-screen.new-design .home-brand h1 .char:nth-child(1) { animation-delay: 0.05s; }
#main-screen.new-design .home-brand h1 .char:nth-child(2) { animation-delay: 0.1s; }
#main-screen.new-design .home-brand h1 .char:nth-child(3) { animation-delay: 0.15s; }
#main-screen.new-design .home-brand h1 .char:nth-child(4) { animation-delay: 0.2s; }
#main-screen.new-design .home-brand h1 .char:nth-child(5) { animation-delay: 0.25s; }
#main-screen.new-design .home-brand h1 .char:nth-child(6) { animation-delay: 0.3s; }
#main-screen.new-design .home-brand h1 .char:nth-child(7) { animation-delay: 0.35s; }
#main-screen.new-design .home-brand h1 .char:nth-child(8) { animation-delay: 0.4s; }
#main-screen.new-design .home-brand h1 .char:nth-child(9) { animation-delay: 0.45s; }
#main-screen.new-design .home-brand h1 .char:nth-child(10) { animation-delay: 0.5s; }
#main-screen.new-design .home-brand h1 .char:nth-child(11) { animation-delay: 0.55s; }
#main-screen.new-design .home-brand h1 .char:nth-child(12) { animation-delay: 0.6s; }
#main-screen.new-design .home-brand h1 .char:nth-child(13) { animation-delay: 0.65s; }
#main-screen.new-design .home-brand h1 .char:nth-child(14) { animation-delay: 0.7s; }

@keyframes charReveal {
    from { opacity: 0; transform: translateY(20px) rotate(-5deg); }
    to { opacity: 1; transform: translateY(0) rotate(0); }
}

#main-screen.new-design .home-brand-line {
    width: 40px;
    height: 4px;
    background: linear-gradient(90deg, #8b5cf6, #c4b5fd);
    border-radius: 100%;
    margin: 0 auto 12px;
    animation: lineGrow 0.5s cubic-bezier(.215,.61,.355,1) 0.7s both;
}

@keyframes lineGrow {
    from { width: 0; }
    to { width: 40px; }
}

#main-screen.new-design .home-brand p {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: #c4b5fd !important;
    margin-bottom: 0;
}

/* --- CTA --- */
#main-screen.new-design #game-buttons { margin-top: 24px; }
#main-screen.new-design .home-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    transition: transform 0.2s cubic-bezier(.215,.61,.355,1), box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
#main-screen.new-design .home-cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}
#main-screen.new-design .home-cta:hover::before { left: 100%; }
#main-screen.new-design .home-cta-arrow { font-size: 18px; transition: transform 0.2s cubic-bezier(.215,.61,.355,1); }
#main-screen.new-design .home-cta:hover {
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}
#main-screen.new-design .home-cta:hover .home-cta-arrow { transform: translateX(4px); }
#main-screen.new-design .home-cta:active { transform: scale(0.98); }

/* --- Tiles --- */
#main-screen.new-design .home-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}
#main-screen.new-design .home-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    transition: transform 0.2s cubic-bezier(.215,.61,.355,1), box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
    overflow: hidden;
}
#main-screen.new-design .home-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #8b5cf6, #c4b5fd);
    transform: scaleY(0);
    transition: transform 0.2s cubic-bezier(.215,.61,.355,1);
}
#main-screen.new-design .home-tile:hover::before { transform: scaleY(1); }
#main-screen.new-design .home-tile:hover {
    transform: translateY(-2px);
    background: rgba(139, 92, 246, 0.12);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}
#main-screen.new-design .home-tile:active { transform: scale(0.98); }
#main-screen.new-design .home-tile-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#main-screen.new-design .home-tile-icon svg {
    width: 20px;
    height: 20px;
    color: #c4b5fd;
}
#main-screen.new-design .home-tint-gold { background: rgba(139, 92, 246, 0.15); }
#main-screen.new-design .home-tint-violet { background: rgba(124, 58, 237, 0.2); }
#main-screen.new-design .home-tint-blue { background: rgba(139, 92, 246, 0.1); }
#main-screen.new-design .home-tint-pink { background: rgba(196, 181, 253, 0.1); }
#main-screen.new-design .home-tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#main-screen.new-design .home-tile-text strong {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}
#main-screen.new-design .home-tile-text small {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #a78bfa;
    line-height: 1.2;
}

/* --- Profile card --- */
#main-screen.new-design .home-profile {
    margin-top: 20px;
    margin-bottom: 0;
    background: rgba(139, 92, 246, 0.08) !important;
    border: 1px solid rgba(139, 92, 246, 0.2) !important;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: none;
}
#main-screen.new-design .home-profile:hover {
    background: rgba(139, 92, 246, 0.12) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}
#main-screen.new-design .home-profile .profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
#main-screen.new-design .home-profile .profile-avatar { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
#main-screen.new-design .home-profile .profile-avatar img {
    width: 56px;
    height: 56px;
    border-radius: 100%;
    object-fit: cover;
    display: block;
    border: 2px solid rgba(139, 92, 246, 0.3);
}
#main-screen.new-design .home-profile #profile-avatar-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 100%;
    background: linear-gradient(135deg, #8b5cf6, #c4b5fd);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 24px;
}
#main-screen.new-design .home-profile .profile-info { min-width: 0; }
#main-screen.new-design .home-profile h3 {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#main-screen.new-design .home-profile .profile-info p {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #a78bfa;
    margin-bottom: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#main-screen.new-design .home-profile .profile-stats-mini {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
#main-screen.new-design .home-profile .mini-stat {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
#main-screen.new-design .home-profile .mini-stat .label {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a78bfa;
}
#main-screen.new-design .home-profile .mini-stat .value {
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

/* --- Status --- */
#main-screen.new-design #loading-message {
    margin-top: 24px;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #a78bfa !important;
}
#main-screen.new-design #connection-status {
    margin-top: 8px;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #a78bfa !important;
}

/* --- Staggered entrance --- */
#main-screen.new-design.active .home-container > * {
    animation: homeRise 0.3s cubic-bezier(.215,.61,.355,1) both;
}
#main-screen.new-design.active .home-container > :nth-child(1) { animation-delay: 0.05s; }
#main-screen.new-design.active .home-container > :nth-child(2) { animation-delay: 0.1s; }
#main-screen.new-design.active .home-container > :nth-child(3) { animation-delay: 0.15s; }
#main-screen.new-design.active .home-container > :nth-child(4) { animation-delay: 0.2s; }
#main-screen.new-design.active .home-container > :nth-child(5) { animation-delay: 0.25s; }
#main-screen.new-design.active .home-container > :nth-child(6) { animation-delay: 0.3s; }
#main-screen.new-design.active .home-container > :nth-child(7) { animation-delay: 0.35s; }

@keyframes homeRise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    #main-screen.new-design,
    #main-screen.new-design * {
        animation: none !important;
        transition: none !important;
    }
}

/* --- Design toggle button --- */
#design-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 100%;
    border: none;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(.215,.61,.355,1), box-shadow 0.2s ease;
    padding: 0;
}
#design-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
}
#design-toggle:active { transform: scale(0.95); }

/* --- Old/New design switch --- */
.home-new { display: none; }
#main-screen.new-design .home-new { display: block; }
#main-screen.new-design .home-old { display: none; }
