* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    background-color: #f5f5dc;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    color: #5d4037;
}

body.is-fullscreen,
html:fullscreen,
body:fullscreen {
    background-color: #f5f5dc;
}

.main-container {
    height: 100dvh;
    max-height: 100dvh;
    width: 100%;
    padding: clamp(8px, 1.5vh, 18px);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
    justify-items: center;
    gap: clamp(6px, 1.2vh, 14px);
    text-align: center;
    transition: opacity 0.55s ease;
    overflow: hidden;
}

.main-container.is-hidden {
    opacity: 0;
    pointer-events: none;
}

html:fullscreen .main-container,
body:fullscreen .main-container {
    height: 100%;
    max-height: 100%;
    width: 100%;
}


.main-title {
    width: min(92vw, 820px);
    justify-self: center;
    margin: 0;
    font-size: clamp(1.05rem, 1.6vh + 0.55rem, 2rem);
    line-height: 1.2;
    max-width: 920px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.church-scene {
    --door-x: 50%;
    --door-y: 73%;
    --character-size: clamp(64px, 12vw, 168px);
    --mary-size: clamp(80px, 14vw, 220px);
    position: relative;
    width: min(95vw, 1120px, calc((100dvh - 11rem) * 16 / 10));
    max-height: min(calc(100dvh - 11rem), 72vh);
    height: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 0;
    align-self: center;
}

.church-building {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.church-building img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    opacity: 0.94;
    user-select: none;
    -webkit-user-drag: none;
}

.statue-mary {
    position: absolute;
    left: 6%;
    bottom: 10%;
    z-index: 4;
    width: var(--mary-size);
    transition: transform 0.3s ease;
}

.statue-mary img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.statue-mary:hover {
    transform: translateY(-8px) scale(1.03);
}

.character-group {
    position: absolute;
    left: 50%;
    bottom: 10%; /* move to bottom */
    transform: translateX(-50%);
    z-index: 7;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
}

.character {
    --x-shift: 0%;
    width: var(--character-size);
    cursor: pointer;
    transition:
        transform 0.25s ease,
        filter 0.25s ease;
    transform: translateX(var(--x-shift));
    transform-origin: center bottom;
    will-change: transform, opacity, filter;
}

.character-button {
    border: none;
    background: transparent;
    padding: 0;
}

.character-button:focus-visible {
    outline: 3px solid rgba(77, 156, 90, 0.9);
    outline-offset: 4px;
    border-radius: 6px;
}

.character-priest {
    --x-shift: -4%;
    margin-right: clamp(-14px, -2vw, -6px);
}

.character-nun {
    --x-shift: 4%;
    margin-left: clamp(-14px, -2vw, -6px);
}

.character:hover {
    transform: translateX(var(--x-shift)) translateY(-8px) scale(1.03);
    filter: saturate(1.04);
}

.character img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.character.is-entering {
    pointer-events: none;
}

.dialogue-box {
    margin-top: 0;
    width: 100%;
    background-color: #fffef8;
    border: 3px solid #d2b48c;
    border-radius: 20px;
    padding: clamp(8px, 1.4vh, 14px) clamp(14px, 2.5vw, 28px);
    max-width: none;
    max-height: min(22vh, 160px);
    overflow-y: auto;
    font-size: clamp(0.82rem, 1.5vh + 0.35rem, 1rem);
    font-weight: 600;
    box-shadow: 0 12px 26px rgba(93, 64, 55, 0.12);
    white-space: pre-line;
    line-height: 1.4;
}

.three-container {
    position: fixed;
    inset: 0;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.7s ease;
    background: #f5f5dc;
}

.three-container.is-active {
    opacity: 1;
    pointer-events: auto;
}

.three-container canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.liturgy-hud {
    position: fixed;
    left: 0;
    right: min(300px, 32vw);
    bottom: 8px;
    z-index: 140;
    padding: 0 10px;
    pointer-events: none;
    transform: translateY(12px);
    opacity: 0;
    transition:
        transform 0.35s ease,
        opacity 0.35s ease;
}


.church-exit-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 250;
    border: 1px solid rgba(150, 116, 86, 0.45);
    border-radius: 8px;
    background: rgba(255, 252, 248, 0.95);
    color: #5d4037;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(82, 58, 44, 0.12);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition:
        opacity 0.24s ease,
        transform 0.24s ease;
}

.church-exit-btn.is-active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.church-exit-btn:not(.is-active) {
    visibility: hidden;
}

.church-exit-btn:hover {
    background: #fff8f0;
    border-color: rgba(149, 109, 73, 0.55);
}

.game-fullscreen-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 251;
    border: 1px solid rgba(150, 116, 86, 0.45);
    border-radius: 8px;
    background: rgba(255, 252, 248, 0.95);
    color: #5d4037;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(82, 58, 44, 0.12);
    transition:
        opacity 0.24s ease,
        transform 0.24s ease,
        background 0.2s ease;
}

.game-fullscreen-btn:hover {
    background: #fff8f0;
    border-color: rgba(149, 109, 73, 0.55);
}

.game-fullscreen-btn.is-interior-only {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.game-fullscreen-btn.is-interior-only.is-active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

body:fullscreen .three-container,
body:fullscreen .three-container canvas {
    width: 100%;
    height: 100%;
}

body:fullscreen .mass-navigator.is-active {
    max-height: calc(100dvh - 24px);
}


.mass-navigator {
    position: fixed;
    top: 10px;
    right: 6px;
    z-index: 141;
    width: min(300px, 32vw);
    max-height: calc(100vh - 24px);
    padding: 8px 8px 6px;
    border-radius: 10px 0 0 10px;
    border: 1px solid rgba(150, 116, 86, 0.4);
    border-right: none;
    background: rgba(255, 252, 248, 0.94);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    box-shadow: -4px 8px 24px rgba(82, 58, 44, 0.12);
    opacity: 0;
    transform: translateX(8px);
    pointer-events: none;
    transition:
        opacity 0.28s ease,
        transform 0.28s ease;
}

.mass-navigator.is-active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.mass-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(173, 139, 110, 0.25);
}

.mass-nav-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #5d4037;
}

.mass-nav-mass-btn {
    border: 1px solid rgba(97, 149, 91, 0.55);
    border-radius: 6px;
    background: rgba(228, 248, 220, 0.95);
    color: #3e5f3a;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 4px 8px;
    cursor: pointer;
}

.mass-nav-mass-btn.is-active {
    background: rgba(255, 236, 220, 0.95);
    border-color: rgba(180, 120, 80, 0.55);
    color: #6d4c35;
}

.mass-nav-hint {
    margin: 6px 2px 0;
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(93, 64, 55, 0.65);
}

.mass-nav-group {
    border: 1px solid rgba(173, 139, 110, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    padding: 6px;
    margin-bottom: 7px;
}


.mass-nav-step-btn:hover {
    border-color: rgba(149, 109, 73, 0.55);
    transform: translateY(-1px);
}

.mass-nav-step-btn.is-active {
    border-color: rgba(97, 149, 91, 0.88);
    background: rgba(228, 248, 220, 0.96);
}

.mass-nav-step-btn.is-complete {
    border-color: rgba(120, 167, 121, 0.45);
    background: rgba(242, 252, 237, 0.82);
}

.mass-nav-part-btn {
    width: 100%;
    border: 1.4px solid rgba(156, 116, 76, 0.32);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.93);
    color: #5d4037;
    padding: 5px 8px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.79rem;
    font-weight: 800;
    cursor: pointer;
}

.mass-nav-part-btn small {
    font-size: 0.67rem;
    font-weight: 700;
    color: rgba(93, 64, 55, 0.78);
}

.mass-nav-groups {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mass-nav-step-list {
    margin: 0;
    padding: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mass-nav-step-btn {
    width: 100%;
    min-height: 0;
    text-align: left;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: 1.4px solid rgba(160, 121, 86, 0.28);
    background: rgba(255, 255, 255, 0.88);
    color: #5d4037;
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
    transition:
        border-color 0.14s ease,
        background 0.14s ease,
        transform 0.14s ease;
}

.mass-nav-label {
    display: block;
    width: 100%;
    white-space: normal;
    word-break: keep-all;
    text-align: left;
}

.mass-nav-part-btn {
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    min-height: 0;
    text-align: left;
}


.mass-step-list {
    margin: 0;
    padding: 5px 0 0;
    display: grid;
    gap: 4px;
}

.mass-nav-status {
    margin: 6px 2px 2px;
    font-size: 0.74rem;
    font-weight: 700;
    color: rgba(93, 64, 55, 0.84);
}

.mass-step-btn {
    width: 100%;
    text-align: left;
    border: 1.4px solid rgba(160, 121, 86, 0.28);
    background: rgba(255, 255, 255, 0.88);
    color: #5d4037;
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    gap: 7px;
    align-items: baseline;
    cursor: pointer;
    transition:
        border-color 0.14s ease,
        background 0.14s ease,
        transform 0.14s ease;
}

.mass-step-btn:hover,
.mass-nav-part-btn:hover {
    border-color: rgba(149, 109, 73, 0.55);
    transform: translateY(-1px);
}

.mass-step-btn.is-active,
.mass-nav-part-btn.is-active {
    border-color: rgba(97, 149, 91, 0.88);
    background: rgba(228, 248, 220, 0.96);
}

.mass-step-btn.is-complete,
.mass-nav-part-btn.is-complete {
    border-color: rgba(120, 167, 121, 0.45);
    background: rgba(242, 252, 237, 0.82);
}

.mass-step-order {
    min-width: 20px;
    font-size: 0.72rem;
    font-weight: 800;
    color: rgba(93, 64, 55, 0.72);
}

.mass-step-title {
    font-size: 0.74rem;
    line-height: 1.25;
    font-weight: 700;
}

.liturgy-hud.is-active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.liturgy-subtitle {
    margin: 0;
    width: 100%;
    max-width: 720px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(210, 180, 140, 0.5);
    font-weight: 600;
    font-size: clamp(0.78rem, 1.2vw, 0.92rem);
    text-align: left;
    color: #5d4037;
    box-shadow: 0 4px 14px rgba(82, 58, 44, 0.1);
}

.liturgy-controls {
    margin: 0 auto;
    width: min(1100px, 96vw);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 2px;
}

.control-btn {
    border: 1.5px solid rgba(156, 116, 76, 0.25);
    background: rgba(255, 255, 255, 0.84);
    border-radius: 10px;
    min-height: 52px;
    padding: 5px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition:
        transform 0.14s ease,
        border-color 0.14s ease,
        background-color 0.14s ease;
    color: #5d4037;
}

.control-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(156, 116, 76, 0.52);
}

.control-btn:active {
    transform: scale(0.97);
}

.control-btn.is-active {
    border-color: rgba(115, 157, 116, 0.8);
    background: rgba(233, 248, 223, 0.96);
}

.control-btn > span:first-child {
    font-size: 1.12rem;
    line-height: 1;
}

.control-label {
    font-size: 0.69rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.liturgy-help {
    width: min(1100px, 96vw);
    margin: 8px auto 0;
    font-size: clamp(0.7rem, 1.1vw, 0.82rem);
    text-align: center;
    color: rgba(93, 64, 55, 0.88);
}

.entry-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(
        circle at var(--zoom-x, 50%) var(--zoom-y, 50%),
        rgba(255, 250, 236, 0) 0%,
        rgba(255, 250, 236, 0.78) 68%,
        rgba(255, 250, 236, 1) 100%
    );
    transition: opacity 0.36s ease;
    z-index: 95;
}

.entry-flash.is-active {
    opacity: 1;
}

#entry-screen.is-entering-zoom #church-scene {
    transform-origin: var(--zoom-x, 50%) var(--zoom-y, 73%);
    animation: door-zoom-in 0.58s cubic-bezier(0.2, 0.84, 0.24, 1) forwards;
}

#entry-screen.is-entering-zoom .main-title,
#entry-screen.is-entering-zoom .entry-footer,
#entry-screen.is-entering-zoom .dialogue-box,
#entry-screen.is-entering-zoom .statue-mary {
    transition: opacity 0.34s ease;
    opacity: 0;
}

@keyframes door-zoom-in {
    0% {
        transform: scale(1);
        filter: blur(0);
    }
    70% {
        transform: scale(1.62);
        filter: blur(1px);
    }
    100% {
        transform: scale(1.95);
        filter: blur(2.5px);
    }
}

@media (max-width: 900px) {
    .church-scene {
        --door-y: 74%;
    }
}

@media (max-height: 720px) {
    
.entry-top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: min(92vw, 820px);
    max-width: calc(100% - 7rem);
    gap: 12px;
    position: relative;
    z-index: 2;
}

.entry-top-bar .main-title {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    text-align: center;
}

.main-title {
        font-size: clamp(0.95rem, 1.2vh + 0.45rem, 1.35rem);
    }

    .dialogue-box {
        max-height: min(18vh, 120px);
        padding: 8px 12px;
    }

    .entry-action-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 640px) {
    .church-scene {
        --door-y: 75%;
        --character-size: clamp(56px, 14vw, 120px);
        --mary-size: clamp(72px, 18vw, 140px);
        width: min(96vw, calc((100dvh - 10rem) * 16 / 10));
        max-height: min(calc(100dvh - 10rem), 58vh);
    }

    .statue-mary {
        left: 2%;
        bottom: 10%;
    }

    .character-group {
        bottom: 2.5%;
    }

    .liturgy-controls {
        grid-template-columns: repeat(4, minmax(68px, 1fr));
        max-height: 118px;
    }

    .mass-navigator.is-active {
        top: 48px;
        right: 4px;
        width: min(240px, 86vw);
        max-height: calc(100dvh - 56px);
    }

    .game-fullscreen-btn {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        font-size: 0.72rem;
        padding: 7px 10px;
    }

    .church-exit-btn {
        top: max(8px, env(safe-area-inset-top));
        left: max(8px, env(safe-area-inset-left));
    }
}


.hotspot-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(40, 28, 20, 0.45);
}

.hotspot-modal[hidden] {
    display: none;
}

.hotspot-modal-card {
    position: relative;
    width: min(420px, 92vw);
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px 18px 16px;
    border-radius: 10px;
    border: 1px solid rgba(150, 116, 86, 0.45);
    background: #fffdf8;
    box-shadow: 0 12px 32px rgba(50, 35, 25, 0.2);
}

.hotspot-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #5d4037;
}

.hotspot-modal-title {
    margin: 0 24px 8px 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: #4e342e;
}

.hotspot-modal-body {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: #5d4037;
    white-space: pre-wrap;
}

.character img {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(32vh, 260px);
    object-fit: contain;
    object-position: center bottom;
}


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

.entry-actions[hidden] {
    display: none !important;
}

.entry-action-btn {
    border: 2px solid #c45c26;
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    background: #fffef8;
    color: #5d4037;
    box-shadow: 0 8px 18px rgba(93, 64, 55, 0.12);
}

.entry-action-btn--yes {
    background: #4d9c5a;
    border-color: #3d7c48;
    color: #fffef8;
}

.entry-action-btn--yes:hover {
    filter: brightness(1.05);
}

.entry-action-btn--no:hover {
    background: #fff8f0;
}

.character.is-greeted {
    filter: saturate(1.08) drop-shadow(0 0 10px rgba(77, 156, 90, 0.45));
}

#entry-screen.is-entering-zoom .entry-actions {
    opacity: 0;
    pointer-events: none;
}


.entry-footer {
    width: min(92vw, 820px);
    max-width: calc(100% - 7rem);
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(6px, 1vh, 10px);
    flex-shrink: 0;
    margin-top: 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
}

#entry-screen.is-entering-zoom .entry-footer {
    opacity: 0;
    pointer-events: none;
}
