/* Phone-first guardrails, loaded last so every screen shares one mobile system. */

@media (max-width: 767px) {
    :root {
        --phone-pad-x: max(0.55rem, env(safe-area-inset-left));
        --phone-pad-top: max(0.55rem, env(safe-area-inset-top));
        --phone-pad-bottom: max(0.55rem, env(safe-area-inset-bottom));
    }

    html {
        width: 100%;
        height: 100%;
        overflow: hidden;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        width: 100%;
        min-width: 0;
        height: 100vh;
        height: 100dvh;
        min-height: 100svh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    img,
    canvas,
    textarea {
        max-width: 100%;
    }

    button,
    a,
    textarea {
        -webkit-tap-highlight-color: transparent;
    }

    button,
    a {
        touch-action: manipulation;
    }

    #startScreen,
    #messageBox,
    #endScreen,
    #arcadeContainer,
    #countdownOverlay,
    #msgModal,
    #giftChoiceModal {
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        max-height: 100dvh;
        overflow: hidden !important;
    }

    /* Opening and countdown */
    #startScreen {
        justify-content: center !important;
        gap: clamp(0.28rem, 1.15dvh, 0.58rem) !important;
        padding-top: var(--phone-pad-top) !important;
        padding-right: var(--phone-pad-x) !important;
        padding-bottom: var(--phone-pad-bottom) !important;
        padding-left: var(--phone-pad-x) !important;
    }

    .start-kicker {
        margin: 0;
        padding: 0.28rem 0.62rem;
        font-size: clamp(0.52rem, 2.4vw, 0.66rem);
        line-height: 1.2;
        letter-spacing: 0.08em;
        text-align: center;
    }

    #startScreen h2 {
        width: min(100%, 430px);
        margin: 0;
        font-size: clamp(1.45rem, 7.8vw, 2.15rem) !important;
        line-height: 1.02;
        text-align: center;
    }

    #birthdayCountdown {
        width: min(100%, 430px);
        margin: 0;
        padding: clamp(0.55rem, 1.6dvh, 0.78rem);
        border-radius: 18px;
    }

    .countdown-title {
        margin-bottom: 0.42rem;
        font-size: clamp(0.62rem, 2.8vw, 0.78rem);
        line-height: 1.2;
        text-align: center;
    }

    .countdown-display {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: clamp(0.24rem, 1.4vw, 0.42rem);
        width: 100%;
    }

    .countdown-unit {
        min-width: 0;
        padding: clamp(0.32rem, 1dvh, 0.48rem) 0.08rem;
        border-radius: 12px;
    }

    .countdown-number {
        font-size: clamp(1.25rem, 7.5vw, 1.9rem) !important;
        line-height: 1;
    }

    .countdown-label {
        margin-top: 0.16rem;
        font-size: clamp(0.46rem, 2.1vw, 0.6rem);
        line-height: 1;
    }

    #countdownMessage {
        margin-top: 0.38rem;
        font-size: clamp(0.52rem, 2.35vw, 0.66rem);
        line-height: 1.22;
        text-align: center;
    }

    .anime-squad {
        width: min(100%, 430px);
        margin: 0;
    }

    .anime-squad-title {
        width: auto;
        max-width: 100%;
        margin: 0 auto 0.32rem;
        padding: 0.18rem 0.55rem;
        font-size: clamp(0.5rem, 2.15vw, 0.61rem);
        line-height: 1.2;
        letter-spacing: 0.045em;
        white-space: normal;
        text-align: center;
    }

    .anime-squad-list {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(0.28rem, 1.2vw, 0.42rem);
        width: 100%;
        padding: 0.05rem 0.18rem 0.22rem;
        overflow: visible !important;
        scroll-snap-type: none !important;
    }

    .anime-chip {
        width: 100%;
        min-width: 0 !important;
        min-height: 42px;
        gap: 0.38rem;
        padding: 0.38rem 0.42rem;
        border-radius: 14px 10px 15px 11px / 11px 15px 10px 14px;
        transform: none !important;
    }

    .anime-chip:last-child {
        grid-column: 1 / -1;
        justify-self: center;
        width: calc(50% - 0.2rem);
    }

    .anime-symbol {
        width: 28px;
        border-radius: 9px;
        font-size: 0.78rem;
    }

    .anime-chip strong {
        font-size: clamp(0.56rem, 2.55vw, 0.68rem);
    }

    .anime-chip small {
        font-size: clamp(0.44rem, 1.95vw, 0.54rem);
    }

    #openBtn {
        min-width: min(64vw, 230px);
        min-height: 44px;
        margin: 0;
        padding: 0.62rem 1.1rem;
        font-size: clamp(0.8rem, 3.6vw, 0.96rem);
    }

    /* Greeting */
    #messageBox {
        padding: 0.35rem !important;
    }

    #messageContent {
        width: calc(100vw - 0.7rem) !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100dvh - 0.7rem) !important;
        border-radius: 20px !important;
        align-content: start;
    }

    #typedText {
        overflow: visible !important;
        overflow-wrap: anywhere;
        min-height: 8.2em !important;
    }

    #giftBtn {
        min-height: 42px;
    }

    /* Ending and dialogs */
    #endScreen {
        padding: 0.35rem !important;
    }

    #endInner {
        width: calc(100vw - 0.7rem) !important;
        max-height: calc(100dvh - 0.7rem) !important;
    }

    #endInner > .btnRow .btn {
        min-height: 40px;
        touch-action: manipulation;
    }

    #msgModal,
    #giftChoiceModal {
        align-items: center !important;
        justify-content: center !important;
        padding-top: var(--phone-pad-top) !important;
        padding-right: var(--phone-pad-x) !important;
        padding-bottom: var(--phone-pad-bottom) !important;
        padding-left: var(--phone-pad-x) !important;
    }

    body #msgModal .modal-content,
    .choice-content {
        width: min(100%, 420px) !important;
        max-width: 420px !important;
        max-height: calc(100dvh - var(--phone-pad-top) - var(--phone-pad-bottom)) !important;
        padding: clamp(0.85rem, 4vw, 1.2rem) !important;
        overflow: hidden !important;
        border-radius: 20px !important;
    }

    .modal-content h3,
    .choice-content h3 {
        margin: 0 0 0.65rem;
        font-size: clamp(1.15rem, 5.5vw, 1.45rem);
        line-height: 1.15;
    }

    .choice-content > p {
        margin: 0 0 0.8rem;
        font-size: clamp(0.76rem, 3.5vw, 0.9rem);
    }

    #userMessageInput {
        width: 100%;
        height: min(30dvh, 165px);
        min-height: 110px;
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        font-size: 16px;
        line-height: 1.4;
    }

    .modal-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
        width: 100%;
    }

    .modal-actions .modal-btn {
        width: 100%;
        min-height: 44px;
        padding: 0.58rem 0.6rem;
    }

    .choice-actions {
        gap: 0.65rem;
    }

    .choice-btn {
        min-height: 58px;
        padding: 0.72rem !important;
        font-size: clamp(0.78rem, 3.6vw, 0.94rem);
    }

    .btn-subtext {
        font-size: clamp(0.6rem, 2.7vw, 0.72rem);
    }

    #btnCloseChoice {
        min-height: 40px;
        margin-top: 0.7rem;
    }

    #toast {
        right: 0.75rem;
        bottom: max(0.8rem, env(safe-area-inset-bottom));
        left: 0.75rem;
        width: auto;
        min-width: 0;
        padding: 0.75rem 1rem;
        font-size: 0.82rem;
        line-height: 1.25;
        transform: none;
    }

    .countdown-cute {
        margin-bottom: 1rem;
        font-size: clamp(1rem, 5vw, 1.4rem);
        letter-spacing: 0.08em;
    }

    #countdownNumber {
        font-size: clamp(5rem, 32vw, 8rem);
    }

    /* Mini-game */
    #arcadeContainer {
        overflow: hidden !important;
    }

    .exit-game-btn {
        top: var(--phone-pad-top) !important;
        right: var(--phone-pad-x) !important;
        min-height: 36px;
        padding: 0.4rem 0.68rem;
        font-size: clamp(0.62rem, 2.8vw, 0.74rem);
    }

    .screen-game {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        max-height: 100dvh;
        justify-content: center !important;
        padding-top: max(3.35rem, env(safe-area-inset-top)) !important;
        padding-right: var(--phone-pad-x) !important;
        padding-bottom: var(--phone-pad-bottom) !important;
        padding-left: var(--phone-pad-x) !important;
        overflow: hidden !important;
    }

    .game-badge {
        min-height: 24px;
        margin-bottom: 0.3rem;
        padding: 0.25rem 0.62rem;
        font-size: clamp(0.52rem, 2.3vw, 0.64rem);
    }

    .game-title {
        margin: 0;
        font-size: clamp(1.75rem, 9.5vw, 2.55rem) !important;
        line-height: 0.96;
    }

    .mascot-stage {
        width: 120px;
        height: 88px;
        margin: 0.15rem auto 0.25rem;
        transform: scale(0.82);
    }

    .game-desc {
        max-width: 94vw;
        margin: 0 auto 0.52rem;
        font-size: clamp(0.68rem, 3vw, 0.82rem);
        line-height: 1.32;
    }

    .game-rules {
        gap: 0.36rem;
        width: min(94vw, 390px);
        margin: 0 auto 0.55rem;
    }

    .game-rule {
        gap: 0;
        padding: 0.4rem 0.18rem;
        border-radius: 13px;
    }

    .game-rule span {
        font-size: clamp(1.1rem, 5.2vw, 1.45rem);
    }

    .game-rule strong {
        font-size: clamp(0.68rem, 3vw, 0.82rem);
    }

    .game-rule small {
        font-size: clamp(0.48rem, 2.15vw, 0.58rem);
    }

    #s-intro > .btn-cute {
        min-height: 42px;
        margin-top: 0;
        padding: 0.58rem 1.25rem;
        font-size: clamp(0.72rem, 3.3vw, 0.88rem);
    }

    .game-topbar {
        gap: 0.38rem;
        width: min(94vw, 390px);
        margin-bottom: 0.3rem;
    }

    .score-bubble,
    .streak-bubble {
        min-height: 38px;
        padding: 0.5rem 0.65rem;
        font-size: clamp(0.68rem, 3vw, 0.84rem);
    }

    .game-feedback {
        min-height: 24px;
        margin-bottom: 0.3rem;
        padding: 0.2rem 0.6rem;
        font-size: clamp(0.65rem, 2.8vw, 0.78rem);
    }

    .game-grid {
        gap: clamp(0.35rem, 1.8vw, 0.55rem);
        width: min(78vw, 39dvh, 310px) !important;
        height: min(78vw, 39dvh, 310px) !important;
        padding: 0.48rem;
        border-radius: 24px;
    }

    .hole {
        border-width: 1px;
        border-radius: 24% 24% 40% 40%;
    }

    .character {
        font-size: clamp(1.9rem, 11vw, 3.25rem);
    }

    .game-hint {
        max-width: 92vw;
        margin: 0.42rem auto 0;
        font-size: clamp(0.56rem, 2.4vw, 0.68rem);
        line-height: 1.25;
    }

    .winner-mascot {
        margin-bottom: 0.12rem;
        font-size: clamp(3rem, 15vw, 4.6rem);
    }

    #s-choose .game-desc {
        margin-bottom: 0.7rem;
    }

    .box-container {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: clamp(0.35rem, 1.8vw, 0.58rem);
        width: min(94vw, 390px);
    }

    .mystery-box {
        width: 100%;
        min-width: 0;
        max-width: 78px;
        justify-self: center;
        border-radius: 18px;
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .mystery-box small {
        right: 5px;
        bottom: 5px;
        width: 17px;
        font-size: 0.56rem;
    }

    #capture-area.cute-coupon {
        width: min(94vw, 360px) !important;
        max-width: 360px;
        margin: 0 0 0.52rem;
        padding: clamp(0.7rem, 3vw, 1rem) !important;
        border-width: 3px !important;
        border-radius: 20px;
        transform: none;
    }

    .coupon-deco-top {
        margin-bottom: 0.25rem;
        font-size: clamp(1.15rem, 5.5vw, 1.55rem);
    }

    .coupon-title {
        font-size: clamp(1.2rem, 6vw, 1.65rem) !important;
        line-height: 1.05;
    }

    .coupon-subtitle {
        margin: 0.25rem auto 0.48rem;
        font-size: clamp(0.62rem, 2.8vw, 0.76rem);
        line-height: 1.25;
    }

    .prize-container-decorated,
    #capture-area .prize-container-decorated {
        gap: 0.3rem;
        margin: 0.42rem 0;
        padding: 0.55rem 0.4rem;
        border-width: 2px;
        border-radius: 14px;
    }

    .deco-icon {
        font-size: clamp(1.25rem, 6vw, 1.7rem);
    }

    .prize-text-styled,
    #capture-area #prize-text {
        font-size: clamp(0.9rem, 4.5vw, 1.2rem) !important;
        line-height: 1.15;
    }

    .coupon-footer small {
        margin-bottom: 0.3rem;
        padding: 0.32rem 0.55rem;
        font-size: clamp(0.5rem, 2.2vw, 0.62rem);
        line-height: 1.2;
    }

    .coupon-deco-bottom {
        font-size: clamp(0.8rem, 3.6vw, 1rem);
    }

    #s-result > .btn-cute {
        min-height: 40px;
        margin-top: 0.22rem;
        padding: 0.5rem 1rem;
        font-size: clamp(0.65rem, 3vw, 0.8rem);
    }

    .game-replay-btn {
        min-height: 36px;
        margin-top: 0.28rem;
        padding: 0.4rem 0.7rem;
        font-size: clamp(0.6rem, 2.6vw, 0.72rem);
    }

    #signatureGlobal {
        display: none !important;
    }
}

@media (max-width: 767px) and (max-height: 620px) {
    #startScreen {
        gap: 0.2rem !important;
    }

    .start-kicker {
        display: none;
    }

    #startScreen h2 {
        font-size: clamp(1.2rem, 6.5vw, 1.65rem) !important;
    }

    #birthdayCountdown {
        padding: 0.42rem;
    }

    .countdown-title {
        margin-bottom: 0.28rem;
    }

    .countdown-unit {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .anime-squad-title {
        margin-bottom: 0.2rem;
    }

    .anime-squad-list {
        gap: 0.22rem 0.3rem;
    }

    .anime-chip {
        min-height: 36px;
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .anime-chip small {
        display: none;
    }

    #openBtn {
        min-height: 40px;
        padding-top: 0.48rem;
        padding-bottom: 0.48rem;
    }

    .mascot-stage {
        display: none;
    }

    .game-desc {
        margin-bottom: 0.35rem;
    }

    .game-rules {
        margin-bottom: 0.38rem;
    }

    #capture-area.cute-coupon {
        margin-bottom: 0.3rem;
        padding: 0.58rem !important;
    }
}

@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    #startScreen {
        display: grid !important;
        grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
        grid-template-rows: auto auto 1fr auto;
        gap: 0.25rem 0.75rem !important;
        padding: max(0.35rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(0.35rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)) !important;
        overflow: hidden !important;
    }

    .start-kicker {
        grid-column: 1;
        grid-row: 1;
        justify-self: center;
        font-size: 0.5rem;
    }

    #startScreen h2 {
        grid-column: 1;
        grid-row: 2;
        align-self: center;
        font-size: clamp(1.2rem, 4.5vw, 1.8rem) !important;
    }

    #birthdayCountdown {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
        width: 100%;
        padding: 0.45rem;
    }

    .anime-squad {
        grid-column: 1 / -1;
        grid-row: 3;
        align-self: center;
        width: 100%;
        max-width: 820px;
    }

    .anime-squad-list {
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.3rem;
        overflow: visible !important;
    }

    .anime-chip,
    .anime-chip:last-child {
        grid-column: auto;
        width: 100%;
        min-height: 38px;
        padding: 0.25rem 0.32rem;
        transform: none !important;
    }

    .anime-symbol {
        width: 25px;
    }

    .anime-chip small {
        display: none;
    }

    #openBtn {
        grid-column: 1 / -1;
        grid-row: 4;
        justify-self: center;
        min-height: 38px;
        padding: 0.42rem 1rem;
    }

    #messageBox,
    #endScreen {
        padding: 0.3rem !important;
        overflow: hidden !important;
    }

    #messageContent,
    #endInner {
        max-height: calc(100dvh - 0.6rem) !important;
    }

    .modal-content,
    .choice-content {
        max-height: calc(100dvh - 0.7rem) !important;
        padding: 0.65rem !important;
    }

    #userMessageInput {
        height: 34dvh;
        min-height: 80px;
    }

    .screen-game {
        justify-content: center !important;
        padding: max(0.45rem, env(safe-area-inset-top)) max(3.4rem, env(safe-area-inset-right)) max(0.35rem, env(safe-area-inset-bottom)) max(3.4rem, env(safe-area-inset-left)) !important;
        overflow: hidden !important;
    }

    .exit-game-btn {
        top: max(0.35rem, env(safe-area-inset-top)) !important;
        right: max(0.5rem, env(safe-area-inset-right)) !important;
    }

    .mascot-stage {
        display: none;
    }

    .game-badge {
        min-height: 21px;
        margin-bottom: 0.15rem;
        padding: 0.18rem 0.5rem;
    }

    .game-title {
        font-size: clamp(1.45rem, 5.5vw, 2.1rem) !important;
    }

    .game-desc {
        margin-bottom: 0.3rem;
        font-size: 0.65rem;
        line-height: 1.2;
    }

    .game-rules {
        width: min(65vw, 390px);
        margin-bottom: 0.3rem;
    }

    .game-rule {
        padding: 0.25rem 0.15rem;
    }

    .game-rule span {
        font-size: 1rem;
    }

    .game-grid {
        width: min(58dvh, 230px) !important;
        height: min(58dvh, 230px) !important;
    }

    .game-topbar {
        min-height: 32px;
        margin-bottom: 0.15rem;
    }

    .score-bubble,
    .streak-bubble {
        min-height: 32px;
        padding: 0.35rem 0.55rem;
    }

    .game-feedback {
        min-height: 20px;
        margin-bottom: 0.15rem;
    }

    .game-hint {
        margin-top: 0.2rem;
    }

    .winner-mascot {
        font-size: 2.8rem;
    }

    .mystery-box {
        max-width: 62px;
    }

    #capture-area.cute-coupon {
        width: min(58vw, 380px) !important;
        margin-bottom: 0.2rem;
        padding: 0.5rem !important;
    }

    .coupon-deco-top,
    .coupon-deco-bottom {
        display: none;
    }

    .coupon-subtitle {
        margin-bottom: 0.25rem;
    }

    .prize-container-decorated,
    #capture-area .prize-container-decorated {
        margin: 0.25rem 0;
        padding: 0.35rem;
    }

    #s-result > .btn-cute,
    .game-replay-btn {
        min-height: 32px;
        margin-top: 0.12rem;
        padding-top: 0.28rem;
        padding-bottom: 0.28rem;
    }
}

@media (hover: none) and (pointer: coarse) {
    .anime-chip:hover,
    .anime-chip:nth-child(even):hover,
    .btn:hover,
    .modal-btn:hover,
    .btn-cute:hover,
    .mystery-box:hover {
        transform: none;
    }
}

/* Static manga ornaments keep the phone greeting playful without floating text or emoji. */
@media (max-width: 767px) {
    #messageBox {
        isolation: isolate;
        background:
            radial-gradient(circle at 9% 18%, rgba(174, 230, 255, 0.2), transparent 18%),
            radial-gradient(circle at 91% 78%, rgba(255, 194, 216, 0.16), transparent 23%),
            linear-gradient(145deg, rgba(9, 15, 42, 0.84), rgba(25, 34, 79, 0.88));
    }

    #messageBox::before,
    #messageBox::after {
        content: "";
        position: absolute;
        z-index: 0;
        pointer-events: none;
    }

    #messageBox::before {
        top: max(2.5dvh, env(safe-area-inset-top));
        right: -23vw;
        width: min(62vw, 270px);
        aspect-ratio: 1;
        border: 2px solid rgba(174, 230, 255, 0.27);
        border-radius: 50%;
        background:
            radial-gradient(circle at center, rgba(174, 230, 255, 0.1) 0 9%, transparent 10% 21%, rgba(255, 194, 216, 0.09) 22% 23%, transparent 24%),
            repeating-conic-gradient(from 14deg, rgba(200, 187, 255, 0.14) 0 2deg, transparent 2deg 18deg);
        box-shadow:
            inset 0 0 0 14px rgba(200, 187, 255, 0.055),
            inset 0 0 0 28px rgba(174, 230, 255, 0.04),
            0 0 40px rgba(174, 230, 255, 0.1);
        transform: rotate(12deg);
    }

    #messageBox::after {
        bottom: -10dvh;
        left: -17vw;
        width: 76vw;
        height: 36dvh;
        border-radius: 50% 50% 0 0;
        background:
            repeating-linear-gradient(142deg, transparent 0 18px, rgba(255, 194, 216, 0.12) 19px 21px, transparent 22px 40px),
            radial-gradient(ellipse at center, rgba(200, 187, 255, 0.12), transparent 67%);
        opacity: 0.9;
        transform: rotate(-7deg);
    }

    #messageContent {
        position: relative;
        z-index: 1;
        border-color: rgba(200, 187, 255, 0.38) !important;
        background:
            radial-gradient(circle at 94% 8%, rgba(174, 230, 255, 0.16), transparent 26%),
            radial-gradient(circle at 7% 93%, rgba(255, 194, 216, 0.12), transparent 30%),
            linear-gradient(145deg, rgba(38, 53, 111, 0.97), rgba(16, 24, 58, 0.98)) !important;
        box-shadow:
            0 18px 0 rgba(79, 95, 162, 0.28),
            0 30px 64px rgba(3, 7, 26, 0.48),
            inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
    }

    #messageContent::before {
        content: "";
        position: absolute;
        inset: 6px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 15px;
        pointer-events: none;
    }
}

/* Mobile keeps the cinematic background visible through every card. */
body #messageBox {
    background: rgba(7, 11, 32, 0.18) !important;
    backdrop-filter: none !important;
}

body #messageContent,
body #endInner,
body .modal-content,
body .choice-content,
body .photo-booth-card,
body .photo-booth-controls,
body .photo-booth-preview {
    background: rgba(7, 11, 32, 0.22) !important;
    backdrop-filter: none !important;
}

/* One active layer at a time: the gift picker sits above the ending and
   keeps its controls readable without hiding the cinematic background. */
body #giftChoiceModal {
    z-index: 22000 !important;
    background: rgba(3, 7, 20, 0.58) !important;
    isolation: isolate;
}

body #giftChoiceModal .choice-content {
    position: relative;
    z-index: 1;
    background: linear-gradient(145deg, rgba(25, 35, 82, 0.9), rgba(9, 15, 42, 0.88)) !important;
    border-color: rgba(200, 187, 255, 0.48) !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42) !important;
}

body #endInner .typing-line {
    min-height: 1.4em;
    margin: 0.12rem 0 !important;
    line-height: 1.45 !important;
}

/* Clear greeting surfaces: the GOJO-Master artwork stays bright and crisp,
   while the content remains readable without visible container outlines. */
body #gojoMasterBackground .gojo-bg-vignette {
    background:
        radial-gradient(circle at 50% 42%, transparent 0 28%, rgba(5, 7, 20, 0.06) 62%, rgba(3, 5, 14, 0.28) 100%),
        linear-gradient(90deg, rgba(4, 7, 21, 0.28), rgba(4, 7, 21, 0.04) 48%, rgba(4, 7, 21, 0.25)) !important;
}

body #gojoMasterBackground .gojo-bg-image,
body #gojoMasterBackground .gojo-bg-video {
    filter: saturate(1.14) contrast(1.08) brightness(1.16) !important;
}

body #messageBox {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

body #messageBox::before {
    background: transparent !important;
    opacity: 0 !important;
}

body #messageContent {
    background: rgba(7, 11, 32, 0.1) !important;
    border: 0 !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

body #messageContent::before {
    display: none !important;
}

body #typedText {
    background: rgba(7, 11, 32, 0.08) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Pesan rahasia memakai permukaan kaca tipis tanpa kotak gelap atau garis
   tebal. Ending di belakangnya akan dipulihkan saat modal ditutup. */
body #msgModal {
    background: rgba(3, 7, 20, 0.08) !important;
    backdrop-filter: none !important;
}

body #msgModal .modal-content {
    background: rgba(7, 11, 32, 0.13) !important;
    border: 0 !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

body #msgModal #userMessageInput {
    background: rgba(7, 11, 32, 0.1) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Ucapan memakai dua frame Gojo: gambar masked menjadi lapisan atas,
   sementara cahaya pointer membuka lapisan bawah di sekitar kursor. */
.gojo-greeting-veil {
    --greet-x: 50%;
    --greet-y: 50%;
    position: absolute;
    inset: 0;
    z-index: 4;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 700ms ease;
}

body #gojoMasterBackground[data-state="message"] .gojo-greeting-veil {
    opacity: 1;
}

.gojo-greeting-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: saturate(1.12) contrast(1.08) brightness(1.08);
}

.gojo-greeting-under {
    z-index: 0;
    transform: scale(1.025);
}

.gojo-greeting-fog {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.86;
    mix-blend-mode: screen;
    filter: blur(3px) saturate(1.18);
}

.gojo-greeting-top {
    transform: scale(1.025);
    -webkit-mask-image: radial-gradient(circle 230px at var(--greet-x) var(--greet-y), transparent 0, transparent 76px, rgba(0, 0, 0, 0.25) 150px, #000 280px);
    mask-image: radial-gradient(circle 230px at var(--greet-x) var(--greet-y), transparent 0, transparent 76px, rgba(0, 0, 0, 0.25) 150px, #000 280px);
    z-index: 3;
}

.gojo-greeting-veil::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background: radial-gradient(circle 300px at var(--greet-x) var(--greet-y), rgba(126, 231, 255, 0.12), transparent 56%);
    mix-blend-mode: screen;
}

.gojo-greeting-cursor {
    position: fixed;
    top: var(--greet-y);
    left: var(--greet-x);
    z-index: 6;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(126, 231, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(79, 216, 255, 0.8), inset 0 0 14px rgba(126, 231, 255, 0.38), 0 0 42px rgba(91, 108, 255, 0.45);
    transform: translate(-50%, -50%);
    transition: width 180ms ease, height 180ms ease, border-color 180ms ease;
}

.gojo-greeting-cursor::before,
.gojo-greeting-cursor::after {
    content: "";
    position: absolute;
    inset: -14px;
    border: 1px solid rgba(126, 231, 255, 0.22);
    border-radius: 50%;
    animation: gojoGreetingPulse 2.4s ease-out infinite;
}

.gojo-greeting-cursor::after {
    inset: -28px;
    border-color: rgba(180, 107, 255, 0.16);
    animation-delay: 0.8s;
}

.gojo-greeting-cursor span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #eaf6ff;
    box-shadow: 0 0 12px #7ee7ff, 0 0 28px #4fd8ff;
    transform: translate(-50%, -50%);
}

@keyframes gojoGreetingPulse {
    0% { opacity: 0.7; transform: scale(0.72); }
    100% { opacity: 0; transform: scale(1.18); }
}

.gojo-greeting-hud {
    position: absolute;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: clamp(0.9rem, 2vw, 1.4rem) clamp(1rem, 2vw, 2rem);
    color: rgba(223, 238, 255, 0.52);
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.42rem, 0.65vw, 0.62rem);
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.gojo-greeting-hud b,
.gojo-greeting-hud small { color: #7ee7ff; font-weight: 400; }
.gojo-greeting-hud small { margin-left: 0.5rem; color: #b46bff; }
.gojo-greeting-hud-top { top: 0; }
.gojo-greeting-hud-bottom { bottom: 0; }

@media (hover: none) {
    .gojo-greeting-cursor { display: none; }
    .gojo-greeting-fog { opacity: 0.3; filter: blur(7px) saturate(1.08); }
    .gojo-greeting-top {
        -webkit-mask-image: radial-gradient(circle 210px at 50% 50%, transparent 0, transparent 72px, rgba(0, 0, 0, 0.3) 145px, #000 260px);
        mask-image: radial-gradient(circle 210px at 50% 50%, transparent 0, transparent 72px, rgba(0, 0, 0, 0.3) 145px, #000 260px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gojo-greeting-fog { display: none; }
}

/* Modal kirim pesan memakai panel gelap agar fokus tetap pada tulisan,
   sekaligus masih menyisakan aksen cyan-violet khas GOJO-Master. */
body #msgModal {
    background: rgba(2, 5, 18, 0.76) !important;
    backdrop-filter: blur(16px) saturate(0.82) !important;
}

body #msgModal .modal-content {
    background: linear-gradient(145deg, rgba(10, 17, 46, 0.98), rgba(4, 8, 24, 0.99)) !important;
    border: 1px solid rgba(126, 231, 255, 0.28) !important;
    border-radius: 22px !important;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.68), inset 0 0 0 1px rgba(180, 107, 255, 0.08) !important;
    color: #dfeeff !important;
}

body #msgModal .modal-content h3 {
    color: #eaf6ff !important;
    text-shadow: 0 0 18px rgba(79, 216, 255, 0.42) !important;
}

body #msgModal #userMessageInput {
    background: rgba(2, 5, 18, 0.78) !important;
    border: 1px solid rgba(126, 231, 255, 0.3) !important;
    color: #f2f7ff !important;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.22) !important;
}

body #msgModal #userMessageInput::placeholder {
    color: rgba(223, 238, 255, 0.5) !important;
}

body #msgModal #userMessageInput:focus {
    background: rgba(3, 8, 28, 0.92) !important;
    border-color: #7ee7ff !important;
    box-shadow: 0 0 0 3px rgba(79, 216, 255, 0.12), inset 0 0 20px rgba(0, 0, 0, 0.24) !important;
}

body #msgModal #cancelMsgBtn {
    color: #dfeeff !important;
    background: rgba(9, 15, 38, 0.9) !important;
    border: 1px solid rgba(223, 238, 255, 0.28) !important;
}

body #msgModal #sendMsgBtn {
    color: #ffffff !important;
    background: linear-gradient(135deg, #254b7e, #6d4cc2) !important;
    border: 1px solid rgba(126, 231, 255, 0.38) !important;
    box-shadow: 0 8px 22px rgba(22, 50, 105, 0.45), 0 0 18px rgba(126, 108, 255, 0.2) !important;
}

/* Tipografi halaman ucapan: lebih bulat untuk judul, lebih bersih untuk isi. */
body #messageContent {
    font-family: 'Fredoka', 'Poppins', sans-serif !important;
}

body #messageContent #title,
body #messageContent .name-under-photo,
body #messageContent #toEndingBtn {
    font-family: 'Fredoka', 'Poppins', sans-serif !important;
}

body #messageContent #typedText,
body #messageContent #timeWrapper,
body #messageContent .birth-date,
body #messageContent .birth-age,
body #messageContent .current-date {
    font-family: 'Space Mono', 'JetBrains Mono', monospace !important;
}

body #messageContent #toEndingBtn {
    min-width: 118px;
    padding: 0.68rem 1.45rem !important;
    letter-spacing: 0.06em;
    font-weight: 700;
}

/* Keep the pointer aura, but remove the visible circular cursor markers. */
body .cursor,
body .gojo-greeting-cursor {
    display: none !important;
}

/* Ending copy should remain comfortably readable on desktop and mobile. */
body #endScreen #endInner > .typing-line {
    font-size: clamp(1rem, 1.35vw, 1.28rem) !important;
    line-height: 1.5 !important;
}

@media (max-width: 600px) {
    body #endScreen #endInner > .typing-line {
        font-size: clamp(0.86rem, 3.8vw, 1.04rem) !important;
        line-height: 1.45 !important;
    }
}

/* Mobile entry notice: the desktop layout remains available by confirmation. */
#mobileWarning[hidden] {
    display: none !important;
}

#mobileWarning {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(3, 7, 20, 0.82);
    backdrop-filter: blur(14px) saturate(0.9);
}

.mobile-warning-card {
    width: min(100%, 420px);
    padding: clamp(1.35rem, 6vw, 2rem);
    border: 1px solid rgba(126, 231, 255, 0.48);
    border-radius: 24px;
    color: #eaf6ff;
    text-align: center;
    background: linear-gradient(145deg, rgba(18, 31, 76, 0.98), rgba(7, 13, 38, 0.98));
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58), 0 0 32px rgba(79, 216, 255, 0.14);
}

.mobile-warning-kicker {
    color: #9cecff;
    font: 700 0.68rem/1.2 'Space Mono', monospace;
    letter-spacing: 0.14em;
}

.mobile-warning-card h2 {
    margin: 0.7rem 0 0.75rem;
    color: #ffc2df;
    font-family: 'Fredoka', 'Poppins', sans-serif;
    font-size: clamp(1.35rem, 6vw, 1.85rem);
    line-height: 1.12;
}

.mobile-warning-card p {
    margin: 0;
    color: rgba(234, 246, 255, 0.84);
    font-size: clamp(0.9rem, 3.8vw, 1rem);
    line-height: 1.55;
}

.mobile-warning-actions {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 0.65rem;
    margin-top: 1.25rem;
}

.mobile-warning-actions button {
    min-height: 2.8rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid rgba(174, 230, 255, 0.32);
    border-radius: 999px;
    color: #eaf6ff;
    background: rgba(255, 255, 255, 0.08);
    font: 700 0.86rem 'Fredoka', 'Poppins', sans-serif;
    cursor: pointer;
}

.mobile-warning-actions button:last-child {
    color: #101734;
    border-color: transparent;
    background: linear-gradient(135deg, #aee6ff, #e5b8ff);
    box-shadow: 0 8px 20px rgba(126, 231, 255, 0.2);
}

.mobile-warning-actions button:focus-visible {
    outline: 3px solid rgba(255, 194, 216, 0.8);
    outline-offset: 3px;
}
