/* Main game interface = the image stage.
   Sized to the image's 16:9 aspect ratio (960×540), centered in the viewport.
   All children use percentage coordinates relative to this box. */
#mainInterface {
    display: none;
    position: absolute;
    /* Largest 16:9 rect that fits in the viewport */
    width:  min(100vw, calc(100vh * 960 / 540));
    height: min(100vh, calc(100vw * 540 / 960));
    left: 50%;
    top:  50%;
    transform: translate(-50%, -50%);
}

/* Background image fills the stage exactly */
#bgImage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    user-select: none;
}

/* Stage content — fixed at image's native resolution, scaled down uniformly by JS */
#stageContent {
    position: absolute;
    top: 0;
    left: 0;
    width: 960px;
    height: 540px;
    transform-origin: top left;
    /* scale set dynamically by stageScale.js */
}

.game-area {
    position: absolute;
    top: var(--game-area-y);
    left: var(--game-area-x);
    width: var(--game-area-width);
    height: var(--game-area-height);
    transform: scale(var(--game-area-scale));
    transform-origin: top left;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: auto;
}

/* Sidebar layout */
#panelPlayerCount {
    position: absolute;
    top: var(--player-count-y);
    left: var(--player-count-x);
    width: var(--player-count-width);
    height: var(--player-count-height);
    transform: scale(var(--player-count-scale));
    transform-origin: top left;
    overflow: hidden;
}

#panelAudio {
    position: absolute;
    top: var(--audio-y);
    left: var(--audio-x);
    width: var(--audio-width);
    height: var(--audio-height);
    transform: scale(var(--audio-scale));
    transform-origin: top left;
    overflow: hidden;
}

.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.audio-label {
    font-size: 11px;
    color: rgba(200, 220, 240, 0.65);
    width: 54px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.slider-wrap {
    position: relative;
    flex: 1;
    height: 14px;
    background: #1c1c1c;
}

/* Static decorative wedge — always full, bottom-left to top-right */
.slider-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #6a6a6a;
    clip-path: polygon(0 100%, 100% 0%, 100% 100%);
    pointer-events: none;
}

.slider-wrap input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

/* Transparent track so the wedge bg shows through */
.slider-wrap input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
    height: 14px;
}
.slider-wrap input[type="range"]::-moz-range-track {
    background: transparent;
    height: 14px;
    border: none;
}

/* Rectangle thumb – 2:1 (width:height) */
.slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 8px;
    height: 14px;
    background: #4d4d4d;
    border: 1px solid #aaa;
    border-radius: 2;
    cursor: pointer;
    margin-top: 0;
}
.slider-wrap input[type="range"]::-moz-range-thumb {
    width: 8px;
    height: 14px;
    background: #4d4d4d;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

#panelChat {
    position: absolute;
    top: var(--chat-y);
    left: var(--chat-x);
    width: var(--chat-width);
    height: var(--chat-height);
    transform: scale(var(--chat-scale));
    transform-origin: top left;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panelChat .chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#panelLobby {
    position: absolute;
    top: var(--lobby-y);
    left: var(--lobby-x);
    width: var(--lobby-width);
    height: var(--lobby-height);
    transform: scale(var(--lobby-scale));
    transform-origin: top left;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panelStatus {
    position: absolute;
    top: var(--status-y);
    left: var(--status-x);
    width: var(--status-width);
    height: var(--status-height);
    transform: scale(var(--status-scale));
    transform-origin: top left;
    display: flex;
    align-items: center;
    overflow: hidden;
}

#panelFaction {
    position: absolute;
    top: var(--faction-y);
    left: var(--faction-x);
    width: var(--faction-width);
    height: var(--faction-height);
    transform: scale(var(--faction-scale));
    transform-origin: top left;
    display: flex;
    align-items: center;
    overflow: hidden;
}

#panelBoardControls {
    position: absolute;
    top: var(--board-controls-y);
    left: var(--board-controls-x);
    width: var(--board-controls-width);
    height: var(--board-controls-height);
    transform: scale(var(--board-controls-scale));
    transform-origin: top left;
    display: flex;
    align-items: center;
    justify-content: left;
    overflow: hidden;
}

.sidebar-section {
    background: transparent;
    border-radius: 10px;
    padding: 15px;
    flex-shrink: 0;
}

/* Make chat and lobby sections flexible */
.sidebar-section.flexible {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-section h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #e0e0e0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.player-count {
    font-size: 1.1rem;
    margin: 0px 0;
    padding: 0px;
    background: transparent;
    border-radius: 8px;
}

/* Mobile layout — disabled during layout calibration */
/*
@media (max-width: 768px) {
    body.main-interface .main-interface {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    body.main-interface .container {
        padding: 10px;
    }
}
*/