.habitability-ui {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.help-text {
    margin-top: 6px;
}

.habitability-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.85em;
}

.habitability-group {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-right: 12px;
    border-right: 1px solid #aaa;
}

.habitability-buttons {
    display: inline-flex;
    gap: 4px;
}

.habitability-group:last-child {
    border-right: none;
    padding-right: 0;
}

.habitability-value {
    min-width: 32px;
    text-align: center;
    font-weight: bold;
}

.habitability-button {
    padding: 2px 6px;
    border: 1px solid #666;
    background: #eee;
    cursor: pointer;
    font-weight: bold;
}

.habitability-button:disabled {
    opacity: 0.45;
    cursor: default;
}

.habitability-ignored-row .habitability-controls {
    opacity: 0.7;
}

.habitability-points {
    font-size: 0.85em;
    color: #b34700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.habitability-summary th {
    text-align: left;
}

.habitability-total {
    font-weight: bold;
}

.habitability-total.over-budget {
    color: #cc3333;
}

.habitability-total.under-budget {
    color: #008800;
}

.habitability-total::after {
    content: " / " attr(data-budget);
    color: inherit;
}

.habitability-errors {
    margin-bottom: 6px;
}

.habitability-range {
    color: #666;
    font-size: 0.85em;
}

.env-bar {
    flex: 1;
    height: 12px;
    background: linear-gradient(to right,
        #400000 0%,
        #00ff00 50%,
        #400000 100%);
    border: 1px solid #404040;
    position: relative;
    margin: 0 8px 0 0;
    cursor: grab;
    touch-action: none;
}

.habitability-ui .env-bar {
    flex: 0 0 auto;
    width: 100%;
}

.env-bar.dragging {
    cursor: grabbing;
}

.env-bar.habitability-ignored {
    cursor: default;
}

.env-range {
    position: absolute;
    top: 1px;
    bottom: 1px;
    background: rgba(0, 170, 0, 0.25);
    border: 1px solid #00aa00;
    clip-path: polygon(0 50%, 6px 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 6px 100%);
}

.env-marker {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    background-color: #ffffff;
    border: 1px solid #000000;
    transform: translate(-50%, -50%) rotate(45deg);
}

.env-marker.habitable {
    background-color: #00ff00;
}

.env-marker.uninhabitable {
    background-color: #ff3333;
}

@media (pointer: coarse) {
    .env-bar {
        height: 24px;
        border-width: 2px;
    }

    .env-range {
        top: 2px;
        bottom: 2px;
        border-width: 2px;
    }

    .env-marker {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
    .create-race,
    .onboarding {
        font-size: 15px;
    }

    .create-race .columns,
    .onboarding .columns {
        padding: 0 6px 10px 6px;
    }

    .create-race .panel-scrollable-text,
    .onboarding .panel-scrollable-text,
    .create-game .panel-scrollable-text {
        padding: 8px 10px;
    }

    .create-race .profile-table th,
    .onboarding .profile-table th {
        width: 100%;
        display: block;
        text-align: left !important;
        padding: 6px 0 2px 0;
    }

    .create-race .profile-table td,
    .onboarding .profile-table td {
        width: 100%;
        display: block;
        padding: 0 0 8px 0;
    }

    .create-game .profile-table th {
        width: 100%;
        display: block;
        text-align: left !important;
        padding: 6px 0 2px 0;
    }

    .create-game .profile-table td {
        width: 100%;
        display: block;
        padding: 0 0 8px 0;
    }

    .create-race .profile-table tr,
    .onboarding .profile-table tr,
    .create-game .profile-table tr {
        border-bottom: none !important;
    }

    .create-race .profile-table tr + tr th,
    .onboarding .profile-table tr + tr th,
    .create-game .profile-table tr + tr th {
        border-top: 1px solid #eee !important;
    }

    .habitability-ui {
        gap: 4px;
    }

    .habitability-controls {
        gap: 6px;
        font-size: 0.85em;
        flex-wrap: wrap;
    }

    .habitability-group {
        padding-right: 8px;
    }

}

.brython .habitability-field {
    display: none;
}

.brython .env-inputs {
    display: none;
}

.create-race .columns.single-column {
    max-width: 800px;
    margin: 0 auto;
    grid-template-columns: minmax(324px, 1fr);
    width: 100%;
}

.create-game .columns.single-column {
    max-width: 800px;
    margin: 0 auto;
    grid-template-columns: minmax(324px, 1fr);
    width: 100%;
}

.colony-help .columns.single-column {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    grid-template-columns: minmax(324px, 1fr);
}

.create-race .column {
    width: 100%;
}

.create-game .column {
    width: 100%;
}

.create-race .panel-scrollable-text,
.onboarding .panel-scrollable-text,
.create-game .panel-scrollable-text {
    padding: 15px 20px;
    padding-top: 0;
}

.create-race .hint {
    padding-left: 16px;
    color: #666;
    font-size: 0.9em;
    line-height: 1.25;
}

.onboarding .hint {
    padding-left: 16px;
    color: #666;
    font-size: 0.9em;
    line-height: 1.25;
}

.race-type-description {
    display: none;
    margin-top: 8px;
    font-size: 0.95em;
    line-height: 1.35;
    color: var(--panel-text);
    opacity: 0.9;
}

.race-type-description.has-text {
    display: block;
}

.starting-tech-warning {
    display: none;
    margin-top: 3px;
    font-style: italic;
}

.ai-slot-editor-host {
    margin-top: 6px;
}

.ai-slot-editor-table {
    width: 100%;
    border-collapse: collapse;
}

.ai-slot-editor-table th,
.ai-slot-editor-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--panel-border, #999);
    text-align: left;
    vertical-align: middle;
}

.ai-slot-editor-table th {
    font-size: 0.9em;
    opacity: 0.9;
}

.ai-slot-editor-table th:nth-child(1),
.ai-slot-editor-table td:nth-child(1) {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    font-weight: bold;
    padding-left: 4px;
    padding-right: 4px;
}

.ai-slot-editor-table th:nth-child(4),
.ai-slot-editor-table td:nth-child(4) {
    width: 84px;
}

.ai-slot-editor-table th:nth-child(5),
.ai-slot-editor-table td:nth-child(5) {
    width: 24%;
    min-width: 130px;
}

.ai-slot-editor-table select,
.ai-slot-editor-table input[type="number"] {
    width: 100%;
    min-width: 0;
}

.create-race .hint.starting-tech-warning.form-errors,
.onboarding .hint.starting-tech-warning.form-errors {
    color: #cc3333;
}

body.lcars.create-race .hint.starting-tech-warning.form-errors,
body.lcars.onboarding .hint.starting-tech-warning.form-errors {
    color: var(--status-warning);
}

.create-race .profile-table th,
.create-race .profile-table td,
.onboarding .profile-table th,
.onboarding .profile-table td,
.create-game .profile-table th,
.create-game .profile-table td {
    border-bottom: none !important;
}

.help-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-slider {
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-label {
    min-width: 140px;
    font-weight: bold;
}

.help-value {
    min-width: 90px;
    text-align: right;
}

.help-results p {
    margin: 0 0 6px 0;
}

.help-results .help-results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.help-results .help-results-table th,
.help-results .help-results-table td {
    padding: 2px 0;
}

.help-results .help-results-table th.env-label {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.help-results .help-results-table td.detail-value {
    text-align: right;
}

.growth-graph {
    width: 100%;
    max-width: 420px;
    height: 140px;
    margin-top: 8px;
    color: #66aa66;
}

.env-inputs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.env-inputs label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.create-game .profile-table .number-stepper,
.create-race .profile-table .number-stepper,
.onboarding .profile-table .number-stepper {
    max-width: 100%;
}

.create-game .profile-table .number-stepper-input,
.create-race .profile-table .number-stepper-input,
.onboarding .profile-table .number-stepper-input {
    width: 7ch;
    min-width: 0;
}

.invite-token-widget {
    min-height: 38px;
    border: 1px solid var(--panel-content-border);
    padding: 4px 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: var(--panel-content-bg);
    color: var(--theme-text);
}

.invite-token-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.invite-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--panel-border);
    background: var(--panel-header-bg);
    color: var(--panel-header-text);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.9em;
}

.invite-chip-remove {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--theme-accent);
    font-size: 0.85em;
    line-height: 1;
    padding: 0;
}

.invite-token-input {
    min-width: 180px;
    flex: 1;
    border: none !important;
    outline: none;
    background: transparent;
    color: var(--theme-text);
}

.invite-suggestions {
    display: none;
    position: relative;
    margin-top: 4px;
    border: 1px solid var(--panel-content-border);
    background: var(--panel-content-bg);
    color: var(--theme-text);
    max-height: 180px;
    overflow-y: auto;
    z-index: 30;
}

.invite-suggestion {
    padding: 6px 8px;
    cursor: pointer;
}

.invite-suggestion:hover {
    background: var(--panel-header-bg);
    color: var(--panel-header-text);
}

/* Single-panel form/help/onboarding layout constraints.
 * Keep scrolling inside panel content only, never on page/columns.
 */
.single-panel-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden !important;
}

.single-panel-page .columns,
.single-panel-page .column {
    height: 100%;
    min-height: 0;
    overflow: hidden !important;
}

.single-panel-page .columns.single-column {
    max-width: 845px;
    margin: 0 auto;
    width: 100%;
}

.single-panel-page .panel-content.panel-stack {
    min-height: 30vh !important;
    max-height: 80vh !important;
    width: 100%;
    max-width: 845px;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
}

.single-panel-page.two-panel-page .panel-content.panel-stack {
    min-height: 0 !important;
    max-height: 40vh !important;
    max-height: 40dvh !important;
}
