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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f4efe6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
    background: #f4efe6;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Loading Screen — critical layout set here so it works before brand.css applies */
#loadingScreen {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: #0a0a0a;
    color: #f4efe6;
    padding: 0;
}
.ls-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px;
}
.ls-foot { padding: 0 24px 32px; }
.ls-bar {
    height: 3px;
    background: #2a2a2a;
    margin-bottom: 10px;
    overflow: hidden;
}
.ls-bar-fill {
    height: 100%;
    background: #ff2e1f;
    width: 0;
    animation: lsBarFill 2.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes lsBarFill {
    0%   { width: 0; }
    75%  { width: 94%; }
    100% { width: 100%; }
}

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

/* Container */
.container {
    width: 100%;
    max-width: 500px;
    background: #22303f;
    border-radius: 20px;
    padding: 30px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(79, 209, 197, 0.15);
    margin: 0 auto;
}

/* Main Menu - transparent so body animations show through */
#mainMenu {
    background: transparent;
}

/* Background particle canvas behind main menu content */
#menuBgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Main Menu Container */
.main-menu-container {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    z-index: 1;
    margin: 0 auto;
}

.container h1 {
    text-align: center;
    color: #4fd1c5;
    margin-bottom: 25px;
    font-size: 1.8rem;
    text-shadow: 0 0 20px rgba(79, 209, 197, 0.5);
    animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(79, 209, 197, 0.5);
    }
    50% {
        text-shadow: 0 0 30px rgba(79, 209, 197, 0.8), 0 0 40px rgba(79, 209, 197, 0.4);
    }
}

.container h2 {
    text-align: center;
    color: #e2e8f0;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* Back Button */
.back-btn {
    background: none;
    border: none;
    color: #4fd1c5;
    font-size: 1rem;
    padding: 10px;
    cursor: pointer;
    margin-bottom: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.back-btn:active {
    opacity: 0.7;
    transform: translateX(-3px);
}

/* User Info */
.user-info {
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: center;
    border: 1px solid rgba(79, 209, 197, 0.2);
    box-shadow: 0 4px 20px rgba(79, 209, 197, 0.1);
    width: 100%;
    max-width: 400px;
}

.main-menu-container .user-info {
    margin-bottom: 10px;
}

.user-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4fd1c5;
}

.balance {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.5);

}

.balance-label {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-right: 5px;
    color: #e2e8f0;
}

.currency {
    font-size: 0.9rem;
    opacity: 0.9;
    color: #fbbf24;
}

/* Logo - Psychology-Driven (Challenge + Risk + Reward) */
.logo-container {
    text-align: center;
    margin-bottom: 40px;
    animation: logoEntrance 0.8s ease-out;
    position: relative;
    padding: 10px 0;
}

@keyframes logoEntrance {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(-15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Stacked word layout */
.logo-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    gap: 0;
}

/* Hamburger Menu Button */
.hamburger-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hamburger-menu:hover {
    border-color: #4fd1c5;
    box-shadow: 0 4px 20px rgba(79, 209, 197, 0.4);
    transform: scale(1.05);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-menu span {
    width: 24px;
    height: 3px;
    background: #4fd1c5;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Main Action Buttons */
.main-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.btn-create,
.btn-join,
.btn-practice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 25px 30px;
    border: none;
    border-radius: 16px;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.btn-create {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-join {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-practice {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    border: 2px dashed rgba(79, 209, 197, 0.3);
}

.btn-create:hover, .btn-join:hover, .btn-practice:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.btn-create:active, .btn-join:active, .btn-practice:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-icon { font-size: 1.8rem; }

/* Slide Menu */
.slide-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: linear-gradient(135deg, #1e2936 0%, #0f1419 100%);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-left: 2px solid rgba(79, 209, 197, 0.2);
}

.slide-menu.active {
    right: 0;
}

.slide-menu-header {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid rgba(79, 209, 197, 0.15);
    background: linear-gradient(135deg, #1a2636 0%, #111827 100%);
}

.slide-menu-header h3 {
    color: #4fd1c5;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Profile card inside slide menu */
.menu-profile {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(79, 209, 197, 0.3);
}

.menu-profile-info {
    flex: 1;
    min-width: 0;
}

.menu-profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-profile-balance {
    font-size: 0.88rem;
    color: #fbbf24;
    font-weight: 700;
    margin-top: 2px;
}

.menu-profile-stats {
    display: flex;
    gap: 12px;
    padding: 10px 20px 14px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.menu-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.menu-stat-val {
    font-size: 1.1rem;
    font-weight: 800;
    color: #e2e8f0;
}

.menu-stat-lbl {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-profile-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.4rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    align-self: flex-start;
    margin-top: 4px;
}

.menu-profile-close:active {
    background: rgba(79, 209, 197, 0.1);
    color: #4fd1c5;
    transform: scale(0.9);
}

.close-menu {
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.close-menu:hover {
    background: rgba(79, 209, 197, 0.1);
    color: #4fd1c5;
}

.close-menu:active {
    transform: scale(0.9);
}

.slide-menu-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(10,10,10,0.08);
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    width: 100%;
    opacity: 0;
    transform: translateX(20px);
    animation: slideIn 0.4s ease-out forwards;
}
.menu-arr {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(10,10,10,0.3);
    flex-shrink: 0;
    transition: color 0.2s, transform 0.2s;
}
.menu-item:active .menu-arr {
    color: rgba(10,10,10,0.8);
    transform: translateX(3px);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.menu-item:nth-child(1)  { animation-delay: 0.05s; }
.menu-item:nth-child(2)  { animation-delay: 0.10s; }
.menu-item:nth-child(3)  { animation-delay: 0.15s; }
.menu-item:nth-child(4)  { animation-delay: 0.20s; }
.menu-item:nth-child(5)  { animation-delay: 0.25s; }
.menu-item:nth-child(6)  { animation-delay: 0.30s; }
.menu-item:nth-child(7)  { animation-delay: 0.35s; }
.menu-item:nth-child(8)  { animation-delay: 0.40s; }
.menu-item:nth-child(9)  { animation-delay: 0.45s; }
.menu-item:nth-child(10) { animation-delay: 0.50s; }

/* Online player count badge */
.online-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

/* Safe-area padding for iPhone home bar */
.screen {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

#gameScreen {
    padding-bottom: 0;
}

.menu-item:active {
    background: rgba(10,10,10,0.04);
}

.menu-text {
    flex: 1;
    min-width: 0;
}

.menu-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0a0a0a;
    margin-bottom: 3px;
}

.menu-desc {
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    color: #6b6b6b;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* AI Mode Selection Modal */
.ai-mode-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.ai-mode-modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.ai-mode-content {
    background: linear-gradient(135deg, #1e2936 0%, #0f1419 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 20px;
    padding: 40px 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s ease-out;
}

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

.ai-mode-content h2 {
    color: #4fd1c5;
    margin-bottom: 25px;
    font-size: 1.8rem;
    text-shadow: 0 0 20px rgba(79, 209, 197, 0.5);
}

.ai-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.ai-mode-btn {
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 16px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: #e2e8f0;
}

.ai-mode-btn:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: #4fd1c5;
    box-shadow: 0 10px 30px rgba(79, 209, 197, 0.4);
}

.ai-mode-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.ai-mode-btn[data-mode="classic"]:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.ai-mode-btn[data-mode="chaotic"]:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 18px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #10b981, #059669, #10b981);
    border-radius: 12px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-primary:hover::after {
    opacity: 1;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

.btn-primary:active::before {
    width: 300px;
    height: 300px;
}

.btn-secondary {
    background: #2d3748;
    color: #e2e8f0;
    border: 1px solid rgba(79, 209, 197, 0.2);
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: rgba(79, 209, 197, 0.6);
    box-shadow: 0 4px 20px rgba(79, 209, 197, 0.2);
    transform: translateY(-2px);
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9rem;
}

/* Deposit Screen */
.deposit-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-text {
    text-align: center;
    color: #fbbf24;
    font-weight: 600;
    font-size: 0.9rem;
}

.wallet-address {
    text-align: center;
}

.wallet-address p {
    margin-bottom: 10px;
    color: #94a3b8;
    font-size: 0.9rem;
}

.address-box {
    background: #0f1419;
    padding: 15px;
    border-radius: 10px;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.85rem;
    margin-bottom: 10px;
    border: 2px dashed #4fd1c5;
    color: #4fd1c5;
}

.deposit-amount {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deposit-amount label {
    font-weight: 600;
    color: #e2e8f0;
}

.deposit-amount input {
    padding: 15px;
    border: 2px solid #374151;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background: #0f1419;
    color: #e2e8f0;
}

.deposit-amount input:focus {
    outline: none;
    border-color: #4fd1c5;
    box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.1);
}

/* Create Game Screen */
.create-game-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Game Mode Selection */
.game-mode-selection {
    margin-bottom: 20px;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.mode-btn {
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 16px;
    padding: 25px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: #e2e8f0;
}

.mode-btn:hover {
    transform: translateY(-5px);
    border-color: #4fd1c5;
    box-shadow: 0 8px 25px rgba(79, 209, 197, 0.3);
}

.mode-btn.selected {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.5);
}

.mode-btn[data-mode="chaotic"].selected {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    box-shadow: 0 6px 25px rgba(245, 158, 11, 0.5);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: modeIconFloat 2s ease-in-out infinite;
}

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

.mode-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 0.85rem;
    opacity: 0.8;
    color: #94a3b8;
}

.mode-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    margin-left: 10px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-weight: 600;
    color: #e2e8f0;
}

.form-group input,
.form-group select {
    padding: 15px;
    border: 2px solid #374151;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background: #0f1419;
    color: #e2e8f0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4fd1c5;
    box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.1);
}

/* Join Game Screen */
.filter-options {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-options label {
    font-weight: 600;
    color: #e2e8f0;
}

.filter-options select {
    padding: 12px;
    border: 2px solid #374151;
    border-radius: 10px;
    font-size: 1rem;
    background: #0f1419;
    color: #e2e8f0;
}

.games-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-item {
    background: #2d3748;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #374151;
    transition: all 0.3s;
}

.game-item:hover {
    transform: translateY(-2px);
    border-color: #4fd1c5;
    box-shadow: 0 4px 20px rgba(79, 209, 197, 0.2);
}

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

.game-item-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.game-item-player {
    font-weight: 600;
    color: #e2e8f0;
}

.game-item-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fbbf24;
}

.game-item-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.game-item-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.no-games {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

/* Game Screen */
#gameScreen {
    padding: 0;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #141c26;
    display: flex;
    flex-direction: column;
}

.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #243342 0%, #1e2d3e 100%);
    color: white;
    border-bottom: 1px solid rgba(79, 209, 197, 0.25);
}

.game-player {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 100px;
}

.game-player:last-child {
    align-items: flex-end;
}

.score {
    font-size: 2.6rem;
    font-weight: 900;
    color: #10b981;
    text-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
    line-height: 1;
    transition: transform 0.15s ease;
}

.score.scored {
    animation: scorePop 0.35s ease-out;
}

@keyframes scorePop {
    0%   { transform: scale(1.6); color: #fbbf24; }
    60%  { transform: scale(0.9); }
    100% { transform: scale(1); color: #10b981; }
}

.game-round {
    font-size: 0.75rem;
    text-align: center;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

#gameCanvas {
    flex: 1;
    width: 100%;
    background: #141c26;
    touch-action: none;
    cursor: none;
}

.game-status {
    padding: 15px;
    background: linear-gradient(135deg, #243342 0%, #1e2d3e 100%);
    color: #4fd1c5;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    border-top: 1px solid rgba(79, 209, 197, 0.25);
}

/* Race Countdown Overlay — NFS-style 5-second pre-game */
.race-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    pointer-events: none;
}

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

.race-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.race-number {
    font-size: clamp(8rem, 30vw, 15rem);
    font-weight: 900;
    line-height: 1;
    color: #4fd1c5;
    text-shadow:
        0 0 20px rgba(79, 209, 197, 1),
        0 0 40px rgba(79, 209, 197, 0.7),
        0 0 80px rgba(79, 209, 197, 0.35);
    animation: racePulse 0.9s ease-out;
}

@keyframes racePulse {
    0%   { transform: scale(2.5); opacity: 0; filter: blur(8px); }
    40%  { transform: scale(1.05); opacity: 1; filter: blur(0); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes raceShake {
    0%, 100% { transform: translateX(0); }
    20%  { transform: translateX(-3px); }
    40%  { transform: translateX(3px); }
    60%  { transform: translateX(-2px); }
    80%  { transform: translateX(2px); }
}

.race-number.go {
    color: #10b981;
    text-shadow:
        0 0 30px rgba(16, 185, 129, 1),
        0 0 60px rgba(16, 185, 129, 0.7),
        0 0 100px rgba(16, 185, 129, 0.35);
    animation: raceGo 0.6s ease-out;
}

@keyframes raceGo {
    0%   { transform: scale(3); opacity: 0; }
    30%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

.race-number.warning {
    color: #f59e0b;
    text-shadow:
        0 0 20px rgba(245, 158, 11, 1),
        0 0 40px rgba(245, 158, 11, 0.7),
        0 0 80px rgba(245, 158, 11, 0.35);
    animation: racePulse 0.9s ease-out, raceShake 0.15s ease-in-out 2;
}

/* Frozen Indicator - Chaotic Mode */
.frozen-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    z-index: 999;
}

.frozen-indicator.active {
    display: flex;
    animation: frozenPulse 0.6s ease-in-out;
}

@keyframes frozenPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
}

.frozen-icon {
    font-size: 5rem;
    animation: frozenSpin 2s linear infinite;
}

@keyframes frozenSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.frozen-text {
    font-size: 2.5rem;
    font-weight: 900;
    color: #67e8f9;
    text-shadow:
        0 0 10px rgba(103, 232, 249, 1),
        0 0 20px rgba(103, 232, 249, 0.8),
        0 0 30px rgba(103, 232, 249, 0.6);
    letter-spacing: 5px;
}

/* Result Screen */
.result-content {
    text-align: center;
    padding: 20px;
}

.result-content h2 {
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 16px;
    letter-spacing: 1px;
    animation: resultEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultEntrance {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.result-content h2.win {
    color: #4ade80;
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.5), 0 0 60px rgba(74, 222, 128, 0.2);
    animation: resultEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), winGlow 2s ease-in-out 0.5s infinite;
}

@keyframes winGlow {
    0%, 100% { text-shadow: 0 0 30px rgba(74, 222, 128, 0.5); }
    50%       { text-shadow: 0 0 50px rgba(74, 222, 128, 0.9), 0 0 80px rgba(74, 222, 128, 0.3); }
}

.result-content h2.lose {
    color: #f87171;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.4);
}

.result-content h2.draw {
    color: #f5c518;
    text-shadow: 0 0 20px rgba(245, 197, 24, 0.4);
}

.result-amount {
    font-size: 3.2rem;
    font-weight: 900;
    margin-bottom: 20px;
    animation: amountEntrance 0.4s ease-out 0.2s both;
    letter-spacing: -1px;
}

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

.amount-won {
    color: #4ade80;
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.4);
}

.amount-lost {
    color: #f87171;
}

/* Confetti canvas */
#confettiCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9000;
}

.result-details {
    background: #2d3748;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #374151;
}

.result-details p {
    margin: 8px 0;
    font-size: 1rem;
    color: #e2e8f0;
}

.result-details span {
    color: #fbbf24;
    font-weight: 600;
}

/* Withdraw Screen */
.withdraw-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Bet Amount Grid */
.bet-amount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.bet-btn {
    padding: 20px;
    border: 2px solid #374151;
    border-radius: 10px;
    background: #2d3748;
    font-size: 1.2rem;
    font-weight: 700;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.bet-btn:hover {
    transform: translateY(-3px);
    border-color: #4fd1c5;
    box-shadow: 0 6px 20px rgba(79, 209, 197, 0.3);
}

.bet-btn:active,
.bet-btn.selected {
    border-color: #4fd1c5;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    transform: scale(0.98);
}

.bet-btn.selected {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
    animation: selectedPulse 2s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 6px 30px rgba(16, 185, 129, 0.7);
    }
}

/* Waiting Room */
.waiting-room-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
}

.waiting-animation {
    text-align: center;
    padding: 30px 0;
}

.pulse-circle {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #4fd1c5 0%, #38b2ac 100%);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(79, 209, 197, 0.5);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.waiting-text {
    font-size: 1.1rem;
    color: #94a3b8;
}

.game-info-box {
    width: 100%;
    background: #2d3748;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(79, 209, 197, 0.2);
}

.game-info-box p {
    margin: 10px 0;
    font-size: 1rem;
    color: #e2e8f0;
}

.game-info-box strong {
    color: #fbbf24;
}

.countdown-timer {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-cancel {
    background: #f44336;
    color: white;
}

.btn-tertiary {
    background: #374151;
    color: #94a3b8;
    padding: 12px 18px;
    font-size: 0.9rem;
    border: 1px solid #4b5563;
}

#playAIBtn {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border: 2px dashed rgba(79, 209, 197, 0.3);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
    animation: aiPulse 2s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 25px rgba(6, 182, 212, 0.6);
        transform: scale(1.02);
    }
}

/* Game Timer */
.game-timer {
    font-size: 0.9rem;
    margin-top: 5px;
    opacity: 0.9;
}

/* Rematch Section */
.rematch-section {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    border-radius: 12px;
    text-align: center;
    margin: 15px 0;
    border: 1px solid rgba(79, 209, 197, 0.2);
}

.rematch-section .btn {
    margin-bottom: 10px;
}

/* Support/Report */
.support-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #374151;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    background: #0f1419;
    color: #e2e8f0;
}

textarea:focus {
    outline: none;
    border-color: #4fd1c5;
    box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.1);
}

.support-info {
    padding: 15px;
    background: #2d3748;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #374151;
}

/* Admin Panel */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #374151;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #4fd1c5;
    border-bottom-color: #4fd1c5;
}

.tab-btn:active {
    opacity: 0.7;
}

.admin-tab {
    display: none;
}

.admin-tab.active {
    display: block;
}

.admin-section {
    padding: 20px 0;
}

.admin-section h3 {
    margin-bottom: 15px;
    color: #e2e8f0;
    font-size: 1.2rem;
}

.admin-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
    background: #2d3748;
    border-radius: 10px;
    border: 1px solid #374151;
}

.admin-item {
    background: #1e2936;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
    color: #e2e8f0;
}

.admin-item.banned {
    border-left-color: #f44336;
}

.admin-item.reported {
    border-left-color: #ff9800;
}

.btn-danger {
    background: #f44336;
    color: white;
}

/* Statistics Screen */
.stats-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 16px;
    padding: 25px 20px;
    text-align: center;
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: #4fd1c5;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Leaderboard Screen */
.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 10px;
    color: #e2e8f0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 12px;
    padding: 15px;
    display: grid;
    grid-template-columns: 60px 1fr auto;
    align-items: center;
    gap: 15px;
}

.leaderboard-item.highlight {
    border-color: #fbbf24;
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}

.leaderboard-item .rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4fd1c5;
}

.leaderboard-item .player-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.leaderboard-item .player-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #94a3b8;
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

/* ── Match History ──────────────────────────────────────────────────────────── */
.mh-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: 10px;
}

.mh-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 1px solid rgba(79, 209, 197, 0.15);
    border-radius: 12px;
    padding: 12px 14px;
}

.mh-item.mh-win  { border-left: 3px solid #22c55e; }
.mh-item.mh-loss { border-left: 3px solid #ef4444; }
.mh-item.mh-draw { border-left: 3px solid #94a3b8; }

.mh-result-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 46px;
    text-align: center;
}

.mh-badge-win  { background: rgba(34, 197, 94, 0.15);  color: #22c55e; }
.mh-badge-loss { background: rgba(239, 68, 68, 0.15);  color: #ef4444; }
.mh-badge-draw { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

.mh-info {
    flex: 1;
    min-width: 0;
}

.mh-opponent {
    font-size: 0.95rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mh-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.mh-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.mh-score {
    font-size: 0.9rem;
    font-weight: 700;
    color: #94a3b8;
}

.mh-net {
    font-size: 0.9rem;
    font-weight: 700;
}

.mh-elo {
    font-size: 0.72rem;
    font-weight: 600;
}

/* Name Setup */
.name-setup-content {
    text-align: center;
    padding: 60px 20px 40px;
}

.name-setup-content h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    background: linear-gradient(180deg, #ffffff, #d4a843);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.name-input-group {
    margin: 30px 0 15px;
}

.name-input {
    width: 100%;
    max-width: 300px;
    padding: 14px 18px;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 12px;
    color: #ffffff;
    outline: none;
    transition: border-color 0.3s;
    letter-spacing: 1px;
}

.name-input:focus {
    border-color: rgba(79, 209, 197, 0.8);
    box-shadow: 0 0 15px rgba(79, 209, 197, 0.2);
}

.name-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}

.name-rules {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
}

.name-changes-left {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 25px;
}

/* === 2x2 Main Menu Grid === */
.menu-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.menu-square {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.25);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
    color: #e2e8f0;
    position: relative;
    overflow: hidden;
}

.menu-square::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 209, 197, 0.05), transparent);
    transition: left 0.6s;
}

.menu-square:hover::before {
    left: 100%;
}

.menu-square:hover {
    border-color: #4fd1c5;
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(79, 209, 197, 0.25);
}

.menu-square:active {
    transform: translateY(-1px) scale(0.97);
}

.square-icon-wrap {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.square-icon {
    font-size: 3rem;
    animation: squareIconFloat 3s ease-in-out infinite;
}

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

.square-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: #4fd1c5;
    letter-spacing: 1px;
}

.square-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
}

/* Hook text above menu grid */
.arena-hook {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 8px;
    margin-top: 10px;
    background: linear-gradient(90deg, #94a3b8, #e2e8f0, #fbbf24, #e2e8f0, #94a3b8);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: hookShimmer 5s linear infinite;
}

@keyframes hookShimmer {
    0% { background-position: 300% 0; }
    100% { background-position: -300% 0; }
}

/* Play square special highlight */
#playSquare {
    border-color: rgba(251, 191, 36, 0.3);
}

#playSquare:hover {
    border-color: #fbbf24;
    box-shadow: 0 8px 30px rgba(251, 191, 36, 0.25);
}

#playSquare .square-label {
    color: #fbbf24;
}

/* Coming Soon squares */
.coming-soon-square {
    border-color: rgba(100, 116, 139, 0.25);
    opacity: 0.7;
}

.coming-soon-square:hover {
    border-color: rgba(100, 116, 139, 0.5);
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.15);
    transform: translateY(-2px);
}

.coming-soon-square .square-label {
    color: #64748b;
    letter-spacing: 3px;
}

.coming-soon-square .square-desc {
    color: #475569;
    font-style: italic;
}

.coming-soon-icon {
    font-size: 3rem !important;
    color: #475569;
    font-weight: 900;
    font-style: normal;
    animation: comingSoonPulse 3s ease-in-out infinite !important;
}

@keyframes comingSoonPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* === Play Flow Screens === */
.play-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 25px;
}

.play-mode-card {
    background: linear-gradient(135deg, #1e2936 0%, #1a2332 100%);
    border: 2px solid rgba(79, 209, 197, 0.3);
    border-radius: 16px;
    padding: 30px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: #e2e8f0;
}

.play-mode-card:hover {
    transform: translateY(-5px);
    border-color: #4fd1c5;
    box-shadow: 0 8px 25px rgba(79, 209, 197, 0.3);
}

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

.play-mode-card[data-playmode="classic"]:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.play-mode-card[data-playmode="chaotic"]:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.play-mode-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.play-mode-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.play-mode-desc {
    font-size: 0.8rem;
    opacity: 0.8;
    color: #94a3b8;
    line-height: 1.4;
}

/* Budget Grid */
.budget-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.budget-btn,
.create-room-amount-btn {
    padding: 22px 10px;
    border: 2px solid #374151;
    border-radius: 14px;
    background: linear-gradient(135deg, #2d3748 0%, #1a2332 100%);
    font-size: 1.3rem;
    font-weight: 700;
    color: #fbbf24;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
    text-align: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.budget-btn:hover,
.create-room-amount-btn:hover {
    transform: translateY(-3px);
    border-color: #fbbf24;
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.3);
}

.budget-btn.selected,
.create-room-amount-btn.selected {
    border-color: #fbbf24;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5);
}

/* =============================================
   ROOM BROWSER — Android-native mobile design
   ============================================= */
#roomBrowserScreen.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: unset;
    padding: 0;
    justify-content: flex-start;
    align-items: stretch;
    background: #0f1419;
}

/* --- Toolbar --- */
.rb-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: env(safe-area-inset-top, 6px) 12px 10px;
    background: #161d27;
    border-bottom: 1px solid #1e2a3a;
}

.rb-back {
    background: none;
    border: none;
    color: #4fd1c5;
    padding: 8px;
    margin: 0 -4px 0 -8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rb-back:active {
    background: rgba(79,209,197,0.12);
}

.rb-toolbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2e8f0;
    flex-shrink: 0;
}

.rb-toolbar-pills {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.rb-pill {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.02em;
}

.rb-pill-mode {
    background: #059669;
}

.rb-pill-mode.chaotic {
    background: #d97706;
}

.rb-pill-budget {
    background: #4f46e5;
}

/* --- Pinned own room --- */
.rb-my-room:empty {
    display: none;
}

.rb-my-room {
    flex-shrink: 0;
    padding: 8px 12px 0;
}

.rb-my-room .rb-card {
    background: linear-gradient(135deg, rgba(79,209,197,0.08) 0%, #1a2332 100%);
    border: 1.5px solid #4fd1c5;
}

/* --- Scrollable room list --- */
.rb-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 8px 12px 12px;
}

.rb-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: #475569;
    font-size: 0.85rem;
    text-align: center;
    gap: 6px;
}

.rb-list-empty svg {
    opacity: 0.3;
    margin-bottom: 4px;
}

/* --- Room card --- */
.rb-card {
    background: #1c2736;
    border: 1.5px solid #2a3545;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rb-card:active {
    background: #212e40;
}

.rb-card:last-child {
    margin-bottom: 0;
}

/* Avatar circle */
.rb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d3748, #374151);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
}

.rb-my-room .rb-avatar {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: white;
}

/* Card text */
.rb-card-info {
    flex: 1;
    min-width: 0;
}

.rb-card-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.rb-card-meta {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 1px;
}

/* Wager amount */
.rb-card-amount {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fbbf24;
    flex-shrink: 0;
    padding-right: 2px;
}

/* Join button */
.rb-join {
    flex-shrink: 0;
    padding: 0;
    width: 56px;
    height: 36px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rb-join:active {
    background: #059669;
    transform: scale(0.94);
}

/* Own room actions row */
.rb-my-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rb-status {
    padding: 5px 10px;
    background: #d97706;
    color: white;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    animation: rbPulse 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes rbPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.rb-cancel {
    padding: 0;
    width: 56px;
    height: 32px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rb-cancel:active {
    background: #b91c1c;
    transform: scale(0.93);
}

/* --- Bottom bar --- */
.rb-bottom {
    flex-shrink: 0;
    padding: 10px 12px calc(env(safe-area-inset-bottom, 6px) + 10px);
    background: #161d27;
    border-top: 1px solid #1e2a3a;
}

.rb-create-btn {
    width: 100%;
    padding: 0;
    height: 48px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rb-create-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* =============================================
   MATCH COUNTDOWN SCREEN — styled entirely in brand.css (vss-* classes)
   ============================================= */

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 20px 15px;
    }

    .container h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 15px;
        font-size: 1rem;
    }

    .bet-amount-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .logo-brand {
        font-size: 1.8rem;
        letter-spacing: 4px;
    }

    .logo-text {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .logo-vs {
        font-size: 0.8rem;
        margin: 0 6px;
    }

    .logo-tagline {
        font-size: 0.65rem;
        letter-spacing: 3px;
    }

    .menu-grid-2x2 {
        gap: 10px;
    }

    .square-icon {
        font-size: 2.5rem;
    }

    .square-label {
        font-size: 1rem;
    }

    .budget-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .play-mode-grid {
        grid-template-columns: 1fr;
    }

    .hamburger-menu {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
    }

    .slide-menu {
        width: 280px;
    }

    .menu-item {
        padding: 15px;
    }

    .menu-icon {
        font-size: 1.5rem;
    }

    .menu-title {
        font-size: 1rem;
    }

    .race-number {
        font-size: 10rem;
    }

    .frozen-icon {
        font-size: 3rem;
    }

    .frozen-text {
        font-size: 1.8rem;
    }

    .mode-grid {
        grid-template-columns: 1fr;
    }

    .mode-name {
        font-size: 1.1rem;
    }

    .ai-mode-content {
        padding: 30px 20px;
    }

    .ai-mode-content h2 {
        font-size: 1.5rem;
    }

    .ai-mode-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ai-mode-btn {
        padding: 25px 15px;
    }

}

/* =============================================
   REMATCH OFFER BANNER
   ============================================= */
.rematch-offer-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #1a2d1a 0%, #162414 100%);
    border-bottom: 2px solid #10b981;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    padding: 10px 14px;
    animation: bannerSlideDown 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes bannerSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.rematch-offer-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rematch-offer-text {
    flex: 1;
    font-size: 0.88rem;
    color: #e2e8f0;
    line-height: 1.3;
}

.rematch-offer-text strong {
    color: #4fd1c5;
}

.rematch-offer-text em {
    color: #94a3b8;
    font-style: normal;
    font-size: 0.8rem;
    display: block;
    margin-top: 2px;
}

.rematch-offer-actions {
    display: flex;
    gap: 8px;
}

.rematch-offer-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rematch-offer-btn.accept {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.rematch-offer-btn.accept:active { transform: scale(0.94); }

.rematch-offer-btn.decline {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid #ef4444;
}

.rematch-offer-btn.decline:active { transform: scale(0.94); }

.rematch-offer-timer {
    font-size: 0.78rem;
    color: #fbbf24;
    font-weight: 700;
    min-width: 28px;
    text-align: right;
}


@keyframes tickerScroll {
    from { transform: translateX(100vw); }
    to   { transform: translateX(-100%); }
}
