* {
    box-sizing: border-box;
}

:root {
    --bg-dark: #050505;
    --panel: #171717;
    --text: #eeeeee;
    --danger: #e32636;
    --success: #00e676;
    --water-top: #38c8ff;
    --water-bottom: #0050a8;
    --cyan: #78d9ff;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 50% 15%, #292929 0, #111 38%, var(--bg-dark) 78%);
    color: var(--text);
    font-family: Arial, sans-serif;
    text-align: center;
}

body.danger {
    animation: dangerFlash .8s infinite;
}

body.game-success main {
    box-shadow:
        0 0 0 1px rgba(0,230,118,.18),
        0 24px 60px rgba(0,0,0,.7),
        0 0 34px rgba(0,230,118,.14);
}

body.game-failure main {
    box-shadow:
        0 0 0 1px rgba(255,60,60,.22),
        0 24px 60px rgba(0,0,0,.7),
        0 0 42px rgba(255,0,0,.18);
}

@keyframes dangerFlash {
    50% { background-color: #310000; }
}

.alarm {
    position: fixed;
    inset: 0 0 auto 0;
    height: 8px;
    z-index: 100;
    background: #720000;
    box-shadow: 0 0 18px rgba(255,0,0,.7);
    animation: alarm 1s infinite;
}

@keyframes alarm {
    50% {
        background: #ff2020;
        box-shadow: 0 0 28px rgba(255,0,0,1);
    }
}

main {
    width: min(920px, calc(100% - 24px));
    margin: 28px auto;
    padding: 28px;
    border: 1px solid #3b3b3b;
    border-radius: 20px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.04), rgba(0,0,0,.18)),
        #111;
    box-shadow:
        0 24px 60px rgba(0,0,0,.7),
        inset 0 1px 0 rgba(255,255,255,.06);
    transition: box-shadow .3s ease;
}

h1 {
    margin-top: 0;
    color: var(--danger);
    letter-spacing: 4px;
    text-shadow:
        0 0 8px rgba(255,0,0,.7),
        0 0 22px rgba(255,0,0,.25);
}

.status-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

#timer {
    display: inline-block;
    min-width: 190px;
    padding: 10px 20px;
    border: 2px solid #522;
    border-radius: 12px;
    background: #080808;
    color: #ff5757;
    font: 48px/1 monospace;
    box-shadow:
        inset 0 0 18px rgba(255,0,0,.15),
        0 0 14px rgba(255,0,0,.16);
}

#timer.timer-warning {
    color: #ffb74d;
    border-color: #754b16;
}

#timer.timer-critical {
    color: #fff;
    border-color: #ff3939;
    animation: timerCriticalPulse .65s ease-in-out infinite;
}

@keyframes timerCriticalPulse {
    50% {
        color: #ff5555;
        box-shadow:
            inset 0 0 22px rgba(255,0,0,.24),
            0 0 28px rgba(255,0,0,.34);
    }
}

button {
    position: relative;
    min-width: 92px;
    padding: 12px 16px;
    margin: 6px 4px;
    border: 1px solid #757575;
    border-bottom: 4px solid #090909;
    border-radius: 9px;
    background: linear-gradient(to bottom, #3a3a3a, #202020);
    color: white;
    font-weight: bold;
    cursor: pointer;
    box-shadow:
        0 5px 0 #090909,
        0 8px 14px rgba(0,0,0,.35),
        inset 0 1px 0 rgba(255,255,255,.13);
    transition:
        transform .08s ease,
        box-shadow .08s ease,
        background .15s ease,
        border-color .15s ease;
    touch-action: manipulation;
}

button:hover:not(:disabled) {
    background: linear-gradient(to bottom, #4b4b4b, #292929);
    border-color: #a0a0a0;
}

button:active:not(:disabled) {
    transform: translateY(5px);
    border-bottom-width: 1px;
    box-shadow:
        0 0 0 #090909,
        0 3px 7px rgba(0,0,0,.35),
        inset 0 2px 5px rgba(0,0,0,.5);
}

button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

button:disabled {
    opacity: .42;
    cursor: not-allowed;
    filter: grayscale(.65);
    box-shadow: none;
    transform: translateY(4px);
}

.sound-toggle {
    min-width: 112px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 13px;
    font-size: 13px;
}

.mission-objective {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    align-items: center;
    gap: 16px;
    width: min(700px,100%);
    margin: 22px auto 30px;
    padding: 16px 18px;
    text-align: left;
    border: 1px solid rgba(106,194,232,.52);
    border-left: 4px solid #5fd1ff;
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(95,209,255,.08), transparent 42%),
        linear-gradient(180deg, rgba(255,255,255,.035), rgba(0,0,0,.08)),
        #10171b;
}

.mission-objective-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid #4fbde9;
    border-radius: 50%;
    color: #8be3ff;
    font-size: 28px;
}

.mission-objective-label,
.canister-label,
.fill-status-label {
    display: block;
    color: var(--cyan);
    font-weight: bold;
    letter-spacing: 2px;
}

.mission-objective-label {
    margin-bottom: 4px;
    font-size: 12px;
}

.mission-objective-copy p {
    margin: 0;
    color: #dce8ed;
    font-size: 17px;
    line-height: 1.45;
}

.mission-objective-value {
    display: grid;
    grid-template-columns: auto auto;
    align-items: end;
    gap: 5px;
    min-width: 92px;
    padding: 8px 12px;
    border: 1px solid #557782;
    border-radius: 10px;
    background: #0a1114;
}

.mission-objective-value span {
    color: #f5fbff;
    font: bold 34px/1 monospace;
}

.mission-objective-value small {
    padding-bottom: 4px;
    color: #79d8fb;
    font-size: 11px;
    font-weight: bold;
}

.game {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    align-items: end;
    justify-content: center;
    gap: clamp(10px,3vw,32px);
    width: 100%;
}

.canister {
    width: min(250px,100%);
    padding: 20px 20px 18px;
    border: 1px solid #4a4a4a;
    border-radius: 18px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.055), transparent 35%),
        var(--panel);
    box-shadow:
        0 14px 30px rgba(0,0,0,.45),
        inset 0 1px 0 rgba(255,255,255,.07);
}

.canister-heading {
    margin-bottom: 14px;
}

.canister-label {
    margin-bottom: 4px;
    font-size: 11px;
}

.canister-heading h2 {
    margin: 0;
    color: #f3f9fc;
    font-size: 22px;
    letter-spacing: 1.2px;
}

.tank {
    position: relative;
    width: 145px;
    margin: 0 auto;
    overflow: hidden;
    border: 6px solid #8d9498;
    border-top-width: 9px;
    border-radius: 18px 18px 30px 30px;
    background: linear-gradient(90deg, #0b1014, #19232b 48%, #0a0f13);
    box-shadow:
        inset 0 0 24px rgba(0,0,0,.9),
        0 8px 18px rgba(0,0,0,.5);
}

.tank-5 { height: 245px; }
.tank-3 { height: 147px; margin-top: 98px; }

.tank::before {
    content: "";
    position: absolute;
    inset: 8px auto 8px 10px;
    width: 16px;
    z-index: 3;
    border-radius: 10px;
    background: linear-gradient(
        to right,
        rgba(255,255,255,.28),
        rgba(255,255,255,.03)
    );
    pointer-events: none;
}

.water {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background:
        linear-gradient(
            to bottom,
            rgba(84,218,255,.96),
            var(--water-top) 12%,
            var(--water-bottom) 70%,
            #003a78
        );
    box-shadow:
        inset 0 10px 14px rgba(255,255,255,.15),
        0 -4px 10px rgba(50,190,255,.35);
    transition: height .55s cubic-bezier(.2,.85,.25,1);
}

.water::before {
    content: "";
    position: absolute;
    top: -7px;
    left: -10%;
    width: 120%;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at center,
        #9be9ff 0,
        #39bfea 47%,
        #006fa7 75%
    );
    animation: waterWave 1.8s ease-in-out infinite;
}

@keyframes waterWave {
    0%,100% { transform: translateX(-2%) scaleY(.9); }
    50% { transform: translateX(2%) scaleY(1.08); }
}

.tank-scale {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.scale-mark {
    position: absolute;
    right: 0;
    width: 30px;
    border-top: 2px solid rgba(120,217,255,.72);
}

.scale-mark b {
    position: absolute;
    right: 34px;
    top: -8px;
    color: #9adff8;
    font: bold 11px/1 monospace;
}

.tank-5 .scale-1 { bottom: 20%; }
.tank-5 .scale-2 { bottom: 40%; }
.tank-5 .scale-3 { bottom: 60%; }
.tank-5 .scale-4 { bottom: 80%; }
.tank-3 .scale-1 { bottom: 33.333%; }
.tank-3 .scale-2 { bottom: 66.667%; }

.fill-status {
    width: min(160px,100%);
    margin: 13px auto 8px;
    padding: 8px 10px 9px;
    border: 1px solid rgba(91,143,163,.62);
    border-radius: 10px;
    background: #0c1418;
}

.fill-status-label {
    margin-bottom: 4px;
    font-size: 9px;
    letter-spacing: 1.6px;
}

.fill-status-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    font-family: monospace;
}

.fill-status-value strong {
    color: #f8fcff;
    font-size: 29px;
}

.fill-status-separator,
.fill-status-capacity {
    color: #aabac1;
    font-size: 18px;
    font-weight: 700;
}

.fill-status-value small {
    color: #79d8fb;
    font-size: 10px;
    font-weight: bold;
}

.canister-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.transfer-controls {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 112px;
    align-self: center;
}

.transfer-label {
    color: #b9c5cb;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1.8px;
}

.transfer-button {
    display: grid;
    place-items: center;
    width: 100px;
    min-width: 0;
    height: 58px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid #4da9d9;
    border-bottom: 5px solid #063b57;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(103,215,255,.28), rgba(0,87,133,.18)),
        #102832;
    color: #8ee8ff;
    font-size: 43px;
    text-shadow:
        0 0 9px rgba(54,207,255,.85),
        0 0 20px rgba(54,207,255,.38);
}



.action-counter {
    margin-top: 18px;
    color: #9bb3bd;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
}

.action-counter strong {
    color: #f4fbff;
    font: bold 16px/1 monospace;
}

#message {
    min-height: 46px;
    margin-top: 10px;
    font-size: 30px;
    font-weight: bold;
}

.message-success {
    color: var(--success);
    text-shadow: 0 0 12px rgba(0,255,102,.35);
}

.message-failure {
    color: #ff5b5b;
    text-shadow: 0 0 14px rgba(255,0,0,.35);
}

.post-game-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.solution-after-explosion,
.retry-button,
.restart {
    display: none;
}

.solution-after-explosion {
    border-color: #7bbbd3;
    background: linear-gradient(to bottom, #254857, #13252d);
}

.retry-button {
    border-color: #63a674;
    background: linear-gradient(to bottom, #285338, #163021);
}

.restart {
    border-color: #7a7070;
}

#intro,
#outro {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: black;
}

#intro {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#outro {
    display: none;
    z-index: 3000;
}

.intro-panel {
    position: relative;
    z-index: 2002;
    width: min(520px, calc(100% - 30px));
    padding: 40px;
    border: 2px solid #700;
    border-radius: 14px;
    background: radial-gradient(#222,#000);
}

#introVideo,
#outroVideo {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: auto;
    transform: translate(-50%,-50%);
    object-fit: contain;
}

#introVideo { z-index: 2001; }
#outroVideo { z-index: 3001; }

#skipIntro,
#skipOutro {
    position: absolute;
    right: 24px;
    bottom: 24px;
    z-index: 3003;
}

#solution {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3002;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at center, rgba(95,0,0,.30), transparent 45%),
        rgba(0,0,0,.90);
}

.solution-card {
    width: min(620px,100%);
    padding: 34px 28px 30px;
    border: 1px solid rgba(255,75,75,.65);
    border-radius: 18px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.055), transparent 34%),
        linear-gradient(180deg, #191919, #090909);
}

.solution-kicker {
    margin: 0 0 9px;
    color: #ff6767;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
}

.solution-card h2 {
    margin: 0;
    color: white;
    font-size: clamp(25px,5vw,39px);
    letter-spacing: 3px;
}

.code-display {
    display: flex;
    justify-content: center;
    gap: clamp(10px,3vw,22px);
    margin: 30px auto 24px;
}

.code-slot {
    display: grid;
    place-items: center;
    width: clamp(74px,20vw,118px);
    aspect-ratio: .78;
    border: 2px solid #686868;
    border-radius: 14px;
    background: #101010;
    color: white;
    font: bold clamp(52px,14vw,86px)/1 monospace;
}

.code-slot-empty {
    color: #777;
    border-style: dashed;
}

.code-slot-revealed {
    color: #ff4242;
    border-color: #ff3b3b;
    background: #170707;
    text-shadow:
        0 0 10px rgba(255,0,0,.9),
        0 0 30px rgba(255,0,0,.45);
}

.solution-hint {
    margin: 0;
    color: #c9c9c9;
    font-size: 16px;
}

.startup-error {
    position: fixed;
    inset: 20px;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    border: 2px solid #ff4141;
    border-radius: 14px;
    background: #1c0707;
    color: #fff;
    font: bold 18px/1.5 Arial,sans-serif;
}

@media (max-width: 600px) {
    main {
        width: calc(100% - 12px);
        margin: 12px auto;
        padding: 14px 8px 20px;
    }

    h1 {
        font-size: 23px;
        letter-spacing: 2px;
    }

    #timer {
        min-width: 155px;
        font-size: 36px;
    }

    .status-toolbar {
        gap: 8px;
    }

    .sound-toggle {
        min-width: 92px;
        padding: 9px 8px;
        font-size: 12px;
    }

    .mission-objective {
        grid-template-columns: auto minmax(0,1fr);
        gap: 11px;
        margin: 17px auto 20px;
        padding: 12px 11px;
    }

    .mission-objective-value {
        grid-column: 1 / -1;
        justify-self: center;
    }

    .game {
        grid-template-columns: minmax(0,1fr) 54px minmax(0,1fr);
        gap: 4px;
    }

    .canister {
        width: 100%;
        min-width: 0;
        padding: 12px 5px;
    }

    .canister-label {
        font-size: 9px;
    }

    .canister-heading h2 {
        font-size: 17px;
    }

    .tank {
        width: 94px;
        border-width: 4px;
        border-top-width: 7px;
    }

    .tank-5 { height: 170px; }
    .tank-3 { height: 102px; margin-top: 68px; }

    .scale-mark {
        width: 22px;
    }

    .scale-mark b {
        right: 25px;
        top: -7px;
        font-size: 9px;
    }

    .fill-status {
        width: calc(100% - 6px);
        padding: 7px 4px 8px;
    }

    .fill-status-value strong {
        font-size: 23px;
    }

    .canister-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .canister-actions button {
        width: calc(100% - 8px);
        margin: 4px;
        padding: 9px 6px;
        font-size: 12px;
    }

    .transfer-controls {
        min-width: 0;
        width: 54px;
        gap: 10px;
    }

    .transfer-label {
        font-size: 8px;
        letter-spacing: .6px;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
    }

    .transfer-button {
        width: 48px;
        height: 48px;
        padding: 0;
        font-size: 32px;
    }

    #message {
        font-size: 22px;
    }

    .solution-card {
        padding: 27px 14px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}


/* Spielstatistik und Aktionen direkt im Lösungsdialog */

.game-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 22px;
    margin-top: 18px;
}

.action-counter,
.best-counter {
    margin-top: 0;
    color: #9bb3bd;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
}

.action-counter strong,
.best-counter strong {
    margin-left: 4px;
    color: #f4fbff;
    font: bold 16px/1 monospace;
}

.best-counter strong {
    color: var(--cyan);
}

.solution-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.solution-actions button:first-child {
    border-color: #63a674;
    background: linear-gradient(to bottom, #285338, #163021);
}

.solution-actions button:last-child {
    border-color: #7a7070;
}

@media (max-width: 600px) {
    .game-stats {
        gap: 14px;
    }

    .action-counter,
    .best-counter {
        font-size: 9px;
        letter-spacing: 1px;
    }

    .solution-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .solution-actions button {
        width: 100%;
        margin: 3px 0;
    }
}


/* Dezente Umfüllanimation: Pfeilimpuls + Wasserreaktion */

.transfer-button.transfer-pulse {
    animation: transferButtonPulse .48s ease-out;
}

.water.water-transfer-out::before {
    animation: waterTransferOut .48s ease-out;
}

.water.water-transfer-in::before {
    animation: waterTransferIn .48s ease-out;
}

@keyframes transferButtonPulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    35% {
        transform: scale(.94);
        filter: brightness(1.45);
        box-shadow:
            0 2px 0 #052736,
            0 0 28px rgba(80,215,255,.55),
            inset 0 2px 7px rgba(0,0,0,.35);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes waterTransferOut {
    0% {
        transform: translateX(0) scaleY(1);
    }
    40% {
        transform: translateX(-4%) scaleY(.72);
    }
    75% {
        transform: translateX(3%) scaleY(1.15);
    }
    100% {
        transform: translateX(0) scaleY(1);
    }
}

@keyframes waterTransferIn {
    0% {
        transform: translateX(0) scaleY(1);
    }
    30% {
        transform: translateX(4%) scaleY(1.2);
    }
    65% {
        transform: translateX(-3%) scaleY(.86);
    }
    100% {
        transform: translateX(0) scaleY(1);
    }
}
