:root {
    --active-color: #187634;
    --background-color: #081116;
    --panel-color: #09151b;
    --divider-color: #244250;
    --line-color: #7d8a90;
    --text-color: #e7e7e7;
    --muted-color: #687178;
    --heading-color: #9baee9;
    --icon-color: #fefefe;
    --icon-active-color: #1c963f;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: #111;
    font-family: Arial, Helvetica, sans-serif;
}

button {
    font: inherit;
}

body {
    display: grid;
    place-items: center;
    padding: 16px;
}

.medical-menu {
    width: min(100%, 1200px);
    aspect-ratio: 1043 / 733;
    display: grid;
    grid-template-rows: 4.5% 6% minmax(0, 54.5%) 2% minmax(0, 33%);
    overflow: hidden;
    color: var(--text-color);
    background: var(--background-color);
    border: 1px solid #1e323c;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.7rem;
    background: var(--active-color);
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    font-weight: 700;
}

.topbar button {
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    font-size: 1.2em;
    cursor: pointer;
}

.medical-header {
    display: grid;
    grid-template-columns: 34% 33% 33%;
    align-items: center;
    border-bottom: 1px solid var(--line-color);
}

.medical-header h1,
.medical-header h2,
.patient-name {
    margin: 0;
    padding: 0 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
    font-size: clamp(0.7rem, 2.1vw, 1.35rem);
    font-weight: 400;
}

.medical-main {
    display: grid;
    grid-template-columns: 34% 33% 33%;
    min-height: 0;
}

.treatment-panel,
.body-panel,
.overview-panel {
    min-width: 0;
    min-height: 0;
    background: var(--panel-color);
}

.treatment-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0.4rem 0.75rem;
}

.category-navigation {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    align-items: center;
    gap: clamp(0.1rem, 0.55vw, 0.45rem);
    width: 100%;
}

.category-button {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background-color: var(--icon-color);
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
    cursor: pointer;
}

.category-button:hover,
.category-button:focus-visible {
    background-color: var(--icon-color);
    outline: none;
}

.category-button.is-active,
.category-button.is-active:hover,
.category-button.is-active:focus-visible {
    background-color: var(--icon-active-color);
}


.category-area {
    position: relative;
    min-height: clamp(3.1rem, 7vw, 4.9rem);
}

.category-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    width: max-content;
    max-width: min(22rem, calc(100vw - 16px));
    padding: 0.35rem 0.55rem;
    color: var(--text-color);
    background: rgba(3, 7, 9, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.6);
    font-size: clamp(0.65rem, 1.2vw, 0.82rem);
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 80ms linear, visibility 80ms linear;
}

.category-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.treatment-list {
    min-height: 0;
    padding-top: 0.35rem;
}



.treatment-content {
    padding: 0.55rem 0.25rem;
    color: var(--muted-color);
    text-align: center;
    font-size: clamp(0.55rem, 1.25vw, 0.82rem);
}

.body-panel {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    padding-top: 0.25rem;
}

.body-image {
    display: grid;
    place-items: center;
    min-height: 0;
    overflow: hidden;
}

.body-stage {
    position: relative;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    isolation: isolate;
}

.body-background,
.body-outline,
.body-part {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.body-background {
    object-fit: contain;
    z-index: 1;
}

.body-part {
    /* Blutverlust hat Vorrang. Nur bei Blutverlust-Stufe 0 wird Damage gezeigt. */
    --part-color: #fefefe;
    background-color: var(--part-color);
    -webkit-mask: var(--part-mask) center / contain no-repeat;
    mask: var(--part-mask) center / contain no-repeat;
    z-index: 2;
    transition: background-color 180ms linear;
}

.body-outline {
    display: none;
    object-fit: contain;
    z-index: 5;
}

.body-outline.is-active {
    display: block;
}

.selected-part {
    padding: 0.3rem;
    text-align: center;
    background: #020506;
    font-size: clamp(0.7rem, 1.8vw, 1.1rem);
}

.overview-panel {
    padding: clamp(0.5rem, 1.5vw, 1rem);
    font-size: clamp(0.55rem, 1.3vw, 0.9rem);
}

.overview-panel p {
    margin: 0 0 0.4em;
}

.overview-panel strong {
    display: block;
    margin-bottom: 0.4em;
}

.overview-panel .muted {
    color: var(--muted-color);
}

.horizontal-divider {
    background: var(--divider-color);
}

.medical-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
}

.activity-panel,
.quick-view-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    padding: 0 0.75rem;
}

.activity-panel {
    border-right: 1px solid var(--line-color);
}

.medical-footer h3 {
    margin: 0;
    padding: 0.35rem 0 0.2rem;
    color: var(--heading-color);
    border-bottom: 1px solid var(--line-color);
    text-align: center;
    font-size: clamp(0.65rem, 1.7vw, 1rem);
    font-weight: 400;
}

.panel-content {
    min-height: 0;
    overflow: auto;
}

@media (max-width: 650px) {
    body {
        padding: 0;
    }

    .medical-menu {
        width: 100%;
        border-inline: 0;
    }

    .treatment-panel,
    .overview-panel,
    .activity-panel,
    .quick-view-panel {
        padding-inline: 0.35rem;
    }
}

/*
 * Bildpfade gehören hier in die CSS-Datei. Relative url()-Pfade werden
 * relativ zu assets/css/style.css aufgelöst, deshalb beginnt der Pfad mit ../img.
 */
.category-button[data-category="triage"] {
    --icon: url("../img/categories/triage_card.png");
}
.category-button[data-category="examine"] {
    --icon: url("../img/categories/examine_patient.png");
}
.category-button[data-category="bandage"] {
    --icon: url("../img/categories/bandage_fracture.png");
}
.category-button[data-category="medication"] {
    --icon: url("../img/categories/medication.png");
}
.category-button[data-category="airway"] {
    --icon: url("../img/categories/airway_management.png");
}
.category-button[data-category="advanced"] {
    --icon: url("../img/categories/advanced_treatment.png");
}
.category-button[data-category="plate"] {
    --icon: url("../img/categories/plate.png");
}
.category-button[data-category="carry"] {
    --icon: url("../img/categories/carry.png");
}
.category-button[data-category="toggle_to_self"] {
    --icon: url("../img/categories/toggle_to_self.png");
}

.body-part[data-part="head"] {
    --part-mask: url("../img/body/parts/head.png");
}
.body-part[data-part="torso"] {
    --part-mask: url("../img/body/parts/torso.png");
}
.body-part[data-part="arm_left"] {
    --part-mask: url("../img/body/parts/arm_left.png");
}
.body-part[data-part="arm_right"] {
    --part-mask: url("../img/body/parts/arm_right.png");
}
.body-part[data-part="leg_left"] {
    --part-mask: url("../img/body/parts/leg_left.png");
}
.body-part[data-part="leg_right"] {
    --part-mask: url("../img/body/parts/leg_right.png");
}

/* Kategorie-Zustände */
.category-button:disabled,
.category-button.is-disabled {
    background-color: #4a5054;
    cursor: default;
    opacity: 0.55;
}

.category-button:disabled:hover,
.category-button:disabled:focus-visible,
.category-button.is-disabled:hover,
.category-button.is-disabled:focus-visible {
    background-color: #4a5054;
}

.category-button.is-active:not(:disabled) {
    background-color: var(--icon-active-color);
}

/* Optionen innerhalb einer Kategorie */
.treatment-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.15rem 0;
    color: var(--text-color);
}

.treatment-option {
    width: 100%;
    min-height: 1.55rem;
    padding: 0.12rem 0.35rem;
    color: #ffffff;
    background: #000000;
    border: 0;
    border-bottom: 0;
    box-shadow: none;
    opacity: 1;
    cursor: pointer;
    text-align: center;
    font-size: clamp(.58rem, 1.3vw, .9rem);
}

.treatment-option:hover,
.treatment-option:focus-visible {
    color: #000000;
    background: #ffffff;
    outline: none;
    border: 0;
    box-shadow: none;
}

.treatment-empty {
    padding: 0.55rem 0.25rem;
    color: var(--muted-color);
    text-align: center;
    font-size: clamp(0.55rem, 1.25vw, 0.82rem);
}

.category-button.is-disabled { opacity: .28; cursor: default; }
.body-equipment { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; z-index:4; pointer-events:none; display:none; }
.body-equipment.is-visible { display:block; }
.log-line { padding:.11rem .35rem; color:#f3f3f3; font-size:clamp(.5rem,1.05vw,.72rem); line-height:1.22; white-space:normal; }
.status-treatment { margin:0 0 .25em !important; font-weight:700; }
.status-chest-seal { color:#efe200; }
.status-fast-io { color:#4c984c; }
.status-critical { color:#ff2020; font-weight:700; }
#injuryStatus p { margin:0 0 .25em; }
.panel-content { padding-top:.25rem; }

/* Torso equipment colours (centrally adjustable) */
:root {
    --equipment-aed-color: #2f99f5;
    --equipment-chest-seal-color: #efe200;
    --equipment-fast-io-color: #4c984c;
}
.body-equipment[data-equipment="aedPads"] { --equipment-color: var(--equipment-aed-color); }
.body-equipment[data-equipment="chestSeal"] { --equipment-color: var(--equipment-chest-seal-color); }
.body-equipment[data-equipment="fastIO"] { --equipment-color: var(--equipment-fast-io-color); }

/* Triage history: compact, non-interactive treatment usage list. */
.triage-history-line {
    display: block;
    padding: 1px 10px;
    color: #fff;
    background: transparent;
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
}
