:root {
    --bg-main: #0c2142;
    --bg-secondary: #122d59;
    --bg-card: #152d54;
    --gold: #f5a623;
    --gold-light: #ffd700;
    --gold-dark: #b87a00;
    --red: #ED1C24;
    --green: #009A44;
    --yellow: #FFDE00;
    --blue: #1DA1F2;
    --text-white: #ffffff;
    --text-muted: #9bb0d1;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html, body {
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

body {
    background-color: #0b0f29;
    background-image:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 2px, transparent 2px, transparent 24px),
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 2px, transparent 2px, transparent 24px),
        radial-gradient(circle at 50% 30%, #17386e 0%, #0b1d3b 100%);
    color: var(--text-white);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.is-standalone-app .top-header {
    padding-top: max(4px, env(safe-area-inset-top));
    height: calc(42px + env(safe-area-inset-top, 0px));
    min-height: calc(42px + env(safe-area-inset-top, 0px));
    max-height: calc(42px + env(safe-area-inset-top, 0px));
}

#app-container {
    width: 100%;
    max-width: 520px;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Header Bar */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    gap: 6px;
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    background: rgba(15, 28, 54, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(245, 166, 35, 0.25);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}

.header-back-pill {
    width: auto !important;
    height: 29px !important;
    padding: 0 9px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    background: linear-gradient(135deg, #e53935, #b71c1c) !important;
    border: 1.5px solid #ffcdd2 !important;
    color: #fff !important;
    border-radius: 15px !important;
    white-space: nowrap;
    flex-shrink: 0;
    gap: 3px;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: var(--gold-light);
    text-shadow: 0 0 10px rgba(245, 166, 35, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.brand-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.icon-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(245, 166, 35, 0.2);
}

@media (max-width: 390px) {
    .brand-title-text {
        font-size: 12.5px;
    }
}

/* User Card in Menu */
.user-profile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(21, 36, 69, 0.8), rgba(15, 28, 54, 0.9));
    border: 1px solid rgba(245, 166, 35, 0.25);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.user-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    background: linear-gradient(135deg, #f5a623, #d97706);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
}

.user-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-meta h3 {
    font-size: 16px;
    font-weight: 700;
}

.user-meta p {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Menu View */
.view-screen {
    display: none;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: 0;
}

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

#menu-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.menu-options {
    padding: 10px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.menu-card {
    background: linear-gradient(135deg, rgba(21, 36, 69, 0.9) 0%, rgba(13, 24, 46, 0.95) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.menu-card:active {
    transform: scale(0.97);
}

.menu-card.gold-border {
    border-color: rgba(245, 166, 35, 0.5);
    background: linear-gradient(135deg, rgba(35, 30, 15, 0.9) 0%, rgba(20, 18, 10, 0.95) 100%);
}

.menu-card-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.menu-card-icon.pass { background: linear-gradient(135deg, #e53935, #ff7043); }
.menu-card-icon.bot { background: linear-gradient(135deg, #43a047, #66bb6a); }
.menu-card-icon.friends { background: linear-gradient(135deg, #f5a623, #ffca28); color: #000; }
.menu-card-icon.quick { background: linear-gradient(135deg, #1e88e5, #42a5f5); }

.menu-card-content h4 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
}

.menu-card-content p {
    font-size: 13px;
    color: var(--text-muted);
}

.badge-pill {
    margin-left: auto;
    background: rgba(245, 166, 35, 0.2);
    color: var(--gold-light);
    border: 1px solid var(--gold);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
    text-transform: uppercase;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

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

.modal-box {
    background: var(--bg-card);
    border: 2px solid rgba(245, 166, 35, 0.4);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 26px 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--gold-light);
    margin-bottom: 14px;
}

.room-code-display {
    font-family: monospace;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--gold-light);
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 18px;
    border-radius: 12px;
    border: 1.5px dashed var(--gold);
    margin: 16px 0;
    display: inline-block;
}

/* Buttons */
.btn-game {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: 0.2s;
    margin-top: 10px;
}

.btn-game-gold {
    background: linear-gradient(135deg, #f5a623, #ffb300);
    color: #1a1300;
    box-shadow: 0 4px 15px rgba(245, 166, 35, 0.4);
}
.btn-game-gold:active { transform: scale(0.97); }

.btn-game-blue {
    background: linear-gradient(135deg, #1e88e5, #1976d2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(30, 136, 229, 0.4);
}
.btn-game-blue:active { transform: scale(0.97); }

.btn-game-close {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

/* Responsive Modal Overlays & Leaderboard Styles */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 8px !important;
    }
    .modal-box {
        padding: 12px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

.lb-select {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    background: #0e1b33 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 215, 0, 0.45) !important;
    border-radius: 6px !important;
    padding: 6px 8px !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    outline: none !important;
    -webkit-appearance: menulist !important;
    appearance: menulist !important;
}

.lb-select:focus {
    border-color: #ffd700 !important;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.3) !important;
}

/* Language Button & Selection Modal */
.lang-badge-btn {
    width: auto !important;
    height: 30px !important;
    padding: 0 8px !important;
    border-radius: 15px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.25), rgba(21, 101, 192, 0.45)) !important;
    border: 1px solid rgba(100, 181, 246, 0.6) !important;
    color: #e3f2fd !important;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.lang-badge-btn:active {
    transform: scale(0.95);
    background: rgba(30, 136, 229, 0.4) !important;
}

.lang-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    user-select: none;
}

.lang-card:active {
    transform: scale(0.96);
}

.lang-card.active {
    background: linear-gradient(135deg, rgba(245, 166, 35, 0.28), rgba(255, 215, 0, 0.18));
    border: 1.5px solid #ffd700;
    box-shadow: 0 0 12px rgba(245, 166, 35, 0.4);
}

.lang-card-flag {
    font-size: 24px;
    line-height: 1;
}

.lang-card-name {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

.lang-card-native {
    font-size: 11px;
    color: var(--gold-light);
    font-weight: 600;
}

/* Brand Header Logo & Official App Install Card */
.brand-logo-img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.55);
    flex-shrink: 0;
}

.home-app-install-card {
    margin: 0 16px 6px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(16, 26, 58, 0.96) 0%, rgba(10, 16, 38, 0.98) 100%);
    border: 1.5px solid rgba(255, 215, 0, 0.45);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 0 15px rgba(245, 166, 35, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-install-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.home-install-app-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.home-install-app-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    object-fit: cover;
    border: 1.5px solid #ffd700;
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
    flex-shrink: 0;
}

.home-install-app-title {
    font-size: 13.5px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.home-install-app-sub {
    font-size: 11px;
    color: #93c5fd;
    margin-top: 2px;
    font-weight: 600;
}

.home-install-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: stretch;
}

.store-install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
    text-align: left;
    color: #ffffff;
    min-width: 0;
}

.store-install-btn:active {
    transform: scale(0.96);
}

.store-install-btn.playstore {
    background: linear-gradient(135deg, #0f2922 0%, #091c18 100%);
    border-color: rgba(0, 230, 118, 0.55);
    box-shadow: 0 3px 10px rgba(0, 200, 83, 0.22);
}

.store-install-btn.ipastore {
    background: linear-gradient(135deg, #10254c 0%, #0a1833 100%);
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 3px 10px rgba(14, 165, 233, 0.25);
}

.store-install-btn.sharelink {
    background: linear-gradient(135deg, #f5a623 0%, #d97706 100%);
    border-color: #ffd700;
    color: #111827;
    padding: 8px 11px;
    font-weight: 800;
    font-size: 11.5px;
    box-shadow: 0 3px 10px rgba(245, 166, 35, 0.35);
    white-space: nowrap;
}

.store-btn-svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.store-btn-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}

.store-btn-small {
    font-size: 8.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #cbd5e1;
    font-weight: 700;
}

.store-btn-big {
    font-size: 11.5px;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Store Install Modal Tabs & Steps */
.install-store-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.install-tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
}

.install-tab-btn.active {
    background: linear-gradient(135deg, rgba(245, 166, 35, 0.26), rgba(255, 215, 0, 0.14));
    border-color: #ffd700;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(245, 166, 35, 0.35);
}

.install-step-box {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
    margin-top: 10px;
    font-size: 11.5px;
    color: #e2e8f0;
    line-height: 1.5;
}

.install-step-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.install-step-item:last-child {
    margin-bottom: 0;
}

.install-step-num {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    color: #111;
    font-size: 10.5px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.pwa-toast-banner {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 12.5px;
    font-weight: 800;
    border: 1.5px solid #86efac;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
}

.pwa-toast-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 380px) {
    .home-install-buttons-row {
        grid-template-columns: 1fr 1fr;
    }
    .store-install-btn.sharelink {
        grid-column: span 2;
        justify-content: center;
    }
}


