/* === Base Reset === */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #0c1e29;
    color: white;
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Top Bar === */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #142735;
    padding: 10px 15px;
    color: #fff;
    z-index: 100;
    position: relative;
    flex: none;
}

.site-name {
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 5px #ffcc00;
}

.back-button, .logout-button {
    background: #ffcc00;
    padding: 6px 12px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    color: black;
    border-radius: 4px;
}

.back-button:hover, .logout-button:hover {
    background: #ffa500;
}

/* === Game Layout === */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 5px;
}

/* === Game Area === */
.game-area {
    position: relative;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #001f3f;
    padding: 5px 0;
    overflow: hidden;
    border: 4px solid #ffcc00;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.8);
}

/* Arena Background - Subtle Grid Effect */
canvas {
    width: 95%;
    max-width: 600px;
    aspect-ratio: 4 / 3;
    background: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, 0.8),
        rgba(0, 0, 0, 0.8) 10px,
        rgba(10, 25, 40, 0.8) 10px,
        rgba(10, 25, 40, 0.8) 20px
    );
    border: 5px solid #ffcc00;
    box-shadow: 0 0 25px rgba(255, 204, 0, 0.6);
    border-radius: 8px;
}


/* === Mobile Controls - Always Visible === */
.mobile-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    z-index: 10;
}

.mobile-controls button {
    width: 50px;
    height: 50px;
    font-size: 22px;
    background: #ffcc00;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    color: black;
}

.mobile-controls button:active {
    background: #ffa500;
}

.vertical-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* === Side Panel - Leaderboard Area === */
.side-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: #1b3a4b;
    padding: 5px 0;
    overflow-y: auto;
}

.leaderboard {
    width: 90%;
    max-width: 360px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 14px;
}

h3 {
    margin: 0 0 4px;
    font-size: 14px;
    color: #ffcc00;
    text-transform: uppercase;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
}

li {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px;
    margin-bottom: 2px;
    border-radius: 3px;
}

/* === Mobile Layout === */
@media (max-width: 768px) {
    .side-panel {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
        padding: 5px 0;
        gap: 5px;
        background: #142735;
    }

    .leaderboard {
        flex: 1;
        max-width: 30%;
        min-width: 80px;
        padding: 4px;
        font-size: 12px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        text-align: center;
        border-radius: 5px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .leaderboard h3 {
        font-size: 12px;
        margin: 0;
        text-transform: uppercase;
        color: #ffcc00;
    }

    .leaderboard ul,
    .leaderboard p {
        display: none; /* Hide detailed lists on mobile */
    }

    .leaderboard::after {
        content: attr(data-compact);
        font-weight: bold;
        color: white;
    }
}


@media (max-width: 768px){
  .leaderboard::after{
    content: attr(data-compact);
    white-space: pre-line;   /* ✅ shows \n as new line */
    line-height: 1.25;
  }
}




/* === Larger Screens (Tablet/Desktop) === */
@media (min-width: 769px) {
    .game-container {
        flex-direction: row;
    }

    .game-area {
        flex: 3;
        justify-content: center;
        height: auto;
    }

    .side-panel {
        flex: 1;
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }

    .mobile-controls {
        display: none;
    }

    canvas {
        max-width: 600px;
    }

    .leaderboard {
        max-width: 250px;
        font-size: 14px;
    }
}

/* === Ultra-Small Phones (Fallback for old phones) === */
@media (max-height: 500px) {
    .game-area {
        height: 45vh;
    }

    canvas {
        width: 90%;
        height: auto;
    }

    .mobile-controls button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    h3, ul, li {
        font-size: 12px;
    }
}

@media (max-width: 450px) {
    .mobile-controls button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}


/* === Landscape Mode Tweaks === */
@media (max-width: 768px) and (orientation: landscape) {
    .game-area {
        height: 45vh;
    }

    canvas {
        max-height: 45vh;
    }

    .side-panel {
        flex-direction: row;
        justify-content: space-around;
        gap: 3px;
        flex-wrap: wrap;
    }

    .leaderboard {
        flex: 1;
        min-width: 100px;
        font-size: 12px;
    }

    .mobile-controls {
        order: 3;
        margin-top: 2px;
        padding-bottom: 3px;
    }
}





/* 🕒 Match Timer Display */
.match-timer {
    font-size: 22px;
    font-weight: bold;
    color: #ffcc00;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 10px;
    box-shadow: 0px 4px 10px rgba(255, 255, 255, 0.3);
}



/* 🔹 Top Navigation Bar */
.top-bar {
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 18px;
}

.top-bar a {
    color: #000000;
    text-decoration: none;
    margin: 0 15px;
    font-weight: bold;
}

.back-button {
    color: #ffcc00;
    text-decoration: none;
    font-weight: bold;
}

/* 🟡 Fix Balance Alignment */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;  /* Push to the right */
}













/* ALL FROM TOP BAR */
/* === 🌟 Top Bar Base === */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 15px 30px;
    position: relative;
    border-bottom: 3px solid #ffcc00;
    box-shadow: 0 5px 20px rgba(255, 204, 0, 0.3);
    flex-wrap: nowrap;
}

/* === 🟡 Centered Logo === */
.site-name-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.site-name-container a {
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Arial Black', sans-serif;
    color: #ffcc00;
    text-decoration: none;
    padding: 10px;
    border-radius: 5px;
    display: inline-block;
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ff9900;
    animation: glow-effect 2s infinite alternate;
    transition: transform 0.2s ease-in-out;
}

.site-name-container a:hover {
    transform: scale(1.1);
    text-shadow: 0 0 15px #ffcc00, 0 0 30px #ff9900;
}

/* === 🔙 Manage Account Button === */
.manage-account-button {
    background: #ffcc00;
    color: black;
    font-size: 16px;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

.manage-account-button:hover {
    background: #ff9900;
}

/* === 🔹 Top Bar Right Section === */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    white-space: nowrap;
}

/* === 💵 Deposit Button === */
.deposit-button {
    background: linear-gradient(45deg, #ffcc00, #ff9900);
    color: black;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease-in-out;
}

.deposit-button:hover {
    background: linear-gradient(45deg, #ff9900, #ff6600);
    transform: scale(1.05);
}

/* === 💰 Balance Highlight === */
#balanceAmount {
    font-size: 18px;
    font-weight: bold;
    color: #00ff99;
    text-shadow: 0 0 5px rgba(0, 255, 153, 0.6);
}

/* === 🚪 Logout Button === */
.logout-button {
    background: red;
    color: white;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    transition: 0.3s;
}

.logout-button:hover {
    background: darkred;
}

/* === 👤 User Info Desktop === */
.user-info-desktop {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* === 📱 Mobile Avatar Dropdown === */
.user-info-avatar {
    position: relative;
    display: none;
}

.username-clickable {
    font-weight: bold;
    color: #ffcc00;
    cursor: pointer;
}

.user-dropdown {
    position: absolute;
    top: 110%;
    right: 0;
    background-color: white;
    color: #333;
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 6px;
    display: none;
    z-index: 1000;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dropdown-username,
.dropdown-balance {
    font-weight: bold;
    margin-bottom: 8px;
}

.dropdown-balance {
    color: #00cc66;
}

.dropdown-logout {
    color: red;
    font-weight: bold;
    text-decoration: none;
}

.dropdown-logout:hover {
    text-decoration: underline;
}

/* === 📱 Responsive Switch (Desktop <-> Mobile) === */
@media screen and (max-width: 1499px) {
    .user-info-desktop {
        display: none;
    }
    .user-info-avatar {
        display: block;
    }
}

/* === 🧠 Login/Register Buttons (Guest Mode) === */
.btn-primary,
.btn-success {
    font-size: 16px;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 6px;
    transition: 0.3s;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-success:hover {
    background: #28a745;
}

/* === 💡 Glowing Animation === */
@keyframes glow-effect {
    from {
        text-shadow: 0 0 10px rgba(255, 255, 0, 0.4);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 255, 0, 1);
    }
}

/* === 📱 Tablet/Mobile Fine-Tune === */
@media (max-width: 1024px) {
    .top-bar {
        flex-direction: row; /* ⬅️ Keep it horizontal */
        flex-wrap: nowrap;   /* ⬅️ Don't wrap to new lines */
        align-items: center;
        justify-content: space-between;
    }

    .top-bar-right {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        margin-top: 0;
    }

    .manage-account-button {
        margin-bottom: 0;
    }

    .site-name-container {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0;
    }
}



@media (max-width: 768px) {
    .top-bar-right {
        gap: 6px;
        font-size: 0.85rem;
    }

    .manage-account-button {
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .deposit-button, .logout-button {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}




/* 🏆 Winner Announcement Popup (copied from 2-coin pool) */
#winnerOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Semi-transparent */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.winner-popup {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.4);
    animation: fadeIn 0.5s ease-in-out;
}

.winner-popup h1 {
    font-size: 50px;
    color: #ffcc00;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.winner-popup p {
    font-size: 25px;
    color: #333;
    margin: 20px 0;
}

.winner-popup button {
    background: #ffcc00;
    color: black;
    font-size: 20px;
    font-weight: bold;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.3s;
}

.winner-popup button:hover {
    background: #ff9900;
}

/* 🟢 Fade-in Effect */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
