html,
body {
    width: 100%;
    height: 100%;
    min-height: -webkit-fill-available;
}

body {
    position: fixed;
    inset: 0;
    margin: 0;
    overflow: hidden;
    color: #fff;
    background: #000;
    font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overscroll-behavior: none;
    touch-action: manipulation;
}

button {
    font: inherit;
}

#app {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #000;
}

#game-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.fmv-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

.fmv-screen {
    position: absolute;
    inset: 0;
    display: none;
}

[data-mode="lobby"] .fmv-lobby,
[data-mode="video"] .fmv-playfield,
[data-mode="choice"] .fmv-playfield,
[data-mode="object"] .fmv-playfield,
[data-mode="ended"] .fmv-playfield {
    display: block;
}

[data-mode="chapter"] .fmv-chapter {
    display: block;
}

[data-mode="loading"] .fmv-loading {
    display: grid;
}

.fmv-loading {
    place-items: center;
    background: #08070a;
}

.fmv-loader {
    min-width: 180px;
    padding: 16px 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.07);
    text-align: center;
    font-size: 18px;
    letter-spacing: 0;
}

.fmv-lobby {
    isolation: isolate;
    background: #151015;
}

.fmv-lobby-bg,
.fmv-playfield video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fmv-lobby-bg {
    z-index: -3;
}

.fmv-lobby::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(90deg, rgba(5, 4, 7, 0.76), transparent 48%, rgba(5, 4, 7, 0.38)),
        linear-gradient(0deg, rgba(5, 4, 7, 0.76), transparent 42%);
}

.fmv-logo {
    position: absolute;
    left: 6.2%;
    top: 7%;
    width: 34%;
    max-height: 28%;
    object-fit: contain;
}

.fmv-lobby-cast {
    position: absolute;
    right: -4%;
    top: 24%;
    z-index: -1;
    width: 72%;
    height: 54%;
    pointer-events: none;
}

.fmv-lobby-cast img {
    position: absolute;
    top: 50%;
    bottom: auto;
    right: 0;
    width: 58%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transform: translateY(calc(-50% + 16px)) scale(0.985);
    filter: drop-shadow(0 24px 18px rgba(0, 0, 0, 0.45));
    transition:
        opacity 900ms ease,
        transform 900ms ease;
    will-change: opacity, transform;
}

.fmv-lobby-cast img.is-active {
    opacity: 1;
    transform: translateY(-50%) scale(1);
    animation: castBob 2400ms ease-in-out infinite;
}

.fmv-lobby-cast img:nth-child(1) {
    left: auto;
    right: 18%;
    width: 54%;
    z-index: 2;
}

.fmv-lobby-cast img:nth-child(2) {
    left: auto;
    right: 12%;
    width: 56%;
    z-index: 4;
}

.fmv-lobby-cast img:nth-child(3) {
    left: auto;
    right: 10%;
    width: 58%;
    z-index: 5;
}

.fmv-lobby-cast img:nth-child(4) {
    left: auto;
    right: 8%;
    width: 58%;
    z-index: 3;
}

.fmv-lobby-cast img:nth-child(5) {
    left: auto;
    right: 6%;
    width: 56%;
    z-index: 1;
}

.fmv-start-button {
    position: absolute;
    left: 8%;
    bottom: 12%;
    width: 220px;
    height: 58px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 4px;
    color: #fff;
    background: linear-gradient(180deg, #cf2a35, #80151f);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 0;
}

.fmv-start-button:active {
    transform: translateY(1px);
}

.fmv-debug-toggle {
    position: absolute;
    left: 8%;
    bottom: calc(12% + 72px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(0, 0, 0, 0.46);
    font-size: 13px;
    font-weight: 800;
}

.fmv-debug-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #d82434;
}

.fmv-playfield {
    background: #000;
}

.fmv-playfield video,
.fmv-video-freeze {
    z-index: 0;
}

.fmv-video-freeze {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    object-fit: cover;
    pointer-events: none;
    transition: opacity 90ms linear;
}

.fmv-video-freeze.is-visible {
    opacity: 1;
}

.fmv-tap-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 0;
    background: transparent;
}

.fmv-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    height: 4px;
    background: rgba(255, 255, 255, 0.13);
    transform: translateZ(0);
}

.fmv-progress-fill {
    width: 100%;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: #d82434;
}

.fmv-hud {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding:
        max(8px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        12px
        max(10px, env(safe-area-inset-left));
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent);
    transition: opacity 160ms ease;
}

.fmv-hud.is-visible,
[data-mode="choice"] .fmv-hud,
[data-mode="object"] .fmv-hud,
[data-mode="ended"] .fmv-hud {
    opacity: 1;
    pointer-events: auto;
}

[data-mode="object"] .fmv-hud {
    background: transparent;
}

[data-mode="object"] .fmv-home-button,
[data-mode="object"] .fmv-controls,
[data-mode="object"] .fmv-progress {
    display: none;
}

.fmv-title-label {
    display: none;
    min-width: 260px;
    font-size: 17px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

[data-debug="true"] .fmv-title-label {
    display: block;
}

.fmv-nav-controls {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.fmv-nav-controls button,
.fmv-controls {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
}

.fmv-nav-controls button,
.fmv-controls button {
    flex: 0 0 auto;
    min-width: clamp(48px, 8vw, 78px);
    height: clamp(34px, 7vh, 44px);
    padding: 0 clamp(8px, 1.5vw, 16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    background: rgba(8, 8, 10, 0.62);
    font-size: clamp(11px, 1.75vw, 14px);
    font-weight: 800;
    white-space: nowrap;
}

.fmv-nav-controls .fmv-back-button {
    min-width: 48px;
    border: 0;
    background: transparent;
    font-size: 30px;
    line-height: 1;
}

.fmv-controls .fmv-voice-toggle {
    min-width: clamp(88px, 15vw, 122px);
}

.fmv-controls .fmv-voice-toggle.is-off {
    color: rgba(255, 255, 255, 0.58);
    background: rgba(56, 56, 62, 0.68);
}

.fmv-controls button:active {
    background: rgba(216, 36, 52, 0.72);
}

.fmv-subtitle {
    position: absolute;
    left: 50%;
    z-index: 5;
    bottom: 38px;
    max-width: 78%;
    min-height: 42px;
    transform: translateX(-50%);
    padding: 8px 18px 10px;
    box-sizing: border-box;
    border-radius: 4px;
    color: #fff;
    background: rgba(0, 0, 0, 0.58);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.32;
    text-align: center;
    text-shadow:
        0 2px 2px #000,
        0 0 8px #000;
    white-space: pre-line;
    pointer-events: none;
}

.fmv-subtitle:empty {
    display: none;
}

.fmv-choice-panel {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 90px 64px 46px;
    box-sizing: border-box;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.62), transparent 44%);
}

[data-mode="choice"] .fmv-choice-panel {
    display: flex;
}

.fmv-choice-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: min(820px, 86%);
}

.fmv-choice-button {
    position: relative;
    min-height: 64px;
    padding: 10px 76px 10px 22px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 4px;
    color: #fff;
    background: linear-gradient(180deg, rgba(210, 38, 54, 0.96), rgba(120, 19, 29, 0.96));
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.35);
    text-align: left;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.24;
    white-space: pre-line;
}

.fmv-choice-button strong {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 4px;
    color: #fff;
    background: #21252d;
    font-size: 13px;
}

.fmv-choice-button.is-used,
.fmv-choice-button:disabled {
    color: rgba(255, 255, 255, 0.58);
    background: linear-gradient(180deg, rgba(83, 83, 88, 0.92), rgba(44, 44, 48, 0.92));
}

.fmv-choice-timer {
    position: absolute;
    left: 50%;
    bottom: 174px;
    width: min(580px, 66%);
    height: 12px;
    transform: translateX(-50%);
    overflow: hidden;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
}

.fmv-choice-timer div {
    width: 100%;
    height: 100%;
    transform-origin: left center;
    background: #e72a36;
}

.fmv-object-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: none;
    overflow: hidden;
    background: transparent;
}

[data-mode="object"] .fmv-object-layer {
    display: block;
}

.fmv-object-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    pointer-events: none;
}

.fmv-object-layer[data-object-name="OBJECT_100"] .fmv-object-image {
    left: 11%;
    top: 8%;
    width: 78%;
    height: 78%;
    object-fit: contain;
    object-position: center center;
}

.fmv-object-layer[data-object-name="OBJECT_110"] .fmv-object-image,
.fmv-object-layer[data-object-name="OBJECT_111"] .fmv-object-image {
    object-position: center bottom;
}

.fmv-object-title {
    position: absolute;
    right: 4%;
    top: 3%;
    z-index: 2;
    min-width: 420px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.62);
    color: rgba(255, 255, 255, 0.68);
    font-size: clamp(24px, 4vw, 44px);
    font-weight: 900;
    text-align: right;
}

.fmv-place-label {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    height: 44px;
    transform: translate(-50%, -50%);
    color: #222;
    font-weight: 900;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.25));
}

.fmv-place-label strong {
    display: grid;
    place-items: center;
    width: 54px;
    height: 46px;
    color: #fff;
    background: #4359b6;
    clip-path: polygon(0 50%, 22% 0, 100% 0, 100% 100%, 22% 100%);
    font-size: 20px;
}

.fmv-place-label span {
    min-width: 94px;
    height: 34px;
    padding: 0 20px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.78);
    font-size: 18px;
}

.fmv-hotspot {
    position: absolute;
    z-index: 1;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.76);
    border-radius: 50%;
    color: #fff;
    background: radial-gradient(circle at 50% 35%, #ff4d5a, #a40f1a 70%);
    box-shadow:
        0 0 0 8px rgba(220, 34, 48, 0.2),
        0 12px 20px rgba(0, 0, 0, 0.38);
    font-size: 34px;
    font-weight: 900;
}

.fmv-hotspot.is-used {
    color: rgba(255, 255, 255, 0.5);
    background: radial-gradient(circle at 50% 35%, #777, #3a3a3f 70%);
    box-shadow:
        0 0 0 8px rgba(255, 255, 255, 0.1),
        0 12px 20px rgba(0, 0, 0, 0.32);
}

.fmv-toast {
    position: absolute;
    left: 50%;
    z-index: 10;
    top: 18%;
    transform: translateX(-50%);
    min-width: 180px;
    padding: 12px 18px;
    border-radius: 4px;
    color: #fff;
    background: rgba(16, 16, 18, 0.86);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
    font-size: 16px;
    font-weight: 800;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.fmv-toast.is-visible {
    opacity: 1;
}

.fmv-audio-debug {
    display: none;
}

.fmv-menu-popup {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.48);
}

.fmv-menu-popup.is-visible {
    display: grid;
}

.fmv-menu-panel {
    display: grid;
    grid-template-columns: repeat(3, 150px);
    gap: 14px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 6px;
    background: rgba(18, 18, 22, 0.9);
    box-shadow: 0 28px 56px rgba(0, 0, 0, 0.45);
}

.fmv-menu-panel button {
    height: 112px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 6px;
    color: #fff;
    background: linear-gradient(180deg, rgba(62, 67, 90, 0.95), rgba(22, 24, 33, 0.95));
    font-size: 18px;
    font-weight: 900;
}

.fmv-chapter {
    overflow: hidden;
    background:
        linear-gradient(115deg, rgba(33, 190, 211, 0.9), rgba(57, 156, 207, 0.82) 44%, rgba(220, 91, 166, 0.9)),
        #2fa7cf;
}

.fmv-chapter::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent 0 190px, rgba(255, 255, 255, 0.08) 191px 192px),
        linear-gradient(135deg, transparent 0 30%, rgba(255, 255, 255, 0.14) 30% 32%, transparent 32% 100%);
    opacity: 0.72;
    pointer-events: none;
}

.fmv-chapter-back {
    position: absolute;
    left: max(22px, env(safe-area-inset-left));
    top: max(18px, env(safe-area-inset-top));
    z-index: 2;
    border: 0;
    color: #fff;
    background: transparent;
    font-size: 38px;
    font-weight: 900;
}

.fmv-chapter-title {
    position: absolute;
    right: 7%;
    top: 5%;
    z-index: 1;
    text-align: right;
    color: rgba(255, 255, 255, 0.42);
}

.fmv-chapter-title strong {
    display: block;
    font-size: clamp(38px, 7vw, 80px);
    font-weight: 900;
}

.fmv-chapter-title span {
    font-size: clamp(15px, 2vw, 24px);
    font-weight: 800;
}

.fmv-chapter-scroll {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.fmv-chapter-map {
    position: relative;
}

.fmv-chapter-line {
    position: absolute;
    left: 160px;
    right: 160px;
    top: 50%;
    border-top: 2px dashed rgba(255, 255, 255, 0.55);
}

.fmv-chapter-node {
    position: absolute;
    width: 142px;
    min-height: 86px;
    transform: translate(-50%, -50%);
    border: 0;
    color: #333;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
    font-size: 14px;
    font-weight: 900;
}

.fmv-chapter-node i {
    display: block;
    height: 58px;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.86) 0 24%, transparent 25%),
        linear-gradient(135deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5));
}

.fmv-chapter-node i::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 29px;
    width: 0;
    height: 0;
    transform: translate(-35%, -50%);
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-left: 16px solid rgba(255, 255, 255, 0.95);
}

.fmv-chapter-node span {
    display: block;
    padding: 5px 8px 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fmv-chapter-node.type-5,
.fmv-chapter-node.type-6 {
    width: 122px;
    min-height: 122px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%) rotate(45deg);
    color: #fff;
    background: linear-gradient(180deg, #f58bb5, #c1427a);
    border: 3px solid rgba(255, 255, 255, 0.62);
}

.fmv-chapter-node.type-5 strong,
.fmv-chapter-node.type-5 span,
.fmv-chapter-node.type-6 strong,
.fmv-chapter-node.type-6 span {
    transform: rotate(-45deg);
}

.fmv-chapter-progress {
    position: absolute;
    left: 4%;
    bottom: 7%;
    z-index: 2;
    width: min(480px, 42vw);
    color: #21415c;
    font-weight: 900;
}

.fmv-progress-track {
    position: relative;
    height: 44px;
    margin-top: 8px;
    border-top: 5px solid #d850a1;
}

.fmv-progress-track i {
    position: absolute;
    top: 6px;
    transform: translateX(-50%);
    font-style: normal;
    color: #c82a84;
    font-size: 13px;
}

@media (max-width: 760px) {
    .fmv-logo {
        width: 42%;
    }

    .fmv-lobby-cast {
        right: -12%;
        top: 25%;
        width: 94%;
        height: 52%;
    }

    .fmv-start-button {
        left: 6%;
        bottom: 8%;
        width: 176px;
        height: 50px;
        font-size: 20px;
    }

    .fmv-debug-toggle {
        left: 6%;
        bottom: calc(8% + 62px);
    }

    .fmv-choice-panel {
        padding: 76px 24px 28px;
    }

    .fmv-choice-list {
        width: 100%;
        gap: 8px;
    }

    .fmv-choice-button {
        min-height: 54px;
        padding-right: 64px;
        font-size: 16px;
    }

    .fmv-choice-timer {
        bottom: 136px;
        width: 74%;
        height: 10px;
    }

    .fmv-subtitle {
        bottom: 26px;
        max-width: 88%;
        font-size: 18px;
    }

    .fmv-hotspot {
        width: 44px;
        height: 44px;
        font-size: 27px;
    }
}

@media (orientation: portrait) {
    .fmv-hud {
        min-height: 56px;
        padding:
            max(8px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            8px
            max(8px, env(safe-area-inset-left));
    }

    .fmv-controls {
        gap: 4px;
    }

    .fmv-controls button {
        min-width: 44px;
        height: 34px;
        padding: 0 8px;
        font-size: 11px;
    }

    .fmv-controls .fmv-voice-toggle {
        min-width: 82px;
    }

    .fmv-choice-list {
        grid-template-columns: 1fr;
        width: 100%;
    }
}

@keyframes castBob {
    0%,
    100% {
        translate: 0 0;
    }

    50% {
        translate: 0 -10px;
    }
}
