@charset "UTF-8";

/* ============================================================================
 * Private Sun Yat-sen Memorial Hall — Main Stylesheet (style.css)
 * ============================================================================
 * COMMENTING STANDARDS
 * 1. Block comments only. Inline comments (//) are strictly prohibited.
 * 2. Section dividers use the === banner format shown above.
 * 3. All prose is written in English.
 * 4. No debugging notes, temporary workarounds, or console output in
 *    committed code.
 * 5. Tailwind Migration Preparation: utility-mappable rules should be annotated
 *    with `@tw:` followed by the suggested Tailwind class equivalents to aid
 *    future migration.
 * ============================================================================
 */

/* ============================================================================
 * Global Layout & Viewport Lock
 * ============================================================================
 * Locks the viewport height to prevent scrolling, ensuring immersion.
 * @tw: fixed inset-0 w-full h-full h-screen h-dvh bg-[#111111] overflow-hidden
 * ============================================================================ */
html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    background-color: #111111;
    overflow: hidden;
}

@media all and (display-mode: standalone) {
    html,
    body {
        height: 100vh;
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

html.is-standalone,
html.is-standalone body {
    height: 100vh;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ============================================================================
 * Typography & Flexbox Foundation
 * ============================================================================
 * Defines global font families catering to native OS preferences.
 * @tw: text-white flex flex-col justify-start items-center box-border
 * ============================================================================ */
body {
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
    position: relative;
    padding: max(60px, 8vh) 20px calc(75px + env(safe-area-inset-bottom, 0px)) 20px;
    padding: max(60px, 8dvh) 20px calc(75px + env(safe-area-inset-bottom, 0px)) 20px;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

/* ============================================================================
 * Main Container
 * ============================================================================
 * Caps maximum width and initializes the 3D perspective context.
 * @tw: flex flex-col items-center justify-center w-full max-w-[500px] my-auto
 * ============================================================================ */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    margin: auto 0;
    perspective: 1000px;
}

/* ============================================================================
 * Portrait Frame Module
 * ============================================================================
 * Embeds anti-jitter 3D transformations for fluid hardware acceleration.
 * @tw: cursor-none w-fit flex justify-center items-center mx-auto mb-[17px]
 * ============================================================================ */
.frame-container {
    cursor: none;
    width: fit-content;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 17px auto;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    /* HW acceleration forcing and subtle scaling to hide border aliasing */
    transform: scale(0.9816) translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform-origin: center center;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-tap-highlight-color: transparent !important;
}

@media (hover: hover) and (pointer: fine) {
    .frame-container:hover {
        /* Maintains translateZ(0) across transforms */
        transform: scale(1) translateZ(0);
    }
}

/* ============================================================================
 * Wood Frame Material
 * ============================================================================
 * Composes complex linear gradients and shadows to simulate a lit wooden frame.
 * @tw: inline-block relative rounded-[4px]
 * ============================================================================ */
.wood-frame {
    display: inline-block;
    line-height: 0;
    box-sizing: border-box;
    border-radius: 4px;
    position: relative;
    padding: clamp(10px, 3.5vw, 20px);
    background: repeating-linear-gradient(90deg,
            rgba(40, 18, 9, 0.06) 0px,
            rgba(40, 18, 9, 0.06) 3px,
            rgba(70, 35, 18, 0.04) 3px,
            rgba(70, 35, 18, 0.04) 6px),
        linear-gradient(135deg, #2d140a 0%, #3f1f11 50%, #200e05 100%);
    background-blend-mode: multiply;
    border: clamp(2px, 0.8vw, 4px) solid #1a0a03;
    box-shadow: 0 clamp(10px, 3vw, 20px) clamp(20px, 6vw, 45px) rgba(0, 0, 0, 0.9),
        inset 0 0 0 clamp(1px, 0.5vw, 2px) #4d2615,
        inset 0 0 0 clamp(2px, 0.6vw, 3px) #150802,
        inset var(--sh-x, 8px) var(--sh-y, 8px) clamp(15px, 4vw, 25px) rgba(0, 0, 0, var(--sh-alpha, 0.65)),
        inset var(--hl-x, -6px) var(--hl-y, -6px) clamp(15px, 4vw, 25px) rgba(255, 255, 255, var(--hl-alpha, 0.04)),
        inset 0 0 clamp(8px, 2.5vw, 15px) rgba(0, 0, 0, 0.85);
    /* Prevents render glitching during transitions */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

/* ============================================================================
 * Portrait Inner Frame
 * ============================================================================
 * @tw: box-border block p-[1px] bg-[#9c7210] border-2 border-[#150802] rounded-[1px] shadow-[0_3px_10px_rgba(0,0,0,0.85)]
 * ============================================================================ */
.wood-frame img {
    box-sizing: border-box;
    display: block;
    padding: 1px;
    background-color: #9c7210;
    border: 2px solid #150802;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.85);
    border-radius: 1px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ============================================================================
 * Portrait Image
 * ============================================================================
 * @tw: w-auto object-cover border-4 border-[#140a05] shadow-[0_0_15px_rgba(0,0,0,0.6)]
 * ============================================================================ */
.portrait-img {
    height: min(440px, 38vh) !important;
    height: min(440px, 38dvh) !important;
    width: auto !important;
    aspect-ratio: 320 / 440;
    object-fit: cover;
    border: 4px solid #140a05;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
    /* Strict hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ============================================================================
 * Attendance Counter
 * ============================================================================
 * @tw: mx-auto mb-[25px] bg-[rgba(35,16,7,0.4)] px-[18px] py-[5px] rounded-[20px] border border-[rgba(138,100,15,0.4)] text-center
 * ============================================================================ */
.attendance-box {
    margin: 0 auto 25px auto;
    font-family: "BiauKai", "Kaiti TC", "Kaiti SC", "標楷體", "KaiTi", "DFKai-SB", serif !important;
    background: rgba(35, 16, 7, 0.4);
    padding: 5px 18px;
    border-radius: 20px;
    border: 1px solid rgba(138, 100, 15, 0.4);
    text-align: center;
}

.attendance-label {
    color: #aaaaaa;
    font-size: 0.95rem;
}

.attendance-count {
    color: #f1c40f;
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0 3px;
}

.attendance-unit {
    color: #aaaaaa;
    font-size: 0.95rem;
}

/* ============================================================================
 * Testament Box
 * ============================================================================
 * Uses traditional vertical reading alignment (writing-mode: vertical-rl).
 * @tw: mt-[15px] w-full relative
 * ============================================================================ */
.testament-box {
    margin-top: 15px;
    width: 100%;
    position: relative;
}

.testament-text {
    writing-mode: vertical-rl;
    text-orient: mixed;
    font-family: "BiauKai", "Kaiti TC", "Kaiti SC", "標楷體", "KaiTi", "DFKai-SB", serif !important;
    height: min(340px, 35vh);
    height: min(340px, 35dvh);
    font-size: clamp(0.9rem, 2.2vh, 1.15rem);
    font-size: clamp(0.9rem, 2.2dvh, 1.15rem);
    text-align: start;
    word-break: break-all;
    color: #dcdee0;
    line-height: 1.8;
    letter-spacing: 4px;
    padding: 0 15px;
    border-left: 1px rgba(255, 255, 255, 0.18) dashed;
    border-right: 1px rgba(255, 255, 255, 0.18) dashed;
    position: relative;
    width: max-content !important;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease;
}

/* ============================================================================
 * Mobile Long-Press Interaction Feedback
 * ============================================================================ */
.testament-box,
.testament-text {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.testament-text.testament-pressing {
    transform: translateX(-50%) scale(0.985);
    border-color: rgba(241, 196, 15, 0.7);
    color: #ffffff;
    text-shadow: 0 0 12px rgba(241, 196, 15, 0.6);
    transition: transform 0.15s ease, border-color 0.15s ease, text-shadow 0.15s ease;
}

/* Desktop spacing adaptations for typography */
@media (min-width: 1025px) {
    .testament-text {
        height: min(280px, 30vh) !important;
        height: min(280px, 30dvh) !important;
        font-size: clamp(14px, 2.5vh, 18px) !important;
        line-height: 2.1 !important;
        letter-spacing: 6px !important;
        padding: 0 40px !important;
        margin-bottom: 10px !important;
    }
}

/* ============================================================================
 * Top Banners & Navigation
 * ============================================================================
 * Controls entry and exit animations of notification toasts.
 * @tw: fixed top-0 left-0 w-full bg-[#231007] text-[#f1c40f] border-b-2 border-[#8a640f] py-[14px] text-center font-bold tracking-[5px] shadow-[0_4px_15px_rgba(0,0,0,0.6)]
 * ============================================================================ */
.memorial-banner,
.status-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #231007;
    color: #f1c40f;
    border-bottom: 2px solid #8a640f;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: 12px;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif !important;
    font-size: 1.05rem;
    font-weight: bold;
    letter-spacing: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
}

.memorial-banner {
    z-index: 10000;
    transform: translateY(0);
    opacity: 1;
}

.memorial-banner.hidden {
    transform: translateY(-100%);
    opacity: 0;
}

.status-banner {
    z-index: 10005;
    pointer-events: none;
    transform: translateY(-100%);
    opacity: 0;
}

.status-banner.show {
    transform: translateY(0);
    opacity: 1;
}

/* Top Hover Trigger Area */
.top-hover-trigger {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 15px;
    z-index: 20000;
}

/* Dropdown Navbar */
.dropdown-nav-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to bottom, #1c0e07, #110804);
    border-bottom: 2px solid #b8860b;
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.9);
    transform: translateY(-100%);
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Festival Banner Text */
.nav-festival-banner {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #f1c40f;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif;
    font-weight: bold;
    font-size: clamp(12px, 3vw, 15px);
    text-align: center;
    letter-spacing: 2px;
    margin: 0;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(241, 196, 15, 0.4);
    pointer-events: none;
}

.nav-festival-banner:empty {
    display: none !important;
}

.nav-festival-banner[role="link"] {
    pointer-events: auto;
    transition: text-shadow 0.2s ease, letter-spacing 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .nav-festival-banner[role="link"]:hover {
        text-shadow: 0 0 14px rgba(241, 196, 15, 0.85);
        letter-spacing: 3px;
    }
}

.nav-festival-banner[role="link"]:active {
    text-shadow: 0 0 18px rgba(241, 196, 15, 1);
    opacity: 0.8;
}

@media (min-width: 1025px) {

    body:not(.banner-active) .top-hover-trigger:hover .dropdown-nav-bar,
    body:not(.banner-active) .dropdown-nav-bar:hover {
        transform: translateY(0);
    }
}

body.banner-active .dropdown-nav-bar {
    transform: translateY(-100%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.dropdown-nav-bar.force-show {
    transform: translateY(0) !important;
}

/* Navigation Links */
.nav-link {
    color: #f1c40f;
    text-decoration: none;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif;
    font-size: 1.02rem;
    letter-spacing: 1px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        color: #ffffff;
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    }
}

.nav-link:active {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* Minguo Date Display */
#minguo-date-display {
    color: #cddee0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif;
    font-size: 1.02rem;
}

/* Mobile Dropdown Arrow */
.mobile-arrow-hint {
    display: none !important;
}

.memorial-banner:not(.hidden)~.top-hover-trigger .mobile-arrow-hint,
.status-banner.show~.top-hover-trigger .mobile-arrow-hint {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.dropdown-nav-bar.force-show+.mobile-arrow-hint {
    opacity: 0 !important;
    pointer-events: none !important;
}

@keyframes arrowBounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(3px);
    }
}

/* ============================================================================
 * Mobile Viewport Adjustments
 * ============================================================================
 * Dynamically corrects padding and layout sizes on constrained devices.
 * ============================================================================ */
@media (max-width: 1024px) {
    body {
        padding-top: calc(44px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 34px));
    }

    .portrait-img {
        height: min(290px, 25vh) !important;
        height: min(290px, 25dvh) !important;
    }

    .attendance-box {
        margin: 10px auto 14px auto;
    }

    .testament-box {
        padding: 0 15px !important;
        box-sizing: border-box;
        width: 100%;
        position: relative;
        margin-top: 6px;
    }

    .testament-text {
        height: min(295px, 29vh) !important;
        height: min(295px, 29dvh) !important;
        font-size: clamp(11.5px, 3.3vw, 14.5px) !important;
        line-height: 1.75 !important;
        letter-spacing: 3.5px !important;
        padding: 0 12px !important;
        box-sizing: border-box;
        width: max-content !important;
        left: 50%;
        transform: translateX(-50%);
    }

    .frame-container,
    .wood-frame,
    .wood-frame img,
    .portrait-img {
        outline: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .wood-frame img {
        padding: 1px !important;
        background-color: #9c7210 !important;
        border: none !important;
        box-shadow: 0 0 0 2px #150802, 0 3px 10px rgba(0, 0, 0, 0.9) !important;
        border-radius: 1px !important;
    }

    .portrait-img {
        border: 2px solid #111111 !important;
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.95), 0 0 15px rgba(0, 0, 0, 0.8) !important;
    }

    /* Mobile Navbar Formatting */
    .dropdown-nav-bar {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 15px 12px 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    body.has-festival #minguo-date-display {
        display: none !important;
    }

    .nav-festival-banner {
        position: relative !important;
        left: auto !important;
        transform: none !important;
        margin: 0 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        font-size: clamp(11px, 2.8vw, 13px) !important;
        white-space: nowrap !important;
        letter-spacing: 0px !important;
        text-shadow: 0 0 8px rgba(241, 196, 15, 0.4);
    }

    .nav-link {
        display: flex !important;
        align-items: center !important;
        margin-right: auto !important;
        font-size: clamp(11px, 2.8vw, 13px) !important;
        white-space: nowrap !important;
        letter-spacing: 0px !important;
    }

    #minguo-date-display {
        display: flex !important;
        align-items: center !important;
        font-size: clamp(11px, 2.8vw, 13px) !important;
        white-space: nowrap !important;
        letter-spacing: 0px !important;
    }
}

@media (pointer: coarse) {
    .mobile-arrow-hint {
        display: block !important;
        position: absolute !important;
        top: calc(10px + env(safe-area-inset-top, 0px)) !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(0);
        width: 26px !important;
        height: 18px !important;
        background: rgba(24, 12, 6, 0.85) !important;
        border: 1px solid rgba(200, 200, 200, 0.18) !important;
        border-radius: 6px !important;
        color: rgba(160, 160, 160, 0.6) !important;
        cursor: pointer !important;
        z-index: 19000 !important;
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4) !important;
        overflow: hidden !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transition:
            opacity 0.4s cubic-bezier(0.215, 0.610, 0.355, 1),
            transform 0.4s cubic-bezier(0.215, 0.610, 0.355, 1),
            visibility 0.4s !important;
        transition-delay: 0.35s !important;
        animation: arrowBounce 2s infinite;
    }

    .memorial-banner:not(.hidden)~.top-hover-trigger .mobile-arrow-hint,
    .status-banner.show~.top-hover-trigger .mobile-arrow-hint,
    .dropdown-nav-bar.force-show+.mobile-arrow-hint,
    body.tab-navigating .mobile-arrow-hint,
    .mobile-arrow-hint.nav-hidden {
        display: block !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateX(-50%) translateY(-40px) !important;
        transition:
            opacity 0s,
            transform 0s,
            visibility 0s !important;
        transition-delay: 0s !important;
    }

    .mobile-arrow-hint svg {
        width: 11px !important;
        height: 11px !important;
        display: block !important;
        margin: 3px auto 0 auto !important;
    }

    .frame-container {
        transform: none !important;
    }
}

/* Mini Screens Fallback */
@media (max-width: 375px) {
    body {
        padding-left: 8px;
        padding-right: 8px;
    }

    .testament-text {
        line-height: 1.4;
        letter-spacing: 2px;
    }

    .attendance-box {
        margin-bottom: 15px;
        padding: 3px 12px;
    }

    .nav-link,
    #minguo-date-display,
    .nav-festival-banner {
        font-size: 11px !important;
    }
}

/* ============================================================================
 * Extremely Short Viewport Fallback
 * ============================================================================
 * Prevents overlaps on low-resolution landscape screens.
 * ============================================================================ */
@media (max-height: 750px) {
    body {
        padding-top: calc(30px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 34px));
    }

    .portrait-img {
        height: min(240px, 24vh) !important;
        height: min(240px, 24dvh) !important;
    }

    .attendance-box {
        margin: 6px auto 10px auto;
        padding: 4px 16px;
    }

    .testament-box {
        margin-top: 4px;
    }

    .testament-text {
        height: min(230px, 28vh) !important;
        height: min(230px, 28dvh) !important;
        font-size: clamp(11px, 2.8vw, 13px) !important;
    }
}

/* ============================================================================
 * Gyroscope Lighting (Touch Devices Only)
 * ============================================================================
 * Disables CSS transitions on touch devices allowing requestAnimationFrame
 * absolute control over transform logic.
 * ============================================================================ */
@media (hover: none),
(pointer: coarse) {
    .wood-frame {
        transition: none;
    }
}

/* ============================================================================
 * Light Mode Overrides (Automatic Switcher)
 * ============================================================================
 * Alters the palette to a warmer historical parchment aesthetic for daytime.
 * @tw: dark:bg-[#111111] bg-[#f5f0e8]
 * ============================================================================ */
@media (prefers-color-scheme: light) {

    html,
    body {
        background-color: #f5f0e8;
    }

    body {
        color: #2c1810;
    }

    /* Modifies frame casting shadow */
    .frame-container {
        filter: drop-shadow(0 10px 22px rgba(80, 45, 10, 0.18));
    }

    .wood-frame {
        background:
            repeating-linear-gradient(90deg,
                rgba(60, 30, 10, 0.12) 0px,
                rgba(60, 30, 10, 0.12) 3px,
                rgba(90, 50, 18, 0.09) 3px,
                rgba(90, 50, 18, 0.09) 6px),
            linear-gradient(135deg, #4a2c12 0%, #633c22 50%, #3e2510 100%);
        background-blend-mode: multiply;
        border-color: #321a08;
        box-shadow:
            0 clamp(10px, 3vw, 20px) clamp(16px, 5vw, 35px) rgba(50, 25, 5, 0.5),
            inset 0 0 0 clamp(1px, 0.5vw, 2px) #7a4e28,
            inset 0 0 0 clamp(2px, 0.6vw, 3px) #251408,
            inset var(--sh-x, 8px) var(--sh-y, 8px) clamp(15px, 4vw, 25px) rgba(0, 0, 0, var(--sh-alpha, 0.45)),
            inset var(--hl-x, -6px) var(--hl-y, -6px) clamp(15px, 4vw, 25px) rgba(220, 170, 90, var(--hl-alpha, 0.09)),
            inset 0 0 clamp(8px, 2.5vw, 15px) rgba(0, 0, 0, 0.4);
    }

    .wood-frame img {
        background-color: #b8880e !important;
        border-color: #251408 !important;
        box-shadow: 0 3px 10px rgba(40, 20, 0, 0.5) !important;
    }

    .portrait-img {
        border-color: #5a3412 !important;
        box-shadow: 0 0 10px rgba(80, 45, 0, 0.25) !important;
    }

    .attendance-box {
        background: rgba(196, 168, 118, 0.25);
        border-color: rgba(138, 100, 15, 0.35);
    }

    .attendance-label,
    .attendance-unit {
        color: #6b4c35;
    }

    .attendance-count {
        color: #8a6400;
    }

    .testament-text {
        color: #2c1810;
        border-left-color: rgba(100, 70, 30, 0.3);
        border-right-color: rgba(100, 70, 30, 0.3);
    }

    .memorial-banner,
    .status-banner {
        background-color: #e8dcc8;
        color: #7a5200;
        border-bottom-color: #b8860b;
        box-shadow: 0 4px 15px rgba(100, 70, 0, 0.15);
    }

    .dropdown-nav-bar {
        background: linear-gradient(to bottom, #ede8dc, #e0d8c8);
        border-bottom-color: #b8860b;
        box-shadow: 0 5px 25px rgba(80, 50, 10, 0.15);
    }

    .nav-link {
        color: #7a5200;
    }

    @media (hover: hover) and (pointer: fine) {
        .nav-link:hover {
            color: #2c1810;
            text-shadow: 0 0 8px rgba(44, 24, 16, 0.3);
        }
    }

    .nav-link:active {
        color: #2c1810;
        text-shadow: 0 0 8px rgba(44, 24, 16, 0.3);
    }

    .nav-festival-banner {
        color: #8a6400;
        text-shadow: 0 0 8px rgba(138, 100, 0, 0.3);
    }

    .nav-festival-banner[role="link"]:hover {
        text-shadow: 0 0 14px rgba(138, 100, 0, 0.6);
    }

    #minguo-date-display {
        color: #5a3e2a;
    }

    .mobile-arrow-hint {
        background: rgba(232, 220, 200, 0.9) !important;
        border-color: rgba(100, 70, 30, 0.25) !important;
        color: rgba(100, 70, 30, 0.55) !important;
        box-shadow: 0 3px 6px rgba(80, 50, 10, 0.2) !important;
    }
}

/* ============================================================================
 * Danmaku Rendering Layer
 * ============================================================================
 * Penetrative overlay strictly for animation frames.
 * @tw: fixed inset-0 w-full h-full pointer-events-none z-[9000] overflow-hidden
 * ============================================================================ */
#danmaku-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9000;
    overflow: hidden;
}

#danmaku-container.hidden {
    display: none !important;
}

.danmaku-item {
    position: absolute;
    white-space: nowrap;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: bold;
    color: #ffffff;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0px 2px 4px rgba(0, 0, 0, 0.8);
    animation: danmaku-slide linear forwards;
    will-change: transform;
}

@keyframes danmaku-slide {
    from {
        transform: translateX(100vw);
    }
    to {
        transform: translateX(-100%);
    }
}

/* ============================================================================
 * Bottom Sheet Modal (iOS App Store Style)
 * ============================================================================
 * Overridden for desktop views subsequently.
 * ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 30000;
    visibility: hidden;
    pointer-events: none;
    transition: background-color 0.1s linear, visibility 0.1s linear;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "Hiragino Sans GB", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.modal-overlay.active {
    background-color: rgba(0, 0, 0, 0.65); /* App Store style deep dimming */
    visibility: visible;
    pointer-events: auto;
}

/* The Sheet Container */
.modal-sheet {
    position: relative;
    background: #faf7f2; /* Harmonized warm off-white */
    width: 100%;
    max-width: 500px;
    border-radius: 14px 14px 0 0;
    padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 16px)) 16px;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.1s linear;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
}

.modal-overlay.active .modal-sheet {
    transform: translateY(0) scale(1);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1); /* Keep entrance slightly snappier */
}

@media (prefers-color-scheme: dark) {
    .modal-sheet {
        background: #1c1c1e; /* Deeper dark mode gray to match iOS/webpage */
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    }
}

/* Modal Header Layout */
.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    position: relative;
}

.sheet-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #000;
    line-height: 1; /* Tight wrap to fix flex geometric center offset */
}

@media (prefers-color-scheme: dark) {
    .sheet-title {
        color: #fff;
    }
}

.sheet-close-btn {
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #3c3c43;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
    outline: none;
}

.sheet-close-btn:hover {
    background: rgba(0, 0, 0, 0.12);
}

/* Input Area Restyling */
.sheet-content {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    padding: 0;
    margin-bottom: 28px;
    box-shadow: none;
    overflow: hidden;
}

@media (prefers-color-scheme: dark) {
    .sheet-content {
        background: #2c2c2e; /* Harmonized dark mode card color */
    }
    
    .sheet-close-btn {
        background: rgba(255, 255, 255, 0.12);
        color: rgba(235, 235, 245, 0.6);
    }
    .sheet-close-btn:hover {
        background: rgba(255, 255, 255, 0.18);
    }
}

.ios-textarea {
    width: 100%;
    height: 90px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 14px 16px;
    color: #000;
    font-size: 1rem;
    resize: none;
    font-family: inherit;
    box-sizing: border-box;
}

.ios-textarea:focus {
    outline: none;
}

@media (prefers-color-scheme: dark) {
    .ios-textarea {
        color: #fff;
    }
}

.char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.75rem;
    color: #8e8e93; /* Apple system gray */
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

/* Footer & Buttons */
.sheet-footer {
    display: flex;
    justify-content: center;
    padding: 0;
}

.ios-submit-btn {
    width: 110px;
    height: 34px;
    background: #8a6400; /* Solemn dark gold */
    color: #f5f0e8; /* Soft cream/off-white text, not as glaring as pure white */
    border: none;
    border-radius: 17px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    -webkit-appearance: none;
    cursor: pointer;
    transition: filter 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Hide desktop-exclusive elements on mobile */
.macos-cancel-btn,
.macos-help-btn,
.macos-popover {
    display: none;
}

/* History Popover (MacOS Spotlight Style) */
.history-popover {
    position: absolute;
    top: 25px; /* Moved up to partially overlap the button */
    right: 0;
    width: 260px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    z-index: 100;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.history-popover.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.history-popover h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 6px;
}

#history-list {
    max-height: 130px; /* Restrict height so it stops around half of the send button */
    overflow-y: auto;
    font-size: 0.85rem;
}

.empty-history {
    color: #8e8e93;
    text-align: center;
    padding: 10px 0;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: #333;
}

.history-item:last-child {
    border-bottom: none;
}

.history-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.retract-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #8e8e93;
    transition: background 0.2s, color 0.2s;
}

.retract-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #8e8e93;
}

@media (prefers-color-scheme: dark) {
    .history-popover {
        background: rgba(40, 40, 40, 0.85);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }
    
    .history-popover h4 {
        color: #eee;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    
    .history-item {
        color: #ddd;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    
    .retract-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #aaa;
    }

    .retract-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

.ios-submit-btn:hover {
    filter: brightness(0.9);
}

.ios-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
    .ios-submit-btn {
        background: #0a84ff; /* Revert to App Store Blue in dark mode */
        color: #ffffff;
    }
}

/* ============================================================================
 * Cloudflare Notification Toast (Global Overrides)
 * ============================================================================
 * @tw: fixed bottom-[-100px] left-1/2 -translate-x-1/2 px-6 py-3 rounded-lg z-[99999] shadow-lg
 * ============================================================================ */
.cloudflare-toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 99999;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    text-align: center;
    font-family: -apple-system, sans-serif;
}

.cloudflare-toast.show {
    bottom: 40px;
}

.cloudflare-toast.success {
    background-color: #2ecc71;
    color: #fff;
}

.cloudflare-toast.error {
    background-color: #e74c3c;
    color: #fff;
}

.cloudflare-toast.info {
    background-color: #3498db;
    color: #fff;
}

.cloudflare-toast.system {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #a67c00;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .cloudflare-toast.system {
        background-color: rgba(40, 40, 40, 0.95);
        color: #b3b3b3;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* ============================================================================
 * macOS Desktop Alert Styles
 * ============================================================================
 * Alters the layout for wider screens to match macOS native dialogues.
 * ============================================================================ */
@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
        background-color: rgba(0, 0, 0, 0);
    }

    .modal-overlay.active {
        background-color: rgba(0, 0, 0, 0.2);
    }

    .modal-sheet {
        width: clamp(280px, 35vw, 360px);
        border-radius: 16px;
        padding: 24px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
        transform: scale(0.9);
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
    }

    .modal-overlay.active .modal-sheet {
        transform: scale(1);
    }

    .sheet-header {
        justify-content: center;
        margin-bottom: 16px;
    }

    .sheet-title {
        font-size: 1.15rem;
        font-weight: 700;
    }

    .history-popover {
        top: 25px;
        bottom: auto;
        transform-origin: top right;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }

    #history-list {
        max-height: 200px; /* More space on desktop */
    }

    /* Make the history button appear on desktop in the top right of the header */
    .sheet-close-btn {
        display: flex;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Sunken field emulation */
    .sheet-content {
        background: rgba(0, 0, 0, 0.03);
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
        border-radius: 8px;
        padding: 0;
        margin-bottom: 24px;
    }

    .ios-textarea {
        height: 120px;
        font-size: 1rem;
    }

    /* Desktop dual-button mapping */
    .sheet-footer {
        display: flex;
        gap: 12px;
        width: 100%;
        justify-content: space-between;
    }

    /* Secondary Action Button */
    .macos-cancel-btn {
        display: flex;
        flex: 1;
        height: 36px;
        background: #e4e4e6;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 500;
        color: #000;
        border: 1px solid rgba(0, 0, 0, 0.05);
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: background 0.2s;
        font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    }

    .macos-cancel-btn:active {
        background: #d4d4d6;
    }

    /* Primary Action Button */
    .ios-submit-btn {
        flex: 1;
        width: auto;
        max-width: none;
        height: 36px;
        background: linear-gradient(180deg, #b8860b 0%, #8a6400 100%); /* Memorial gold gradient */
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 500;
        color: #fff;
        border: none;
        text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
        box-shadow:
            0 1px 1px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.25),
            inset 0 0 0 1px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: center;
        align-items: center;
        line-height: normal;
    }

    .ios-submit-btn:active {
        background: #8a6400;
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    }
}

/* ============================================================================
 * macOS Desktop Dark Mode Variants
 * ============================================================================ */
@media (min-width: 600px) and (prefers-color-scheme: dark) {
    .modal-sheet {
        background: rgba(40, 40, 40, 0.85);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15);
    }

    .sheet-title {
        color: #fff;
    }

    .sheet-close-btn {
        background: rgba(255, 255, 255, 0.15);
        color: #ddd;
    }

    .sheet-content {
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
    }

    .macos-cancel-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    }

    .macos-cancel-btn:active {
        background: rgba(255, 255, 255, 0.15);
    }

    .macos-help-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #ddd;
    }

    .macos-help-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .macos-popover {
        background: rgba(40, 40, 40, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .macos-popover h4 {
        color: #eee;
    }

    .macos-popover p {
        color: #bbb;
    }

    .ios-submit-btn {
        background: linear-gradient(180deg, #1b6aec 0%, #0c4ec3 100%);
        box-shadow:
            0 1px 1px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.15),
            inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    }

    .ios-submit-btn:active {
        background: #0c4ec3;
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    }
}


/* Captcha Modal (Overlay over everything) */
#captcha-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    visibility: hidden;
    pointer-events: none;
    z-index: 40000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, visibility 0.3s ease;
}

#captcha-modal-overlay.active {
    background-color: rgba(0, 0, 0, 0.75);
    visibility: visible;
    pointer-events: auto;
}

.captcha-modal-content {
    background: transparent;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: 440px;
}

#captcha-modal-overlay.active .captcha-modal-content {
    opacity: 1;
    transform: scale(1);
}

@media (max-width: 450px) {
    #captcha-modal-overlay.active .captcha-modal-content {
        transform: scale(min(1, calc(100vw / 460)));
    }
}

/* Fix iOS Safari bug where overflow: hidden with border-radius fails to clip transformed children */
.cc-glass {
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);
    transform: translateZ(0);
}

/* Disable native iOS image drag, magnifying glass, and callout menus */
.clawcap-machine img {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    user-select: none;
    pointer-events: none;
}
@media (max-width: 410px) {
    #captcha-modal-overlay.active .captcha-modal-content { transform: scale(0.85); }
}
@media (max-width: 380px) {
    #captcha-modal-overlay.active .captcha-modal-content { transform: scale(0.75); }
}
@media (max-width: 340px) {
    #captcha-modal-overlay.active .captcha-modal-content { transform: scale(0.65); }
}

/* Deep Dark Mode for PlayCaptcha */
@media (prefers-color-scheme: dark) {
    #captcha-root .clawcap {
        --clawcap-bg: #1c1c1e;
        --clawcap-ink: #ffffff;
        --clawcap-muted: #c7c7cc;
        --clawcap-accent: #ff5159;
        
        --cc-bg: #1c1c1e !important;
        --cc-ink: #ffffff !important;
        --cc-muted: #c7c7cc !important;
        --cc-line: rgba(255, 255, 255, 0.15) !important;
        --cc-fill: #2c2c2e !important;
        --cc-fill-2: #3a3a3c !important;
        --cc-accent: #ff5159 !important;
    }
    
    #captcha-root .clawcap-glass {
        background: linear-gradient(180deg, #242426 0%, #1c1c1e 100%) !important;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 1px 8px rgba(0, 0, 0, 0.5) !important;
    }
    
    #captcha-root .cc-glass-shine {
        display: none !important;
    }
    
    #captcha-root .clawcap-panel {
        background: linear-gradient(180deg, #2a2a2c 0%, #202022 100%) !important;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
    }
    
    #captcha-root .clawcap-steps-pill {
        background: #4a4a4c !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3) !important;
    }
    
    #captcha-root .clawcap-steps li.is-active .clawcap-step-n {
        background: #ffffff !important;
        color: #1c1c1e !important;
    }
    
    #captcha-root .clawcap-info-n, #captcha-root .clawcap-info-done {
        background: #ffffff !important;
        color: #1c1c1e !important;
    }
    
    #captcha-root .cc-tray-door, #captcha-root .cc-tray-skin {
        background: linear-gradient(180deg, #3a3a3c 0%, #2c2c2e 100%) !important;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -10px 13px -10px rgba(0, 0, 0, 0.5) !important;
    }
}
