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

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-pink: #ff3b6f;
    --accent-pink-dark: #cc2f59;
    --accent-blue: #4a6cf7;
    --accent-orange: #ff6b35;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #0a0f1f 100%);
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
}

.menu-screen {
    padding: 40px 20px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
}

.menu-screen::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    background: var(--bg-primary);
    z-index: 11;
}

.menu-header {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 10;
    background: var(--bg-primary);
    padding-top: 40px;
    margin-top: -40px;
    padding-bottom: 4px;
}

.btn-webview-back {
    display: none;
}

.webview .btn-webview-back {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 0;
    top: 40px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 12;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.menu-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.tabs-container {
    overflow-x: auto;
    margin-bottom: 20px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
}

.tab[data-filter="isdev"] {
    display: none;
}

.tab {
    padding: 8px 12px;
    border-radius: 9999px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

@media (hover: hover) {
    .tab:hover {
        border-color: rgba(255, 255, 255, 0.3);
        color: var(--text-primary);
    }
}

.tab.active {
    background: var(--accent-pink);
    border-color: var(--accent-pink);
    color: var(--text-primary);
}

.search-container {
    margin-bottom: 16px;
    padding: 0 4px;
}

.search-container.hidden {
    display: none;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    border-color: var(--accent-pink);
}

.game-card.hidden {
    display: none;
}

.games-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
}

.games-list .game-card {
    width: 100%;
}

.game-card {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 19px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    animation: fadeIn 0.3s ease;
    position: relative;
}

@media (hover: hover) {
    .game-card:hover {
        transform: translateX(4px);
        background: var(--bg-card);
    }
}

.game-card:active {
    transform: scale(0.98);
}

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

.card-image {
    width: 96px;
    height: 96px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 16px;
    overflow: hidden;
}

.card-icon {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.card-icon-emoji {
    font-size: 40px;
    line-height: 1;
}

/* Game-specific backgrounds */
.shlyapa-bg {
    background: linear-gradient(135deg, #ff6b6b 0%, #c92a2a 100%);
}

.kto-iz-nas-bg {
    background: linear-gradient(135deg, #ff922b 0%, #e8590c 100%);
}

.zayac-bg {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.heads-up-bg {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.five-seconds-bg {
    background: linear-gradient(135deg, #ff9500 0%, #e68600 100%);
}

.taboo-bg {
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
}

.danetki-bg {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.spy-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.never-have-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.crocodile-bg {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.codenames-bg {
    background: linear-gradient(135deg, #e53935 0%, #1e88e5 100%);
}

.secrethitler-bg {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.wavelength-bg {
    background: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
}

.erotic-dice-bg {
    background: linear-gradient(135deg, #7c4dff 0%, #e91e63 100%);
}

.kamasutra-bg {
    background: linear-gradient(135deg, #ff3b6f 0%, #ff1744 100%);
}

.decoder-bg {
    background: linear-gradient(135deg, #10b981 0%, #065f46 100%);
}

.soobrazhariy-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #16a34a 100%);
}

.hundred-to-one-bg {
    background: linear-gradient(135deg, #ff3b6f 0%, #4a6cf7 100%);
}

.quiz-bg {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
}

.melody-bg {
    background: linear-gradient(135deg, #ff3b6f 0%, #4a6cf7 100%);
}

.truth-detector-bg {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
}

.drawful-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.fibbage-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
}

.quiplash-bg {
    background: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
}

.imaginarium-bg {
    background: linear-gradient(135deg, #9333ea 0%, #6d28d9 100%);
}

.tod-bg {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
}

.werewords-bg {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 6px;
}

.card-favorite {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    transition: transform 0.2s ease;
}

@media (hover: hover) {
    .card-favorite:hover {
        transform: scale(1.2);
    }
}

.card-favorite-icon {
    width: 15px;
    height: 15px;
    opacity: 0.5;
    transition: opacity 0.2s ease, filter 0.2s ease;
    filter: invert(1);
}

.card-favorite.active .card-favorite-icon {
    opacity: 1;
    filter: invert(74%) sepia(30%) saturate(400%) hue-rotate(3deg) brightness(80%) contrast(85%);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-pink);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
    min-width: 0;
}

.card-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    padding-left: 112px;
}

.favorites-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    color: var(--text-secondary);
    opacity: 0.5;
    padding: 20px;
    font-size: 15px;
}

.favorites-empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    filter: invert(1);
    opacity: 0.3;
}

.favorites-empty.hidden {
    display: none;
}

.player-badge,
.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.card-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Join banner */
.join-banner {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(13, 19, 41, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    z-index: 20;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.join-banner.hidden {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.join-banner-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.join-banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.join-banner-or {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

.join-banner-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.join-banner-qr {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, background 0.2s ease;
}

.join-banner-qr img {
    filter: invert(1);
    opacity: 0.85;
}

.join-banner-qr:active {
    transform: scale(0.93);
}

@media (hover: hover) {
    .join-banner-btn:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    }
    .join-banner-qr:hover {
        background: rgba(255, 255, 255, 0.14);
        transform: scale(1.05);
    }
}

.join-banner-btn:active {
    transform: scale(0.97);
}

.games-list.has-join-banner {
    padding-bottom: 70px;
}

/* Responsive */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
    }

    .menu-screen {
        padding: 24px 12px;
        padding-top: calc(24px + env(safe-area-inset-top, 0px));
    }

    .menu-header {
        padding-top: 24px;
        margin-top: -24px;
    }

    .webview .btn-webview-back {
        top: 24px;
    }

    .menu-title {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .tabs-container {
        margin-bottom: 16px;
    }

    .tab {
        padding: 7px 10px;
        font-size: 10px;
    }

    .games-list {
        gap: 12px;
    }

    .game-card {
        padding: 14px;
        border-radius: 12px;
    }

    @media (hover: hover) {
        .game-card:hover {
            transform: translateY(-2px);
        }
    }

    .card-image {
        width: 72px;
        height: 72px;
        margin-right: 12px;
    }

    .card-header {
        margin-bottom: 4px;
    }

    .card-title {
        font-size: 16px;
    }

    .player-badge,
    .mode-badge {
        font-size: 11px;
        padding: 2px 8px;
    }

    .card-tags {
        padding-left: 84px;
        margin-top: 8px;
    }

    .card-favorite {
        top: 10px;
        right: 10px;
        font-size: 18px;
    }

    .card-description {
        font-size: 13px;
        line-height: 1.3;
    }
}

@media (max-height: 600px) {
    .menu-screen {
        padding: 20px 16px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
    }

    .menu-header {
        padding-top: 20px;
        margin-top: -20px;
    }

    .webview .btn-webview-back {
        top: 20px;
    }

    .menu-title {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .card-image {
        width: 72px;
        height: 72px;
    }

}


/* Tablet and larger devices */
@media (min-width: 768px) {
    .games-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .game-card {
        flex-direction: column;
        padding: 20px;
        text-align: center;
    }

    .card-image {
        margin-right: 0;
        margin-bottom: 16px;
        width: 96px;
        height: 96px;
    }

    .card-content {
        width: 100%;
    }

    .card-header {
        justify-content: center;
    }

    .card-title {
        font-size: 16px;
    }

    .card-description {
        font-size: 13px;
    }

    .card-tags {
        padding-left: 0;
        justify-content: center;
    }

    .card-favorite {
        top: 14px;
        right: 14px;
    }
}

/* ===== Onboarding ===== */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(180deg, #0d1329 0%, #0a0f1f 100%);
    display: none;
    align-items: center;
    justify-content: center;
}

.onboarding-overlay.visible {
    display: flex;
}

.onboarding-overlay.hiding {
    display: flex;
    animation: onboardingFadeOut 0.4s ease forwards;
}

@keyframes onboardingFadeOut {
    to { opacity: 0; }
}

.onboarding-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    animation: onboardingSlideIn 0.35s ease;
}

.onboarding-screen.active {
    display: flex;
}

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

.onboarding-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.onboarding-hero {
    font-size: 72px;
    margin-bottom: 24px;
    line-height: 1;
}

.onboarding-title {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.25;
}

.onboarding-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 320px;
}

.onboarding-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #ff3b6f, #cc2f59);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
    box-shadow: 0 4px 20px rgba(255, 59, 111, 0.3);
}

.onboarding-btn:active {
    transform: scale(0.97);
}

.onboarding-btn-premium {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.onboarding-btn-skip {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: none;
    border-radius: 30px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s;
}

.onboarding-btn-skip:active {
    color: #fff;
}

/* Player count options */
.onboarding-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
    margin-top: 32px;
}

.onboarding-players .onboarding-option {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: var(--bg-secondary);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.onboarding-players .onboarding-option:active {
    transform: scale(0.95);
}

.onboarding-players .onboarding-option.selected {
    border-color: var(--accent-pink);
    background: linear-gradient(135deg, rgba(255, 59, 111, 0.2), rgba(74, 108, 247, 0.1));
    box-shadow: 0 0 20px rgba(255, 59, 111, 0.2);
}

/* Genre options */
.onboarding-genres {
    flex-direction: column;
    gap: 12px;
}

.onboarding-genre {
    width: 100%;
    padding: 18px 20px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: var(--bg-secondary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    font-family: inherit;
    transition: all 0.2s;
}

.onboarding-genre:active {
    transform: scale(0.98);
}

.onboarding-genre.selected {
    border-color: var(--accent-pink);
    background: linear-gradient(135deg, rgba(255, 59, 111, 0.15), rgba(74, 108, 247, 0.08));
}

.onboarding-genre-emoji {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
}

.onboarding-genre-label {
    font-size: 17px;
    font-weight: 700;
    display: block;
}


/* Progress bar */
.onboarding-loading-content {
    gap: 16px;
}

.onboarding-loading-emoji {
    font-size: 56px;
    animation: onboardingPulse 1.5s ease-in-out infinite;
}

@keyframes onboardingPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.onboarding-progress-bar {
    width: 100%;
    max-width: 280px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
}

.onboarding-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-pink), var(--accent-blue));
    border-radius: 8px;
    transition: width 0.1s linear;
}

/* Paywall features */
.onboarding-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 28px;
    width: 100%;
    text-align: left;
}

.onboarding-feature {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}
