/* ==========================================================================
   Core Variables and Base Styles
   ========================================================================== */
:root {
    /* Theme Colors - Mapped to API endpoint naming */
    --background-color: var(--background-color, #f5f5f5);
    --text-color: var(--text-color, #333);
    --textDark-color: var(--textDark-color, #000);
    --textLight-color: var(--textLight-color, #5e5252);
    --primary-color: var(--primary-color, #4CAF50);
    --primaryDark-color: var(--primaryDark-color, #388E3C);
    --primaryLight-color: var(--primaryLight-color, #81C784);
    --secondary-color: var(--secondary-color, #809ef6);
    --black-color: var(--black-color, #000);
    --white-color: var(--white-color, #fff);
    --gray-color: var(--gray-color, #757575);
    --error-color: var(--error-color, #f44336);
    --success-color: var(--success-color, #045c07);
    
    /* Layout */
    --border-radius: 8px;
    --spacing: 16px;
    --header-height: 70px;
    
    /* Typography */
    --header-font-size: 1.2rem;
    --header-font-weight: 600;
    --header-line-height: 1.4;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.1);
    
    /* Transitions */
    --transition-speed: 0.2s;
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base Styles */
body {
    font-family: Arial, sans-serif;
    background-color: #333;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    touch-action: pan-y pinch-zoom;
}

/* ==========================================================================
   Layout and Containers
   ========================================================================== */
#app {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 685px;
    max-height: 685px;
    overflow: hidden;
    border: none;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: var(--background-color);
}

/* Optimize app height for taller screens to utilize more vertical space */
@media screen and (min-height: 668px) {
    #app {
        height: 750px !important; /* Increase height for taller screens */
        max-height: 750px !important;
    }
}

/* Further optimize for very tall screens */
@media screen and (min-height: 800px) {
    #app {
        height: 800px !important; /* Increase height further for very tall screens */
        max-height: 800px !important;
    }
}

/* Base container style that should be shared across all main content containers */
.container {
    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-image: var(--background-image, url('/images/default/Background.png'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--border-radius);
    box-sizing: border-box;
}

.profile-section,
.game-selection-container {
    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: var(--spacing);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-image: var(--background-image, url('/images/default/Background.png'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--border-radius);
    box-sizing: border-box;
}

/* Content wrapper for proper padding and scrolling */
.content-wrapper {
    width: 100%;
    max-width: 100%;
    height: 100%;
    padding: var(--spacing);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
}

/* Game board specific container */
.game-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing);
    flex: 1;
    margin-top: var(--header-height); /* Position below header */
}

.game-board-content {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.game-grid {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing);
    padding: var(--spacing);
    justify-content: center;
    align-items: start;
}

/* Profile specific container */
.profile-section {
    justify-content: flex-start;
    align-items: center;
}

.profile-section .content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing);
}

/* Responsive adjustments */
@media (max-width: 430px) {
    .container,
    .profile-section,
    .game-selection-container,
    .game-board-container {
        padding: calc(var(--spacing) / 2);
    }

    .content-wrapper {
        padding: calc(var(--spacing) / 2);
    }
}

@media (max-height: 600px) {
    .container,
    .profile-section,
    .game-selection-container,
    .game-board-container {
        height: calc(100% - var(--header-height) - 10px);
    }
}

/* Profile specific adjustments */
.profile-section {
    width: 100%; /* Ensure full width */
}

.profile-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px;
}

/* Game selection specific adjustments */
.game-selection-container {
    overflow-y: auto;
}

/* Game board specific adjustments */
.game-board-container {
    justify-content: flex-start;
    align-items: center;
}

/* Games section with dynamic scrolling */
.games-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    padding: 12px; /*controls space from top on first box*/
    overflow: hidden;
    border-radius: var(--border-radius);
}

.games-overview {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.current-games,
.pending-invites,
.awaiting-opponent,
.finished-games {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--border-radius);
    padding: 1px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 420px;
    margin: 0 auto 16px auto;
}

.current-games h3,
.pending-invites h3,
.awaiting-opponent h3,
.finished-games h3 {
    font-size: 0.9rem;
    color: var(--textDark-color);
    margin-bottom: 8px;
    display: flex;
    align-items: left;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

.active-games,
.finished-games {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: rgba(248, 248, 248, 0.95);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--border-radius);
    flex: 1;
    min-height: 0;
}

/* Games list with conditional scrolling */
.games-list {
    margin-top: 4px;
    overflow-y: hidden; /* Changed from auto to hidden to prevent scrollbars on home page */
    flex: 1;
    min-height: 0; /* Important for flex child scrolling */
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* Single, consolidated games-grid style - remove all other instances */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 2px;
    margin: 0 auto;
    width: 100%;
    justify-content: center;
}

/* Event selection container */
.events-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    height: 100vh;
    min-height: 400px;
    width: 100%;
    background: rgba(255,255,255,0.95);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    padding: 0;
    overflow-y: auto;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    padding: var(--spacing);
    min-height: 200px;
    overflow-y: auto;
}

.no-events-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    width: 100%;
    font-size: 1.1rem;
    color: var(--gray-color);
    background: transparent;
    border-radius: var(--border-radius);
    text-align: center;
    font-style: italic;
}

/* Game selection container */
.game-selection-container {
    height: calc(100% - (var(--spacing) * 2));
    width: calc(100% - (var(--spacing) * 2));
    overflow-y: auto;
    padding: var(--spacing);
    margin: var(--spacing);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
}

#games-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing);
    padding: var(--spacing);
    justify-items: center;
    height: fit-content;
    width: 100%;
    box-sizing: border-box;
}

.game-selection-item {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Update pagination styles */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 4px 0; /* Reduced padding */
    border-top: 1px solid #eee;
    height: 24px; /* Fixed height for pagination container */
}

.pagination-btn {
    width: 24px; /* Fixed width */
    height: 24px; /* Fixed height - 1/3 of previous */
    padding: 0;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 12px;
}

/* Left arrow for Previous button */
.pagination-btn[onclick*="- 1"]::before {
    content: "\f104"; /* Font Awesome arrow-left */
}

/* Right arrow for Next button */
.pagination-btn[onclick*="+ 1"]::before {
    content: "\f105"; /* Font Awesome arrow-right */
}

.page-info {
    font-size: 0.9rem;
    color: #666;
    min-width: 40px;
    text-align: center;
}

/* Leaderboard section */
.leaderboard-section {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.players-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
}

.players-list .player-item {
    display: flex;
    align-items: left;
    padding: 2px 2px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    height: 18px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.players-list .player-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--white-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    margin-right: 2px;
    z-index: 1;
}

.players-list .player-name {
    flex: 1;
    align-items: left;
    font-size: 10px;
    font-weight: 500;
    color: var(--textDark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
    z-index: 1;
    position: relative;
}

.players-list .player-score {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    z-index: 2;
    position: relative;
    text-align: right;
}

/* Mobile optimizations */
@media screen and (max-width: 480px) {
    .players-list {
        padding: 0 4px;
    }

    .players-list .player-item {
        height: 30px;
        padding: 3px 6px;
    }

    .players-list .player-avatar {
        width: 18px;
        height: 18px;
        margin-right: 6px;
    }

    .players-list .player-name {
        font-size: 10px;
        margin-right: 2px;
    }

    .players-list .player-score {
        font-size: 10px;
    }
}

/* Ensure proper scrolling on small screens */
@media screen and (max-height: 600px) {
    .players-list {
        max-height: 50vh;
    }
}

/* Profile section */
.profile-section {
    height: 100%;
    overflow-y: auto;
    padding: 8px;
    width: 100%; /* Ensure full width */
}

.profile-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    padding: 10px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.profile-field label {
    font-size: 0.8rem;
    color: var(--gray-color);
    margin-bottom: 2px;
}

.profile-field .value {
    font-size: 1rem;
    color: var(--text-color);
}

.profile-avatar-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Hide scrollbar but keep functionality */
.games-list::-webkit-scrollbar,
.events-list::-webkit-scrollbar,
.players-list::-webkit-scrollbar {
    width: 4px;
}

.games-list::-webkit-scrollbar-thumb,
.events-list::-webkit-scrollbar-thumb,
.players-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* Ensure content fits viewport */
.game-selection-item {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* ==========================================================================
   Game Board and Grid Styles
   ========================================================================== */
.game-board-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: var(--spacing);
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: var(--spacing);
    background-color: rgba(204, 204, 204, 0.9);
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1;
    margin: 0 auto;
    box-sizing: border-box;
    border-radius: var(--border-radius);
}

.game-title {
    text-align: center;
    width: 100%;
    padding: var(--spacing);
    margin-bottom: var(--spacing);
    font-size: 6px;
    box-sizing: border-box;
}

.game-info {
    padding: 4px;
    margin-bottom: 4px;
}

/* Remove score and tiles display styles */
.score-display,
.tiles-display {
    display: none;
}

.grid-cell {
    aspect-ratio: 1;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 1px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.grid-cell.answered {
    cursor: default;
    pointer-events: none;
}

.grid-cell .cell-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.grid-cell .cell-icon {
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    object-fit: contain;
    transition: all var(--transition-speed);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.grid-cell.answered .cell-icon {
    opacity: 1;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
}

/* Remove the background-image approach and rely on img tag */
.grid-cell.completed-correct,
.grid-cell.completed-incorrect {
    background-color: var(--background-color);
    border: none;
}

.grid-cell.completed-correct::after,
.grid-cell.completed-incorrect::after {
    display: none;
}

.grid-cell .points-info {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    min-width: 24px;
    text-align: center;
}

.grid-cell.completed-correct .points-info {
    background: rgba(76, 175, 80, 0.1);
}

.grid-cell.completed-incorrect .points-info {
    background: rgba(244, 67, 54, 0.1);
}

/* Hide numbers by default */
.cell-number {
    display: none;
}

/* Responsive adjustments for game grid */
@media (max-width: 480px) {
    .game-grid {
        width: 95vw;
        max-width: 300px;
        gap: min(1.5vh, 6px);
        padding: min(1.5vh, 6px);
    }

    .cell-icon {
        width: 100%;
        height: 100%;
    }

    .cell-number {
        font-size: min(2vh, 0.9rem);
    }
}

@media (max-height: 600px) {
    .game-grid {
        max-width: 280px;
        gap: min(1vh, 4px);
        padding: min(1vh, 4px);
    }

    .cell-content {
        padding: min(1vh, 4px);
    }
}

/* ==========================================================================
   Forms and Inputs
   ========================================================================== */
.auth-form {
    width: min(90%, 400px);
    margin: 0 auto;
    padding: clamp(20px, 5vh, 40px);
    background: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    max-height: 90vh;
    overflow-y: hidden; /* Changed from auto to hidden to prevent scrollbars during login */
}

.auth-form h2 {
    margin-bottom: clamp(16px, 4vh, 32px);
    text-align: center;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 500;
}

.auth-form form {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 3vh, 24px);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--background-color);
    box-sizing: border-box;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Custom validation styling - only applied when explicitly validated */
.auth-form input.validation-error {
    border-color: var(--error-color);
}

.auth-form input.validation-error:focus {
    box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.1);
}

.auth-form input.validation-success {
    border-color: var(--primary-color);
}

.auth-form .error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    text-align: center;
    margin: 4px 0;
    padding: 4px;
    border-radius: var(--border-radius);
    background-color: rgba(244, 67, 54, 0.1);
    transition: all 0.3s ease;
}

.auth-form .error-message.hidden {
    display: none;
}

.auth-form .dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
    padding: 0;
    border-top: none;
}

/* Mobile optimizations for auth forms */
@media screen and (max-width: 430px) {
    .auth-form {
        width: 95%;
        padding: 16px;
        margin: 8px auto;
    }

    .auth-form input {
        font-size: 16px;
        padding: 10px;
    }

    .auth-form .dialog-buttons {
        margin-top: 16px;
    }
}

/* Ensure proper display on small screens */
@media screen and (max-height: 500px) {
    .auth-form {
        padding: 12px;
        max-height: 95vh;
    }

    .auth-form h2 {
        margin-bottom: 12px;
    }

    .auth-form form {
        gap: 12px;
    }
}

/* ==========================================================================
   Buttons and Interactive Elements
   ========================================================================== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
}

.button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Dialog Buttons */
.dialog-btn {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
}

.dialog-btn-primary {
    background-color: var(--primary-color);
}

.dialog-btn-secondary {
    background-color: var(--gray-color);
}

.dialog-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Answer Buttons */
.answer-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
    position: relative;
    overflow: hidden;
}

.answer-button:active {
    transform: scale(0.98);
}

.answer-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Finish Game Button */
.finish-game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
}

.finish-game-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Auth Form Buttons */
.auth-form button {
    width: 100%;
    padding: 2px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
    margin-top: 1px;
}

.auth-form button:hover {
    opacity: 0.9;
}

.auth-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer Link Buttons */
.footer-link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
    text-decoration: none;
}

.footer-link-button:hover {
    opacity: 0.9;
}

/* Pagination Buttons */
.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
}

.pagination-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden {
    display: none !important;
}

.transparent-bg {
    background: transparent !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 480px) {
    .header {
        padding: calc(var(--spacing) / 2);
    }
    
    .grid-cell {
        min-width: 70px;
        min-height: 70px;
    }
}

@media (max-height: 600px) {
    .auth-form {
        padding: 15px;
    }
    
    .auth-form input,
    .auth-form button {
        padding: 8px;
    }
}

/* ==========================================================================
   Authentication Form Styles
   ========================================================================== */
.auth-form h2 {
    margin-bottom: clamp(16px, 4vh, 32px);
    text-align: center;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 500;
}
.Consent-txt {
    text-align: center;
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 600;
    border:2px solid var(--primary-color);
    border-radius: 10px;
    padding: 10px;
    box-shadow:2px 2px var(--text-color);
    
}
.auth-form form {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 3vh, 24px);
}

/* Form buttons container */
.form-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Spacing between buttons */
}

.auth-form button {
    width: 100%;
    padding: clamp(10px, 2vh, 16px);
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color:var(--white-color);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.auth-form button:hover {
    background-color: var(--primaryLight-color);
}

.auth-form button:disabled {
    background-color: var(--background-color);
    cursor: not-allowed;
}

/* Logo in auth form */
.logo-container {
    text-align: center;
    margin: 15px 0;
}

.auth-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

/* Forgot password link styling */
.forgot-password {
    text-align: center;
    margin-top: 8px;
}

/* Logo in auth form */
.logo-container {
    text-align: center;
    margin: 1px 0;
}

.auth-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

/* Forgot password link styling */
.forgot-password {
    text-align: center;
    margin-top: 8px;
}

.forgot-password a {
    color: var(--secondary-color);
    font-size: 10px;
    text-decoration: none;
    transition: color var(--transition-speed);
}

.forgot-password a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Privacy policy section styling */
.privacy-policy-section {
    margin: 15px 0;
    text-align: center;
}

.privacy-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
}

.privacy-links a {
    color: var(--secondary-color);
    font-size: 10px;
    text-decoration: none;
    transition: color var(--transition-speed);
}

.privacy-links a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.privacy-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 10px;
    color: var(--text-color);
    text-align: left;
    margin-top: 5px;
}

.privacy-checkbox input {
    margin-top: 3px;
}

/* ==========================================================================
   Game Board Styles
   ========================================================================== */
.game-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing);
}

/* ==========================================================================
   Profile Summary Styles
   ========================================================================== */
.profile-summary {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Default avatar style for header and small displays */
.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

/* Override for profile page avatar */
#profile-container .avatar-container {
    width: 120px;
    height: 120px;
    position: relative;
    margin: 0 auto;
    border-radius: 60px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#profile-container .avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.profile-details {
    display: grid;
  /*  grid-template-columns: 2fr 1fr;*/
   /* grid-template-columns: 15% 85%;*/
    gap: var(--spacing);
}

.profile-info h3 {
    margin-bottom: var(--spacing);
}

.profile-info p,
.profile-stats p {
    margin-bottom: calc(var(--spacing) / 2);
}

/* ==========================================================================
   Games Section Styles
   ========================================================================== */
.game-item {
    background: var(--white-color);
    padding: 8px;
    border-radius: var(--border-radius);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.game-item:last-child {
    margin-bottom: 0;
}

.game-item .game-info {
    flex: 1;
}

.game-item .game-info h3 {
    margin: 0 0 2px 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

.game-item .game-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--gray-color);
}

.game-item .game-info .score {
    color: var(--text-color);
    font-weight: 500;
    margin-top: 2px;
}

.game-status {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--background-color);
    color: var(--secondary-color);
}

.game-status.completed {
    background: var(--background-color);
    color: var(--primary-color);
}

.no-games {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 80px; /* Match the height of a single game icon */
    height: 80px; /* Fixed height to match game icon height */
    width: 100%;
    text-align: center;
    color: var(--gray-color);
    padding: var(--spacing);
    font-style: italic;
    font-size: 1.1rem;
    background: rgba(255,255,255,0.95);
    border-radius: var(--border-radius);
}

.game-item.error {
    border-left: 4px solid var(--error-color);
    background-color: var(--background-color);
}

.game-item.error .game-info h3 {
    color: var(--error-color);
}

.game-item.error .game-info p {
    color: var(--error-color);
}

/* ==========================================================================
   Expand Button Styles
   ========================================================================== */
.expand-btn {
    padding: 4px 8px;
    margin-left: var(--spacing);
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--secondary-color);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.expand-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* ==========================================================================
   Footer Navigation
   ========================================================================== */
.footer {
    position: relative;
    bottom: 0;
    width: 100%;
    padding: 12px 16px;
    background-color: var(--background-color);
    border-top: 1px solid var(--primaryDark-color);
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    background-color: var(--primary-color);
    color: var(--white-color);
    text-decoration: none;
}

.footer-link-button:hover {
    opacity: 0.9;
}

.footer-link-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

@media (max-width: 480px) {
    .footer {
        padding: 8px;
    }
    
    .footer-link-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   Event Selection Screen Styles
   ========================================================================== */
.event-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--primary-color);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    box-sizing: border-box;
}

.event-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.event-item h3 {
    margin: 0 0 8px 0;
    color: var(--text-color);
    font-size: 1.2rem;
}

.event-item p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 12px;
}

.event-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing);
    padding-top: var(--spacing);
    border-top: 1px solid var(--white-color);
    font-size: 0.8em;
    color: var(--gray-color);
    gap: var(--spacing);
}

.event-duration {
    display: flex;
    align-items: center;
    gap: 4px;
}

.event-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Button styles for event items */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-color-dark, #0056b3);
    transform: translateY(-1px);
}

.btn-text {
    font-weight: 500;
}

.event-difficulty {
    padding: 2px 8px;
    background-color: var(--background-color);
    color: var(--primary-color);
    border-radius: 12px;
    font-weight: 500;
}

/* ==========================================================================
   Game Type Selection Screen Styles
   ========================================================================== */
.gametype-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: var(--spacing);
    height: calc(100vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

.gametype-list {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing);
    flex: 1;
    min-height: 0;
}

.gametype-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: calc(var(--spacing) / 2);
}

.gametype-item i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: calc(var(--spacing) / 2);
}

.gametype-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gametype-item h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.2rem;
}

.gametype-item p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

.gametype-item.direct-access {
    border-left-color: var(--secondary-color);
}

.gametype-item.direct-access i {
    color: var(--secondary-color);
}

.gametype-item.versus {
    border-left-color: #e91e63;
}

.gametype-item.versus i {
    color: #e91e63;
}

/* ==========================================================================
   Game Board Screen Styles
   ========================================================================== */
.game-title {
    text-align: center;
    width: 100%;
    padding: calc(var(--spacing) / 2);
    margin-bottom: var(--spacing);
    font-size: 8px;
}

/* Answer result section */
.answer-result {
    margin: var(--spacing) 0;
    padding: var(--spacing);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    position: relative;
    z-index: 2002;
}

.close-card-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: white;
    cursor: pointer;
    margin-top: var(--spacing);
    transition: all 0.3s;
    position: relative;
    z-index: 2002;
}

.card-answers {
    position: relative;
    z-index: 2002;
    margin: var(--spacing) 0;
}

/* Styles for answered state */
.answer-button.answered-correct {
    background-color: rgba(76, 175, 80, 0.15);
    border-color: var(--primary-color);
}

.answer-button.answered-incorrect {
    background-color: rgba(244, 67, 54, 0.15);
    border-color: #f44336;
}

.answer-button.selected {
    font-weight: bold;
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.answer-button {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.answer-button:active {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(0.98);
}

.answer-button:disabled {
    cursor: default;
    opacity: 0.8;
}

.answer-button .points-indicator {
    position: absolute;
    right: 12px;
    color: var(--text-color);
    font-size: 0.9em;
}

/* ==========================================================================
   Grid Cell Completed States
   ========================================================================== */
.grid-cell.completed-correct {
    position: relative;
    background-color: var(--background-color);
    border: none;
}

.grid-cell.completed-correct::after {
    display: none;
}

.grid-cell.completed-incorrect {
    position: relative;
    background-color: var(--background-color);
    border: none;
}

.grid-cell.completed-incorrect::after {
    display: none;
}

/* ==========================================================================
   Viewport Wrapper Styles
   ========================================================================== */
.viewport-size {
    position: fixed;
    top: 50%;
    right: calc(50% + 220px);
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--white-color);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--border-radius);
    z-index: 1000;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* ==========================================================================
   Add empty cell style
   ========================================================================== */
.grid-cell.empty {
    display: none;
}

.grid-cell.empty:hover {
    background-color: transparent;
}

/* ==========================================================================
   Games List Container
   ========================================================================== */
#games-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    padding: 20px;
    justify-items: center;
}

.game-selection-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.game-selection-item h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-color);
}

.game-info {
    margin: 12px 0;
}

.game-info p {
    font-size: 0.9rem;
    color: var(--gray-color);
    line-height: 1.4;
    /* Multi-browser line clamp support */
    display: -webkit-box;
    display: -moz-box;
    display: box;
    -webkit-line-clamp: 3;
    -moz-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Fallback for browsers that don't support line-clamp */
    max-height: 4.2em; /* line-height * 3 lines */
}

/* ==========================================================================
   Add fallback for older browsers
   ========================================================================== */
@supports not (display: -webkit-box) {
    .game-info p {
        display: block;
        max-height: 4.2em;
        position: relative;
        overflow: hidden;
    }
    
    .game-info p::after {
        content: '...';
        position: absolute;
        bottom: 0;
        right: 0;
        background: var(--background-color);
        padding-left: 4px;
    }
}

.game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--white-color);
}

.game-stats {
    font-size: 0.9rem;
    margin-top: 2px;
}

.game-stats i {
    color: var(--primary-color);
    font-size: 0.9rem;
}

/* ==========================================================================
   Custom Dialog Styles
   ========================================================================== */
/* FEEDBACK - Custom Dialog Styles */
.custom-dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 16px;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* FEEDBACK - Dialog container styles */
/* CRITICAL: All dialogs must stay within 400px app container width */
.custom-dialog {
    background: #fff; /* Match card background */
    border-radius: 12px; /* Match card border radius */
    box-shadow: 0 2px 8px rgba(0,0,0,0.12); /* Match card shadow */
    padding: 5px; /* Reduced padding */
    display: flex;
    flex-direction: column;
    overflow: visible; /* Prevent double scrollbars */
    width: calc(100% - 10px); /* 5px margin on each side */
    max-width: 390px !important; /* Never exceed app container width (400px - 10px) */
    max-height: calc(100% - 60px); /* Use container height, not viewport */
}

/* FEEDBACK - Dialog header styles */
.dialog-header {
    padding: 18px 18px 0 18px; /* Match card modal spacing */
    border-bottom: none; /* Remove border for card look */
    text-align: center;
    width: 100%;
    margin: 0 auto;
}

.dialog-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

/* FEEDBACK - Dialog content styles */
.dialog-content {
    padding: 5px;
    flex: 1;
    overflow-y: auto; /* Only content scrolls */
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    background: none; /* Remove background for card look */
    border-radius: 0 0 12px 12px;
    min-height: 200px; /* Ensure minimum space for content */
}

/* FEEDBACK - Dialog button styles */
.dialog-buttons {
    padding: 18px;
    border-top: none;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: none;
    width: 100%;
    margin: 0 auto;
}

.dialog-btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 100px;
}

/* Remove nested scrollbars on overlay */
.custom-dialog-overlay {
    overflow: hidden !important;
}

/* Responsive adjustments for mobile */
@media screen and (max-width: 480px) {
    .custom-dialog {
        border-radius: 8px;
    }
    .dialog-content {
        padding: 10px;
        border-radius: 0 0 8px 8px;
    }
    .dialog-header {
        padding: 10px 10px 0 10px;
    }
    .dialog-buttons {
        padding: 10px;
    }
}

/* Ensure modal stays within app container on all screen sizes */
@media screen and (max-height: 700px) {
    .custom-dialog-overlay {
        padding: 8px;
    }
}

/* Optimize modal height for taller screens to utilize more vertical space */
@media screen and (min-height: 668px) {
    .custom-dialog {
        max-height: calc(100% - 60px) !important; /* Use container height, not viewport */
        height: auto !important;
    }
    
    .dialog-content {
        max-height: calc(100% - 150px) !important; /* Use container height */
        padding: 5px !important; /* Reduced padding */
    }
    
    /* Optimize form content height for taller screens */
    .custom-dialog-overlay .auth-form .dialog-content {
        max-height: calc(100% - 150px) !important; /* Use container height */
        padding: 5px !important; /* Reduced padding */
    }
}

/* Further optimize for very tall screens */
@media screen and (min-height: 800px) {
    .custom-dialog {
        max-height: calc(100% - 60px) !important; /* Use container height */
        height: auto !important;
    }
    
    .dialog-content {
        max-height: calc(100% - 130px) !important; /* Use container height */
        padding: 5px !important; /* Reduced padding */
    }
    
    /* Optimize form content height for very tall screens */
    .custom-dialog-overlay .auth-form .dialog-content {
        max-height: calc(100% - 130px) !important; /* Use container height */
        padding: 5px !important; /* Reduced padding */
    }
}

/* FEEDBACK - Success/Error States */
.dialog-title.success {
    color: var(--success-color);
}

.dialog-title.error {
    color: var(--error-color);
}

/* ==========================================================================
   Player Selection Dialog Styles
   ========================================================================== */
.player-selection-dialog {
    max-width: 400px;
    width: 95%;
    margin: 0 auto;
}

.player-selection-dialog .dialog-content {
    padding: 10px;
    overflow-y: auto;
    max-height: 60vh;
}

/* Player Search Container */
.player-search-container {
    margin-bottom: 12px;
    padding: 0 4px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.1);
}

.search-icon {
    color: var(--text-color);
    font-size: 14px;
    margin-right: 8px;
    flex-shrink: 0;
}

.player-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--textDark-color);
    font-family: inherit;
}

.player-search-input::placeholder {
    color: var(--text-color);
    opacity: 0.7;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    width: 20px;
    height: 20px;
}

.clear-search-btn:hover {
    background: var(--primaryLight-color);
    color: var(--primary-color);
}

.clear-search-btn i {
    font-size: 10px;
}

/* No Search Results */
.no-search-results {
    text-align: center;
    padding: 20px;
    color: var(--text-color);
}

.no-search-results.hidden {
    display: none;
}

.no-results-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.no-results-content i {
    font-size: 24px;
    color: var(--text-color);
    opacity: 0.5;
}

.no-results-content p {
    margin: 0;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
}

/* Players List Grid */
.player-selection-dialog .players-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 8px 0;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
}

/* Table Layout */
.player-select-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 4px;
    margin-bottom: 8px;
}

.player-select-table .player-cell {
    width: 50%;
    padding: 0;
    vertical-align: middle;
}

/* Player Item Styling */
.player-select-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    height: 32px;
    gap: 6px;
    transition: transform 0.2s, background-color 0.2s;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.player-select-item:hover {
    transform: translateY(-2px);
    background: var(--primaryLight-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.player-selection-dialog .player-select-item .player-avatar {
    width: 22px !important;
    height: 22px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 1px solid var(--white-color) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    flex-shrink: 0 !important;
}

.player-select-item .player-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--textDark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 55px);
    padding-right: 4px;
    text-align: left; /* Ensure left alignment */
    margin-right: auto; /* Push any following elements to the right */
}

.player-select-item .player-score {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    min-width: 30px;
    text-align: right;
    flex-shrink: 0;
    margin-left: auto; /* Push score to the right */
}

/* Grid Layout for Players */
.player-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 8px 0;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
}

/* Mobile optimizations */
@media screen and (max-width: 480px) {
    .player-selection-dialog {
        width: 90%;
        max-width: 350px;
    }
    
    .player-search-container {
        margin-bottom: 10px;
        padding: 0 2px;
    }
    
    .search-input-wrapper {
        padding: 6px 10px;
    }
    
    .search-icon {
        font-size: 12px;
        margin-right: 6px;
    }
    
    .player-search-input {
        font-size: 13px;
    }
    
    .clear-search-btn {
        width: 18px;
        height: 18px;
        right: 6px;
    }
    
    .clear-search-btn i {
        font-size: 9px;
    }
    
    .no-search-results {
        padding: 15px;
    }
    
    .no-results-content i {
        font-size: 20px;
    }
    
    .no-results-content p {
        font-size: 13px;
    }
    
    .player-select-table {
        border-spacing: 3px;
    }
    
    .player-select-item {
        height: 30px;
        padding: 4px 6px;
    }
    
    .player-selection-dialog .player-select-item .player-avatar {
        width: 18px !important;
        height: 18px !important;
    }
    
    .player-select-item .player-name {
        font-size: 11px;
    }
    
    .player-select-item .player-score {
        font-size: 11px;
        min-width: 25px;
    }
    
    .player-selection-dialog .players-list,
    .player-select-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Leaderboard Section Styles
   ========================================================================== */
.leaderboard-section {
    background: var(--background-color);
    border-radius: var(--border-radius);
    margin: var(--spacing) 0;
    padding: var(--spacing);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

.tab-button {
    padding: 8px 24px;
    border: none;
    border-radius: 20px;
    background-color: var(--white-color);
    color: var(--gray-color);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.tab-button.active {
    background-color: var(--primary-color);
    color: var(--white-color);
}

.top-players {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--spacing);
    margin-bottom: calc(var(--spacing) * 2);
    padding-bottom: var(--spacing);
    border-bottom: 1px solid #eee;
    min-height: 100px;
    padding-top: 20px;
}

.player-card {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing) * 0.5);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    text-align: center;
    width: 120px;
    position: relative;
    margin-bottom: 0;
}

.player-card .player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0;
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* First place */
.first-place {
    background: linear-gradient(135deg, #FFD700, #FDB931);
    border: 2px solid #FFD700;
    height: 60px;
    margin-bottom: 0;
    padding-bottom: 2px;
    margin-top: 20px;
}

/* Second place */
.second-place {
    background: linear-gradient(135deg, #C0C0C0, #A8A8A8);
    border: 2px solid #C0C0C0;
    height: 55px;
    align-self: flex-end;
    margin-bottom: 0;
    padding-bottom: 2px;
    margin-top: 20px;
}

/* Third place */
.third-place {
    background: linear-gradient(135deg, #CD7F32, #B87333);
    border: 2px solid #CD7F32;
    height: 50px;
    align-self: flex-end;
    margin-bottom: 0;
    padding-bottom: 2px;
    margin-top: 20px;
}

.player-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: auto;
    padding-bottom: 2px;
}

.player-name {
    font-weight: 500;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.player-score {
    color: var(--text-color);
    font-weight: 600;
    font-size: 9px;
    width: 100%;
    text-align: center;
}

/* ==========================================================================
   Responsive adjustments for leaderboard
   ========================================================================== */
@media (max-width: 480px) {
    .top-players {
        gap: calc(var(--spacing) / 2);
    }

    .player-card {
        width: 100px;
        padding: calc(var(--spacing) / 2);
    }

    .player-avatar {
        width: 50px;
        height: 50px;
    }

    .player-name {
        font-size: 0.8rem;
    }

    .player-score {
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   Current Player Section Styles
   ========================================================================== */
.current-player-section {
    margin-top: var(--spacing);
    padding-top: var(--spacing);
}

/* Position divider styles */
.position-divider {
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
}

.divider-line {
    flex: 1;
    height: 2px;
    background: var(--primary-color);
    opacity: 0.3;
}

.divider-text {
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    padding: 0 8px;
}

/* Current player highlight */
.current-player {
    background-color: rgba(76, 175, 80, 0.1) !important;
    border-left: 3px solid var(--primary-color);
    position: relative;
}

.current-player::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.current-player .player-name {
    color: var(--primary-color);
    font-weight: 600;
}

.current-player .player-score {
    color: var(--primary-color);
    font-weight: 600;
}

/* Players table styles */
.players-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}

.players-table .player-item {
    background: #f8f8f8;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.players-table .player-item:hover {
    background: #f0f0f0;
}

.players-table .player-avatar-cell {
    width: 40px;
    padding: 4px;
}

.players-table .player-score-cell {
    width: 80px;
    text-align: right;
    padding: 4px 8px;
}

.players-table .player-name-cell {
    padding: 4px 8px;
}

/* Mobile optimizations */
@media screen and (max-width: 480px) {
    .position-divider {
        margin: 12px 0;
    }

    .divider-text {
        font-size: 11px;
    }

    .players-table .player-avatar-cell {
        width: 32px;
    }

    .players-table .player-score-cell {
        width: 70px;
    }
}

.points-indicator {
    float: right;
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.answer-result {
    margin: var(--spacing) 0;
    padding: var(--spacing);
    border-radius: var(--border-radius);
    background-color: #f5f5f5;
    text-align: center;
}

.result-header {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 4px;
}

.points-earned {
    font-size: 1.1em;
    color: var(--primary-color);
    font-weight: 500;
}

.answer-button.positive-value .points-indicator {
    color: var(--primary-color);
}

.answer-button.negative-value .points-indicator {
    color: #f44336;
}

/* Game icon styles - update to be more responsive */
.game-icon {
    position: relative;
    width: 80px;
    height: 80px;
    padding: 8px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.game-players {
    position: absolute;
    top: -15px;  /* Position above the icon instead of below */
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.5rem;
    color: var(--gray-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 4px;
    /*background: rgba(255, 255, 255, 0.95); */ /* Fixed comment syntax */
    border-radius: 4px;
    /*box-shadow: 0 1px 2px rgba(0,0,0,0.1);*/
}

/* Adjust games grid to accommodate player names */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px 2px;
    padding: 2px;
    margin: 0 auto;
    width: 100%;
    justify-content: center;
}

/* Adjust current games section to have more space */
.current-games {
    flex: 1;
    min-height: 0;
    padding: 8px;
    background: var(--background-color);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--border-radius);
    margin-bottom: 8px;  /* Add some space between sections */
}

/* Mobile adjustments */
@media (max-width: 360px) {
    .game-players {
        font-size: 0.6rem;
        top: -14px;  /* Adjusted for mobile */
        padding: 1px 3px;
    }
    
    .games-grid {
        gap: 18px 2px;  /* Reduced gap for mobile */
    }
    
    .no-games {
        min-height: 60px; /* Match mobile game icon height */
        height: 60px; /* Fixed height to match mobile game icon height */
        font-size: 1rem; /* Slightly smaller text on mobile */
    }
}

/* Styles for awaiting opponent tiles */
.game-icon.awaiting-opponent-tile {
    cursor: not-allowed;
    opacity: 0.8;
    position: relative;
}

.game-icon.awaiting-opponent-tile:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.awaiting-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    text-align: center;
    padding: 5px;
    font-size: 12px;
}

/* Pagination adjustments */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 4px 0; /* Reduced padding */
    border-top: 1px solid #eee;
    height: 24px; /* Fixed height for pagination container */
}

.pagination-btn {
    width: 24px; /* Fixed width */
    height: 24px; /* Fixed height - 1/3 of previous */
    padding: 0;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 12px;
}

/* Left arrow for Previous button */
.pagination-btn[onclick*="- 1"]::before {
    content: "\f104"; /* Font Awesome arrow-left */
}

/* Right arrow for Next button */
.pagination-btn[onclick*="+ 1"]::before {
    content: "\f105"; /* Font Awesome arrow-right */
}

.page-info {
    font-size: 0.9rem;
    color: #666;
    min-width: 40px;
    text-align: center;
}

/* Section headers */
.active-games h3,
.finished-games h3 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: #666;
}

/* Game info text */
.game-icon .game-info {
    font-size: 0.65rem;
}

.game-icon .game-id {
    font-size: 0.65rem;
    margin-bottom: 1px;
}

.game-icon .game-progress,
.game-icon .game-score {
    font-size: 0.6rem;
}

/* Completed game specific styles */
.game-icon.completed {
    background: rgba(76, 175, 80, 0.05);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.game-icon.completed .game-score {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.7rem;
    margin-top: 2px;
}

.end-game-link {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    padding: 1px 4px;
    border-radius: 8px;
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

/* Mobile adjustments */
@media (max-width: 360px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 2px;
    }

    .game-icon {
        width: 60px;
        height: 60px;
        padding: 6px;
    }

    .game-icon img {
        width: 32px;
        height: 32px;
    }

    .game-icon .game-info {
        font-size: 0.65rem;
    }
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #ccc;
    color: #666;
}

.page-info {
    font-size: 0.9rem;
    color: #666;
    min-width: 60px;
    text-align: center;
}

@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
        padding: 2px;
    }

    .game-icon {
        padding: 8px;
    }

    .game-icon img {
        width: 70%;
        height: 70%;
    }

    .pagination-btn {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
}

/* ==========================================================================
   Adjust game lists to remove scrolling
   ========================================================================== */
.games-list {
    margin-top: var(--spacing);
    max-height: none;
    overflow: visible;
}

.game-popup .status {
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
    margin: 8px 0;
}

.game-popup .status.completed {
    background: #e8f5e9;
    color: var(--primary-color);
}

.game-popup .status.in-progress {
    background: #e3f2fd;
    color: #1976d2;
}

.game-popup .finish-game-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    margin-top: 12px;
    width: 100%;
    transition: background-color 0.2s;
}

.game-popup .finish-game-btn:hover {
    background: #388e3c;
}

.game-popup .players-avatars {
    display: flex;
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.game-popup .player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-popup .player-avatar:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

.game-actions {
    padding: var(--spacing);
    text-align: center;
    margin-top: var(--spacing);
}

.finish-game-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    max-width: 300px;
    transition: all 0.2s;
}

.finish-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Remove error message styles */
.error-message {
    width: 100%;
    margin: 4px 0;
    padding: 4px;
    border-radius: var(--border-radius);
    font-size: 14px;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.error-message.hidden {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Remove finish button styles */
.finish-button,
.finish-icon {
    display: none !important;
}

.end-game-link {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

.game-icon:hover .end-game-link {
    opacity: 1;
}

.end-game-link:hover {
    background: var(--error-color);
    color: white;
}

.game-icon.completed {
    background: rgba(76, 175, 80, 0.05);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.game-icon.completed:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.game-icon.completed .game-score {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Update media query for mobile devices */
@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
        padding: 2px;
    }
    
    .no-games {
        min-height: 60px; /* Match mobile game icon height */
        height: 60px; /* Fixed height to match mobile game icon height */
        font-size: 1rem; /* Slightly smaller text on mobile */
    }
}

/* ==========================================================================
   Header and Navigation
   ========================================================================== */
/* Main Navigation Header */
.header.main-nav {
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 var(--spacing);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(245, 245, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* Subpage Header */
.header.subpage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 var(--spacing);
    background: rgba(255, 255, 255, 0.95); /* Unified white background for all top menus */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.header.subpage h1 {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: var(--header-font-size);
    font-weight: var(--header-font-weight);
    color: var(--textDark-color);
    z-index: 1;
}

.header.subpage .back-button {
    z-index: 2;
    position: relative; /* Override absolute positioning for flexbox layout */
    left: auto; /* Remove absolute positioning */
}

.header.subpage .header-spacer {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .header.subpage {
        padding: 10px;
    }
    .header.subpage .header-spacer {
        width: 36px;
        height: 36px;
    }
}

/* Standardized Back Button Styles */
.back-button {
    position: absolute;
    left: 15px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    z-index: 100;
}

.back-button i,
.back-button svg {
    color: var(--primary-color);
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    .back-button {
        left: 10px;
        width: 36px;
        height: 36px;
    }
    
    .back-button i,
    .back-button svg {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
}

/* Header Title Styles */
.header.subpage h1 {
    font-size: var(--header-font-size);
    font-weight: var(--header-font-weight);
    color: var(--textDark-color);
    margin: 0;
    text-align: center;
    width: 100%;
}

/* Header Buttons - Consolidated Styles */
.header.main-nav button,
.play-button,
.leaderboard-button,
.refresh-button,
.logout-button,
.login-button,
.category-button {
    width: 50px;
    height: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none;
    cursor: pointer;
    transition: transform var(--transition-speed) ease;
    color: var(--textDark-color);
}

/* Header Button Images */
.header.main-nav button img,
.play-button img,
.leaderboard-button img,
.refresh-button img,
.logout-button img,
.login-button img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.header.main-nav .avatar,
.header.main-nav .play-icon,
.header.main-nav .leave-icon,
.header.main-nav .trophy-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: transparent !important;
    mix-blend-mode: normal !important;
    -webkit-mix-blend-mode: normal !important;
    color: var(--textDark-color);
}

/* Header Button Hover States */
.header.main-nav button:hover,
.play-button:hover,
.leaderboard-button:hover,
.refresh-button:hover,
.logout-button:hover,
.login-button:hover {
    transform: scale(1.1);
    background: transparent !important;
}

/* Refresh Section - Bottom positioning */
.refresh-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    margin-bottom: 8px;
}

/* Refresh Button Specific Styles */
.refresh-button {
    position: relative;
    width: 60px;
    height: 60px;
    background: var(--primary-color) !important;
    border-radius: 50% !important;
    border: 2px solid var(--primaryDark-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.refresh-button:hover {
    background: var(--primaryDark-color) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.refresh-button.refreshing {
    pointer-events: none;
    opacity: 0.7;
    background: var(--primaryLight-color) !important;
}

.refresh-button.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.refresh-button .refresh-icon {
    font-size: 24px;
    font-weight: bold;
    color: var(--white-color);
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.refresh-button:hover .refresh-icon {
    color: var(--white-color);
    transform: rotate(90deg);
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    .header.subpage {
        padding: 10px;
    }
    
    .back-button {
        left: 10px;
        width: 36px;
        height: 36px;
    }
    
    .back-button svg {
        width: 20px;
        height: 20px;
    }
}

/* Game Stats in Header */
.header.subpage .game-stats {
    position: absolute;
    right: 15px;
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--textDark-color);
}

.header.subpage .game-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Player Avatars in Header */
.header.subpage .players-avatars {
    position: absolute;
    right: 15px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.header.subpage .players-avatars img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    .header.subpage .game-stats {
        right: 10px;
        font-size: 11px;
        gap: 8px;
    }
    
    .header.subpage .players-avatars {
        right: 10px;
    }
    
    .header.subpage .players-avatars img {
        width: 20px;
        height: 20px;
    }
}

/* Back Button Icon Styles */
.back-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

@media (max-width: 480px) {
    .back-icon {
        width: 18px;
        height: 18px;
    }
}

/* ==========================================================================
   Universal Spinner System
   ========================================================================== */

/* Global Spinner Overlay */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.spinner-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Spinner Container */
.spinner-container {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 120px;
    max-width: 200px;
    text-align: center;
}

/* Spinner Animation */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(76, 175, 80, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Spinner Text */
.spinner-text {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    line-height: 1.4;
}

/* Spinner Animation Keyframes */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Inline Spinner for Buttons */
.spinner-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Button Loading State */
.button-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.button-loading .spinner-inline {
    margin-right: 6px;
}

/* Form Loading State */
.form-loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
}

.form-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    border-radius: var(--border-radius);
}

.form-loading .spinner-inline {
    margin-right: 8px;
}

/* Form Spinner Message */
.form-spinner-message {
    position: relative;
    z-index: 11;
    background: var(--primary-color);
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    margin-top: 8px;
    box-shadow: var(--shadow-md);
    font-weight: 500;
}

/* Small Spinner Variant */
.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-small .spinner-inline {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
}

/* Large Spinner Variant */
.spinner-large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

.spinner-large .spinner-inline {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .spinner-container {
        padding: 16px;
        min-width: 100px;
        max-width: 160px;
    }
    
    .spinner {
        width: 28px;
        height: 28px;
        border-width: 2.5px;
    }
    
    .spinner-text {
        font-size: 13px;
    }
}

/* ==========================================================================
   Header and Navigation
   ========================================================================== */

/* ==========================================================================
   Error States and Network Issues
   ========================================================================== */

/* Network error styling */
.network-error,
.connection-error {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border: 2px solid #feb2b2;
    border-radius: 12px;
    padding: 20px;
    margin: 10px 0;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.network-error h3,
.connection-error h3 {
    color: #c53030;
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
}

.network-error p,
.connection-error p {
    color: #742a2a;
    margin: 0 0 15px 0;
    font-size: 14px;
    line-height: 1.4;
}

.retry-button {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.retry-button:hover {
    background: linear-gradient(135deg, #3182ce 0%, #2c5aa0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
}

.retry-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.retry-button i {
    font-size: 12px;
}

/* Connection error specific styling */
.connection-error {
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    border-color: #9ae6b4;
}

.connection-error h3 {
    color: #22543d;
}

.connection-error p {
    color: #2f855a;
}

/* Game error styling */
.game-item.error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    text-align: center;
}

.game-item.error h3 {
    color: #c53030;
    margin: 0 0 8px 0;
    font-size: 16px;
}

.game-item.error p {
    color: #742a2a;
    margin: 0;
    font-size: 14px;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #f56565;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: none;
}

.offline-indicator.show {
    display: block;
}

/* Loading states */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #718096;
    font-size: 14px;
}

.loading-state .spinner {
    margin-right: 10px;
}

/* Responsive error styling */
@media (max-width: 480px) {
    .network-error,
    .connection-error {
        padding: 15px;
        margin: 8px 0;
    }
    
    .network-error h3,
    .connection-error h3 {
        font-size: 16px;
    }
    
    .network-error p,
    .connection-error p {
        font-size: 13px;
    }
    
    .retry-button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ===================== UNIFIED MODAL STYLES ===================== */
/* Consolidated modal styles for all dialogs including auth forms */
.custom-dialog-overlay {
    overflow: hidden !important; /* Prevent overlay scrollbar */
    box-sizing: border-box !important;
}

.custom-dialog {
    width: calc(100% - 10px) !important; /* 5px margin on each side */
    max-width: 390px !important; /* CRITICAL: Never exceed 400px app container width */
    min-width: 280px !important;
    max-height: calc(100% - 60px) !important; /* Use container height, not viewport */
    height: auto !important;
    padding: 5px !important;
    box-sizing: border-box !important;
    overflow: hidden !important; /* Only content scrolls */
    margin: 0 auto !important;
}

.dialog-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 5px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Responsive adjustments for small screens */
@media screen and (max-width: 480px) {
    .custom-dialog {
        width: calc(100% - 10px) !important; /* 5px margin on each side */
        max-width: 390px !important; /* CRITICAL: Never exceed app container width */
        min-width: 0 !important;
        max-height: calc(100% - 40px) !important; /* Use container height */
    }
    
    .dialog-content {
        padding: 5px !important;
    }
}

@media screen and (max-height: 700px) {
    .custom-dialog {
        max-height: calc(100% - 60px) !important; /* Use container height, not viewport */
    }
    
    .dialog-content {
        max-height: calc(100% - 180px) !important; /* Ensure content fits */
    }
}

/* Ensure all modals stay within app container */
.custom-dialog-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

/* CRITICAL: Override any viewport-based sizing to ensure app container width is respected */
.custom-dialog {
    max-width: 390px !important; /* Never exceed 400px app container */
}

/* PC and desktop screens - ensure dialogs respect app container width */
@media screen and (min-width: 600px) {
    .custom-dialog {
        max-width: 390px !important; /* Never exceed app container width */
    }
}

@media screen and (min-width: 1200px) {
    .custom-dialog {
        max-width: 390px !important; /* Never exceed app container width */
    }
}
/* ===================== END UNIFIED MODAL STYLES ===================== */

/* ===================== FEEDBACK MODAL CONTINUE BUTTON HOVER CONTRAST FIX ===================== */
.dialog-btn-primary {
    background-color: var(--secondary-color) !important; /* Yellow button */
    color: #222 !important; /* Dark text for contrast */
}
.dialog-btn-primary:hover, .dialog-btn-primary:focus {
    background-color: #ffe066 !important; /* Slightly darker yellow on hover */
    color: #222 !important; /* Keep text dark for contrast */
    opacity: 1 !important;
}
/* If background is primary-color, text should be secondary-color */
.dialog-btn-primary.reverse {
    background-color: var(--primary-color) !important;
    color: var(--secondary-color) !important;
}
.dialog-btn-primary.reverse:hover, .dialog-btn-primary.reverse:focus {
    background-color: #357ab8 !important; /* Slightly darker primary on hover */
    color: var(--secondary-color) !important;
    opacity: 1 !important;
}
/* ===================== END FEEDBACK MODAL CONTINUE BUTTON HOVER CONTRAST FIX ===================== */

/* ===================== FEEDBACK MODAL CONTINUE BUTTON STRONG CONTRAST ===================== */
.dialog-btn-primary {
    background-color: var(--primary-color) !important; /* Default: primary background */
    color: var(--secondary-color) !important; /* Default: secondary text */
}
.dialog-btn-primary:hover, .dialog-btn-primary:focus {
    background-color: var(--secondary-color) !important; /* Hover: secondary background */
    color: var(--primary-color) !important; /* Hover: primary text */
    opacity: 1 !important;
}
/* ===================== END FEEDBACK MODAL CONTINUE BUTTON STRONG CONTRAST ===================== */

/* ==========================================================================
   Direct Game Link Styles
   ========================================================================== */
.direct-game-link-container {
    position: relative;
    margin-top: auto;
    padding: var(--spacing);
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.direct-game-link-btn {
    width: 100%;
    background-color: transparent;
    color: var(--white-color);
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.3);
}

.direct-game-link-btn:hover {
    background-color: rgba(255, 152, 0, 0.1);
    border-color: #ffb74d;
    box-shadow: 0 0 12px rgba(255, 152, 0, 0.5);
    transform: translateY(-1px);
}

.direct-game-link-btn:active {
    transform: translateY(0);
    box-shadow: 0 0 6px rgba(255, 152, 0, 0.4);
}

/* ==========================================================================
   Join Event Button Styles
   ========================================================================== */
/* Join Event button follows standard button hover pattern with reduced padding
   for better mobile experience and consistent styling with other app buttons */
.join-event-section {
    position: relative;
    margin-top: auto;
    padding: var(--spacing);
    width: 100%;
    text-align: center;
}

.join-event-button {
    width: 100%;
    max-width: 300px;
    background-color: var(--primary-color);
    color: var(--white-color);
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 auto;
}

/* Standard button hover effect: opacity change and subtle upward movement */
.join-event-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.join-event-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.join-event-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.join-event-icon {
    font-size: 18px;
    line-height: 1;
}

.join-event-text {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Responsive adjustments for join event button */
@media screen and (max-width: 480px) {
    .join-event-button {
        max-width: 280px;
        padding: 8px 16px;
        font-size: 15px;
    }
    
    .join-event-icon {
        font-size: 16px;
    }
    
    .join-event-text {
        font-size: 15px;
    }
}

/* Dark theme adjustments for join event button */
@media (prefers-color-scheme: dark) {
    .join-event-button {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .join-event-button:hover {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    }
}

/* ==========================================================================
   Empty State Styles
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 300px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    color: var(--textDark-color);
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.empty-state p {
    color: var(--textLight-color);
    font-size: 16px;
    margin: 0 0 24px 0;
    line-height: 1.5;
    max-width: 300px;
}

.empty-state-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.empty-state-actions .btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.empty-state-actions .btn-primary {
    background-color: var(--primary-color);
    color: var(--white-color);
}

.empty-state-actions .btn-primary:hover {
    background-color: var(--primaryDark-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.empty-state-actions .btn-primary:active {
    transform: translateY(0);
}

/* Responsive adjustments for empty state */
@media (max-width: 480px) {
    .empty-state {
        padding: 32px 16px;
        min-height: 250px;
    }
    
    .empty-state-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }
    
    .empty-state h3 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .empty-state p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .empty-state-actions .btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* ==========================================================================
   Version Update Notification Styles
   ========================================================================== */

#version-update-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

#version-update-notification.show {
    opacity: 1;
    visibility: visible;
}

.update-notification-content {
    background-color: var(--white-color);
    border-radius: var(--border-radius);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease-in-out;
}

#version-update-notification.show .update-notification-content {
    transform: scale(1);
}

.update-notification-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.update-notification-icon i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.update-notification-text {
    color: var(--text-color);
}

.update-notification-title {
    font-size: 20px;
    font-weight: var(--header-font-weight);
    margin-bottom: 8px;
    color: var(--textDark-color);
}

.update-notification-subtitle {
    font-size: 16px;
    color: var(--textLight-color);
    line-height: 1.4;
}

.update-notification-details {
    margin-top: 8px;
    font-size: 14px;
    color: var(--textLight-color);
    opacity: 0.8;
    line-height: 1.3;
}

/* Mobile responsive adjustments for version notification */
@media (max-width: 480px) {
    .update-notification-content {
        padding: 24px 20px;
        margin: 20px;
    }
    
    .update-notification-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }
    
    .update-notification-title {
        font-size: 18px;
        margin-bottom: 6px;
    }
    
    .update-notification-subtitle {
        font-size: 14px;
    }
}

/* Dark theme support for version notification */
@media (prefers-color-scheme: dark) {
    .update-notification-content {
        background-color: #2d2d2d;
        color: var(--white-color);
    }
    
    .update-notification-title {
        color: var(--white-color);
    }
    
    .update-notification-subtitle {
        color: #b0b0b0;
    }
}

