/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a12;
    color: #e0e0e0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(30, 60, 40, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(20, 40, 60, 0.2) 0%, transparent 60%),
        #0a0a12;
}

/* ==================== SCREENS SYSTEM ==================== */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

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

/* ==================== AUTH SCREEN ==================== */
.auth-container {
    width: min(400px, 90vw);
    text-align: center;
}

.auth-header {
    margin-bottom: 28px;
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 6px;
}

.auth-header h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.4rem;
    letter-spacing: 6px;
    color: #4CAF50;
    margin-bottom: 2px;
}

.auth-subtitle {
    font-size: 0.75rem;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
}

.auth-form {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px 24px;
}

.auth-form.hidden {
    display: none;
}

.auth-form h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 3px;
    color: #4CAF50;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 14px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 5px;
    text-transform: uppercase;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.25s;
}

.form-group input:focus {
    border-color: rgba(76, 175, 80, 0.5);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.form-group small {
    display: block;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.25);
    margin-top: 3px;
}

.form-error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: #ef9a9a;
    margin-bottom: 12px;
}

.form-error.hidden {
    display: none;
}

.auth-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
    position: relative;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.4);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
    color: rgba(255, 255, 255, 0.6);
}

.auth-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.btn-loader.hidden { display: none; }

.auth-switch {
    margin-top: 14px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.auth-switch a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-forgot {
    margin-top: 8px;
    margin-bottom: -4px;
    font-size: 0.7rem;
    text-align: right;
}

.auth-forgot a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 600;
}

.auth-forgot a:hover {
    text-decoration: underline;
}

.forgot-desc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.5;
    margin-bottom: 18px;
}

.form-success {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.75rem;
    color: #81C784;
    margin-bottom: 12px;
    line-height: 1.4;
}

.form-success.hidden {
    display: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

/* ==================== LOBBY SCREEN ==================== */
#lobby-screen.active-screen {
    flex-direction: column;
}

.lobby-container {
    width: min(500px, 94vw);
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    gap: 12px;
}

.lobby-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    flex-shrink: 0;
}

.lobby-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.lobby-user-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.lobby-username {
    font-weight: 600;
    font-size: 0.85rem;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lobby-rating {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.lobby-stats-bar {
    margin-left: auto;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.lobby-actions-top {
    display: flex;
    gap: 4px;
}

.lobby-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.lobby-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.lobby-title {
    text-align: center;
    flex-shrink: 0;
}

.lobby-logo {
    font-size: 1.8rem;
    margin-bottom: 2px;
}

.lobby-title h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 4px;
    color: #4CAF50;
}

.lobby-main-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.lobby-play-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 18px;
    background: rgba(76, 175, 80, 0.08);
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    color: #e0e0e0;
    text-align: left;
}

.lobby-play-btn:hover {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.lobby-play-local {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

.lobby-play-local:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.lobby-play-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.lobby-play-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lobby-play-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.15rem;
    letter-spacing: 2px;
    color: #fff;
}

.lobby-play-desc {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.35);
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

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

.search-content {
    text-align: center;
}

.search-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(76, 175, 80, 0.2);
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-content h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    letter-spacing: 3px;
    color: #4CAF50;
    margin-bottom: 8px;
}

.search-content p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 20px;
}

.search-mode-tag {
    display: inline-block;
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.75rem;
    color: rgba(76, 175, 80, 0.9);
    margin: -8px 0 12px 0 !important;
    letter-spacing: 0.5px;
}

.search-cancel-btn {
    padding: 8px 24px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    color: #ef9a9a;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-cancel-btn:hover {
    background: rgba(244, 67, 54, 0.2);
}

/* Online Players List */
.lobby-players-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.lobby-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.lobby-section-header h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
}

.lobby-refresh-btn {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.3s;
    padding: 4px;
}

.lobby-refresh-btn:hover {
    transform: rotate(180deg);
}

.online-players-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px;
}

.online-players-list::-webkit-scrollbar {
    display: block;
    width: 4px;
}

.online-players-list::-webkit-scrollbar-track {
    background: transparent;
}

.online-players-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.player-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.2s;
    cursor: pointer;
}

.player-list-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.player-list-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.player-list-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.player-list-info:hover {
    background: rgba(255,255,255,0.06);
}

.player-list-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-list-rating {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.35);
}

.player-list-status {
    font-size: 0.58rem;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.player-invite-btn {
    padding: 5px 14px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.player-invite-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.4);
}

.player-busy {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    flex-shrink: 0;
}

/* Challenge sent overlay */
.challenge-sent-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.challenge-timer-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 12px 0 4px;
    overflow: hidden;
}

.challenge-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFD700);
    border-radius: 2px;
    width: 100%;
    transition: width 1s linear;
}

.challenge-timer-text {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
}

/* Profile change password */
.profile-change-password {
    margin-bottom: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 12px;
}

.profile-change-password h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.profile-change-password h3:hover {
    color: #4CAF50;
}

#pw-toggle-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
    display: inline-block;
}

.change-pw-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.change-pw-section.hidden {
    display: none;
}

.change-pw-section .form-group {
    margin-bottom: 8px;
}

.change-pw-section .form-group label {
    font-size: 0.65rem;
}

.change-pw-section .form-group input {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.status-available {
    background: rgba(76, 175, 80, 0.15);
    color: #81C784;
}

.status-in-game {
    background: rgba(244, 67, 54, 0.1);
    color: #ef9a9a;
}

.player-list-invite {
    padding: 5px 10px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 6px;
    color: #81C784;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.player-list-invite:hover {
    background: rgba(76, 175, 80, 0.2);
}

.empty-list {
    text-align: center;
    padding: 20px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.25);
}

/* Lobby Stats */
.lobby-my-stats {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    color: #4CAF50;
}

.stat-label {
    display: block;
    font-size: 0.55rem;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
}

/* ==================== GAME SCREEN ==================== */
#game-screen.active-screen {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== GAME CONTAINER ==================== */
#game-container {
    width: 100vw;
    height: 100vh;
    max-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    overflow: hidden;
}

/* ==================== TOP BAR (Players + Status) ==================== */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 8px 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 10px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    flex: 1;
    max-width: 380px;
}

.player-info.active-player {
    background: rgba(76, 175, 80, 0.12);
    border: 1px solid rgba(76, 175, 80, 0.3);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.08);
}

.player-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.active-player .player-avatar {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    border-color: rgba(76, 175, 80, 0.5);
    color: #fff;
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.3);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.player-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-name {
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    color: #e0e0e0;
}

.player-ball-type {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    box-shadow: inset -1.5px -1.5px 3px rgba(0,0,0,0.35), inset 1px 1px 2px rgba(255,255,255,0.2);
    overflow: hidden;
}

.player-ball-type.solid-ball {
    background: linear-gradient(135deg, #F5D130 0%, #c4a020 100%);
}

.player-ball-type.stripe-ball {
    background: linear-gradient(135deg, #f0ece4 0%, #d0ccc4 100%);
}

.player-ball-type.stripe-ball::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(135deg, #F5D130 0%, #c4a020 100%);
}

.player-ball-type:empty {
    display: none;
}

.player-type {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

.balls-pocketed {
    display: flex;
    gap: 4px;
    min-height: 24px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    align-items: center;
}

.ball-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset -2px -2px 4px rgba(0,0,0,0.35),
        inset 1px 1px 3px rgba(255,255,255,0.2),
        0 1px 3px rgba(0,0,0,0.3);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.ball-icon:hover {
    transform: scale(1.25);
    z-index: 10;
}

.ball-number {
    font-size: 8px;
    font-weight: 700;
    font-family: 'Inter', Arial, sans-serif;
    line-height: 1;
    text-align: center;
    z-index: 2;
    position: relative;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
    pointer-events: none;
}

.ball-stripe-band {
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 14px;
    z-index: 1;
    opacity: 0.92;
    border-top: 1px solid rgba(255,255,255,0.15);
    border-bottom: 1px solid rgba(0,0,0,0.15);
}

.ball-solid .ball-number {
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.92);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111 !important;
    text-shadow: none;
    font-size: 7px;
}

.ball-stripe .ball-number {
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111 !important;
    text-shadow: none;
    font-size: 7px;
}

.ball-icon::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 6px;
    height: 5px;
    background: radial-gradient(ellipse, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0) 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
}

#game-status {
    text-align: center;
    flex: 1;
    padding: 0 12px;
}

#turn-indicator {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: #4CAF50;
    letter-spacing: 2px;
}

#mode-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
}

#game-message {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    min-height: 16px;
    transition: all 0.3s;
    font-weight: 400;
}

/* ==================== GAME AREA ==================== */
#game-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 1200px;
}

/* ==================== POWER BAR ==================== */
#power-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#power-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.3);
}

#power-bar {
    width: 6px;
    height: clamp(120px, 40vh, 260px);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 40px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
}

#power-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 0%;
    border-radius: 40px;
    background: linear-gradient(to top,
        #4CAF50 0%,
        #8BC34A 30%,
        #FFC107 55%,
        #FF9800 75%,
        #f44336 100%
    );
    transition: height 0.05s;
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.4);
}

/* ==================== TABLE CONTAINER ==================== */
#table-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

#gameCanvas {
    border-radius: 6px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(0, 60, 0, 0.08);
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ==================== SIDE PANEL ==================== */
#side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

#spin-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#spin-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.3);
}

#spinCanvas {
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.3s;
}

#spinCanvas:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#action-buttons button {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

#action-buttons button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
}

#action-buttons button svg {
    opacity: 0.6;
    flex-shrink: 0;
}

#action-buttons button:hover svg {
    opacity: 0.9;
}

/* ==================== QUICK CHAT ==================== */
.quick-chat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.quick-chat.hidden {
    display: none;
}

.chat-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.25);
}

.chat-messages {
    max-height: 60px;
    overflow-y: auto;
    width: 100%;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.5);
}

.chat-msg {
    padding: 2px 4px;
    animation: fadeSlideIn 0.3s ease;
}

.chat-quick-btns {
    display: flex;
    gap: 3px;
}

.chat-quick-btns button {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.chat-quick-btns button:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.15);
}

/* ==================== ONLINE BADGE ==================== */
.online-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 1px;
    padding: 1px 5px;
    border-radius: 4px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.online-badge.hidden {
    display: none;
}

/* ==================== RATING CHANGE ==================== */
.rating-change {
    margin: 10px 0 16px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.rating-change.hidden {
    display: none;
}

.rating-up {
    color: #4CAF50;
}

.rating-down {
    color: #ef5350;
}

/* ==================== INVITE MODAL ==================== */
.invite-content {
    text-align: center;
    padding: 30px 24px;
}

.invite-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.invite-content h2 {
    text-align: center;
    color: #FFD700;
}

.invite-content p {
    margin: 10px 0 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.invite-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.invite-accept {
    padding: 10px 28px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.invite-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

.invite-reject {
    padding: 10px 28px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    color: #ef9a9a;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.invite-reject:hover {
    background: rgba(244, 67, 54, 0.2);
}

/* ==================== DISCONNECT MODAL ==================== */
.disconnect-content {
    text-align: center;
    padding: 30px 24px;
}

.disconnect-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.disconnect-content h2 {
    text-align: center;
    color: #ef5350;
}

.disconnect-content p {
    margin: 10px 0 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ==================== BACK BUTTON IN MODE MODAL ==================== */
.mode-back-row {
    margin-top: 12px;
}

.mode-btn-back {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 6px;
}

.mode-btn-back:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* ==================== PROFILE MODAL ==================== */
.profile-content {
    max-width: min(420px, 92vw);
    max-height: 85vh;
}

.profile-info {
    text-align: center;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 8px;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
}

.profile-username {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e0e0e0;
    display: block;
}

.profile-rating-big {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 20px;
}

.profile-stat {
    text-align: center;
    padding: 10px 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ps-value {
    display: block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    color: #4CAF50;
}

.ps-label {
    display: block;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
}

.profile-match-history h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
}

.match-history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.match-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 0.72rem;
}

.match-result {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 4px;
}

.match-win {
    background: rgba(76, 175, 80, 0.15);
    color: #81C784;
}

.match-loss {
    background: rgba(244, 67, 54, 0.1);
    color: #ef9a9a;
}

/* ==================== LEADERBOARD MODAL ==================== */
.leaderboard-content {
    max-width: min(450px, 92vw);
    max-height: 80vh;
}

.leaderboard-content h2 {
    text-align: center;
}

.leaderboard-list {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-rank {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.3);
    min-width: 28px;
    text-align: center;
}

.lb-rank-1 { color: #FFD700; }
.lb-rank-2 { color: #C0C0C0; }
.lb-rank-3 { color: #CD7F32; }

.lb-name {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: #e0e0e0;
}

.lb-rating {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    color: #4CAF50;
    letter-spacing: 1px;
}

.lb-winrate {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.35);
    min-width: 40px;
    text-align: right;
}

/* ==================== MODALS ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: clamp(16px, 4vw, 32px);
    max-width: min(480px, 92vw);
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    z-index: 1;
}

.modal-content h2 {
    font-family: 'Bebas Neue', sans-serif;
    color: #4CAF50;
    margin-bottom: 20px;
    font-size: 1.6rem;
    letter-spacing: 2px;
}

.close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Rules List */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.65);
}

.rule-item strong {
    color: #e0e0e0;
    font-weight: 600;
}

.rule-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Win Modal */
.win-content {
    text-align: center;
    padding: 40px 32px;
}

.win-trophy {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: trophyBounce 1s ease infinite alternate;
}

@keyframes trophyBounce {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-6px) scale(1.05); }
}

.win-content h2 {
    font-size: 2rem;
    color: #FFD700;
    text-align: center;
}

.win-content p {
    margin: 12px 0 24px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
}

.btn-play-again {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 12px 32px;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all 0.25s;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
}

.btn-play-again:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.4);
}

/* Rematch buttons */
.rematch-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.btn-rematch {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 12px 32px;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all 0.25s;
    box-shadow: 0 4px 20px rgba(255, 152, 0, 0.3);
    min-width: 200px;
}

.btn-rematch:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 152, 0, 0.4);
}

.btn-back-lobby {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.25s;
    min-width: 200px;
}

.btn-back-lobby:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.btn-back-lobby.btn-sm {
    font-size: 0.7rem;
    padding: 8px 16px;
    min-width: auto;
    margin-top: 8px;
}

.btn-decline {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 10px 24px;
    background: rgba(239, 83, 80, 0.2);
    color: #ef5350;
    border: 1px solid rgba(239, 83, 80, 0.4);
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.25s;
}

.btn-decline:hover {
    background: rgba(239, 83, 80, 0.35);
}

.rematch-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rematch-waiting.hidden,
.rematch-received.hidden {
    display: none;
}

#win-buttons-offline.hidden,
#win-buttons-online.hidden {
    display: none;
}

.rematch-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 152, 0, 0.2);
    border-top: 3px solid #FF9800;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.rematch-waiting p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.rematch-received {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.rematch-received-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #FF9800;
    margin: 0;
}

.rematch-received-btns {
    display: flex;
    gap: 12px;
}

/* ==================== MODE SELECTION MODAL ==================== */
.mode-content {
    max-width: min(420px, 92vw);
    padding: clamp(14px, 3vw, 28px) clamp(14px, 3vw, 28px);
    text-align: center;
}

.mode-header {
    margin-bottom: 16px;
}

.mode-logo {
    font-size: 2.2rem;
    margin-bottom: 4px;
}

.mode-content h2 {
    font-size: 1.7rem;
    letter-spacing: 4px;
    margin-bottom: 2px;
    text-align: center;
}

.mode-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #e0e0e0;
    text-align: left;
}

.mode-btn:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.mode-btn-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.mode-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-btn-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.15rem;
    letter-spacing: 2px;
    color: #fff;
}

.mode-btn-desc {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.mode-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 2px 0;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mode-divider::before,
.mode-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

/* ==================== DIFFICULTY SELECT ==================== */
.difficulty-select {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    animation: fadeSlideIn 0.35s ease;
}

.difficulty-select.hidden {
    display: none;
}

/* ==================== RULES SELECTION GRID ==================== */
.rules-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rules-btn {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 10px !important;
    gap: 6px !important;
}

.rules-btn .mode-btn-icon {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    border-radius: 12px;
}

.rules-btn .mode-btn-text {
    align-items: center;
}

.rules-btn .mode-btn-title {
    font-size: 1rem;
}

.rules-btn .mode-btn-desc {
    font-size: 0.6rem;
    text-align: center;
}

#rules-select-step.hidden,
#player-select-step.hidden {
    display: none;
}

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

.diff-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
}

.diff-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.diff-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s;
    color: #e0e0e0;
    text-align: left;
}

.diff-btn:hover { transform: translateY(-1px); }
.diff-easy:hover { background: rgba(76, 175, 80, 0.1); border-color: rgba(76, 175, 80, 0.3); }
.diff-medium:hover { background: rgba(255, 193, 7, 0.1); border-color: rgba(255, 193, 7, 0.3); }
.diff-hard:hover { background: rgba(244, 67, 54, 0.1); border-color: rgba(244, 67, 54, 0.3); }

.diff-stars { font-size: 0.8rem; flex-shrink: 0; min-width: 42px; text-align: center; }
.diff-name { font-family: 'Bebas Neue', sans-serif; font-size: 1rem; letter-spacing: 2px; min-width: 60px; }
.diff-desc { font-size: 0.65rem; color: rgba(255, 255, 255, 0.35); margin-left: auto; }

/* ==================== AI BADGE ==================== */
.ai-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 1.5px;
    padding: 1px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, #7C4DFF, #536DFE);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(124, 77, 255, 0.3);
}

.ai-badge.hidden { display: none; }

/* ==================== AI THINKING INDICATOR ==================== */
.ai-thinking {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(124, 77, 255, 0.3);
    border-radius: 10px;
    z-index: 10;
    pointer-events: none;
}

.ai-thinking-text {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: #B388FF;
}

.ai-thinking-dots { display: flex; gap: 4px; }

.ai-thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7C4DFF;
    animation: dotPulse 1.2s ease infinite;
}

.ai-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%      { opacity: 1; transform: scale(1.2); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    #game-container { gap: 6px; padding: 6px 8px; }
    #top-bar { padding: 6px 10px; border-radius: 10px; }
    .player-info { padding: 4px 8px; gap: 6px; }
    .player-avatar { width: 28px; height: 28px; font-size: 0.9rem; }
    .player-name { font-size: 0.75rem; }
    .player-type { font-size: 0.6rem; }
    .ball-icon { width: 18px; height: 18px; }
    .ball-number { font-size: 6px; }
    .ball-solid .ball-number, .ball-stripe .ball-number { width: 8px; height: 8px; font-size: 6px; }
    .ball-stripe-band { top: 3px; height: 12px; }
    #game-area { gap: 8px; }
    #action-buttons button span { display: none; }
    #action-buttons button { padding: 8px; justify-content: center; }
    #spin-label, #power-label { font-size: 0.6rem; }
    .quick-chat { display: none; }
}

@media (max-width: 900px) and (orientation: landscape) {
    #game-container { gap: 4px; padding: 4px 6px; }
    #top-bar { padding: 3px 8px; border-radius: 8px; gap: 2px; }
    .player-info { padding: 2px 6px; gap: 4px; }
    .player-avatar { width: 22px; height: 22px; font-size: 0.75rem; }
    .player-name { font-size: 0.65rem; }
    .player-type { font-size: 0.55rem; }
    #turn-indicator { font-size: 0.85rem; }
    #game-message { font-size: 0.6rem; }
    #game-status { padding: 0 8px; }
    .balls-pocketed { gap: 2px; min-height: 18px; }
    .ball-icon { width: 16px; height: 16px; }
    #game-area { gap: 6px; }
    #side-panel { gap: 8px; }
    #spinCanvas { width: 60px !important; height: 60px !important; }
    #action-buttons { gap: 4px; }
    #action-buttons button { padding: 5px; }
    #action-buttons button svg { width: 14px; height: 14px; }
}

@media (max-width: 600px) and (orientation: portrait) {
    #game-container { gap: 6px; padding: 4px; justify-content: flex-start; padding-top: 6px; }
    #top-bar { flex-wrap: wrap; gap: 2px; border-radius: 10px; padding: 4px 8px; order: 0; }
    .player-info { flex: 1; min-width: 0; padding: 3px 6px; gap: 5px; max-width: none; }
    .player-avatar { width: 24px; height: 24px; font-size: 0.75rem; }
    .player-name { font-size: 0.68rem; }
    .player-type { font-size: 0.55rem; letter-spacing: 1px; }
    #game-status { width: 100%; order: -1; padding: 2px 0; }
    #turn-indicator { font-size: 0.85rem; letter-spacing: 1.5px; }
    #game-message { font-size: 0.62rem; min-height: 14px; }
    .balls-pocketed { gap: 2px; min-height: 18px; }
    .ball-icon { width: 16px; height: 16px; }
    .ball-number { font-size: 5.5px; }
    .ball-solid .ball-number, .ball-stripe .ball-number { width: 8px; height: 8px; font-size: 5.5px; }
    .ball-stripe-band { top: 3px; height: 10px; }
    .ball-icon::after { top: 1px; left: 3px; width: 5px; height: 4px; }
    #game-area { flex-direction: column; gap: 6px; width: 100%; }
    #table-container { width: 100%; order: 0; }
    #gameCanvas { width: 100%; height: auto; }
    #power-bar-container { flex-direction: row; align-items: center; gap: 8px; order: 1; width: 100%; justify-content: center; }
    #power-bar { width: clamp(120px, 50vw, 250px); height: 6px; }
    #power-fill { left: 0; bottom: 0; width: 0% !important; height: 100% !important; background: linear-gradient(to right, #4CAF50, #FFC107, #f44336); }
    #power-label { font-size: 0.6rem; }
    #side-panel { flex-direction: row; align-items: center; gap: 12px; order: 2; }
    #spinCanvas { width: 56px !important; height: 56px !important; }
    #spin-label, #power-label { font-size: 0.55rem; letter-spacing: 2px; }
    #action-buttons { flex-direction: row; gap: 4px; }
    #action-buttons button { padding: 6px; justify-content: center; }
    #action-buttons button span { display: none; }
    #action-buttons button svg { width: 14px; height: 14px; }
}

@media (max-width: 380px) and (orientation: portrait) {
    #game-container { padding: 2px; gap: 4px; }
    #top-bar { padding: 3px 6px; }
    .player-avatar { width: 20px; height: 20px; font-size: 0.65rem; }
    .player-name { font-size: 0.6rem; }
    .player-details { gap: 0; }
    .balls-pocketed { gap: 1px; }
    .ball-icon { width: 14px; height: 14px; }
    .ball-solid .ball-number, .ball-stripe .ball-number { width: 7px; height: 7px; font-size: 5px; }
    #spinCanvas { width: 48px !important; height: 48px !important; }
}

@media (max-height: 400px) and (orientation: landscape) {
    #game-container { padding: 2px 4px; gap: 2px; }
    #top-bar { padding: 2px 6px; border-radius: 6px; }
    .player-info { padding: 1px 4px; }
    .player-avatar { width: 18px; height: 18px; font-size: 0.6rem; }
    .player-name { font-size: 0.58rem; }
    .player-type { display: none; }
    #turn-indicator { font-size: 0.75rem; }
    #game-message { font-size: 0.55rem; }
    .balls-pocketed { gap: 1px; }
    .ball-icon { width: 14px; height: 14px; }
    #game-area { gap: 4px; }
    #spinCanvas { width: 48px !important; height: 48px !important; }
    #action-buttons button { padding: 4px; }
}

@media (max-width: 480px) {
    .modal-content { border-radius: 14px; padding: 16px 14px; }
    .modal-content h2 { font-size: 1.3rem; }
    .mode-logo { font-size: 2rem; }
    .mode-content h2 { font-size: 1.5rem; }
    .mode-btn { padding: 10px 12px; gap: 10px; }
    .mode-btn-icon { width: 34px; height: 34px; font-size: 1.2rem; }
    .mode-btn-title { font-size: 1rem; }
    .mode-btn-desc { font-size: 0.6rem; }
    .rules-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .rules-btn { padding: 10px 6px !important; }
    .rules-btn .mode-btn-icon { width: 36px; height: 36px; font-size: 1.3rem; }
    .rules-btn .mode-btn-title { font-size: 0.85rem; }
    .rules-btn .mode-btn-desc { font-size: 0.55rem; }
    .diff-btn { padding: 10px 12px; }
    .diff-name { font-size: 0.85rem; }
    .diff-desc { font-size: 0.58rem; }
    .rule-item { font-size: 0.72rem; padding: 8px 10px; }
    .rule-icon { font-size: 1rem; }
    .win-trophy { font-size: 2.4rem; }
    .win-content h2 { font-size: 1.5rem; }
    .btn-play-again { font-size: 0.75rem; padding: 10px 24px; }
    .btn-rematch { font-size: 0.75rem; padding: 10px 24px; min-width: 160px; }
    .btn-back-lobby { font-size: 0.65rem; padding: 8px 16px; min-width: 160px; }
    .rematch-received-btns { gap: 8px; }
    .auth-container { width: 92vw; }
    .auth-logo { font-size: 2.2rem; }
    .auth-header h1 { font-size: 1.8rem; }
}

/* ==================== SCROLLBAR (safety) ==================== */
::-webkit-scrollbar { display: none; }

::selection {
    background: rgba(76, 175, 80, 0.3);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    z-index: 99999;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    text-align: center;
    max-width: 90vw;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

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

.toast-info {
    background: linear-gradient(135deg, #2196F3, #1565C0);
}

.toast-success {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
}

.toast-warning {
    background: linear-gradient(135deg, #FF9800, #E65100);
}

.toast-error {
    background: linear-gradient(135deg, #f44336, #c62828);
}
