* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gradient-color1: rgba(255, 209, 255, 0.95);
    --gradient-color2: rgba(250, 208, 196, 0.95);
}

body {
    background-color: #eef0f1;
    color: hsla(0, 0%, 9%, 0.9);
}

#content {
    display: flex;
    height: calc(100vh - 80px); /* Increased space to prevent footer overlap on desktop */
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    z-index: 3;
    flex-shrink: 0;
    margin-bottom: 60px; /* Increased margin to ensure instruction text is always visible */
    /* Ensure content doesn't overflow */
    overflow-wrap: break-word;
    word-break: break-word;
    /* Make it clear that content is interactive on touch devices */
    cursor: pointer;
    transition: opacity 0.2s ease;
}

/* Add visual feedback for touch interactions */
#content:active {
    opacity: 0.8;
}

main {
    position: relative;
    height: 100vh;
    overflow: hidden;
    perspective: 100px;
}

main::before {
    content: "";
    position: fixed;
    bottom: -50vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(150vh, 1440px);
    height: min(100vh, 1440px);
    background: radial-gradient(circle,
            var(--gradient-color1) 0%,
            var(--gradient-color2) 60%,
            transparent 100%);
    border-radius: 50%;
    filter: blur(132px);
    z-index: -1;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.6s ease-in-out;
}

main.fade-out::before {
    opacity: 0;
}

.authorbook,
.fade-out .authorbook {
    opacity: 1;
    transition: opacity 0.6s ease-in-out;
}

.fade-out .authorbook {
    opacity: 0;
}

.details {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 30px; /* Increased padding to ensure better spacing from footer */
}

.quote h1 {
    font-family: "Nanum Myeongjo", serif;
    font-weight: 400;
    font-size: 3.5rem;
    line-height: 120%;
    max-width: 93%;
    /* Better text rendering */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent text from being too wide on mobile */
    word-wrap: break-word;
    hyphens: auto;
}

.authorbook,
.instruction {
    font-family: "Chivo Mono", serif;
    font-weight: 300;
    font-style: normal;
}

.authorbook {
    font-size: 1rem;
}

.instruction {
    font-size: 0.8rem;
    opacity: 0.6;
}

.instruction span {
    background-color: rgb(199, 199, 199);
    padding: 4px;
    border-radius: 4px;
}

a {
    text-decoration: underline;
    color: inherit;
    opacity: 0.65;
    /* Better touch targets for mobile */
    min-height: 44px;
    display: inline-block;
    padding: 2px 0;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    a {
        min-height: 48px;
        padding: 4px 0;
    }
    
    .instruction {
        opacity: 0.8;
    }
    
    .instruction span {
        padding: 6px 8px;
        font-size: 0.85rem;
    }
    
    /* Make content area more obviously interactive */
    #content {
        cursor: default;
        /* Prevent text selection on tap */
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        /* Prevent highlight on tap */
        -webkit-tap-highlight-color: transparent;
    }
    
    #content::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
        opacity: 0;
        background: rgba(255, 255, 255, 0.1);
        transition: opacity 0.2s ease;
    }
    
    #content:active::after {
        opacity: 1;
    }
    
    /* Always show footer on touch devices */
    #license {
        transform: translateY(0) !important;
        position: relative !important;
        background-color: rgba(255, 255, 255, 0.95) !important;
    }
}

/* Hover states for non-touch devices */
@media (hover: hover) and (pointer: fine) {
    a:hover {
        opacity: 0.9;
    }
    
    .instruction span:hover {
        background-color: rgb(180, 180, 180);
    }
}

/* License Footer Styles */
#license {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    padding: 6px 20px;
    text-align: center;
    font-family: "Chivo Mono", serif;
    font-size: 0.7rem;
    font-weight: 300;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 100;
    transform: translateY(100%);  /* Hide footer by default */
    transition: transform 0.3s ease;
}

/* Show footer when hovering near bottom of page */
main:hover #license {
    transform: translateY(0);
}

#license p {
    margin: 3px 0;
    opacity: 0.8;
}

#contact-link {
    text-decoration: underline;
    font-weight: 400;
    opacity: 0.9;
}

#contact-link:hover {
    opacity: 1;
}

/* Responsive Media Queries */

/* Small Mobile Devices (portrait) */
@media (max-width: 479px) {
    #content {
        padding: 15px;
        height: calc(100vh - 80px); /* Increased to prevent overlap */
        margin-bottom: 20px;
    }
    
    .details {
        padding-bottom: 15px;
    }
    
    .quote h1 {
        font-size: 1.8rem;
        line-height: 115%;
        max-width: 100%;
    }
    
    .details {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .authorbook {
        font-size: 0.9rem;
    }
    
    .instruction {
        font-size: 0.75rem;
        align-self: flex-end;
    }
    
    main::before {
        width: 120vh;
        height: 80vh;
        bottom: -40vh;
    }
    
    #license {
        font-size: 0.6rem;
        padding: 8px 8px;
        transform: translateY(0); /* Always show on mobile */
        position: relative;
        background-color: rgba(255, 255, 255, 0.9);
    }
    
    #license p:last-child {
        display: none;
    }
}

/* Large Mobile Devices (portrait) */
@media (min-width: 480px) and (max-width: 767px) {
    #content {
        padding: 20px;
        height: calc(100vh - 70px); /* Increased to prevent overlap */
        margin-bottom: 20px;
    }
    
    .details {
        padding-bottom: 12px;
    }
    
    .quote h1 {
        font-size: 2rem;
        line-height: 118%;
        max-width: 100%;
    }
    
    .details {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .instruction {
        align-self: flex-end;
        font-size: 0.8rem;
    }
    
    main::before {
        width: 130vh;
        height: 90vh;
        bottom: -45vh;
    }
    
    #license {
        font-size: 0.65rem;
        padding: 6px 15px;
        transform: translateY(0); /* Always show on mobile */
        position: relative;
        background-color: rgba(255, 255, 255, 0.9);
    }
    
    #license p:last-child {
        display: none;
    }
}

/* Tablets (portrait) */
@media (min-width: 768px) and (max-width: 1023px) {
    #content {
        padding: 25px;
        margin-bottom: 30px;
    }
    
    .details {
        margin-top: 20px;
        padding-bottom: 15px;
    }
    
    .quote h1 {
        font-size: 2.8rem;
        max-width: 95%;
    }
    
    .authorbook {
        font-size: 1.1rem;
    }
    
    .instruction {
        font-size: 0.85rem;
    }
    
    main::before {
        width: 140vh;
        height: 110vh;
    }
    
    #license {
        font-size: 0.7rem;
        padding: 8px 25px;
    }
}

/* Small Laptops */
@media (min-width: 1024px) and (max-width: 1365px) {
    #content {
        padding: 30px;
        margin-bottom: 50px; /* Ensure proper spacing from footer */
    }
    
    .details {
        padding-bottom: 25px; /* Additional spacing for better separation */
    }
    
    .quote h1 {
        font-size: 3.2rem;
        max-width: 90%;
    }
    
    main::before {
        width: 145vh;
        height: 120vh;
    }
}

/* Mobile Landscape Orientation */
@media (max-height: 500px) and (orientation: landscape) {
    #content {
        padding: 10px 20px;
        height: calc(100vh - 50px); /* Adjusted for landscape */
        justify-content: center;
        margin-bottom: 15px;
    }
    
    .details {
        margin-top: 10px;
        padding-bottom: 10px;
    }
    
    .quote {
        margin-bottom: 10px;
    }
    
    .quote h1 {
        font-size: 1.6rem;
        line-height: 110%;
    }
    
    .authorbook {
        font-size: 0.85rem;
    }
    
    .instruction {
        font-size: 0.7rem;
    }
    
    main::before {
        width: 150vh;
        height: 60vh;
        bottom: -30vh;
    }
    
    #license {
        padding: 4px 15px;
        font-size: 0.6rem;
        transform: translateY(0);
        position: relative;
    }
    
    #license p:last-child {
        display: none;
    }
}

/* Tablet Landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    #content {
        padding: 20px 40px;
        margin-bottom: 35px; /* Ensure proper spacing */
    }
    
    .details {
        padding-bottom: 20px; /* Additional spacing */
    }
    
    .quote h1 {
        font-size: 2.5rem;
        max-width: 85%;
    }
    
    main::before {
        width: 160vh;
        height: 100vh;
        bottom: -50vh;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    #content {
        max-width: 1600px;
        margin: 0 auto 70px auto; /* Increased bottom margin for ultra-wide */
        padding: 40px;
    }
    
    .details {
        padding-bottom: 35px; /* Additional spacing for large screens */
    }
    
    .quote h1 {
        font-size: 4rem;
        max-width: 85%;
    }
    
    .authorbook {
        font-size: 1.2rem;
    }
    
    .instruction {
        font-size: 0.9rem;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    main::before {
        filter: blur(100px);
    }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    main::before {
        transition: none;
    }
    
    #license {
        transition: none;
    }
}