/* REVAMED MANSION — ACT II FINALE — THE DEEP WELL */

.act2-deep-well {
    position: relative;
    min-height: max(620px, 100dvh);
    overflow-x: hidden;
    overflow-y: visible;
    padding: clamp(18px, 3vw, 34px);
    padding-bottom: calc(clamp(18px, 3vw, 34px) + env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 50% 90%, rgba(90, 130, 140, 0.12), transparent 42%),
        linear-gradient(180deg, #0a0f10 0%, #050807 55%, #020302 100%);
    color: #d9ece6;
}

.deep-well-shaft {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.deep-well-shaft-back {
    inset: 6% 12% 8%;
    border-radius: 50% / 8%;
    border: 1px solid rgba(130, 176, 168, 0.14);
    background:
        repeating-radial-gradient(circle at 50% 0%, rgba(255,255,255,0.02) 0 40px, transparent 40px 90px),
        linear-gradient(180deg, rgba(20, 34, 32, 0.6), rgba(2, 4, 3, 0.95));
    box-shadow: inset 0 0 140px rgba(0,0,0,0.85);
}

.deep-well-shaft-mid {
    inset: 30% 22% 0;
    background: linear-gradient(180deg, rgba(30, 52, 48, 0.15), rgba(0,0,0,0.9));
    clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
}

.deep-well-observation-deck {
    position: absolute;
    inset: 12% 4% auto;
    height: 10%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    opacity: 0.5;
}

.deep-well-observation-deck span {
    flex: 1;
    margin: 0 6px;
    border-top: 1px solid rgba(130, 176, 168, 0.3);
    border-left: 1px solid rgba(130, 176, 168, 0.15);
    border-right: 1px solid rgba(130, 176, 168, 0.15);
}

.deep-well-containment-gate {
    position: absolute;
    top: 14%;
    left: 50%;
    width: min(220px, 46%);
    height: 30%;
    transform: translateX(-50%);
    border: 3px solid rgba(150, 190, 182, 0.35);
    border-radius: 6px;
    background: repeating-linear-gradient(90deg, rgba(150,190,182,0.08) 0 6px, transparent 6px 22px);
    transition: transform 0.6s ease, opacity 0.6s ease;
    pointer-events: none;
}

.deep-well-containment-gate.is-open {
    transform: translateX(-50%) scaleX(0.4);
    opacity: 0.35;
}

.gate-claw-mark {
    position: absolute;
    width: 3px;
    height: 60%;
    top: 20%;
    background: rgba(220, 90, 70, 0.45);
    border-radius: 2px;
}

.gate-claw-mark.m1 { left: 30%; transform: rotate(8deg); }
.gate-claw-mark.m2 { left: 50%; transform: rotate(-4deg); }
.gate-claw-mark.m3 { left: 68%; transform: rotate(10deg); }

.deep-well-copy {
    position: relative;
    z-index: 3;
    max-width: 680px;
}

.deep-well-copy h3 {
    font-size: clamp(22px, 3vw, 30px);
    margin: 6px 0 10px;
    color: #eaf6f2;
}

.deep-well-copy p {
    line-height: 1.5;
    color: #b9d3cc;
}

.deep-well-console {
    position: relative;
    z-index: 3;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid rgba(130, 176, 168, 0.22);
    border-radius: 10px;
    background: rgba(6, 12, 11, 0.7);
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#deep-well-inspect {
    position: relative;
    touch-action: manipulation;
}

.deep-well-hint-text {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: rgba(150, 190, 182, 0.08);
    border: 1px dashed rgba(150, 190, 182, 0.3);
    font-size: 0.92rem;
    line-height: 1.45;
}

.deep-well-status {
    margin: 0;
    min-height: 1.4em;
    font-size: 0.98rem;
    color: #cfe6df;
}

.deep-well-power-panel,
.deep-well-cross-button,
.deep-well-evidence-button,
.deep-well-unlock-button {
    position: relative;
    z-index: 3;
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.deep-well-damper-zone {
    position: relative;
    z-index: 3;
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    max-width: 620px;
}

.damper-station {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(150, 190, 182, 0.2);
    background: rgba(8, 16, 14, 0.65);
    text-align: center;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.damper-station.is-open {
    border-color: rgba(220, 90, 70, 0.5);
}

.damper-station.is-partial {
    border-color: rgba(220, 180, 70, 0.5);
}

.damper-station.is-sealed {
    border-color: rgba(110, 220, 150, 0.55);
    box-shadow: 0 0 14px rgba(110, 220, 150, 0.15);
}

.damper-station.is-triggered {
    animation: deep-well-detect 0.9s ease;
}

@keyframes deep-well-detect {
    0%, 100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 3px rgba(220, 90, 70, 0.55); }
    60% { box-shadow: 0 0 0 1px rgba(220, 90, 70, 0.35); }
}

.damper-label {
    margin: 0 0 6px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9fc3ba;
}

.damper-station output {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.deep-well-return {
    position: relative;
    z-index: 3;
    margin-top: 18px;
}

.deep-well-complete-card {
    position: absolute;
    inset: 8% 6%;
    z-index: 8;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    padding: clamp(18px, 3vw, 32px);
    border-radius: 14px;
    border: 1px solid rgba(150, 190, 182, 0.3);
    background: rgba(4, 10, 9, 0.96);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.deep-well-complete-sub {
    font-size: 0.94rem;
    color: #a9c9c0;
}

/*
 * Mobile Deep Well authority:
 * index.html intentionally locks the document for cinematic screens and
 * shared .scene rules use a fixed 16:9 clipping model. The Deep Well is a
 * content-driven room, so while it is the active room we explicitly restore
 * vertical document scrolling and let this scene grow with its controls.
 */
@media (max-width: 480px) {
    html:has(#scene-deep-well:not([hidden])),
    body:has(#scene-deep-well:not([hidden])) {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    body:has(#scene-deep-well:not([hidden])) #game-screen {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    #scene-deep-well.act2-deep-well {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        max-height: none;
        aspect-ratio: auto;
        overflow-x: hidden;
        overflow-y: visible;
        padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
        touch-action: pan-y;
    }

    .deep-well-containment-gate { width: 70%; }
    .deep-well-damper-zone { grid-template-columns: repeat(2, 1fr); }
}
