/* Daily Shapes v4.0 - Responsive Design System */

/* ================================
   BASE RESPONSIVE VARIABLES
   ================================ */
:root {
    /* Responsive breakpoints */
    --mobile-min: 320px;
    --mobile-max: 767px;
    --tablet-min: 768px;
    --tablet-max: 1023px;
    --desktop-min: 1024px;
    --desktop-large: 1440px;
    
    /* Responsive font scales */
    --font-scale-mobile: clamp(0.875rem, 2.5vw, 1rem);
    --font-scale-tablet: clamp(1rem, 1.5vw, 1.125rem);
    --font-scale-desktop: 1.125rem;
    
    /* Responsive spacing */
    --spacing-mobile: clamp(4px, 1.5vw, 8px);
    --spacing-tablet: clamp(8px, 1vw, 12px);
    --spacing-desktop: 16px;
    
    /* Canvas sizes - maintaining aspect ratio */
    --canvas-mobile: min(90vw, 380px);
    --canvas-tablet: min(70vw, 450px);
    --canvas-desktop: 380px;
}

/* Smooth transitions for responsive changes */
.main-header,
.header-top-row,
.header-buttons,
.auth-button,
.nav-button,
.app-container,
.canvas-container,
#geoCanvas {
    transition: all 0.3s ease;
}

/* ================================
   UNIVERSAL WELCOME CONTENT STYLES
   Responsive across all devices using clamp()
   ================================ */
.welcome-content {
    width: 100% !important;
}

.welcome-content strong {
    font-size: inherit !important;
    font-weight: 700 !important;
    word-wrap: break-word !important;
}

/* Mobile welcome content styles */
@media screen and (max-width: 767px) {
    .welcome-overlay {
        width: calc(100% - 28px) !important;
        max-width: min(340px, calc(100vw - 30px)) !important;
        padding: clamp(12px, 3vw, 16px) !important;
    }

    .welcome-content h2 {
        font-size: clamp(16px, 4vw, 20px) !important;
        margin: 0 0 clamp(8px, 2vw, 12px) 0 !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .welcome-content p {
        font-size: clamp(13px, 3.5vw, 16px) !important;
        margin: clamp(6px, 1.5vw, 8px) 0 !important;
        line-height: 1.4 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Desktop optimizations for welcome content */
@media screen and (min-width: 768px) {
    .welcome-overlay,
    #welcomeOverlay {
        width: 390px !important;
        max-width: 390px !important;
        min-width: 390px !important;
        padding: 30px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        top: 60% !important;
        transform: translate(-50%, -50%) !important;
    }

    .welcome-content {
        width: 100% !important;
    }

    .welcome-content h2 {
        font-size: 19px !important;
        margin: 0 0 9px 0 !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .welcome-content p {
        font-size: 15px !important;
        margin: 6px 0 !important;
        line-height: 1.35 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Success confirmation modal - compact desktop version */
    div#successConfirmationModal div.success-modal-content,
    div#successConfirmationModal #successConfirmationContent,
    div.success-modal#successConfirmationModal div.success-modal-content,
    div.success-modal#successConfirmationModal #successConfirmationContent,
    #successConfirmationModal .success-modal-content,
    #successConfirmationContent {
        max-height: 185px !important;
        min-height: auto !important;
    }

    div#successConfirmationModal div.success-modal-header,
    #successConfirmationModal .success-modal-header {
        padding: 8px 16px !important;
        height: auto !important;
        min-height: auto !important;
    }

    div#successConfirmationModal div.success-modal-body,
    #successConfirmationModal .success-modal-body {
        padding: 8px 16px 12px 16px !important;
    }

    div#successConfirmationModal button.success-nav-btn,
    #successConfirmationModal .success-nav-btn {
        padding: 8px 24px !important;
        font-size: 15px !important;
    }
}

/* ================================
   COMPETITION MODAL MOBILE FIXES
   ================================ */

/* Competition modal improvements for all mobile devices */
@media screen and (max-width: 767px) {
    /* Competition modal layout fixes */
    .success-modal-content {
        max-height: 490px !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
}

@media screen and (max-width: 767px) and (min-height: 700px) {
    .success-modal-content {
        max-height: 85vh !important;
    }

    /* Leaderboard table responsive improvements */
    .leaderboard-row {
        grid-template-columns: 50px 1fr 85px 45px 45px !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        gap: 6px !important;
    }

    /* Ensure score column has minimum width and better positioning */
    .col-score {
        min-width: 75px !important;
        text-align: right !important;
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        padding-right: 4px !important;
    }

    /* Player name truncation with better handling */
    .col-player {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        min-width: 0 !important;
        font-size: 0.8rem !important;
    }

    /* Rank column optimization */
    .col-rank {
        font-size: 0.8rem !important;
        font-weight: 700 !important;
    }

    /* Days and average columns */
    .col-days, .col-avg {
        font-size: 0.75rem !important;
        text-align: right !important;
    }

    /* Competition lists container optimization for mobile */
    #competitionActiveView .success-modal-body,
    #competitionExpiredView .success-modal-body {
        height: 450px !important;
        padding: 16px 20px !important;
    }

    #activeCompetitionsList,
    #expiredCompetitionsList {
        max-height: calc(100% - 70px) !important;
        margin-bottom: 12px !important;
    }

    /* Competition list buttons optimization */
    #competitionActiveView .success-nav-btn,
    #competitionExpiredView .success-nav-btn {
        margin-top: 12px !important;
        padding: 8px 16px !important;
        font-size: 14px !important;
        flex-shrink: 0 !important;
    }

    /* HTML TABLE leaderboard responsive fixes - High specificity */
    div.success-modal-content .leaderboard-table,
    #competitionModal .leaderboard-table,
    .success-modal .leaderboard-table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    div.success-modal-content .leaderboard-table .rank-cell,
    #competitionModal .leaderboard-table .rank-cell,
    .success-modal .leaderboard-table .rank-cell,
    .leaderboard-table th.rank-cell,
    .leaderboard-table td.rank-cell {
        width: 50px !important;
        font-size: 0.8rem !important;
        padding: 8px 4px !important;
    }

    div.success-modal-content .leaderboard-table .award-cell,
    #competitionModal .leaderboard-table .award-cell,
    .success-modal .leaderboard-table .award-cell,
    .leaderboard-table th.award-cell,
    .leaderboard-table td.award-cell {
        width: 40px !important;
        font-size: 0.9rem !important;
        padding: 8px 4px !important;
    }

    div.success-modal-content .leaderboard-table .username-cell,
    #competitionModal .leaderboard-table .username-cell,
    .success-modal .leaderboard-table .username-cell,
    .leaderboard-table th.username-cell,
    .leaderboard-table td.username-cell {
        width: auto !important;
        font-size: 0.8rem !important;
        padding: 8px 6px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    div.success-modal-content .leaderboard-table .total-score-cell,
    div.success-modal-content .leaderboard-table .score-cell,
    #competitionModal .leaderboard-table .total-score-cell,
    #competitionModal .leaderboard-table .score-cell,
    .success-modal .leaderboard-table .total-score-cell,
    .success-modal .leaderboard-table .score-cell,
    .leaderboard-table th.total-score-cell,
    .leaderboard-table td.total-score-cell,
    .leaderboard-table th.score-cell,
    .leaderboard-table td.score-cell {
        width: 85px !important;
        font-size: 0.8rem !important;
        padding: 8px 8px 8px 4px !important;
        text-align: right !important;
    }

    div.success-modal-content .leaderboard-table .days-cell,
    #competitionModal .leaderboard-table .days-cell,
    .success-modal .leaderboard-table .days-cell,
    .leaderboard-table th.days-cell,
    .leaderboard-table td.days-cell {
        width: 45px !important;
        font-size: 0.75rem !important;
        padding: 8px 4px !important;
    }

    .success-modal-body {
        overflow-y: hidden !important;
        flex: 1 !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        padding-bottom: 20px !important;
    }

    /* Competition navigation buttons - make shorter and move up */
    .success-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-bottom: 0 !important;
        flex: 1 !important;
        min-height: 0 !important;
    }

    .success-nav-btn {
        padding: 10px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        min-height: 40px !important;
    }

    /* How competitions work - scrollable container that fills available space */
    .success-buttons > div:last-child {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: white !important;
        border: 2px solid #000 !important;
        border-radius: 8px !important;
        padding: 16px !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        box-shadow: 2px 2px 0px #000 !important;
    }

    /* Style the scrollable text content */
    .success-buttons > div:last-child strong {
        display: block !important;
        margin-bottom: 10px !important;
        color: #000 !important;
        font-size: 18px !important;
    }

    .success-buttons > div:last-child ul {
        margin: 0 !important;
        padding-left: 20px !important;
        color: #333 !important;
        font-size: 16px !important;
        line-height: 1.6 !important;
    }

    .success-buttons > div:last-child li {
        margin-bottom: 8px !important;
    }
}

/* Very small phones - additional optimizations */
@media screen and (max-width: 480px) {
    .success-modal-content {
        max-height: 490px !important;
        width: 95% !important;
    }

    /* Success confirmation modal specific sizing for small screens */
    #successConfirmationModal .success-modal-content {
        max-height: 300px !important;
        min-height: 180px !important;
        width: 90% !important;
        max-width: 340px !important;
    }

    #successConfirmationModal .success-modal-header {
        padding: 14px 18px !important;
    }

    #successConfirmationModal .success-modal-body {
        padding: 12px 18px 18px 18px !important;
    }

    #successConfirmationModal .success-nav-btn {
        padding: 14px 28px !important;
        font-size: 16px !important;
        min-height: 48px !important;
    }

    /* Competition modal - ensure "How competitions work" fits */
    #competitionMainView .success-modal-body {
        padding: 10px 16px 16px 16px !important;
    }

    #competitionMainView .success-buttons {
        gap: 10px !important;
        margin-top: 0px !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] {
        margin-top: 12px !important;
        padding: 12px !important;
        font-size: 13px !important;
        line-height: 1.5 !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] strong {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] li {
        margin-bottom: 5px !important;
        font-size: 13px !important;
    }
}

/* Taller small phones can use more space */
@media screen and (max-width: 480px) and (min-height: 700px) {
    .success-modal-content {
        max-height: 90vh !important;
    }

    .success-modal-header {
        padding: 12px 16px !important;
        height: auto !important;
        min-height: 60px !important;
    }

    .success-modal-header h2 {
        font-size: 18px !important;
    }

    .success-modal-body {
        padding: 16px 18px !important;
    }

    /* Further reduce button size */
    .success-nav-btn {
        padding: 8px 14px !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }

    /* How competitions work container fills available space on small phones */
    .success-buttons > div:last-child {
        flex: 1 !important;
        min-height: 0 !important;
        padding: 12px !important;
        font-size: 14px !important;
        margin-bottom: 0 !important;
    }

    .success-buttons > div:last-child strong {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }

    .success-buttons > div:last-child ul {
        padding-left: 18px !important;
        font-size: 14px !important;
    }

    /* Competition lists container height fixes for small phones */
    #competitionActiveView .success-modal-body,
    #competitionExpiredView .success-modal-body {
        height: 400px !important;
    }

    #activeCompetitionsList,
    #expiredCompetitionsList {
        max-height: calc(100% - 80px) !important;
    }

    /* HTML TABLE leaderboard - Small phones optimization - High specificity */
    div.success-modal-content .leaderboard-table .rank-cell,
    #competitionModal .leaderboard-table .rank-cell,
    .success-modal .leaderboard-table .rank-cell,
    .leaderboard-table th.rank-cell,
    .leaderboard-table td.rank-cell {
        width: 35px !important;
        font-size: 0.7rem !important;
        padding: 6px 3px !important;
    }

    div.success-modal-content .leaderboard-table .award-cell,
    #competitionModal .leaderboard-table .award-cell,
    .success-modal .leaderboard-table .award-cell,
    .leaderboard-table th.award-cell,
    .leaderboard-table td.award-cell {
        width: 30px !important;
        font-size: 0.8rem !important;
        padding: 6px 2px !important;
    }

    div.success-modal-content .leaderboard-table .username-cell,
    #competitionModal .leaderboard-table .username-cell,
    .success-modal .leaderboard-table .username-cell,
    .leaderboard-table th.username-cell,
    .leaderboard-table td.username-cell {
        font-size: 0.7rem !important;
        padding: 6px 4px !important;
        max-width: 120px !important;
    }

    div.success-modal-content .leaderboard-table .total-score-cell,
    div.success-modal-content .leaderboard-table .score-cell,
    #competitionModal .leaderboard-table .total-score-cell,
    #competitionModal .leaderboard-table .score-cell,
    .success-modal .leaderboard-table .total-score-cell,
    .success-modal .leaderboard-table .score-cell,
    .leaderboard-table th.total-score-cell,
    .leaderboard-table td.total-score-cell,
    .leaderboard-table th.score-cell,
    .leaderboard-table td.score-cell {
        width: 90px !important;
        font-size: 0.7rem !important;
        padding: 6px 6px 6px 2px !important;
        min-width: 80px !important;
    }

    div.success-modal-content .leaderboard-table .days-cell,
    #competitionModal .leaderboard-table .days-cell,
    .success-modal .leaderboard-table .days-cell,
    .leaderboard-table th.days-cell,
    .leaderboard-table td.days-cell {
        display: none !important; /* Hide days column on small screens */
    }
}

/* ================================
   VERY SMALL DEVICES (Up to 320px) - iPhone SE
   ================================ */
@media screen and (max-width: 320px) {
    /* Ultra-compact leaderboard for iPhone SE */
    .leaderboard-row {
        grid-template-columns: 32px 1fr 75px !important;
        padding: 4px 6px !important;
        font-size: 0.65rem !important;
        gap: 2px !important;
    }

    .col-score {
        min-width: 65px !important;
        font-size: 0.65rem !important;
        padding-right: 2px !important;
    }

    .col-player {
        font-size: 0.65rem !important;
        max-width: calc(100vw - 130px) !important;
    }

    .col-rank {
        font-size: 0.65rem !important;
    }

    /* Leaderboard modal adjustments for iPhone SE */
    /* CRITICAL: Modal wrapper must prevent all scrolling */
    #customLeaderboardModal,
    .leaderboard-modal {
        overflow: hidden !important;
    }

    .leaderboard-modal-content {
        width: calc(100vw - 10px) !important;
        margin: 5px !important;
        display: flex !important;
        flex-direction: column !important;
        height: 95vh !important; /* FIXED height - prevents growing */
        max-height: 95vh !important;
        overflow: hidden !important; /* CRITICAL: Prevent entire modal from scrolling */
        touch-action: none !important; /* Prevent touch scrolling on modal itself */
    }

    /* FIXED sections at top - no scrolling */
    .leaderboard-header,
    .custom-competition-info,
    .leaderboard-stats,
    .medal-legend,
    .user-rank-display {
        flex: 0 0 auto !important; /* Don't grow, don't shrink, auto height */
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow content to show (buttons, etc) */
    }

    .leaderboard-header {
        padding: 10px !important;
    }

    .leaderboard-header h2 {
        font-size: 1rem !important;
    }

    /* SCROLLABLE section - only the leaderboard container */
    .leaderboard-container {
        flex: 1 1 auto !important; /* Grow to fill space, shrink if needed, auto basis */
        min-height: 0 !important; /* CRITICAL: Required for flex children with overflow */
        overflow: hidden !important; /* Container itself doesn't scroll */
        display: flex !important;
        flex-direction: column !important;
    }

    /* Table wrapper doesn't scroll */
    .leaderboard-table {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Header row is sticky */
    .leaderboard-header-row {
        flex: 0 0 auto !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: #f8f9fa !important;
    }

    /* ONLY the body scrolls */
    #customLeaderboardBody,
    #leaderboardBody {
        flex: 1 1 auto !important;
        min-height: 0 !important; /* CRITICAL */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important; /* Only allow vertical scrolling */
    }

    /* Loading and error states inside container */
    .leaderboard-loading,
    .leaderboard-error {
        flex: 1 !important;
        overflow: visible !important;
    }

    /* FIXED sections at bottom - no scrolling */
    .pagination-controls,
    .leaderboard-footer {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow buttons to show */
    }

    /* HTML TABLE leaderboard - iPhone SE ultra-compact - High specificity */
    div.success-modal-content .leaderboard-table .rank-cell,
    #competitionModal .leaderboard-table .rank-cell,
    .success-modal .leaderboard-table .rank-cell,
    .leaderboard-table th.rank-cell,
    .leaderboard-table td.rank-cell {
        width: 30px !important;
        font-size: 0.65rem !important;
        padding: 4px 2px !important;
    }

    div.success-modal-content .leaderboard-table .award-cell,
    #competitionModal .leaderboard-table .award-cell,
    .success-modal .leaderboard-table .award-cell,
    .leaderboard-table th.award-cell,
    .leaderboard-table td.award-cell {
        width: 25px !important;
        font-size: 0.7rem !important;
        padding: 4px 1px !important;
    }

    div.success-modal-content .leaderboard-table .username-cell,
    #competitionModal .leaderboard-table .username-cell,
    .success-modal .leaderboard-table .username-cell,
    .leaderboard-table th.username-cell,
    .leaderboard-table td.username-cell {
        font-size: 0.65rem !important;
        padding: 4px 3px !important;
        max-width: 100px !important;
    }

    div.success-modal-content .leaderboard-table .total-score-cell,
    div.success-modal-content .leaderboard-table .score-cell,
    #competitionModal .leaderboard-table .total-score-cell,
    #competitionModal .leaderboard-table .score-cell,
    .success-modal .leaderboard-table .total-score-cell,
    .success-modal .leaderboard-table .score-cell,
    .leaderboard-table th.total-score-cell,
    .leaderboard-table td.total-score-cell,
    .leaderboard-table th.score-cell,
    .leaderboard-table td.score-cell {
        width: 85px !important;
        font-size: 0.65rem !important;
        padding: 4px 4px 4px 2px !important;
        min-width: 75px !important;
    }

    #dateTitle {
        font-size: clamp(0.9rem, 4vw, 1.2rem) !important;
        max-width: calc(100vw - 40px) !important;
        margin-right: 8px !important;
    }

    .main-header {
        padding: 8px 10px !important;
    }


    /* Canvas adjustments for iPhone SE to make room for welcome content */
    #geoCanvas {
        width: min(280px, calc(100vw - 20px)) !important;
        height: min(280px, calc(100vw - 20px)) !important;
        max-width: 280px !important;
        max-height: 280px !important;
    }
}

/* ================================
   SMALL DEVICES (321px to 480px)
   ================================ */
@media screen and (max-width: 480px) and (min-width: 321px) {
    #dateTitle {
        font-size: clamp(1rem, 4.5vw, 1.4rem) !important;
        max-width: calc(100vw - 45px) !important;
        margin-right: 8px !important;
    }
}

/* ================================
   MOBILE OPTIMIZATION (320px - 767px)
   ================================ */
@media screen and (max-width: 767px) {
    /* CRITICAL FIX: Leaderboard modal scroll fix for ALL mobile devices */
    /* Modal wrapper must prevent all scrolling */
    #customLeaderboardModal,
    .leaderboard-modal {
        overflow: hidden !important;
    }

    .leaderboard-modal-content {
        display: flex !important;
        flex-direction: column !important;
        height: 95vh !important; /* FIXED height - prevents growing */
        max-height: 95vh !important;
        overflow: hidden !important; /* CRITICAL: Prevent entire modal from scrolling */
        touch-action: none !important; /* Prevent touch scrolling on modal itself */
    }

    /* FIXED sections at top - no scrolling */
    .leaderboard-header,
    .custom-competition-info,
    .leaderboard-stats,
    .medal-legend,
    .user-rank-display {
        flex: 0 0 auto !important; /* Don't grow, don't shrink, auto height */
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow content to show (buttons, etc) */
    }

    /* SCROLLABLE section - only the leaderboard container */
    .leaderboard-container {
        flex: 1 1 auto !important; /* Grow to fill space, shrink if needed, auto basis */
        min-height: 0 !important; /* CRITICAL: Required for flex children with overflow */
        overflow: hidden !important; /* Container itself doesn't scroll */
        display: flex !important;
        flex-direction: column !important;
    }

    /* Table wrapper doesn't scroll */
    .leaderboard-table {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Header row is sticky */
    .leaderboard-header-row {
        flex: 0 0 auto !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: #f8f9fa !important;
    }

    /* ONLY the body scrolls */
    #customLeaderboardBody,
    #leaderboardBody {
        flex: 1 1 auto !important;
        min-height: 0 !important; /* CRITICAL */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important; /* Only allow vertical scrolling */
    }

    /* Loading and error states inside container */
    .leaderboard-loading,
    .leaderboard-error {
        flex: 1 !important;
        overflow: visible !important;
    }

    /* FIXED sections at bottom - no scrolling */
    .pagination-controls,
    .leaderboard-footer {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow buttons to show */
    }

    /* Header adjustments for mobile */
    .main-header {
        margin-bottom: var(--spacing-mobile);
    }
    
    .header-top-row {
        padding: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #dateTitle {
        font-size: clamp(1.1rem, 5vw, 1.6rem);
        flex: 1;
        min-width: 0;
        margin-right: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 50px);
        text-align: left !important;
    }
    
    .header-buttons {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    
    .auth-button,
    .nav-button {
        padding: 6px 12px;
        font-size: clamp(0.75rem, 3vw, 0.875rem);
        min-height: 36px;
        min-width: 60px;
    }
    
    /* Canvas container for mobile */
    .canvas-container {
        margin: var(--spacing-mobile) 0;
        touch-action: none;
        -webkit-touch-callout: none;
    }
    
    #geoCanvas {
        width: var(--canvas-mobile);
        height: var(--canvas-mobile);
        max-width: calc(100vw - 16px);
        max-height: calc(100vw - 16px);
        border-width: 2px;
        box-shadow: 2px 2px 0px #000000;
    }
    
    /* Day selector for mobile */
    .day-selector-container {
        flex-wrap: wrap;
        gap: 8px;
        font-size: clamp(0.75rem, 3vw, 0.875rem);
    }
    
    .day-dropdown {
        font-size: clamp(0.75rem, 3vw, 0.875rem);
        padding: 4px 8px;
    }
    
    /* Results and percentage displays */
    .results-container {
        padding: 0 var(--spacing-mobile);
        width: 100%;
    }
    
    .percentage-table {
        font-size: clamp(0.875rem, 3vw, 1rem);
    }
    
    .percentage-cell {
        padding: 6px !important;
    }
    
    /* Attempt buttons for mobile */
    .attempt-button {
        padding: 10px 20px;
        font-size: clamp(1rem, 4vw, 1.25rem);
        width: min(140px, 40vw);
    }
    
    /* Modal adjustments for mobile */
    .auth-modal-content {
        width: 95%;
        margin: 10px;
        max-height: 85vh;
    }
    
    .auth-modal-header {
        padding: 15px;
    }
    
    .auth-modal-header h2 {
        font-size: clamp(1.25rem, 5vw, 1.5rem);
    }
    
    .form-group input {
        padding: 8px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Completion view mobile adjustments - keep horizontal layout */
    .action-buttons {
        flex-direction: row; /* Keep horizontal like initial play buttons */
        gap: 15px;
        padding: 0 16px;
        transform: translateX(-8px); /* Maintain positioning */
    }
    
    .action-button {
        width: 140px; /* Match wider desktop width */
        padding: clamp(8px, 3vw, 10px) clamp(16px, 5vw, 20px); /* Responsive padding */
        font-size: clamp(14px, 4vw, 16px); /* Responsive font size */
    }
    
    .countdown-text {
        font-size: 13px;
        margin-top: 8px;
    }
    
    /* Commentary overlay for mobile */
    .commentary-overlay {
        font-size: clamp(0.875rem, 3vw, 1rem);
        padding: 8px 12px;
    }

}

/* Very narrow mobile devices (350px - 400px width) - Specific height adjustments */
@media screen and (min-width: 350px) and (max-width: 400px) and (min-height: 600px) and (max-height: 800px) {
    /* Optimize for small screens like 360x630, 390x715, etc */

    /* Force 356px canvas (360px with borders) */
    :root {
        --canvas-mobile: 356px !important;
    }

    canvas#geoCanvas,
    #geoCanvas {
        width: 356px !important;
        height: 356px !important;
        min-width: 356px !important;
        max-width: 356px !important;
        min-height: 356px !important;
        max-height: 356px !important;
    }

    /* Remove all padding and allow canvas borders to show */
    html {
        overflow-x: visible !important;
    }

    body {
        overflow-x: visible !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .app-container {
        overflow: visible !important;
    }

    .canvas-container,
    .canvas-container-fixed {
        overflow: visible !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Instruction area */
    #instructionArea,
    .instruction-area {
        font-size: 12px !important;
        padding: 3px !important;
        margin: 2px 0 !important;
        min-height: 24px !important;
    }

    /* Progress display */
    #demoProgressDisplay,
    .demo-progress-display {
        font-size: 12px !important;
        min-height: 24px !important;
        padding: 2px 4px !important;
        margin: 2px 0 !important;
    }

    /* Buttons - make more compact */
    .canvas-play-button,
    .attempt-button,
    .action-button {
        padding: 6px 12px !important;
        font-size: 13px !important;
        min-height: 32px !important;
        margin: 2px !important;
    }

    /* Score displays - make more compact */
    .percentage-table {
        font-size: 12px !important;
    }

    .percentage-cell {
        padding: 2px !important;
    }

    /* Fixed percentage area */
    #fixedPercentageArea {
        padding: 4px !important;
        margin: 2px 0 !important;
    }

    .split-display-large {
        font-size: 44px !important;
        min-height: 40px !important;
    }

    /* Goal display */
    #goal-display {
        font-size: 12px !important;
        padding: 4px !important;
        margin: 2px 0 !important;
    }

    /* Progression button container */
    #progressionButtonContainer,
    #fixedButtonArea {
        margin: 2px 0 !important;
        padding: 2px !important;
    }


    /* Mechanic info */
    .mechanic-info {
        font-size: 11px !important;
        padding: 2px !important;
        margin: 2px 0 !important;
    }

    /* Results container */
    .results-container {
        padding: 2px !important;
        margin: 2px 0 !important;
    }

    /* Attempt result displays */
    .attempt-result {
        margin: 2px 0 !important;
        padding: 2px !important;
    }
}

/* Small mobile devices (321px - 375px) - iPhone SE Plus, smaller iPhones */
@media screen and (min-width: 321px) and (max-width: 375px) {
    .app-container {
        gap: 4px;
        padding-top: 4px;
    }

    #geoCanvas {
        width: min(85vw, 320px);
        height: min(85vw, 320px);
    }

    /* Leaderboard modal adjustments for iPhone SE (2020) and similar */
    /* CRITICAL: Modal wrapper must prevent all scrolling */
    #customLeaderboardModal,
    .leaderboard-modal {
        overflow: hidden !important;
    }

    .leaderboard-modal-content {
        width: calc(100vw - 10px) !important;
        margin: 5px !important;
        display: flex !important;
        flex-direction: column !important;
        height: 95vh !important; /* FIXED height - prevents growing */
        max-height: 95vh !important;
        overflow: hidden !important; /* CRITICAL: Prevent entire modal from scrolling */
        touch-action: none !important; /* Prevent touch scrolling on modal itself */
    }

    /* FIXED sections at top - no scrolling */
    .leaderboard-header,
    .custom-competition-info,
    .leaderboard-stats,
    .medal-legend,
    .user-rank-display {
        flex: 0 0 auto !important; /* Don't grow, don't shrink, auto height */
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow content to show (buttons, etc) */
    }

    /* SCROLLABLE section - only the leaderboard container */
    .leaderboard-container {
        flex: 1 1 auto !important; /* Grow to fill space, shrink if needed, auto basis */
        min-height: 0 !important; /* CRITICAL: Required for flex children with overflow */
        overflow: hidden !important; /* Container itself doesn't scroll */
        display: flex !important;
        flex-direction: column !important;
    }

    /* Table wrapper doesn't scroll */
    .leaderboard-table {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Header row is sticky */
    .leaderboard-header-row {
        flex: 0 0 auto !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: #f8f9fa !important;
    }

    /* ONLY the body scrolls */
    #customLeaderboardBody,
    #leaderboardBody {
        flex: 1 1 auto !important;
        min-height: 0 !important; /* CRITICAL */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important; /* Only allow vertical scrolling */
    }

    /* Loading and error states inside container */
    .leaderboard-loading,
    .leaderboard-error {
        flex: 1 !important;
        overflow: visible !important;
    }

    /* FIXED sections at bottom - no scrolling */
    .pagination-controls,
    .leaderboard-footer {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        overflow: visible !important; /* Allow buttons to show */
    }

    /* Move daily mode canvas up by 10px for 375x560 layout */
    @media (min-height: 540px) and (max-height: 580px) {
        body:not(.practice-mode-active) .canvas-container,
        body:not(.practice-mode-active) #canvasContainer {
            margin-top: -10px !important;
        }

        /* Move next attempt/shape button up by 10px (override style.css which sets 5px) */
        html body .fixed-button-area,
        html body #fixedButtonArea,
        html body div.fixed-button-area,
        html body .app-container .fixed-button-area,
        body.ready .fixed-button-area {
            margin-top: -5px !important;
        }

        /* Move countdown text up for better spacing */
        .countdown-text {
            margin-top: 4px !important;
        }

        /* Reduce split display text size for 375x547 iPhone SE */
        .split-display-large {
            font-size: 44px !important;
        }
    }

    /* Fix app-container to not clip canvas borders */
    .app-container {
        overflow: visible !important; /* Allow canvas borders to show */
    }

    /* JOIN COMPETITION POPUP FIX for iPhone SE (375x667) */
    @media (min-height: 640px) and (max-height: 700px) {
        /* Position modal wrapper MUCH HIGHER on screen */
        .join-competition-modal,
        .invite-auth-modal,
        .already-joined-modal,
        .join-success-modal,
        .invite-error-modal {
            align-items: flex-start !important;
            padding-top: 5vh !important;
        }

        /* Make join competition modal MUCH TALLER */
        .join-competition-modal .competition-modal-content,
        .invite-auth-modal .competition-modal-content,
        .already-joined-modal .competition-modal-content,
        .join-success-modal .competition-modal-content,
        .invite-error-modal .competition-modal-content {
            max-height: 90vh !important;
            width: 90% !important;
            max-width: 360px !important;
        }

        /* Ensure modal body is scrollable if needed */
        .join-competition-modal .competition-modal-body,
        .invite-auth-modal .competition-modal-body,
        .already-joined-modal .competition-modal-body,
        .join-success-modal .competition-modal-body,
        .invite-error-modal .competition-modal-body {
            overflow-y: auto !important;
            max-height: calc(90vh - 100px) !important;
            -webkit-overflow-scrolling: touch !important;
            padding: 14px !important;
        }

        /* CRITICAL: Keep post-authentication success modal SMALL */
        #successConfirmationModal .success-modal-content,
        #successConfirmationContent {
            max-height: 300px !important;
            min-height: 180px !important;
        }

        /* Reset positioning for success confirmation modal */
        #successConfirmationModal.success-modal {
            align-items: center !important;
            padding-top: 0 !important;
        }

        /* Compact header for more content space */
        .join-competition-modal .competition-modal-header,
        .invite-auth-modal .competition-modal-header,
        .already-joined-modal .competition-modal-header,
        .join-success-modal .competition-modal-header,
        .invite-error-modal .competition-modal-header {
            padding: 12px 16px !important;
            flex-shrink: 0 !important;
        }

        /* Compact header text */
        .join-competition-modal .competition-modal-header h2,
        .invite-auth-modal .competition-modal-header h2,
        .already-joined-modal .competition-modal-header h2,
        .join-success-modal .competition-modal-header h2,
        .invite-error-modal .competition-modal-header h2 {
            font-size: 1.15rem !important;
        }

        /* Compact content areas */
        .join-competition-preview,
        .invite-competition-preview,
        .already-joined-message {
            padding: 0 !important;
        }

        .join-competition-preview h3,
        .invite-competition-preview h3,
        .already-joined-message h3 {
            font-size: 1.1rem !important;
            margin-bottom: 10px !important;
        }

        .competition-desc {
            font-size: 0.9rem !important;
            margin: 8px 0 !important;
        }

        /* Make detail items more compact */
        .competition-details {
            margin: 10px 0 !important;
        }

        .competition-details .detail-item {
            margin: 6px 0 !important;
            font-size: 0.85rem !important;
        }

        /* Make info items more compact */
        .join-competition-info {
            margin: 10px 0 !important;
        }

        .join-competition-info .info-item,
        .success-info .info-item {
            margin: 6px 0 !important;
            font-size: 0.85rem !important;
        }

        .info-icon {
            font-size: 1rem !important;
        }

        /* Compact buttons */
        .join-actions,
        .invite-auth-actions,
        .already-joined-actions,
        .success-actions {
            margin-top: 12px !important;
            gap: 10px !important;
        }

        .join-actions button,
        .invite-auth-actions button,
        .already-joined-actions button,
        .success-actions button {
            padding: 10px 16px !important;
            font-size: 0.9rem !important;
        }
    }
}

/* Specific fix for small viewports (560px-600px height) to prevent canvas clipping */
@media screen and (min-width: 360px) and (max-width: 390px) and (min-height: 540px) and (max-height: 620px) {
    .app-container {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        min-height: auto !important;
        gap: 0px !important;
        padding-top: 0px !important;
        padding-bottom: 0px !important;
    }

    body {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Center canvas container horizontally */
    .canvas-container,
    .canvas-container-fixed {
        transform: translateX(-50%) scale(0.9474) !important;
        position: relative !important;
        left: 50% !important;
        overflow: visible !important;
        margin-top: 0px !important;
        margin-bottom: 0px !important;
    }

    /* Compress canvas margins */
    #geoCanvas {
        margin: 0px 0 !important;
    }

    /* Reduce header spacing */
    .main-header {
        margin-bottom: -4px !important;
        padding-bottom: 0px !important;
    }

    /* Compress instruction area */
    #instructionArea,
    .instruction-area {
        padding: 2px 4px 0px 4px !important;
        margin: 10px 0 -8px 0 !important;
        min-height: 16px !important;
        max-height: 18px !important;
        line-height: 1.1 !important;
        font-size: 13px !important;
        display: flex !important;
        align-items: flex-end !important;
        justify-content: center !important;
    }

    #instructionText,
    .instruction-text {
        font-size: 13px !important;
        line-height: 1.1 !important;
        transform: translateY(12px) !important;
        display: inline-block !important;
        position: relative !important;
    }

    /* Reduce progress display spacing - move up closer to canvas */
    body #progressDisplay,
    body .progress-display,
    body #demoProgressDisplay,
    body div#progressDisplay,
    body div.progress-display,
    body div#demoProgressDisplay {
        margin: -16px 0 -16px 0 !important;
        padding: 0px !important;
    }

    /* Move fixed areas - split display and score up a bit */
    body #fixedPercentageArea,
    body .fixed-percentage-area,
    body .split-display,
    body .split-display-large {
        margin-top: 2px !important;
        position: relative !important;
        z-index: 1 !important;
    }

    /* Move button area up */
    body #fixedButtonArea,
    body .fixed-button-area,
    body div#fixedButtonArea,
    body div.fixed-button-area {
        margin-top: 0px !important;
        padding-top: 0px !important;
    }

    /* Ensure body has padding for footer visibility */
    body {
        padding-bottom: 50px !important;
    }

    /* Ensure app container doesn't extend beyond viewport */
    .app-container {
        max-height: none !important;
        overflow-y: auto !important;
    }

    /* CRITICAL: Override the welcomeOverlay height restriction */
    body:has(#welcomeOverlay:not([style*="display: none"])) .app-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* COMPETITION MODAL - responsive to screen height */
    .competition-modal-content {
        max-height: 440px !important;
        width: 92% !important;
        max-width: 350px !important;
    }

    /* Header - compact padding */
    .competition-modal-header {
        padding: 10px 12px !important;
    }

    .competition-modal-header h2,
    .competition-modal-title {
        font-size: 1.1rem !important;
    }

    /* Body area - compact padding */
    .competition-modal-body {
        padding: 12px !important;
    }

    /* Main view buttons */
    .competition-main-buttons {
        gap: 10px !important;
        margin: 0 !important;
    }

    .competition-primary-btn {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }

    .competition-primary-btn .btn-icon {
        font-size: 1.5rem !important;
    }

    .competition-primary-btn .btn-subtitle {
        font-size: 0.75rem !important;
    }

    /* Empty state */
    .competition-empty-state {
        padding: 12px !important;
    }

    .empty-state-icon {
        font-size: 2rem !important;
        margin: 8px 0 !important;
    }

    .empty-state-title {
        font-size: 1rem !important;
        margin: 8px 0 !important;
    }

    .empty-state-text {
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
        margin: 8px 0 12px 0 !important;
    }

    /* Invitation cards */
    .invitation-section {
        margin-bottom: 10px !important;
    }

    .invitation-card {
        padding: 10px !important;
        margin-bottom: 8px !important;
    }

    /* Loading spinner */
    .competition-loading {
        padding: 20px !important;
    }
}

    .header-top-row {
        padding: 6px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #dateTitle {
        font-size: clamp(1.2rem, 3vw, 1.6rem);
        text-align: left;
        margin-right: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 60px);
    }

    .header-buttons {
        justify-content: center;
    }

    .auth-button,
    .nav-button {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    /* Stack day selector vertically on very small screens */
    .day-selector-container {
        flex-direction: column;
        align-items: stretch;
    }

    .day-dropdown,
    .stats-button {
        width: 100%;
        margin: 2px 0;
    }
}

/* ================================
   TABLET LAYOUT (768px - 1023px)
   ================================ */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* App container for tablet */
    .app-container {
        max-width: 600px;
        gap: var(--spacing-tablet);
        padding: 20px;
    }
    
    /* Header for tablet */
    .main-header {
        width: 100%;
        margin-bottom: 16px;
    }
    
    .header-top-row {
        padding: 12px 16px;
    }
    
    #dateTitle {
        font-size: 1.875rem;
        margin-right: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-buttons {
        gap: 10px;
    }
    
    .auth-button,
    .nav-button {
        padding: 8px 18px;
        font-size: 0.9375rem;
        min-height: 40px;
    }
    
    /* Canvas for tablet */
    #geoCanvas {
        width: var(--canvas-tablet);
        height: var(--canvas-tablet);
        border-width: 3px;
        box-shadow: 4px 4px 0px #000000;
    }
    
    /* Results display for tablet */
    .results-container {
        max-width: 500px;
        margin: 0 auto;
    }
    
    .percentage-table {
        font-size: 1.125rem;
    }
    
    .percentage-cell {
        padding: 10px !important;
    }
    
    /* Attempt buttons for tablet */
    .attempt-button {
        padding: 14px 32px;
        font-size: 1.375rem;
        width: 170px;
    }
    
    /* Modal for tablet */
    .auth-modal-content {
        width: 500px;
        max-width: 90%;
    }
}

/* Tablet landscape orientation */
@media screen and (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    .app-container {
        max-width: 700px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px 20px;
    }
    
    .main-header {
        width: 100%;
    }
    
    .canvas-container {
        flex: 0 0 auto;
    }
    
    #geoCanvas {
        width: min(50vh, 380px);
        height: min(50vh, 380px);
    }
    
    .results-container {
        flex: 1;
        min-width: 250px;
        padding-left: 20px;
    }
}

/* ================================
   DESKTOP/LAPTOP LAYOUT (1024px+)
   ================================ */
@media screen and (min-width: 1024px) {
    body {
        padding: 20px;
    }

    /* App container for desktop */
    .app-container {
        max-width: 800px;
        gap: var(--spacing-desktop);
        padding: 30px;
        margin-top: 20px;
    }
    
    /* Header for desktop */
    .main-header {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .header-top-row {
        padding: 15px 20px;
        border-radius: 8px;
    }
    
    #dateTitle {
        font-size: 2rem;
        margin-right: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-buttons {
        gap: 12px;
    }
    
    .auth-button,
    .nav-button {
        padding: 10px 24px;
        font-size: 1rem;
        min-height: 44px;
        transition: all 0.2s ease;
    }
    
    .auth-button:hover,
    .nav-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }
    
    /* Canvas container - push canvas down to match half-screen gap */
    .canvas-container,
    .canvas-container-fixed {
        margin-top: 60px !important;
    }

    /* Canvas for desktop */
    #geoCanvas {
        width: var(--canvas-desktop);
        height: var(--canvas-desktop);
        border-width: 3px;
        box-shadow: 5px 5px 0px #000000;
        transition: box-shadow 0.2s ease;
    }
    
    #geoCanvas:hover {
        box-shadow: 6px 6px 0px #000000;
    }
    
    /* Day selector for desktop */
    .day-selector-container {
        font-size: 1rem;
    }
    
    .day-dropdown {
        font-size: 1rem;
        padding: 6px 12px;
    }
    
    /* Results for desktop */
    .results-container {
        max-width: 500px;
    }
    
    .percentage-table {
        font-size: 1.25rem;
    }
    
    .percentage-cell {
        padding: 12px !important;
    }
    
    /* Attempt buttons for desktop */
    .attempt-button {
        padding: 16px 36px;
        font-size: 1.5rem;
        width: 180px;
        transition: all 0.2s ease;
    }
    
    .attempt-button:hover:not(.disabled) {
        transform: translate(-3px, -3px);
        box-shadow: 6px 6px 0px #000;
    }
    
    /* Modal for desktop */
    .auth-modal-content {
        width: 450px;
        max-width: 90%;
    }
    
    /* Account dropdown for desktop */
    .account-dropdown {
        min-width: 180px;
    }
    
    .dropdown-item {
        padding: 14px 18px;
        font-size: 0.9375rem;
    }
}

/* Large desktop (1440px+) */
@media screen and (min-width: 1440px) {
    .app-container {
        max-width: 900px;
        padding: 40px;
    }

    #dateTitle {
        font-size: 2.25rem;
        margin-right: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .auth-button,
    .nav-button {
        font-size: 1.0625rem;
        padding: 12px 28px;
    }
}

/* ================================
   ORIENTATION & SPECIAL CASES
   ================================ */

/* Landscape mode warning for small devices */
/* DISABLED: CSS-based orientation detection causes issues with soft keyboard on mobile
   Orientation checking is now handled entirely by JavaScript for better control */
@media screen and (max-height: 500px) and (orientation: landscape) and (min-width: 600px) {
    /* Only apply if screen is wide enough to be true landscape, not just keyboard-induced */
    body::before {
        content: "Please rotate your device to portrait mode for the best experience";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        padding: 20px;
        border: 2px solid #000;
        border-radius: 8px;
        z-index: 9999;
        text-align: center;
        font-size: 1rem;
        max-width: 80%;
    }

    .app-container {
        opacity: 0.3;
        pointer-events: none;
    }
}

/* High resolution displays */
@media screen and (-webkit-min-device-pixel-ratio: 2),
       screen and (min-resolution: 192dpi) {
    #geoCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ================================
   ACCESSIBILITY & TOUCH TARGETS
   ================================ */

/* Ensure minimum touch target sizes on touch devices */
@media (pointer: coarse) {
    .auth-button,
    .nav-button,
    .attempt-button,
    .dropdown-item,
    .social-auth-button {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-group input {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .auth-submit-button {
        min-height: 48px;
    }
}

/* ================================
   AUTHENTICATION ENHANCEMENTS
   ================================ */
   
/* Authentication feedback and enhanced styles */
.auth-feedback {
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 0.875rem;
    text-align: center;
}

.auth-feedback.error {
    background-color: #fee;
    border: 1px solid #f66;
    color: #c33;
}

.auth-feedback.success {
    background-color: #efe;
    border: 1px solid #6c6;
    color: #363;
}

.email-feedback {
    margin-top: 5px;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 3px;
}

.email-feedback.valid {
    background-color: #e8f5e8;
    color: #2d5a2d;
    border: 1px solid #4caf50;
}

.email-feedback.invalid {
    background-color: #ffeaea;
    color: #c62828;
    border: 1px solid #f44336;
}

.input-help {
    margin-top: 4px;
    font-size: 0.75rem;
    color: #666;
}

.form-group input.valid-email {
    border-color: #4caf50;
}

.form-group input.invalid-email {
    border-color: #f44336;
}

.social-auth-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.social-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
}

.social-auth-button.google .social-icon {
    background-color: #4285f4;
    color: white;
}

.social-auth-button.facebook .social-icon {
    background-color: #1877f2;
    color: white;
}

.social-auth-button.apple .social-icon {
    background-color: #000;
    color: white;
}

.social-auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Enhanced button states */
.auth-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Guest mode indicator */
.guest-indicator {
    padding: 4px 8px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #856404;
    margin-left: 10px;
    display: none;
}

.guest-indicator.show {
    display: inline-block;
}

/* Game info container */
.game-info-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 10px;
}

.mechanic-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.mechanic-label {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

.mechanic-name {
    font-size: 1rem;
    font-weight: 700;
    color: #000;
    margin-top: 2px;
}

/* Orientation blocking */
.orientation-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    flex-direction: column;
}

.orientation-content {
    text-align: center;
    padding: 20px;
}

.rotate-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotate 2s infinite linear;
}

.orientation-message h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.orientation-message p {
    font-size: 1rem;
    opacity: 0.8;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(90deg); }
}

/* Perfect cut celebration animations */
.commentary-show {
    animation: commentaryBounce 0.5s ease-out;
}

@keyframes commentaryBounce {
    0% {
        transform: translateX(-50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

.perfect-cut-particles {
    pointer-events: none;
}

.golden-particle {
    animation: sparkle 1.5s ease-out forwards;
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0);
    }
}

.confetti-container {
    pointer-events: none;
}

/* Score display enhancements */
.score-value {
    font-weight: 700;
    color: #333;
}

.score-perfect {
    color: #FFD700 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.score-excellent {
    color: #4CAF50 !important;
}

.score-good {
    color: #2196F3 !important;
}

.score-fair {
    color: #FF9800 !important;
}

.score-poor {
    color: #F44336 !important;
}

/* Game completion overlay */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.5s ease-out;
}

.completion-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 2px solid #000;
    animation: slideUp 0.5s ease-out;
}

.completion-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.final-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.final-score .score-label {
    font-size: 1.2rem;
    font-weight: 600;
}

.final-score .score-value {
    font-size: 2rem;
    font-weight: 700;
}

.perfect-cuts {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    margin: 15px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.completion-message {
    margin: 20px 0;
    color: #666;
    font-size: 1rem;
}

.close-completion {
    background-color: #6496ff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.close-completion:hover {
    background-color: #5080e0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Daily stats styling */
.daily-stats {
    text-align: left;
}

.daily-stats h3 {
    margin-bottom: 15px;
    color: #333;
}

.daily-stats h4 {
    margin: 20px 0 10px 0;
    color: #333;
}

.daily-stats p {
    margin: 8px 0;
    color: #666;
}

.shape-score {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

/* ================================
   GLOBAL LEADERBOARD STYLES
   ================================ */

/* Leaderboard Modal */
.leaderboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    animation: fadeIn 0.3s ease-out;
}

.leaderboard-modal-content {
    background: white;
    border-radius: 12px;
    border: 2px solid #000;
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #000;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
    flex: 0 0 auto;
}

.leaderboard-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.leaderboard-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.leaderboard-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Leaderboard Stats */
.leaderboard-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f1f3f4;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
    gap: 10px;
    flex: 0 0 auto;
}

.stats-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-left span {
    font-size: 0.875rem;
    color: #666;
}

.days-remaining {
    font-weight: 600;
    color: #FF6B35;
}

.stats-right {
    display: flex;
    align-items: center;
}

.find-me-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #6496ff;
    color: white;
    border: 2px solid #000;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.find-me-button:hover:not(:disabled) {
    background: #5080e0;
    transform: translateY(-1px);
}

.find-me-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.find-me-rank {
    color: #FFD700;
    font-weight: 700;
}

/* User Rank Display */
.user-rank-display {
    padding: 15px 20px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-bottom: 1px solid #ddd;
    flex: 0 0 auto;
}

.user-rank-card {
    display: flex;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    color: #000;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 15px;
}

.user-rank-card span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-rank-card strong {
    font-size: 1.2rem;
    color: #333;
}

/* Leaderboard Container */
.leaderboard-container {
    flex: 1;
    overflow: hidden;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.leaderboard-table {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 80px 1fr 80px 60px 60px;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.leaderboard-header-row {
    background: #f8f9fa;
    font-weight: 700;
    font-size: 0.875rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Make only the leaderboard body scrollable, not the header */
#customLeaderboardBody,
#leaderboardBody {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.leaderboard-row:not(.leaderboard-header-row):hover {
    background: #f8f9fa;
}

.leaderboard-row.current-user {
    background: rgba(100, 150, 255, 0.1);
    border-color: #6496ff;
}

.leaderboard-row.current-user:hover {
    background: rgba(100, 150, 255, 0.15);
}

.leaderboard-row.highlight {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% { background: rgba(255, 215, 0, 0.5); }
    100% { background: rgba(100, 150, 255, 0.1); }
}

/* Medal styling */
.leaderboard-row.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 215, 0, 0.05));
}

.leaderboard-row.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1), rgba(192, 192, 192, 0.05));
}

.leaderboard-row.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1), rgba(205, 127, 50, 0.05));
}

/* Column styling */
.col-rank {
    font-weight: 700;
    color: #333;
}

.col-player {
    font-weight: 600;
    color: #000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-score {
    font-weight: 700;
    color: #4CAF50;
    text-align: right;
}

.col-days, .col-avg {
    text-align: right;
    color: #666;
    font-size: 0.875rem;
}

/* Loading and Error States */
.leaderboard-loading, .leaderboard-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 15px;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #6496ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.leaderboard-error button {
    padding: 8px 16px;
    background: #6496ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background: #f8f9fa;
    flex: 0 0 auto;
}

.pagination-controls button {
    padding: 8px 16px;
    background: #6496ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.pagination-controls button:hover:not(:disabled) {
    background: #5080e0;
}

.pagination-controls button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#pageInfo {
    font-weight: 600;
    color: #666;
}

/* Footer */
.leaderboard-footer {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    border-radius: 0 0 10px 10px;
    flex: 0 0 auto;
}

.refresh-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: #666;
}

.refresh-button {
    background: none;
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.refresh-button:hover {
    background: #f0f0f0;
    border-color: #999;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .leaderboard-modal-content {
        width: 98%;
        max-height: 95vh;
    }
    
    .leaderboard-header {
        padding: 15px;
    }
    
    .leaderboard-header h2 {
        font-size: 1.25rem;
    }
    
    .leaderboard-stats {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 15px;
    }
    
    .stats-right {
        justify-content: center;
    }
    
    .user-rank-card {
        justify-content: space-between;
        gap: 10px;
    }
    
    .leaderboard-row {
        grid-template-columns: 50px 1fr 75px 45px !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        gap: 6px !important;
    }

    .col-avg {
        display: none; /* Hide average column on mobile */
    }

    .leaderboard-header-row .col-avg {
        display: none;
    }

    /* Enhanced score column protection for tablets */
    .col-score {
        min-width: 65px !important;
        font-size: 0.8rem !important;
    }

    /* Better player name handling on tablets */
    .col-player {
        font-size: 0.8rem !important;
    }

    /* Compact rank column on tablets */
    .col-rank {
        font-size: 0.8rem !important;
    }
    
    .pagination-controls {
        padding: 12px 15px;
    }
    
    .refresh-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .leaderboard-row {
        grid-template-columns: 35px 1fr 85px !important;
        padding: 6px 6px !important;
        font-size: 0.7rem !important;
        gap: 3px !important;
    }

    .col-days {
        display: none; /* Hide days column on very small screens */
    }

    .leaderboard-header-row .col-days {
        display: none;
    }

    /* Critical: Give score column more space and better positioning */
    .col-score {
        min-width: 70px !important;
        flex-shrink: 0 !important;
        font-size: 0.7rem !important;
        font-weight: 700 !important;
        text-align: right !important;
        padding-right: 2px !important;
    }

    /* Very compact player names with better ellipsis handling */
    .col-player {
        font-size: 0.7rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        min-width: 0 !important;
        max-width: calc(100vw - 140px) !important;
    }

    /* Compact rank column */
    .col-rank {
        font-size: 0.7rem !important;
        font-weight: 700 !important;
        text-align: center !important;
    }
    
    .user-rank-card {
        flex-direction: column;
        gap: 8px;
    }
    
    .user-rank-card span {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* ================================
   PRINT STYLES
   ================================ */
@media print {
    .main-header,
    .day-selector-container,
    .auth-modal,
    .account-dropdown,
    .stats-overlay {
        display: none !important;
    }
    
    #geoCanvas {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ALL DESKTOP SIZES - CONSISTENT PROGRESS TRACKER */
@media screen and (min-width: 451px) and (max-width: 1199px) {
    body div#demoProgressDisplay.demo-progress-display,
    body #demoProgressDisplay,
    body .demo-progress-display {
        font-size: 20px !important; /* Consistent 20px for all desktop modes */
        min-height: 45px !important;
        padding: 8px !important;
        line-height: 1.3 !important;
    }
}

/* FORCE LEADERBOARD TITLE SIZE REDUCTION ON FULL SCREEN DESKTOP */
@media screen and (min-width: 1200px) {
    .leaderboard-header h2,
    .leaderboard-header h2#leaderboardTitle,
    .leaderboard-modal-content .leaderboard-header h2,
    div.leaderboard-header h2,
    div.leaderboard-modal-content div.leaderboard-header h2,
    body .leaderboard-header h2 {
        font-size: 23px !important; /* 40% reduction from 38.77px */
        line-height: 1.2 !important;
        max-width: 100% !important;
    }

    /* PROGRESS TRACKER TEXT SIZE FOR FULL SCREEN DESKTOP */
    html body div#demoProgressDisplay.demo-progress-display,
    html body #demoProgressDisplay,
    html body .demo-progress-display,
    body div#demoProgressDisplay.demo-progress-display,
    body #demoProgressDisplay,
    body .demo-progress-display {
        font-size: 20px !important; /* Reduced from 22px */
        min-height: 45px !important;
        padding: 8px !important;
        line-height: 1.3 !important;
        margin: 75px auto 5px auto !important;
    }
}

/* MOBILE DEVICES - SLIGHTLY LARGER PROGRESS TRACKER TEXT SIZE */
/* Covers DS iPhone 12-15 (390px), iPhone Pro Max (430px), Android Flagship (412px), Android (360px) */
@media screen and (min-width: 350px) and (max-width: 450px) and (min-height: 600px) {
    body div#demoProgressDisplay.demo-progress-display,
    body #demoProgressDisplay,
    body .demo-progress-display {
        font-size: 18px !important; /* Further reduced from 20px for better mobile experience */
        min-height: 35px !important;
        padding: 6px !important;
        line-height: 1.2 !important;
    }
}

/* ================================
   CRITICAL OVERRIDE: Scale 380px canvas for narrow screens
   Canvas stays 380x380 internally, CSS scales it visually
   This must be at the END of the file to win cascade battles
   ================================ */

/* 360px wide screens (360x630, etc) - scale to 330px */
@media screen and (min-width: 350px) and (max-width: 365px) and (min-height: 600px) and (max-height: 800px) {
    /* Scale canvas container to fit: 330px / 380px = 0.868421 */
    .canvas-container,
    .canvas-container-fixed {
        transform: translateX(-50%) scale(0.8684) !important;
        position: relative !important;
        left: 50% !important;
    }

    /* Canvas stays 380x380 internally */
    body canvas#geoCanvas,
    body #geoCanvas,
    div canvas#geoCanvas,
    .canvas-container canvas#geoCanvas,
    canvas#geoCanvas.canvas {
        width: 380px !important;
        height: 380px !important;
    }

    /* Reduce instruction area height significantly */
    #instructionArea,
    .instruction-area {
        padding: 0px 4px !important;
        margin: -4px 0 -8px 0 !important;
        min-height: 16px !important;
        max-height: 18px !important;
        line-height: 1.1 !important;
        font-size: 13px !important;
    }

    #instructionText,
    .instruction-text {
        font-size: 13px !important;
        line-height: 1.1 !important;
    }

    /* Move canvas up with negative margin */
    .canvas-container,
    .canvas-container-fixed {
        margin-top: -10px !important;
        margin-bottom: -10px !important;
    }

    /* Reduce app container spacing significantly */
    .app-container {
        gap: 0px !important;
        padding-top: 0px !important;
        padding-bottom: 0px !important;
        overflow: visible !important;
    }

    /* Reduce header spacing */
    .main-header {
        margin-bottom: -4px !important;
        padding-bottom: 0px !important;
    }

    /* Reduce progress display spacing */
    #progressDisplay,
    .progress-display {
        margin: -4px 0 !important;
        padding: 1px 0 !important;
    }

    /* Move fixed areas up */
    #fixedPercentageArea,
    .fixed-percentage-area {
        margin-top: -8px !important;
    }

    #fixedButtonArea,
    .fixed-button-area {
        margin-top: -8px !important;
    }

    /* Welcome content for 360px screens */
    .welcome-overlay,
    #welcomeOverlay {
        width: 95% !important;
        max-width: 315px !important;
        padding: 12px 14px !important;
        overflow: hidden !important;
    }

    .welcome-content h2 {
        font-size: 18px !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.3 !important;
    }

    .welcome-content p {
        font-size: 15px !important;
        margin: 6px 0 !important;
        line-height: 1.35 !important;
    }

    /* Competition modal optimizations for 360x630 screens */
    /* Make modal much taller to fill screen like "view competitions" */
    #competitionModal .success-modal-content {
        max-height: 92vh !important;
        height: 92vh !important;
    }

    #competitionMainView .success-modal-header {
        padding: 14px 18px !important;
        height: auto !important;
        min-height: 50px !important;
        flex-shrink: 0 !important;
    }

    #competitionMainView .success-modal-header h2 {
        font-size: 18px !important;
    }

    #competitionMainView .success-modal-body {
        padding: 6px 16px 10px 16px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-navigation {
        margin-top: 0px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-buttons {
        gap: 8px !important;
        margin-top: 0px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-nav-btn {
        padding: 10px 16px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        flex-shrink: 0 !important;
    }

    /* How competitions work container - extended down to fill space */
    #competitionMainView .success-buttons > div[style*="margin-top"] {
        margin-top: 8px !important;
        padding: 12px 14px !important;
        font-size: 13.5px !important;
        line-height: 1.5 !important;
        max-height: none !important;
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] strong {
        font-size: 14.5px !important;
        margin-bottom: 8px !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] ul {
        padding-left: 18px !important;
        margin: 0 !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] li {
        margin-bottom: 6px !important;
        font-size: 13.5px !important;
        line-height: 1.5 !important;
    }

    /* Ensure overflow is visible to show scaled canvas */
    body,
    html {
        overflow-x: visible !important;
    }
}

/* 366-400px wide screens (390x715, etc) - scale to 360px */
@media screen and (min-width: 366px) and (max-width: 400px) and (min-height: 600px) and (max-height: 800px) {
    /* Scale canvas container to fit: 360px / 380px = 0.947368 */
    .canvas-container,
    .canvas-container-fixed {
        transform: translateX(-50%) scale(0.9474) !important;
        position: relative !important;
        left: 50% !important;
    }

    /* Canvas stays 380x380 internally */
    body canvas#geoCanvas,
    body #geoCanvas,
    div canvas#geoCanvas,
    .canvas-container canvas#geoCanvas,
    canvas#geoCanvas.canvas {
        width: 380px !important;
        height: 380px !important;
    }

    /* Competition modal optimizations for 390x715 screens */
    /* Make modal much taller to fill screen like "view competitions" */
    #competitionModal .success-modal-content {
        max-height: 93vh !important;
        height: 93vh !important;
    }

    #competitionMainView .success-modal-header {
        padding: 16px 20px !important;
        height: auto !important;
        min-height: 55px !important;
        flex-shrink: 0 !important;
    }

    #competitionMainView .success-modal-header h2 {
        font-size: 20px !important;
    }

    #competitionMainView .success-modal-body {
        padding: 8px 18px 12px 18px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-navigation {
        margin-top: 0px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-buttons {
        gap: 10px !important;
        margin-top: 0px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #competitionMainView .success-nav-btn {
        padding: 12px 18px !important;
        font-size: 15px !important;
        min-height: 44px !important;
        flex-shrink: 0 !important;
    }

    /* How competitions work container - extended down to fill space */
    #competitionMainView .success-buttons > div[style*="margin-top"] {
        margin-top: 10px !important;
        padding: 14px 16px !important;
        font-size: 14px !important;
        line-height: 1.55 !important;
        max-height: none !important;
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] strong {
        font-size: 15px !important;
        margin-bottom: 10px !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] ul {
        padding-left: 20px !important;
        margin: 0 !important;
    }

    #competitionMainView .success-buttons > div[style*="margin-top"] li {
        margin-bottom: 7px !important;
        font-size: 14px !important;
        line-height: 1.55 !important;
    }

    /* Ensure overflow is visible to show scaled canvas */
    body,
    html {
        overflow-x: visible !important;
    }

    .app-container {
        overflow: visible !important;
    }
}
