body {
    font-family: "Trebuchet MS", Arial, sans-serif;
    margin: 0 5%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #222;
    color: #f0f0f0;
    /* Slightly bigger default font */
    font-size: 22px;
}

/* Mobile specific layout */
body.mobile #sidePanel,
body.mobile #rightPanel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 50px;
    background: rgba(0,0,0,0.95);
    overflow-y: auto;
    padding: 10px;
    z-index: 1000;
    flex-direction: column;
}

body.mobile #sidePanel.show,
body.mobile #rightPanel.show {
    display: flex;
}

#mobileMenu {
    display: none;
}

body.mobile #mobileMenu {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #333;
    padding: 5px 0;
    justify-content: space-around;
    z-index: 1100;
}

body.mobile #mobileMenu button {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
}

#mobileOverlay {
    display: none;
}

body.mobile #mobileOverlay.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 50px;
    background: rgba(0,0,0,0.7);
    z-index: 900;
}

body.mobile {
    margin: 0;
}
header {
    text-align: center;
    padding-top: 10px;
}
#menuBar {
    margin: 10px 0;
}
#menuBar input,
#menuBar select,
#menuBar button,
#menuBar a {
    margin-right: 4px;
    padding: 4px 6px;
    background: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 3px;
    text-decoration: none;
}
#menuBar button {
    cursor: pointer;
}
#mainContent {
    flex: 1;
    display: flex;
    width: 100%;
    justify-content: center;
}
#sidePanel {
    width: 15vw;
    max-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.card {
    background: rgba(0,0,0,0.7);
    padding: 8px;
    border-radius: 8px;
}
.cardTitle {
    text-align: center;
    font-weight: bold;
    margin-bottom: 6px;
}
.statLine {
    margin-bottom: 6px;
    font-weight: bold;
}
#playerList {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 17px;
}
#canvasContainer {
    display: flex;
    justify-content: center;
}
#rightPanel {
    width: 15vw;
    max-width: 220px;
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    gap: 10px;
}
#leaderboard {
    width: 100%;
    background: rgba(0,0,0,0.7);
    padding: 8px;
    border-radius: 5px;
    height: fit-content;
}
#roomStats {
    width: 100%;
}
.lbTitle {
    text-align: center;
    margin-bottom: 4px;
    font-weight: bold;
}
#leaderboard table {
    width: 100%;
    border-collapse: collapse;
    font-size: 17px;
}
#leaderboard th, #leaderboard td {
    padding: 2px 4px;
    border-bottom: 1px solid #666;
}
#leaderboard th {
    text-align: left;
}
#gameCanvas {
    border: 1px solid #333;
    background: #fafafa;
}
#towerList {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}
.towerOption {
    width: 72px;
    height: 72px;
    border: 1px solid #666;
    border-radius: 5px;
    margin: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #444;
    color: #fff;
}
.towerOption.selected {
    border-color: #2b6;
    background: #2b2;
}
.towerOption.locked {
    opacity: 0.4;
    position: relative;
}
.towerOption.locked::after {
    content: '🔒';
    position: absolute;
    top: 2px;
    right: 2px;
}
.towerCost {
    font-size: 17px;
    color: #ffd700;
}
#upgradeList {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.upgradeOption {
    border: 1px solid #666;
    margin: 4px 0;
    padding: 4px;
    font-size: 17px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #333;
    border-radius: 4px;
}
.upgradeOption button {
    margin-top: 2px;
    padding: 2px 6px;
    background: #555;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#speedControl {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.speedBtn {
    padding: 2px 6px;
    background: #555;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}
.speedBtn.selected {
    background: #2b2;
}

.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 17px;
    pointer-events: none;
    white-space: nowrap;
}

/* Responsive layout tweaks for smaller screens */
@media (max-width: 1000px) {
    body {
        margin: 0 2%;
        font-size: 18px;
    }
}

@media (max-width: 700px) {
    body {
        margin: 0 2%;
        font-size: 16px;
    }
    #menuBar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    #mainContent {
        flex-direction: column;
        align-items: center;
    }
    #sidePanel,
    #rightPanel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        margin-left: 0;
    }
    #canvasContainer {
        order: 2;
        width: 100%;
        margin: 10px 0;
    }
}
