/* Mobile WoW-style Chat System - Mobile Only */
.wow-chat-log {
    position: fixed;
    top: 100px;
    left: 20px;
    width: 300px;
    max-height: 250px;
    z-index: 15000;
    font-family: 'Courier New', 'Lucida Console', monospace;
    pointer-events: none;
    overflow: hidden;
    display: none; /* Hidden by default, shown only on mobile */
}

.wow-chat-message {
    color: #FF69FF; /* WoW whisper pink */
    font-size: 12px;
    line-height: 1.2;
    margin: 2px 0;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transform: translateY(-10px);
    animation: wowMessageFadeIn 0.3s ease-out forwards;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wow-chat-message.fade-out {
    animation: wowMessageFadeOut 0.5s ease-in forwards;
}

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

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

/* Flying bubble animation - perfect circle with three dots */
.flying-chat-bubble {
    position: fixed;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 248, 255, 0.95));
    border: 2px solid rgba(74, 144, 226, 0.8);
    border-radius: 50%; /* Perfect circle */
    width: 36px; /* Smaller size for mobile */
    height: 36px; /* Smaller size for mobile */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 16000;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 25px rgba(74, 144, 226, 0.15);
    backdrop-filter: blur(12px);
}

/* Three dots inside the circle */
.flying-chat-bubble::before {
    content: '• • •';
    color: #000000;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 1px;
    animation: dotPulse 1.5s ease-in-out infinite;
}

/* Animated dots pulsing effect */
@keyframes dotPulse {
    0%, 100% { 
        opacity: 0.4; 
        transform: scale(0.8);
    }
    50% { 
        opacity: 1; 
        transform: scale(1.1);
    }
}

/* Hide on desktop - Mobile only component */
@media (min-width: 769px) {
    .wow-chat-log,
    .flying-chat-bubble {
        display: none !important;
    }
}

/* Responsive sizing for very small screens */
@media (max-width: 320px) {
    .wow-chat-log {
        width: 250px;
        left: 10px;
        top: 10px;
    }
    
    .wow-chat-message {
        font-size: 11px;
    }
}

/* Discord Authentication Button Styles */
.discord-auth-btn {
    position: relative;
    transition: all 0.3s ease;
}

/* Guest user state - encouraging style */
.discord-auth-btn.guest-state {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    border: 2px solid #7289DA;
    box-shadow: 0 0 20px rgba(88, 101, 242, 0.3);
}

.discord-auth-btn.guest-state:hover {
    background: linear-gradient(135deg, #4752C4, #5865F2);
    box-shadow: 0 0 25px rgba(88, 101, 242, 0.5);
    transform: translateY(-2px);
}

.discord-auth-btn.guest-state::before {
    content: '🎭';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #7289DA;
    animation: guestPulse 2s ease-in-out infinite;
}

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

/* Authenticated user state - success style */
.discord-auth-btn.authenticated-state {
    background: linear-gradient(135deg, #57F287, #00D96F);
    border: 2px solid #00D96F;
    box-shadow: 0 0 20px rgba(87, 242, 135, 0.3);
}

.discord-auth-btn.authenticated-state:hover {
    background: linear-gradient(135deg, #3BA55D, #57F287);
    box-shadow: 0 0 25px rgba(87, 242, 135, 0.5);
}

.discord-auth-btn.authenticated-state::before {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 14px;
    background: #57F287;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    font-weight: bold;
}

/* Default login state */
.discord-auth-btn.login-state {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    border: 2px solid #7289DA;
}

.discord-auth-btn.login-state:hover {
    background: linear-gradient(135deg, #4752C4, #5865F2);
    transform: translateY(-1px);
}

/* Discord icon glow effect */
.discord-auth-btn .discord-icon {
    transition: all 0.3s ease;
}

.discord-auth-btn:hover .discord-icon {
    filter: drop-shadow(0 0 8px rgba(114, 137, 218, 0.8));
}

/* Loading state */
.discord-auth-btn.loading-state {
    background: linear-gradient(135deg, #99AAB5, #B9BBBE);
    border: 2px solid #B9BBBE;
    cursor: not-allowed;
}

.discord-auth-btn.loading-state .discord-icon {
    animation: discordLoading 1s ease-in-out infinite;
}

@keyframes discordLoading {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.9); }
}

/* User avatar display when authenticated */
.discord-user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    vertical-align: middle;
}

/* Top Right Discord Button - Always Visible */
.top-right-discord-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #5865F2, #7289DA);
    border: 2px solid #7289DA;
    border-radius: 20px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 16000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    opacity: 0.9;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.top-right-discord-btn:hover,
.top-right-discord-btn:active {
    background: linear-gradient(135deg, #4752C4, #5865F2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
    opacity: 1;
}

/* Mobile active state for better touch feedback */
@media (hover: none) {
    .top-right-discord-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

.top-right-discord-btn .discord-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    filter: drop-shadow(0 0 5px rgba(114, 137, 218, 0.5));
}

.top-right-discord-btn .discord-label {
    font-size: 14px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

/* Authentication states for top right button */
.top-right-discord-btn.guest-state {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    border-color: #7289DA;
    animation: guestPulse 2s ease-in-out infinite;
}

.top-right-discord-btn.guest-state:hover {
    background: linear-gradient(135deg, #4752C4, #5865F2);
}

.top-right-discord-btn.logged-in-state {
    background: linear-gradient(135deg, #57F287, #00D96F);
    border-color: #00D96F;
}

.top-right-discord-btn.logged-in-state:hover {
    background: linear-gradient(135deg, #3BA55D, #57F287);
}

.top-right-discord-btn.logged-in-state::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #57F287;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid white;
}

.top-right-discord-btn.loading-state {
    background: linear-gradient(135deg, #99AAB5, #B9BBBE);
    border-color: #B9BBBE;
    cursor: not-allowed;
}

.top-right-discord-btn.loading-state .discord-icon {
    animation: discordLoading 1s ease-in-out infinite;
}

/* Mobile responsiveness for top right button */
@media (max-width: 768px) {
    .top-right-discord-btn {
        top: 15px;
        right: 15px;
        padding: 6px 10px;
        border-radius: 16px;
    }

    .top-right-discord-btn .discord-icon {
        width: 20px;
        height: 20px;
        margin-right: 6px;
    }

    .top-right-discord-btn .discord-label {
        font-size: 12px;
    }

    .top-right-discord-btn.logged-in-state::after {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .top-right-discord-btn {
        top: 10px;
        right: 10px;
        padding: 5px 8px;
        border-radius: 14px;
    }

    .top-right-discord-btn .discord-icon {
        width: 18px;
        height: 18px;
        margin-right: 5px;
    }

    .top-right-discord-btn .discord-label {
        font-size: 11px;
    }
}

/* Hide top right button when menus are open */
.html-menu-overlay:not(.hidden) ~ #gameContainer .top-right-discord-btn {
    display: none;
}

/* Authentication Popup Modal */
.auth-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.auth-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.auth-popup {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid #0f3460;
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s ease;
    position: relative;
}

.auth-popup-overlay.show .auth-popup {
    transform: scale(1) translateY(0);
}

.auth-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.auth-popup-close:hover {
    opacity: 1;
}

.auth-popup-title {
    text-align: center;
    color: #ffffff;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 30px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.auth-tab.active {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    opacity: 1;
}

.auth-tab:hover {
    opacity: 1;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeInSlide 0.3s ease;
}

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

.auth-input-group {
    margin-bottom: 20px;
}

.auth-input-label {
    display: block;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    opacity: 0.9;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.auth-input:focus {
    outline: none;
    border-color: #5865F2;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.auth-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-button-primary {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    color: white;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

.auth-button-primary:hover {
    background: linear-gradient(135deg, #4752C4, #5865F2);
    box-shadow: 0 6px 20px rgba(88, 101, 242, 0.4);
    transform: translateY(-2px);
}

.auth-button-discord {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    color: white;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

.auth-button-discord:hover {
    background: linear-gradient(135deg, #4752C4, #5865F2);
    box-shadow: 0 6px 20px rgba(88, 101, 242, 0.4);
    transform: translateY(-2px);
}

.auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1;
}

.auth-divider span {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    padding: 0 15px;
    position: relative;
    z-index: 2;
}

.auth-error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: 8px;
    padding: 12px;
    color: #ff6b6b;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}

.auth-success {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.3);
    border-radius: 8px;
    padding: 12px;
    color: #4caf50;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}

.auth-loading {
    display: none;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 10px;
}

.auth-loading.show {
    display: block;
}

.auth-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #5865F2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Terms Agreement */
.auth-terms {
    margin-top: 20px;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-terms-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    margin: 0;
}

.auth-terms-link {
    color: #5865F2;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.auth-terms-link:hover {
    color: #7289DA;
    text-decoration: underline;
}

/* Mobile responsiveness for auth popup - More compact */
@media (max-width: 768px) {
    .html-menu-overlay {
        position: unset ;
    }
    .auth-popup {
        padding: 30px 15px 20px 15px; /* Increase top padding for close button space */
        margin: 15px;
        max-width: none;
        border-radius: 15px;
    }

    .auth-popup-title {
        display: none; /* Hide title on mobile */
    }

    .auth-tabs {
        margin-bottom: 20px;
        margin-top: 15px; /* Add space from top to avoid close button overlap */
    }

    .auth-tab {
        padding: 8px;
        font-size: 13px;
    }

    .auth-form {
        margin-top: 0;
    }

    .auth-input-group {
        margin-bottom: 15px;
    }

    .auth-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px;
        margin-bottom: 12px;
    }

    .auth-input-label {
        margin-bottom: 5px;
        font-size: 13px;
    }

    .auth-button {
        padding: 14px; /* Keep same as desktop */
        margin-bottom: 15px; /* Keep same as desktop */
        font-size: 16px; /* Keep same as desktop */
    }

    .auth-error,
    .auth-success {
        margin: 10px 0;
        padding: 8px;
        font-size: 13px;
    }

    .auth-terms {
        margin-top: 15px;
        padding: 12px 0;
    }

    .auth-terms-text {
        font-size: 11px;
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .auth-popup {
        padding: 25px 12px 15px 12px; /* Increase top padding for close button space */
        margin: 10px;
        border-radius: 12px;
    }

    .auth-popup-title {
        display: none; /* Ensure hidden on small mobile */
    }

    .auth-popup-close {
        top: 15px; /* Keep same as desktop */
        right: 15px;
        font-size: 24px; /* Keep same as desktop */
        z-index: 1000; /* Ensure it's above other elements */
    }

    .auth-tabs {
        margin-bottom: 12px;
        margin-top: 20px; /* Add more space on small mobile to avoid close button */
    }

    .auth-tab {
        padding: 6px;
        font-size: 12px;
    }

    .auth-input-group {
        margin-bottom: 12px;
    }

    .auth-input {
        padding: 8px;
        margin-bottom: 8px;
    }

    .auth-input-label {
        margin-bottom: 4px;
        font-size: 12px;
    }

    .auth-button {
        padding: 14px; /* Keep same as desktop */
        margin-bottom: 15px; /* Keep same as desktop */
        font-size: 16px; /* Keep same as desktop */
    }

    .auth-terms {
        margin-top: 12px;
        padding: 10px 0;
    }

    .auth-terms-text {
        font-size: 10px;
        line-height: 1.2;
    }
}

/* User Profile Widget - Shows when logged in */
.user-profile-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 15000; /* Higher z-index for mobile */
    cursor: pointer;
    touch-action: manipulation; /* Better touch handling */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0); /* Remove iOS tap highlight */
}

.user-profile-widget:hover {
    opacity: 0.9;
}

/* Active state for mobile touch feedback */
.user-profile-widget:active {
    opacity: 0.8;
}

.profile-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

.avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #5865F2, #7289DA);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    border-radius: 50%;
}

.profile-info {
    background: linear-gradient(135deg, rgba(16, 20, 40, 0.9), rgba(20, 25, 50, 0.9));
    border: 1px solid rgba(88, 101, 242, 0.3);
    border-radius: 12px;
    padding: 8px 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.profile-username {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    color: #57F287;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.profile-logout-btn {
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid rgba(255, 59, 48, 0.4);
    border-radius: 10px;
    padding: 10px;
    color: #ff6b6b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    min-width: 32px;
    min-height: 32px; /* Minimum touch target size for mobile */
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2);
}

.profile-logout-btn:hover {
    background: rgba(255, 59, 48, 0.2);
    border-color: rgba(255, 59, 48, 0.5);
    transform: scale(1.05);
}

.profile-logout-btn:active {
    background: rgba(255, 59, 48, 0.3);
    transform: scale(0.95);
}

/* Mobile responsiveness for user profile widget */
@media (max-width: 768px) {
    .user-profile-widget {
        top: 10px;
        right: 10px;
        gap: 10px;
    }

    .profile-avatar {
        width: 36px;
        height: 36px;
    }

    .avatar-fallback {
        font-size: 18px;
    }

    .profile-username {
        font-size: 14px;
        font-weight: 600;
    }

    .profile-stats {
        gap: 20px;
    }

    .stat-label {
        font-size: 10px;
        letter-spacing: 0.8px;
    }

    .stat-value {
        font-size: 13px;
        font-weight: 700;
    }

    .profile-logout-btn {
        padding: 12px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    .user-profile-widget {
        top: 8px;
        right: 8px;
        gap: 8px;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
    }

    .avatar-fallback {
        font-size: 16px;
    }

    .profile-username {
        font-size: 13px;
    }

    .profile-stats {
        gap: 16px;
    }

    .stat-label {
        font-size: 9px;
    }

    .stat-value {
        font-size: 12px;
    }
}

/* Guest Profile Widget - Shows when playing as guest */
.guest-profile-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 15000;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.guest-profile-widget:hover {
    opacity: 0.9;
}

.guest-profile-widget:active {
    opacity: 0.8;
}

.guest-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.guest-avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FF8C00, #FFA500);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    border-radius: 50%;
}

.guest-info {
    background: linear-gradient(135deg, rgba(40, 30, 16, 0.9), rgba(50, 35, 20, 0.9));
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 12px;
    padding: 8px 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.guest-username {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guest-stats {
    display: flex;
    gap: 20px;
}

.save-progress-btn {
    background: linear-gradient(135deg, #FF6B35, #F7931E, #FFB347);
    border: 2px solid rgba(255, 193, 7, 0.6);
    border-radius: 14px;
    padding: 12px 16px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    font-size: 13px;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    min-height: 36px;
    backdrop-filter: blur(12px);
    box-shadow: 
        0 4px 15px rgba(255, 140, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: savePulse 3s ease-in-out infinite;
}

/* Subtle pulsing animation to draw attention */
@keyframes savePulse {
    0%, 100% {
        box-shadow: 
            0 4px 15px rgba(255, 140, 0, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            0 6px 20px rgba(255, 140, 0, 0.6),
            0 4px 12px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

/* Shimmer effect overlay */
.save-progress-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.save-progress-btn:hover::before {
    left: 100%;
}

.save-progress-btn:hover {
    background: linear-gradient(135deg, #FF5722, #FF8A50, #FFB74D);
    border-color: rgba(255, 193, 7, 0.8);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 25px rgba(255, 140, 0, 0.5),
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: none; /* Pause the pulse on hover */
}

.save-progress-btn:active {
    background: linear-gradient(135deg, #E64A19, #FF7043, #FFAB40);
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 2px 10px rgba(255, 140, 0, 0.3),
        0 1px 5px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Enhanced icon styling */
.save-progress-btn svg {
    transition: transform 0.3s ease;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.save-progress-btn:hover svg {
    transform: scale(1.1) rotate(5deg);
}

/* Add a subtle glow effect on focus for accessibility */
.save-progress-btn:focus {
    outline: none;
    box-shadow: 
        0 0 0 3px rgba(255, 140, 0, 0.3),
        0 4px 15px rgba(255, 140, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Mobile responsiveness for guest profile widget */
@media (max-width: 768px) {
    .guest-profile-widget {
        top: 10px;
        right: 10px;
        gap: 10px;
    }

    .guest-avatar {
        width: 36px;
        height: 36px;
    }

    .guest-avatar-fallback {
        font-size: 18px;
    }

    .guest-username {
        font-size: 14px;
        font-weight: 600;
    }

    .guest-stats {
        gap: 20px;
    }

    .save-progress-btn {
        padding: 14px 18px;
        min-height: 48px;
        font-size: 14px;
        font-weight: 700;
        border-radius: 12px;
        letter-spacing: 0.3px;
        box-shadow: 
            0 4px 15px rgba(255, 140, 0, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

@media (max-width: 480px) {
    .guest-profile-widget {
        top: 8px;
        right: 8px;
        gap: 8px;
    }

    .guest-avatar {
        width: 32px;
        height: 32px;
    }

    .guest-avatar-fallback {
        font-size: 16px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .guest-username {
        font-size: 13px;
    }

    .guest-stats {
        gap: 16px;
    }

    .save-progress-btn {
        padding: 12px 16px;
        font-size: 13px;
        min-height: 44px;
        letter-spacing: 0.2px;
        border-radius: 10px;
    }
}

/* Ensure guest widget follows same z-index rules as user widget */
@media (max-width: 1023px) {
    #gameContainer #guestProfileWidget.guest-profile-widget,
    #guestProfileWidget.guest-profile-widget,
    div#guestProfileWidget {
        z-index: 2147483647 !important;
        position: fixed !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Ultra-narrow screens - stack content vertically */
@media (max-width: 360px) {
    .user-profile-widget,
    .guest-profile-widget {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 8px;
    }

    .profile-info,
    .guest-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 6px;
    }

    .profile-stats,
    .guest-stats {
        justify-content: center;
        gap: 24px;
    }

    .save-progress-btn {
        align-self: stretch;
        justify-content: center;
        padding: 12px;
        font-size: 13px;
    }

    .profile-logout-btn {
        align-self: center;
        padding: 12px;
        min-width: 44px;
        min-height: 44px;
    }

    .stat-label {
        font-size: 8px;
    }

    .stat-value {
        font-size: 10px;
        font-weight: 700;
    }
}

/* Guest Account Linking Prompt */
.guest-link-prompt {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-radius: 12px;
    padding: 16px;
    max-width: 320px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    animation: slideInRight 0.3s ease-out;
    z-index: 1001;
    display: none;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.guest-link-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.guest-link-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.guest-link-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
    color: #ffffff;
}

.guest-link-message {
    font-size: 14px;
    margin-bottom: 2px;
    color: rgba(255, 255, 255, 0.9);
}

.guest-link-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 12px;
}

.guest-link-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.guest-link-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.guest-link-close {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.guest-link-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Responsive adjustments for guest link prompt */
@media (max-width: 768px) {
    .guest-link-prompt {
        right: 10px;
        left: 10px;
        max-width: none;
        top: 60px;
    }
}

/* Hide user profile widget when menus are open on desktop only */
@media (min-width: 1024px) {
    .html-menu-overlay:not(.hidden) ~ #gameContainer .user-profile-widget {
        display: none;
    }
}

/* Mobile and tablet: Always keep profile widget on top */
@media (max-width: 1023px) {
    #gameContainer #userProfileWidget.user-profile-widget,
    #userProfileWidget.user-profile-widget,
    div#userProfileWidget {
        z-index: 2147483647 !important; /* Maximum possible z-index */
        position: fixed !important;
        /* Removed display: flex !important to allow JavaScript control */
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}