:root {
    --ink: #070713;
    --panel: rgba(10, 10, 29, 0.91);
    --panel-solid: #0d0d23;
    --cream: #f7f1e7;
    --muted: #a8a6bd;
    --gold: #d6b978;
    --cyan: #71dcff;
    --teal: #45e2cf;
    --violet: #b66cff;
    --pink: #ff6c9f;
    --line: rgba(203, 198, 255, 0.2);
    --speaker-color: var(--gold);
    --display: Georgia, 'Times New Roman', serif;
    --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--ink);
}

body {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: clamp(10px, 2vw, 26px);
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--cream);
    background:
        radial-gradient(circle at 15% 12%, rgba(60, 208, 255, 0.13), transparent 31rem),
        radial-gradient(circle at 86% 78%, rgba(183, 90, 255, 0.15), transparent 34rem),
        #05050d;
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
}

button {
    color: inherit;
    font: inherit;
}

button:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 4px;
}

button:disabled {
    cursor: default;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-aurora {
    position: fixed;
    inset: -30%;
    pointer-events: none;
    background:
        conic-gradient(from 130deg at 50% 50%, transparent 0 22%, rgba(80, 211, 255, 0.07) 29%, transparent 39% 62%, rgba(190, 86, 255, 0.08) 70%, transparent 82%),
        radial-gradient(ellipse at center, transparent 24%, rgba(5, 5, 14, 0.6) 70%);
    filter: blur(40px);
    animation: auroraDrift 18s ease-in-out infinite alternate;
}

#game-container {
    position: relative;
    isolation: isolate;
    width: min(1440px, calc(100vw - clamp(20px, 4vw, 52px)));
    height: min(900px, calc(100vh - clamp(20px, 4vw, 52px)));
    height: min(900px, calc(100dvh - clamp(20px, 4vw, 52px)));
    max-height: 900px;
    overflow: hidden;
    border: 1px solid rgba(199, 194, 255, 0.34);
    border-radius: clamp(18px, 2vw, 30px);
    background: #0b0a1d;
    box-shadow:
        0 38px 90px rgba(0, 0, 0, 0.64),
        0 0 0 1px rgba(75, 225, 255, 0.05),
        inset 0 0 90px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

#game-container[data-state="title"],
#game-container[data-state="choice"],
#game-container[data-state="final"] {
    cursor: default;
}

.scene-backdrop,
.scene-shade,
.pixel-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scene-backdrop {
    z-index: -4;
    inset: -2%;
    background: #0d1030 url('moonlit-arena.webp') center center / cover no-repeat;
    image-rendering: auto;
    transform: scale(1.025);
    transition: filter 1.1s ease, transform 2.2s ease;
}

.scene-shade {
    z-index: -3;
    background:
        linear-gradient(180deg, rgba(3, 6, 23, 0.09) 0%, rgba(5, 5, 18, 0.01) 42%, rgba(4, 4, 15, 0.82) 100%),
        radial-gradient(ellipse at 50% 48%, transparent 22%, rgba(4, 4, 16, 0.1) 54%, rgba(4, 4, 16, 0.58) 112%);
    transition: background 1s ease, opacity 1s ease;
}

.pixel-grain {
    z-index: 100;
    opacity: 0.055;
    background-image:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 4px),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 90 90' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
    background-size: auto, 180px 180px;
    mix-blend-mode: soft-light;
}

#game-container[data-state="title"] .scene-backdrop {
    filter: brightness(0.62) saturate(0.82);
    transform: scale(1.08);
}

#game-container[data-scene="lobby"] .scene-backdrop {
    filter: brightness(0.7) saturate(0.72) hue-rotate(7deg);
}

#game-container[data-scene="bonded"] .scene-backdrop {
    filter: brightness(0.91) saturate(1.13);
}

#game-container[data-scene="epilogue"] .scene-backdrop,
#game-container[data-scene="victory"] .scene-backdrop {
    filter: brightness(0.52) saturate(1.18) hue-rotate(8deg);
    transform: scale(1.1);
}

#game-container[data-scene="victory"] .scene-shade {
    background:
        radial-gradient(circle at 50% 42%, rgba(255, 89, 156, 0.14), transparent 30%),
        linear-gradient(180deg, rgba(5, 5, 18, 0.12), rgba(4, 3, 14, 0.9));
}

.corner {
    position: absolute;
    z-index: 95;
    width: 42px;
    height: 42px;
    pointer-events: none;
    opacity: 0.58;
}

.corner::before,
.corner::after {
    content: '';
    position: absolute;
    background: linear-gradient(90deg, var(--gold), rgba(214, 185, 120, 0.1));
}

.corner::before {
    width: 36px;
    height: 1px;
}

.corner::after {
    width: 1px;
    height: 36px;
}

.corner-top-left {
    top: 13px;
    left: 13px;
}

.corner-top-right {
    top: 13px;
    right: 13px;
    transform: rotate(90deg);
}

.corner-bottom-right {
    right: 13px;
    bottom: 13px;
    transform: rotate(180deg);
}

.corner-bottom-left {
    bottom: 13px;
    left: 13px;
    transform: rotate(270deg);
}

.game-hud {
    position: absolute;
    z-index: 70;
    top: 0;
    left: 0;
    right: 0;
    min-height: 86px;
    padding: clamp(17px, 2.2vw, 28px) clamp(20px, 3vw, 42px);
    display: grid;
    grid-template-columns: 1fr minmax(180px, 320px) 1fr;
    align-items: center;
    gap: 24px;
    background: linear-gradient(180deg, rgba(5, 6, 24, 0.72), transparent);
    visibility: visible;
    transition: opacity 0.7s ease, transform 0.7s ease, visibility 0.7s;
}

.brand-lockup,
.brand-copy,
.sync-copy,
.hud-controls {
    display: flex;
    align-items: center;
}

.brand-lockup {
    gap: 12px;
}

.brand-gem {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(113, 220, 255, 0.46);
    border-radius: 11px 11px 15px 11px;
    color: var(--pink);
    background: linear-gradient(145deg, rgba(113, 220, 255, 0.14), rgba(182, 108, 255, 0.14));
    box-shadow: inset 0 0 16px rgba(113, 220, 255, 0.09), 0 0 22px rgba(255, 108, 159, 0.08);
    transform: rotate(45deg);
    font-size: 0;
}

.brand-gem::before {
    content: '♥';
    font-size: 13px;
    text-shadow: 0 0 10px currentColor;
    transform: rotate(-45deg);
}

.brand-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
}

.brand-copy strong {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.2em;
}

.brand-copy small {
    color: rgba(247, 241, 231, 0.52);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sync-meter {
    width: min(100%, 320px);
    justify-self: center;
}

.sync-copy {
    justify-content: space-between;
    margin-bottom: 8px;
    color: rgba(247, 241, 231, 0.7);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.16em;
}

.sync-copy strong {
    color: var(--cream);
    font-size: 10px;
}

.sync-track {
    position: relative;
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#sync-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--teal) 45%, var(--pink));
    box-shadow: 0 0 13px rgba(96, 221, 255, 0.75);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.hud-controls {
    justify-content: flex-end;
    gap: 8px;
}

.icon-button {
    min-height: 40px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: rgba(247, 241, 231, 0.8);
    background: rgba(7, 7, 22, 0.42);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
    border-color: rgba(113, 220, 255, 0.55);
    color: #fff;
    background: rgba(22, 20, 51, 0.74);
    transform: translateY(-1px);
}

.icon-button[aria-pressed="true"] {
    border-color: rgba(69, 226, 207, 0.56);
    color: var(--teal);
}

.control-icon {
    width: 16px;
    text-align: center;
    font-size: 15px;
}

.control-label {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.scene {
    position: absolute;
    z-index: 10;
    inset: 0;
    overflow: hidden;
}

.character {
    --entry-x: 0%;
    --speaker-scale: 1;
    position: absolute;
    z-index: 12;
    bottom: clamp(150px, 21%, 190px);
    width: min(58%, 820px);
    aspect-ratio: 658 / 379;
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(var(--speaker-scale));
    transform-origin: 50% 100%;
    filter: brightness(0.68) saturate(0.72) drop-shadow(0 24px 26px rgba(0, 0, 0, 0.72));
    transition:
        opacity 0.55s ease,
        transform 0.65s cubic-bezier(0.2, 0.9, 0.3, 1.08),
        filter 0.45s ease,
        visibility 0.55s;
    will-change: transform, opacity, filter;
}

.character-left {
    --entry-x: -12%;
    left: -7%;
}

.character-right {
    --entry-x: 12%;
    right: -7%;
}

.character.hidden {
    visibility: hidden;
    opacity: 0;
    transform: translate3d(var(--entry-x), 5%, 0) scale(0.95);
    pointer-events: none;
}

.character img {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    image-rendering: pixelated;
}

.portrait-aura {
    position: absolute;
    z-index: 1;
    left: 15%;
    right: 15%;
    bottom: -5%;
    height: 52%;
    border-radius: 50%;
    opacity: 0.3;
    filter: blur(28px);
    transform: scale(0.85);
    transition: opacity 0.4s ease, transform 0.5s ease;
}

.character-left .portrait-aura {
    background: radial-gradient(ellipse, rgba(85, 208, 255, 0.7), rgba(112, 84, 255, 0.12) 48%, transparent 72%);
}

.character-right .portrait-aura {
    background: radial-gradient(ellipse, rgba(69, 226, 207, 0.64), rgba(255, 108, 159, 0.12) 48%, transparent 72%);
}

.character.speaking {
    --speaker-scale: 1.045;
    z-index: 15;
    filter: brightness(1.06) saturate(1.13) drop-shadow(0 25px 28px rgba(0, 0, 0, 0.72));
}

.character-left.speaking {
    filter: brightness(1.06) saturate(1.13) drop-shadow(0 0 13px rgba(113, 220, 255, 0.34)) drop-shadow(0 25px 28px rgba(0, 0, 0, 0.72));
}

.character-right.speaking {
    filter: brightness(1.06) saturate(1.13) drop-shadow(0 0 13px rgba(69, 226, 207, 0.3)) drop-shadow(0 25px 28px rgba(0, 0, 0, 0.72));
}

.character.speaking .portrait-aura {
    opacity: 0.75;
    transform: scale(1.05);
    animation: auraBreathe 3s ease-in-out infinite;
}

.character-nameplate {
    position: absolute;
    z-index: 5;
    top: 12%;
    min-width: 116px;
    padding: 9px 13px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(100deg, rgba(8, 9, 29, 0.9), rgba(15, 15, 40, 0.62));
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(8px);
    transition: opacity 0.4s ease, border-color 0.4s ease, transform 0.4s ease;
}

.character-left .character-nameplate {
    left: 12%;
    border-left: 2px solid var(--cyan);
    border-radius: 4px 12px 12px 4px;
}

.character-right .character-nameplate {
    right: 12%;
    border-right: 2px solid var(--teal);
    border-radius: 12px 4px 4px 12px;
    text-align: right;
}

.character-nameplate small,
.character-nameplate strong {
    display: block;
    font-family: var(--mono);
}

.character-nameplate small {
    margin-bottom: 3px;
    color: rgba(247, 241, 231, 0.45);
    font-size: 7px;
    letter-spacing: 0.18em;
}

.character-nameplate strong {
    font-size: clamp(10px, 1vw, 13px);
    letter-spacing: 0.12em;
}

.character:not(.speaking) .character-nameplate {
    opacity: 0.55;
    transform: translateY(4px);
}

.bond-thread {
    position: absolute;
    z-index: 20;
    top: 45%;
    left: 31%;
    right: 31%;
    height: 28px;
    opacity: 0;
    transform: scaleX(0.2);
    transition: opacity 0.45s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.bond-thread.visible {
    opacity: 1;
    transform: scaleX(1);
}

.bond-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan) 16%, var(--pink) 50%, var(--teal) 84%, transparent);
    box-shadow: 0 0 12px var(--pink), 0 0 25px rgba(113, 220, 255, 0.45);
}

.bond-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    color: var(--pink);
    background: #11102a;
    box-shadow: 0 0 18px rgba(255, 108, 159, 0.7);
    transform: translate(-50%, -50%);
    animation: heartBeat 1.1s ease-in-out infinite;
}

.love-scene {
    position: absolute;
    z-index: 23;
    inset: 76px 0 138px;
    display: grid;
    place-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease, visibility 1s;
}

.love-scene.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.love-scene::before {
    content: '';
    position: absolute;
    inset: 4% 8%;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(129, 82, 255, 0.27), rgba(255, 88, 157, 0.06) 43%, transparent 70%);
    filter: blur(28px);
}

.love-halo {
    position: absolute;
    width: min(70vw, 810px);
    aspect-ratio: 1;
    border: 1px solid rgba(216, 189, 255, 0.14);
    border-radius: 50%;
    box-shadow:
        0 0 90px rgba(127, 82, 255, 0.16),
        inset 0 0 80px rgba(255, 105, 165, 0.1);
    animation: haloRotate 22s linear infinite;
}

.love-halo::before,
.love-halo::after {
    content: '';
    position: absolute;
    inset: 9%;
    border: 1px dashed rgba(113, 220, 255, 0.12);
    border-radius: inherit;
}

.love-halo::after {
    inset: 20%;
    border-color: rgba(255, 108, 159, 0.18);
}

.love-scene img {
    position: relative;
    z-index: 2;
    width: min(82%, 980px);
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    filter: saturate(1.12) brightness(1.06) drop-shadow(0 30px 36px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 19px rgba(148, 90, 255, 0.32));
    animation: loveReveal 1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.fx-layer {
    position: absolute;
    z-index: 40;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.heart {
    --heart-color: var(--pink);
    position: absolute;
    bottom: 20%;
    color: var(--heart-color);
    font-family: var(--sans);
    font-size: clamp(18px, 2.6vw, 38px);
    line-height: 1;
    opacity: 0;
    text-shadow: 0 0 13px currentColor;
    transform: translate3d(-50%, 0, 0) scale(0.4) rotate(var(--tilt, 0deg));
    animation: heartFloat var(--heart-duration, 2.4s) cubic-bezier(0.16, 0.85, 0.38, 1) forwards;
}

.heart::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: -12px -9px 0 currentColor, 12px -15px 0 currentColor, 18px 6px 0 rgba(255, 255, 255, 0.75);
}

.screen-flash {
    position: absolute;
    z-index: 90;
    inset: 0;
    pointer-events: none;
    background: #d9f6ff;
    animation: screenFlash 0.62s ease-out forwards;
}

.dialogue-box {
    --speaker-color: var(--gold);
    position: absolute;
    z-index: 60;
    right: clamp(20px, 3vw, 44px);
    bottom: clamp(18px, 2.5vw, 35px);
    left: clamp(20px, 3vw, 44px);
    min-height: clamp(164px, 21%, 196px);
    padding: clamp(19px, 2.2vw, 30px) clamp(21px, 2.8vw, 38px) clamp(17px, 2vw, 25px);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(214, 208, 255, 0.24);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(10, 10, 29, 0.97), rgba(15, 13, 37, 0.94));
    background:
        linear-gradient(115deg, color-mix(in srgb, var(--speaker-color) 6%, transparent), transparent 30%),
        linear-gradient(145deg, rgba(10, 10, 29, 0.97), rgba(15, 13, 37, 0.9));
    box-shadow:
        0 26px 62px rgba(0, 0, 0, 0.52),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px) saturate(1.15);
    cursor: pointer;
    visibility: visible;
    transition: opacity 0.6s ease, transform 0.7s ease, border-color 0.4s ease, background 0.4s ease, visibility 0.7s;
}

.dialogue-box::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 22px;
    width: min(27%, 260px);
    height: 2px;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--speaker-color), transparent);
    box-shadow: 0 0 14px color-mix(in srgb, var(--speaker-color) 65%, transparent);
    transition: background 0.4s ease;
}

.dialogue-box[data-speaker="unfazed"] {
    --speaker-color: var(--cyan);
}

.dialogue-box[data-speaker="kaise"] {
    --speaker-color: var(--teal);
}

.dialogue-meta,
.dialogue-footer,
.frame-progress,
.speaker-badge {
    display: flex;
    align-items: center;
}

.dialogue-meta {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: clamp(12px, 1.5vw, 17px);
}

.speaker-badge {
    gap: 9px;
    color: var(--speaker-color);
    font-family: var(--mono);
    font-size: clamp(10px, 0.9vw, 12px);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.speaker-orb {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
    transform: rotate(45deg);
}

.chapter-label {
    color: rgba(247, 241, 231, 0.62);
    font-family: var(--mono);
    font-size: clamp(8px, 0.72vw, 10px);
    letter-spacing: 0.18em;
}

.dialogue-text {
    max-width: 980px;
    min-height: 2.6em;
    margin: 0;
    color: var(--cream);
    font-family: var(--mono);
    font-size: clamp(14px, 1.3vw, 18px);
    line-height: 1.7;
    letter-spacing: 0.01em;
    text-wrap: pretty;
}

.dialogue-text::after {
    content: '';
    display: inline-block;
    width: 0.48em;
    height: 1em;
    margin-left: 0.22em;
    vertical-align: -0.15em;
    border-right: 2px solid var(--speaker-color);
    opacity: 0;
}

.dialogue-box.is-typing .dialogue-text::after {
    opacity: 0.85;
    animation: cursorBlink 0.7s steps(1) infinite;
}

.choice-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.choice-list.hidden {
    display: none;
}

.choice-button {
    min-height: 52px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid rgba(113, 220, 255, 0.22);
    border-radius: 10px;
    color: rgba(247, 241, 231, 0.84);
    background: rgba(113, 220, 255, 0.06);
    font-family: var(--mono);
    font-size: clamp(9px, 0.82vw, 11px);
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.choice-button:hover,
.choice-button:focus-visible {
    border-color: var(--teal);
    color: #fff;
    background: rgba(69, 226, 207, 0.12);
    transform: translateY(-2px);
}

.choice-button span:last-child {
    color: var(--teal);
    font-size: 15px;
}

.dialogue-footer {
    justify-content: space-between;
    gap: 20px;
    margin-top: auto;
    padding-top: 11px;
}

.interaction-hint,
.frame-progress {
    color: rgba(247, 241, 231, 0.6);
    font-family: var(--mono);
    font-size: clamp(8px, 0.7vw, 10px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.frame-progress {
    gap: 12px;
    color: rgba(247, 241, 231, 0.56);
    flex-shrink: 0;
    white-space: nowrap;
}

.continue-indicator {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    color: var(--speaker-color);
    font-size: 22px;
    line-height: 1;
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dialogue-box.is-ready .continue-indicator {
    opacity: 1;
    transform: translateX(0);
    animation: nudgeRight 1.2s ease-in-out infinite;
}

.epilogue-button {
    position: absolute;
    z-index: 72;
    top: 42%;
    left: 50%;
    min-width: min(360px, calc(100% - 40px));
    padding: 17px 26px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(110deg, rgba(92, 43, 156, 0.94), rgba(174, 56, 128, 0.94));
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 108, 159, 0.25);
    transform: translate(-50%, -50%);
    cursor: pointer;
    overflow: hidden;
    animation: buttonReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.epilogue-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 22%, rgba(255, 255, 255, 0.19) 45%, transparent 68%);
    transform: translateX(-120%);
    transition: transform 0.7s ease;
}

.epilogue-button:hover::before {
    transform: translateX(120%);
}

.epilogue-button:hover {
    border-color: rgba(255, 255, 255, 0.68);
}

.button-kicker,
.button-main {
    position: relative;
    display: block;
}

.button-kicker {
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.55);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.2em;
}

.button-main {
    font-family: var(--mono);
    font-size: clamp(12px, 1.1vw, 15px);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.epilogue-button.hidden,
.ending-card.hidden {
    display: none;
}

.ending-card {
    position: absolute;
    z-index: 85;
    top: 47%;
    left: 50%;
    width: min(520px, calc(100% - 36px));
    padding: clamp(26px, 4vw, 50px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 22px;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 108, 159, 0.14), transparent 48%),
        rgba(9, 8, 28, 0.86);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.65), 0 0 60px rgba(135, 81, 255, 0.17);
    backdrop-filter: blur(20px) saturate(1.2);
    text-align: center;
    transform: translate(-50%, -50%);
    animation: endingReveal 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ending-kicker {
    margin: 0 0 10px;
    color: var(--gold);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.38em;
}

.ending-card h2 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(38px, 5vw, 64px);
    font-weight: 400;
    letter-spacing: -0.035em;
}

.ending-card > p:not(.ending-kicker) {
    margin: 12px auto 25px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: clamp(10px, 1vw, 12px);
    line-height: 1.6;
}

.ending-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.primary-button,
.secondary-button,
.start-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary-button,
.secondary-button {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.primary-button {
    color: #09111b;
    background: linear-gradient(110deg, var(--cyan), var(--teal));
}

.secondary-button {
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--cream);
    background: rgba(255, 255, 255, 0.06);
}

.primary-button:hover,
.secondary-button:hover {
    transform: translateY(-2px);
}

.secondary-button:hover {
    border-color: rgba(255, 255, 255, 0.46);
    background: rgba(255, 255, 255, 0.1);
}

.share-status {
    position: absolute;
    right: 0;
    bottom: 14px;
    left: 0;
    color: var(--teal);
    font-family: var(--mono);
    font-size: 9px;
}

#game-container[data-state="title"] .game-hud,
#game-container[data-state="title"] .dialogue-box {
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    pointer-events: none;
}

#game-container[data-state="final"] .dialogue-box {
    opacity: 0;
    visibility: hidden;
    transform: translateY(28px);
    pointer-events: none;
}

.title-screen {
    position: absolute;
    z-index: 80;
    inset: 0;
    padding: clamp(30px, 5vw, 72px);
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 50% 38%, rgba(106, 83, 255, 0.11), transparent 28%),
        linear-gradient(180deg, rgba(6, 6, 20, 0.18), rgba(6, 5, 19, 0.58));
    cursor: default;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease, visibility 0.8s;
}

.title-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.title-content {
    width: min(700px, 100%);
    text-align: center;
}

.title-eyebrow {
    margin-bottom: clamp(24px, 4vh, 42px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    color: rgba(247, 241, 231, 0.62);
    font-family: var(--mono);
    font-size: clamp(8px, 0.8vw, 10px);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    animation: titleRise 0.8s 0.05s both;
}

.title-eyebrow span {
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(113, 220, 255, 0.6));
}

.title-eyebrow span:last-child {
    transform: rotate(180deg);
}

.title-heart {
    position: relative;
    width: 74px;
    height: 74px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(113, 220, 255, 0.28);
    border-radius: 23px 23px 31px 23px;
    color: var(--pink);
    background: linear-gradient(145deg, rgba(113, 220, 255, 0.12), rgba(182, 108, 255, 0.12));
    box-shadow: 0 0 50px rgba(111, 92, 255, 0.18), inset 0 0 25px rgba(113, 220, 255, 0.06);
    transform: rotate(45deg);
    animation: titleGem 0.9s 0.14s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.title-heart span {
    font-size: 26px;
    text-shadow: 0 0 18px currentColor;
    transform: rotate(-45deg);
}

.title-heart i {
    position: absolute;
    top: -8px;
    right: 4px;
    width: 7px;
    height: 7px;
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan);
}

.title-brand {
    margin: 0 0 8px;
    color: var(--gold);
    font-family: var(--mono);
    font-size: clamp(9px, 1vw, 12px);
    font-weight: 700;
    letter-spacing: 0.42em;
    animation: titleRise 0.8s 0.2s both;
}

.title-content h1 {
    margin: 0;
    color: #fff;
    font-family: var(--display);
    font-size: clamp(44px, 7vw, 92px);
    font-weight: 400;
    line-height: 0.92;
    letter-spacing: -0.055em;
    text-wrap: balance;
    text-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
    animation: titleRise 0.9s 0.26s both;
}

.title-content h1 span,
.title-content h1 em {
    display: block;
}

.title-content h1 em {
    color: transparent;
    background: linear-gradient(95deg, var(--cyan), #d5c8ff 47%, var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    font-weight: 400;
}

.title-intro {
    margin: clamp(19px, 3vh, 29px) auto 0;
    color: rgba(247, 241, 231, 0.7);
    font-family: var(--mono);
    font-size: clamp(10px, 1.1vw, 13px);
    line-height: 1.8;
    animation: titleRise 0.8s 0.34s both;
}

.start-button {
    min-width: min(280px, 100%);
    min-height: 58px;
    margin-top: clamp(25px, 4vh, 38px);
    padding: 0 17px 0 25px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    border-radius: 999px;
    color: #0b1220;
    background: linear-gradient(110deg, #b8efff, var(--teal));
    box-shadow: 0 14px 42px rgba(61, 211, 210, 0.17);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    animation: titleRise 0.8s 0.42s both;
}

.start-button b {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--cream);
    background: #111229;
    font-size: 16px;
    transition: transform 0.25s ease;
}

.start-button:hover {
    transform: translateY(-3px);
}

.start-button:hover b {
    transform: rotate(45deg);
}

.title-details {
    margin-top: clamp(23px, 4vh, 38px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 2vw, 24px);
    color: rgba(247, 241, 231, 0.6);
    font-family: var(--mono);
    font-size: clamp(8px, 0.78vw, 10px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: titleRise 0.8s 0.5s both;
}

.title-details span {
    white-space: nowrap;
}

.title-details b {
    color: var(--cream);
    font-weight: 400;
}

.title-details i {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--pink);
    box-shadow: 0 0 8px var(--pink);
}

.title-note {
    position: absolute;
    bottom: clamp(22px, 3.2vw, 42px);
    margin: 0;
    color: rgba(247, 241, 231, 0.5);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: titleRise 0.8s 0.58s both;
}

noscript {
    position: fixed;
    z-index: 200;
    right: 20px;
    bottom: 20px;
    left: 20px;
    padding: 18px;
    border: 1px solid var(--pink);
    border-radius: 12px;
    color: #fff;
    background: var(--panel-solid);
    font-family: var(--mono);
    text-align: center;
}

@keyframes auroraDrift {
    to { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.08); }
}

@keyframes auraBreathe {
    50% { opacity: 0.5; transform: scale(0.95); }
}

@keyframes heartBeat {
    50% { transform: translate(-50%, -50%) scale(1.14); }
}

@keyframes haloRotate {
    to { transform: rotate(360deg); }
}

@keyframes loveReveal {
    from { opacity: 0; transform: translateY(20px) scale(0.91); filter: blur(8px) saturate(0.7); }
}

@keyframes heartFloat {
    0% { opacity: 0; transform: translate3d(-50%, 20px, 0) scale(0.3) rotate(var(--tilt)); }
    14% { opacity: 1; }
    75% { opacity: 0.86; }
    100% { opacity: 0; transform: translate3d(calc(-50% + var(--drift, 0px)), -280px, 0) scale(1.16) rotate(calc(var(--tilt) * -1)); }
}

@keyframes screenFlash {
    0% { opacity: 0.86; }
    100% { opacity: 0; }
}

@keyframes cursorBlink {
    50% { opacity: 0; }
}

@keyframes nudgeRight {
    50% { transform: translateX(3px); }
}

@keyframes buttonReveal {
    from { opacity: 0; transform: translate(-50%, -42%) scale(0.9); }
}

@keyframes endingReveal {
    from { opacity: 0; transform: translate(-50%, -45%) scale(0.92); filter: blur(7px); }
}

@keyframes titleRise {
    from { opacity: 0; transform: translateY(14px); }
}

@keyframes titleGem {
    from { opacity: 0; transform: rotate(45deg) scale(0.7); }
}

@media (max-width: 880px) {
    .game-hud {
        grid-template-columns: 1fr auto;
    }

    .sync-meter {
        position: absolute;
        top: 72px;
        right: 22px;
        left: 22px;
        width: auto;
    }

    .sync-copy {
        margin-bottom: 5px;
    }

    .hud-controls {
        grid-column: 2;
    }

    .character {
        bottom: clamp(155px, 24%, 205px);
        width: 67%;
    }

    .character-left {
        left: -13%;
    }

    .character-right {
        right: -13%;
    }

    .character-nameplate {
        display: none;
    }
}

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

    #game-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .corner {
        display: none;
    }

    .scene-backdrop {
        inset: -2% -58%;
        background-position: center center;
    }

    .game-hud {
        min-height: 68px;
        padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    }

    .brand-lockup {
        gap: 9px;
    }

    .brand-gem {
        width: 30px;
        height: 30px;
        border-radius: 9px;
        font-size: 10px;
    }

    .brand-copy strong {
        font-size: 10px;
    }

    .brand-copy small,
    .control-label {
        display: none;
    }

    .icon-button {
        width: 38px;
        min-height: 38px;
        padding: 0;
        justify-content: center;
    }

    .sync-meter {
        top: 62px;
        right: 14px;
        left: 14px;
    }

    .sync-copy {
        font-size: 7px;
    }

    .character {
        bottom: min(35vh, 285px);
        width: 110vw;
        max-width: none;
    }

    .character-left {
        left: -43%;
    }

    .character-right {
        right: -43%;
    }

    .scene.solo-left .character-left {
        left: -13%;
    }

    .scene.solo-right .character-right {
        right: -13%;
    }

    .bond-thread {
        top: 41%;
        left: 24%;
        right: 24%;
    }

    .love-scene {
        inset: 88px -12% 252px;
    }

    .love-scene img {
        width: 115%;
    }

    .love-halo {
        width: 105vw;
    }

    .dialogue-box {
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
        left: 12px;
        min-height: 225px;
        padding: 18px 18px 15px;
        border-radius: 15px;
    }

    #game-container[data-state="choice"] .dialogue-box {
        min-height: 335px;
    }

    .dialogue-text {
        min-height: 3.35em;
        font-size: clamp(13px, 3.6vw, 16px);
        line-height: 1.6;
    }

    .interaction-hint,
    .frame-progress {
        font-size: 9px;
    }

    .choice-list {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .choice-button {
        min-height: 45px;
        padding: 9px 12px;
    }

    .interaction-hint {
        max-width: 190px;
        line-height: 1.4;
    }

    .epilogue-button {
        top: 39%;
    }

    .ending-card {
        top: 44%;
    }

    .title-screen {
        padding: max(40px, env(safe-area-inset-top)) 22px max(35px, env(safe-area-inset-bottom));
    }

    .title-eyebrow {
        gap: 9px;
    }

    .title-eyebrow span {
        width: 24px;
    }

    .title-heart {
        width: 61px;
        height: 61px;
        margin-bottom: 17px;
    }

    .title-heart span {
        font-size: 22px;
    }

    .title-content h1 {
        font-size: clamp(44px, 14vw, 60px);
    }

    .title-details {
        gap: 10px;
    }

    .title-note {
        bottom: max(18px, env(safe-area-inset-bottom));
    }
}

@media (max-height: 640px) and (min-width: 681px),
       (max-height: 500px) and (orientation: landscape) {
    .game-hud {
        min-height: 62px;
        padding-top: 13px;
        padding-bottom: 13px;
    }

    .character {
        bottom: 130px;
        width: 52%;
    }

    .dialogue-box {
        min-height: 142px;
        padding-top: 15px;
        padding-bottom: 13px;
    }

    .dialogue-meta {
        margin-bottom: 8px;
    }

    .dialogue-text {
        font-size: 13px;
        line-height: 1.55;
    }

    .dialogue-footer {
        padding-top: 6px;
    }

    .title-heart,
    .title-details {
        display: none;
    }

    .title-eyebrow {
        margin-bottom: 18px;
    }

    .title-content h1 {
        font-size: 58px;
    }

    .title-note {
        bottom: 14px;
    }
}

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

    .screen-flash {
        display: none;
    }
}

@media (prefers-contrast: more) {
    .dialogue-box,
    .ending-card {
        border-color: rgba(255, 255, 255, 0.65);
        background: rgba(4, 4, 16, 0.96);
    }

    .dialogue-text,
    .interaction-hint,
    .chapter-label {
        color: #fff;
    }
}
