/* Body and canvas */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f7fa;
    color: #222;
    margin: 0;
    padding: 0;
}

/* Flex container for canvas and UI */
#mainLayout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    margin-top: 32px;
}

/* Canvas styling for flex layout */
#gameWorld {
    margin: 0;
    flex: 1 1 auto;
    max-width: 70vw;
    height: auto;
}

/* UI floats right of canvas */
#ui {
    max-width: 560px;
    margin: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 10px;
    flex: 0 0 560px;
    position: sticky;
    top: 16px;
}

/* Panels lay their fieldsets out side-by-side and wrap. */
.panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 10px;
}
#controls {
    border-radius: 8px;
    background-color: lavenderblush;
    padding: 10px;
}

/* Tabs */
#tabs {
    display: flex;
    gap: 4px;
    margin: 8px 0;
}
#tabs .tab {
    flex: 1 1 auto;
    margin-top: 0;
    padding: 8px 6px;
    font-size: 0.9rem;
    background: #cfd8dc;
    color: #37474f;
    border-radius: 6px 6px 0 0;
}
#tabs .tab.active {
    background: #4fc3f7;
    color: #fff;
}
#tabs .tab:hover {
    background: #b0bec5;
}
#tabs .tab.active:hover {
    background: #0288d1;
}

/* Each fieldset is a compact column inside a panel. */
fieldset {
    flex: 1 1 250px;
    min-width: 232px;
    background-color: lavenderblush;
    border: 1px solid #e0c0cc;
    border-radius: 6px;
    margin: 0;
    padding: 5px 9px 7px;
}
fieldset legend {
    font-weight: 600;
    font-size: 0.82rem;
    color: #d32f2f;
    padding: 0 5px;
}

#runName {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    border-radius: 6px;
    background-color: rgb(252, 225, 234);
    color: #d32f2f;
    text-align: center;
}

/* Compact label/input rows inside the panels. */
.panel label {
    display: inline-block;
    width: 152px;
    font-size: 0.74rem;
    font-weight: 500;
    color: #455a64;
    text-align: right;
    margin: 0 5px 3px 0;
    vertical-align: middle;
}
.panel input[type="number"] {
    width: 56px;
    border: 1px solid #b0bec5;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.76rem;
    margin: 0 0 3px 0;
    box-sizing: border-box;
    vertical-align: middle;
}
.panel select {
    max-width: 150px;
    font-size: 0.76rem;
    padding: 2px 4px;
    margin: 0 0 3px 0;
    vertical-align: middle;
}
.panel input[type="checkbox"] {
    accent-color: #4fc3f7;
    margin: 0 0 3px 0;
    vertical-align: middle;
}

/* Button styling */
button {
    background: #4fc3f7;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}
button:hover {
    background: #0288d1;
}

/* Database status indicator */
.db-status {
    border: 1px solid #000;
    background-color: darkgrey;
    text-align: center;
    border-radius: 6px;
}
.db-connected {
    background-color: lightgreen;
}
.db-disconnected {
    background-color: lightcoral;
}

/* Responsive for smaller screens */
@media (max-width: 900px) {
    #mainLayout {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }
    #ui {
        max-width: 100%;
        width: 100%;
        position: static;
        margin-top: 24px;
    }
    #gameWorld {
        max-width: 100vw;
    }
}
