/* Bridge Champ Platform color palette */
:root {
    --primary-blue: #2055c8;
    --primary-green: #50C878;
    --primary-orange: #FF6B6B;
    --primary-purple: #9B59B6;
    --primary-pink: #FF69B4;
    --accent-yellow: #FFD93D;
    --accent-cyan: #00D4FF;
    --gradient-1: linear-gradient(135deg, #2055c8 0%, #1a4aa0 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #2055c8 0%, #1a4aa0 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(32, 85, 200, 0.4);
}

@media (orientation: portrait) {
body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: black;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

}

@media (orientation: landscape) {
body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: black;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


.table-container {
    /* Set size relative to the viewport's smaller dimension (vmin) */
    width: 100%;
    height: auto; /* Height will be set by JavaScript to fit content */
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 15px;
    box-sizing: border-box;
    background: rgb(244,244,244);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(255, 255, 255, 0.3);
    /* Center the container within the viewport */
    margin: auto;
    /* Ensure it's centered by flexbox parent */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
    /* Allow container to grow to fit content - no clipping */
    overflow: visible;
    min-height: fit-content;
    /* Initially invisible until grid is rendered */
    opacity: 0;
    visibility: hidden;
    position: relative; /* Required for ::before pseudo-element background */
    z-index: 20;
}

.table-container.grid-rendered {
    opacity: 1;
    visibility: visible;
}

.table-container:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 50px rgba(255, 255, 255, 0.4);
}

.table-container table {
    width: 100%; /* Table fills the container */
    height: 100%; /* Table fills the container */
    border-collapse: collapse;
    border-spacing: 0; /* Remove any gaps between rows/columns */
    table-layout: fixed; /* Helps with consistent column sizing */
    background: rgb(244,244,244);
    position: relative; /* Required for ::before pseudo-element background */
    z-index: 21;
}

.table-container th, .table-container td {
    border-left: 2px solid rgba(32, 85, 200, 0.3);
    border-right: 2px solid rgba(32, 85, 200, 0.3);
    border-top: none;         /* Remove top border to eliminate gaps between rows */
    border-bottom: none;      /* Remove bottom border to eliminate gaps between rows */
    padding: 0px;
    margin: 0px;
    text-align: left;
    text-overflow: ellipsis; /* Handle overflowing content */
    word-wrap: break-word;
    overflow-wrap: break-word; /* Allow words to break and wrap */
    white-space: normal; /* Allow text to wrap to multiple lines */
    /* font-size will be set by JavaScript per cell, don't set to 0 here */
    background: transparent;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    line-height: 0; /* Remove line-height spacing that causes gaps between rows */
    vertical-align: top; /* Align cells to top to prevent baseline spacing */
    overflow: visible; /* Allow text to wrap and be visible */
    z-index: 10;
}

/* Add top border to first row and bottom border to last row for outer grid */
.table-container tr:first-child th,
.table-container tr:first-child td {
    border-top: 2px solid rgba(32, 85, 200, 0.3);
}

.table-container tr:last-child th,
.table-container tr:last-child td {
    border-bottom: 2px solid rgba(32, 85, 200, 0.3);
}

.table-container tr {
    line-height: 0; /* Remove line-height spacing on rows */
    margin: 0;
    padding: 0;
}

.table-container th:hover, .table-container td:hover {
    background: rgba(32, 85, 200, 0.3);
    border-color: rgba(32, 85, 200, 1);
    border-width: 3px;
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(32, 85, 200, 0.5), 
                0 0 20px rgba(32, 85, 200, 0.4),
                inset 0 0 15px rgba(255, 255, 255, 0.3);
    filter: brightness(1.15);
    z-index: 15;
}

.table-container img{
    display: block;           /* Allow margin auto to work */
    margin: 0;                /* Remove ALL margins including vertical */
    padding: 0;               /* Remove any padding */
    width: 100%;              /* Fill cell width completely */
    height: 100%;             /* Fill cell height completely */
    object-fit: cover;        /* Cover the cell while maintaining aspect ratio */
    z-index: 10;
    vertical-align: top;      /* Align to top to prevent baseline spacing */
    position: absolute;       /* Position absolutely to fill cell completely */
    top: 0;
    left: 0;
}

/* Tick images: fill the cell as much as possible while maintaining aspect ratio */
.table-container img.tick-image {
    width: 100%;
    height: 100%;
    object-fit: contain;      /* Fit entirely within the cell without cropping */
}

/* Border layer dissolve transition */
.cell-border-layer {
    transition: opacity 1.2s ease-out;
}

/* Bottom hidden menu bar for nn.html */
.bottom-menu {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 10vh;                    /* Bottom 10% of the screen */
    background-color: rgba(0, 0, 0, 0.7);
    transform: translateY(100%);     /* Hidden below the viewport initially */
    transition: transform 0.25s ease-out;
    z-index: 900;
}

.bottom-menu.bottom-menu--visible {
    transform: translateY(0);        /* Slide up into view */
}

/* Advert rectangle below the table - matches table width and position */
.ad-rectangle {
    position: fixed;
    bottom: 0;
    left: auto;
    width: auto;
    top: auto;
    box-sizing: border-box;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 255, 0.9) 100%);
    backdrop-filter: blur(10px);
    color: #2C3E50;
    font-weight: 700;
    font-size: 2vmin;
    z-index: 100;
    border-top: 3px solid rgba(32, 85, 200, 0.3);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

/* Left vertical vibrant progress bar */
.left-progress-bar {
    position: fixed;
    left: 0;
    bottom: 0; /* Will be adjusted by JavaScript to align with table bottom */
    width: 2.5vw;
    height: 80vh; /* Default height, will be adjusted by JavaScript */
    background: linear-gradient(
        to top,
        rgba(255, 107, 107, 0.3),
        rgba(255, 217, 61, 0.1)
    );
    border-radius: 0 20px 20px 0;
    overflow: hidden;
    box-shadow: var(--shadow-md), 0 0 20px rgba(255, 107, 107, 0.3);
    z-index: 800;
    margin: 0;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(5px);
}

/* Actual progress fill inside the left bar (grows upward) */
.left-progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(
        to top,
        #FF6B6B,
        #FF8E8E,
        #FFB3B3,
        #FFD93D
    );
    border-radius: 18px 18px 0 0;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.5s ease;
    box-shadow: 0 -4px 20px rgba(255, 107, 107, 0.5), inset 0 2px 10px rgba(255, 255, 255, 0.3);
    overflow: visible; /* Allow rocket to be visible */
}

/* Rocket inside progress bar */
.progress-rocket {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5vmin;
    z-index: 805;
    pointer-events: none;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: rocketFloat 2s ease-in-out infinite;
}

@keyframes rocketFloat {
    0%, 100% {
        transform: translateX(-50%) translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateX(-50%) translateY(-3px) rotate(5deg);
    }
}

/* Rocket trail effect */
.progress-rocket::after {
    content: '✨';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1vmin;
    opacity: 0.7;
    animation: trailSparkle 1s ease-in-out infinite;
}

@keyframes trailSparkle {
    0%, 100% {
        opacity: 0.7;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.2);
    }
}

/* Right vertical vibrant progress bar */
.right-progress-bar {
    position: fixed;
    right: 0;
    bottom: 0; /* Will be adjusted by JavaScript to align with table bottom */
    width: 2.5vw;
    height: 80vh; /* Default height, will be adjusted by JavaScript */
    background: linear-gradient(
        to top,
        rgba(74, 144, 226, 0.3),
        rgba(0, 212, 255, 0.1)
    );
    border-radius: 20px 0 0 20px;
    overflow: hidden;
    box-shadow: var(--shadow-md), 0 0 20px rgba(74, 144, 226, 0.3);
    z-index: 800;
    margin: 0;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(5px);
}

/* Actual progress fill inside the right bar (grows upward, starts at 0%) */
.right-progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(
        to top,
        #4A90E2,
        #6BA3E8,
        #8CB6EE,
        #00D4FF
    );
    border-radius: 18px 18px 0 0;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.5s ease;
    box-shadow: 0 -4px 20px rgba(74, 144, 226, 0.5), inset 0 2px 10px rgba(255, 255, 255, 0.3);
    overflow: visible; /* Allow rocket to be visible */
}

/* Vibrant gold progress bar for winner (on loser's device) */
.left-progress-fill.winner-gold {
    background: linear-gradient(
        to top,
        #FFD700,
        #FFED4E,
        #FFF176,
        #FFEB3B
    ) !important;
    box-shadow: 0 -4px 30px rgba(255, 215, 0, 0.8), inset 0 2px 15px rgba(255, 255, 255, 0.5) !important;
    animation: goldGlow 2s ease-in-out infinite;
}

.right-progress-fill.winner-gold {
    background: linear-gradient(
        to top,
        #FFD700,
        #FFED4E,
        #FFF176,
        #FFEB3B
    ) !important;
    box-shadow: 0 -4px 30px rgba(255, 215, 0, 0.8), inset 0 2px 15px rgba(255, 255, 255, 0.5) !important;
    animation: goldGlow 2s ease-in-out infinite;
}

@keyframes goldGlow {
    0%, 100% {
        box-shadow: 0 -4px 30px rgba(255, 215, 0, 0.8), inset 0 2px 15px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow: 0 -4px 40px rgba(255, 215, 0, 1), inset 0 2px 20px rgba(255, 255, 255, 0.7);
    }
}

/* Flash animation for opponent win */
@keyframes opponentWinFlash {
    0%, 100% {
        box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
        transform: scale(1);
    }
    25% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
        transform: scale(1.05);
    }
    50% {
        box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
        transform: scale(1);
    }
    75% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
        transform: scale(1.05);
    }
}

.right-progress-bar.opponent-won-flash {
    animation: opponentWinFlash 0.5s ease-in-out 6; /* Flash 6 times over 3 seconds */
}

/* Landscape mode: Position progress bars side by side on the left */
@media (orientation: landscape) {
    .right-progress-bar {
        right: auto;
        /* left position will be set dynamically by JavaScript */
    }
    
    /* Landscape mode: Position ad rectangle to the right of grid */
    .ad-rectangle {
        top: auto;
        bottom: auto;
        height: auto; /* Will be set by JavaScript to match grid height */
        border-top: none;
        border-left: 3px solid rgba(32, 85, 200, 0.3);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    }
}

/* Percentage labels above each progress bar */
.progress-percent-label {
    position: absolute;
    top: -35px; /* Position above the progress bar */
    left: 50%;
    transform: translateX(-50%);
    font-size: 2vmin;
    font-weight: 800;
    color: #2C3E50;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.6);
    pointer-events: none;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Trophy icon above progress bars (below percentage label) */
.progress-trophy {
    position: absolute;
    top: -60px; /* Position above percentage label */
    left: 50%;
    transform: translateX(-50%);
    font-size: 3vmin;
    z-index: 803;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(255, 215, 0, 1), 0 0 20px rgba(255, 215, 0, 0.6);
    animation: trophyPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.5));
}

@keyframes trophyPulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.1);
    }
}

/* Medal icon above progress bars (for duel winners, below percentage label) */
.progress-medal {
    position: absolute;
    top: -60px; /* Position above percentage label */
    left: 50%;
    transform: translateX(-50%);
    font-size: 3.5vmin;
    z-index: 804;
    pointer-events: none;
    text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.8);
    animation: medalPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 6px 12px rgba(255, 215, 0, 0.7));
}

@keyframes medalPulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.15);
    }
}

/* Vertical text label inside the left progress bar */
.left-progress-label-vertical {
    position: absolute;
    top: 20px;             /* Start from the top with small padding */
    left: 50%;
    transform: translateX(-50%);
    writing-mode: vertical-rl;  /* Stack letters vertically, first letter at top */
    text-orientation: upright;   /* Keep letters upright (not rotated) */
    white-space: nowrap;
    font-weight: bold;
    color: #000;
    background-color: transparent;
    z-index: 802;          /* Above the fill but inside the bar */
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9), 0 0 3px rgba(255, 255, 255, 0.9);
    pointer-events: none;
    font-size: calc(1.2vmin + 2px);
    line-height: 1.2;      /* Spacing between letters */
}

/* Vertical text label inside the right progress bar */
.right-progress-label-vertical {
    position: absolute;
    top: 20px;             /* Start from the top with small padding */
    left: 50%;
    transform: translateX(-50%);
    writing-mode: vertical-rl;  /* Stack letters vertically, first letter at top */
    text-orientation: upright;   /* Keep letters upright (not rotated) */
    white-space: nowrap;
    font-weight: bold;
    color: #000;
    background-color: transparent;
    z-index: 802;          /* Above the fill but inside the bar */
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9), 0 0 3px rgba(255, 255, 255, 0.9);
    pointer-events: none;
    font-size: calc(1.2vmin + 2px);
    line-height: 1.2;      /* Spacing between letters */
}

/* "Wins" label below the name (vertical text) */
.progress-wins-label {
    position: absolute;
    top: 80px;             /* Position below the name */
    left: 50%;
    transform: translateX(-50%);
    writing-mode: vertical-rl;  /* Stack letters vertically, first letter at top */
    text-orientation: upright;   /* Keep letters upright (not rotated) */
    white-space: nowrap;
    font-weight: bold;     /* Bold text */
    color: #000;           /* Black color */
    background-color: transparent;
    z-index: 802;          /* Above the fill but inside the bar */
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9), 0 0 3px rgba(255, 255, 255, 0.9);
    pointer-events: none;
    font-size: calc(1.0vmin + 2px);
    line-height: 1.2;      /* Spacing between letters */
}

@media (orientation: portrait) {
.overlay {
      position: absolute; /* Positions this image relative to the container */
    margin: 0;
    display:flexbox;
    justify-content: center;
    align-items: center;
    width: 90vmin; /* Ensure body takes full viewport height */
    height: auto; /* 'auto' allows aspect-ratio to control height */
    aspect-ratio: 4 / 3; /* Maintain a 4:3 aspect ratio */
    background-color: white;
   /*  overflow: hidden;  Hide potential scrollbars from body margins */
    align-self: center;
    margin-left: auto;
    margin-right: auto;   
    background-color: white;
    padding: 20px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Ensure it appears above other content */ 
}

/* Override for game question overlays created by showOverlay */
.overlay.showoverlay-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: white !important; /* Default white, will be changed to black for "Smashing" via JavaScript */
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Overlay button container */
.overlay-button-container {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10002;
    pointer-events: none;
}

/* Thick arrow buttons */
.overlay-arrow-btn {
    background: rgba(32, 85, 200, 0.9);
    border: 5px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 40px;
    font-weight: 900;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.overlay-arrow-btn:hover {
    background: rgba(26, 74, 160, 0.9);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.overlay-arrow-btn:active {
    transform: scale(0.95);
}

/* Center buttons (help and refresh) */
.overlay-center-btn {
    background: rgba(32, 85, 200, 0.9);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.overlay-center-btn:hover {
    background: rgba(26, 74, 160, 0.9);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.overlay-center-btn:active {
    transform: scale(0.95);
}

.overlay-help-btn {
    font-size: 28px;
}

.overlay-refresh-btn {
    font-size: 26px;
}

.overlay-dynamicImage {
   /*  position: relative;  Positions this image relative to the container */
position: absolsute; 
top: 100px;
       width: 80vh;       /* Make the image take up the full width of the div */
    height: auto;      /* Make the image take up the full height of the div */
    aspect-ratio: 4/3;
    object-fit: fill;    /* Optional: Center the image within the container */
    object-position: center; 
        z-index: 10001
}
}

@media (orientation: landscape) {
.overlay{
    position: absolute; /* Positions this image relative to the container */
    margin: 0;
    display:flexbox;
top: 20px;

    height: 100vmin; /* Ensure body takes full viewport height */
    width: auto; /* 'auto' allows aspect-ratio to control height */
    aspect-ratio: 4 / 3; /* Maintain a 4:3 aspect ratio */
     background-color: white;
     /* overflow: hidden; Hide potential scrollbars from body margins */
     text-align: center;
    align-self: center;
    margin-left: auto;
    margin-right: auto;
    background-color: white;
    padding: 20px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Ensure it appears above other content */

    .overlay-dynamicImage {
   /*  position: relative;  Positions this image relative to the container */
position: absolsute; 
top: 200px;
     text-align: center;
    align-self: center;
    margin-left: auto;
    margin-right: auto;

    height: 80vh;      /* Make the image take up the full height of the div */
           width: auto;       /* Make the image take up the full width of the div */
    aspect-ratio: 4/3;
    object-fit: fill;    /* Optional: Center the image within the container */
    object-position: center; 
        z-index: 10001
}
}


}

.overlay-dynamicImage {
   /*  position: relative;  Positions this image relative to the container */
position: absolsute; 
       width: auto;       /* Make the image take up the full width of the div */
    height: 80vh;      /* Make the image take up the full height of the div */
    aspect-ratio: 4/3;
    object-fit: fill;    /* Optional: Center the image within the container */
    object-position: center; 
        z-index: 10001
}

.ddd {
display: block;  
margin-left: auto; 
margin-right: auto;
    transform: translate(-50%, -50%); 
    z-index: 2; /* Ensures the overlay image is on top */
    display: block; /* Initially hides the image */
    pointer-events: none;
    /* Add desired width/height for the overlay image */
    width: 100%;
    height: auto; 
    object-fit: cover;
}


    #fadingDiv {
        position: absolute; /* Positions this image relative to the container */   
        opacity: 0; /* Start hidden */
        transition: opacity 1s ease-in-out; /* Smooth transition for opacity changes */
        pointer-events: none;
        background-color: transparent;
        top: 5%;
        left: 50%;
        text-align: center;
        background-position: center;
        font-size:  36;
    }   

    

    .fade-in {
        opacity: 1;
    }

    .fade-out {
        opacity: 0;
    }

#customAlertOverlay {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top of everything */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    background-color: rgba(0,0,0,0.5); /* Black background with opacity */
    justify-content: center;
    align-items: center;
}

#customAlertBox {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 30px;
    border: 3px solid rgba(32, 85, 200, 0.3);
    border-radius: 20px;
    width: 80%;
    max-width: 400px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(102, 126, 234, 0.2);
    text-align: center;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#customAlertHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

#customAlertTitle {
    font-weight: bold;
    font-size: 1.2em;
}

#customAlertClose {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
}

#customAlertBody {
    margin-bottom: 20px;
}

#customAlertFooter button {
    padding: 10px 20px;
    cursor: pointer;
}

/* Settings Dialog Overlay */
.settings-overlay {
    display: none; /* Hidden by default, shown only when Settings=yes */
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 20px 0;
}

.settings-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 30px;
    padding-bottom: 40px; /* Extra padding at bottom to ensure footer is accessible */
    border: 3px solid rgba(32, 85, 200, 0.3);
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(102, 126, 234, 0.2);
    overflow-y: auto;
    overflow-x: hidden;
    margin: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: slideInFromTop 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

@keyframes slideInFromTop {
    from {
        transform: translateY(-100vh);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.settings-box:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 50px rgba(32, 85, 200, 0.3);
}

.settings-header {
    border-bottom: 2px solid #ddd;
    padding-bottom: 15px;
    margin-bottom: 20px;
    position: relative;
}

.settings-up-arrow {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(32, 85, 200, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 20px;
    color: rgba(32, 85, 200, 0.8);
    user-select: none;
}

.settings-up-arrow:hover {
    background: rgba(32, 85, 200, 0.2);
    border-color: rgba(32, 85, 200, 0.8);
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(32, 85, 200, 0.4);
}

.settings-up-arrow:active {
    transform: translateX(-50%) scale(0.95);
}

.settings-header h2 {
    margin: 0;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2em;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.settings-body {
    margin-bottom: 20px;
}

.settings-group {
    margin-bottom: 20px;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.settings-group input[type="text"],
.settings-group input[type="email"],
.settings-group input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(32, 85, 200, 0.3);
    border-radius: 10px;
    font-size: 1em;
    box-sizing: border-box;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.settings-group input[type="text"]:focus,
.settings-group input[type="email"]:focus,
.settings-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1), var(--shadow-sm);
    transform: translateY(-1px);
}

.settings-group input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.settings-group label:has(input[type="checkbox"]),
.settings-group label:has(input[type="radio"]) {
    display: flex;
    align-items: center;
    font-weight: normal;
    margin-bottom: 0;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.radio-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.duel-mode-group {
    background: linear-gradient(135deg, rgba(32, 85, 200, 0.1) 0%, rgba(26, 74, 160, 0.1) 100%);
    padding: 20px;
    border-radius: 16px;
    border: 2px solid rgba(32, 85, 200, 0.3);
    box-shadow: var(--shadow-sm);
}

.duel-mode-group h3 {
    margin-top: 0;
    margin-bottom: 15px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.4em;
    font-weight: 700;
}

/* Vibrant duel buttons */
.duel-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
}

.duel-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.duel-button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
}

.duel-button:hover::before {
    left: 100%;
}

.duel-button:active {
    transform: translateY(0) !important;
}

#duelIdInput:focus {
    outline: none;
    border-color: var(--primary-blue) !important;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-1px);
}

/* Disabled duel mode styling */
.duel-mode-disabled {
    opacity: 0.5;
    background-color: #e0e0e0 !important;
    pointer-events: none;
    cursor: not-allowed;
}

.duel-mode-disabled h3 {
    color: #999 !important;
}

.duel-mode-disabled label {
    color: #999 !important;
    cursor: not-allowed;
}

.duel-mode-disabled input[type="email"],
.duel-mode-disabled input[type="radio"] {
    cursor: not-allowed;
    opacity: 0.6;
}

.game-description {
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.15) 0%, rgba(0, 212, 255, 0.15) 100%);
    padding: 20px;
    border-radius: 12px;
    border-left: 5px solid var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

.game-description p {
    margin: 8px 0;
    color: #333;
    line-height: 1.5;
}

.game-description p:first-child {
    margin-top: 0;
}

.game-description p:last-child {
    margin-bottom: 0;
}

.settings-footer {
    border-top: 2px solid #ddd;
    padding-top: 15px;
    padding-bottom: 10px; /* Extra padding to ensure button is accessible */
    text-align: center;
    position: relative; /* Ensure footer stays in flow */
}

.start-button {
    background: var(--gradient-4);
    color: white;
    padding: 14px 45px;
    border: none;
    border-radius: 12px;
    font-size: 1.3em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md), 0 4px 15px rgba(32, 85, 200, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.start-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 6px 20px rgba(32, 85, 200, 0.6);
}

.start-button:hover::before {
    left: 100%;
}

.start-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
    .settings-box {
        width: 95%;
        padding: 20px;
        padding-bottom: 30px; /* Ensure footer is accessible on small screens */
        margin: 20px 10px; /* Reduce horizontal margin on small screens */
    }
    
    .settings-header h2 {
        font-size: 1.5em;
    }
    
    .start-button {
        width: 100%;
        padding: 15px;
    }
    
    /* Ensure settings overlay allows scrolling */
    .settings-overlay {
        padding: 10px 0;
        align-items: flex-start; /* Align to top to allow scrolling */
    }
}

/* Portrait mode adjustments for settings box */
@media (orientation: portrait) {
    .settings-box {
        margin: 10px;
        padding: 15px;
        padding-bottom: 25px; /* Ensure footer is accessible in portrait */
    }
    
    .settings-overlay {
        align-items: flex-start;
        padding: 10px 0;
    }
}

/* Confetti container - full screen overlay */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
    display: none; /* Hidden by default, shown when progress reaches 100% */
}

/* Confetti pieces */
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--confetti-color, #FF6B6B);
    top: -10px;
    left: var(--confetti-left, 50%);
    opacity: 0.9;
    animation: confettiFall var(--confetti-duration, 3s) linear forwards;
    border-radius: 2px;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Confetti shapes - circles */
.confetti-piece.circle {
    border-radius: 50%;
}

/* Confetti shapes - triangles */
.confetti-piece.triangle {
    width: 0;
    height: 0;
    background: transparent;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 10px solid var(--confetti-color, #FF6B6B);
}

/* Confetti shapes - stars */
.confetti-piece.star {
    background: transparent;
    font-size: 12px;
    line-height: 1;
    color: var(--confetti-color, #FF6B6B);
}

/* Rain container for loser animation */
.rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10001;
    overflow: hidden;
    display: none; /* Hidden by default, shown when opponent wins */
}

/* Rain drop */
.rain-drop {
    position: absolute;
    width: 2px;
    height: 20px;
    background: linear-gradient(to bottom, rgba(74, 144, 226, 0.8), rgba(74, 144, 226, 0.3));
    top: -20px;
    left: var(--rain-left, 50%);
    opacity: 0.7;
    animation: rainFall 2s linear forwards;
    border-radius: 0 0 2px 2px;
}

/* Rain fall animation - 2 seconds */
@keyframes rainFall {
    0% {
        transform: translateY(0);
        opacity: 0.7;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0.3;
    }
}
