html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #d8c3a5;
    overflow: hidden;
}

.scene {
    position: relative;
    width: 60%;
    max-width: 600px;
    background: #bfefff;
    display: flex;
    flex-direction: column;
    align-items: center;
    aspect-ratio: 1 / 1;
}

img {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
}

.mail-text {
    position: absolute;

    left: 85%;
    top: 48%;
    transform: translate(-50%, -50%);

    width: 25.8%;
    height: 5%;

    display: flex;
    justify-content: center;
    align-items: center;

    background: white;
    border: max(2px, 0.2vw) solid #453004;
    border-radius: 999px;

    font-family: "Courier New", monospace;
    font-size: clamp(10px, 1.2vw, 16px);
    font-weight: bold;
    color: #453004;
    text-decoration: none;

    white-space: nowrap;
    z-index: 100;

    opacity: 0;
    animation: showText 0s linear 3s forwards;

    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.mail-text:hover {
    background: #f8f3e8;
    transform: translate(-50%, -50%) scale(1.05);
}

@keyframes showText {
    to {
        opacity: 1;
    }
}

.too-many-text {
    display: none;
    position: absolute;
    left: 50%;
    top: 9%;
    transform: translateX(-50%);
    width: 60%;
    height: 5%;
    justify-content: center;
    align-items: center;
    background: white;
    border: max(2px, 0.2vw) solid #453004;
    border-radius: 999px;
    font-family: "Courier New", monospace;
    font-size: clamp(8px, 1vw, 13px);
    font-weight: bold;
    color: #453004;
    white-space: nowrap;
    z-index: 20;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.too-many-text.visible {
    display: flex;
}

.too-many-text:hover {
    background: #f8f3e8;
    transform: translateX(-50%) scale(1.05);
}

.chicken-scene {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
    background: #d8c3a5;
    z-index: 50;
}

.chicken-scene.active {
    display: flex;
}

.chicken-wrapper {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
}

.chicken-wrapper img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    cursor: default;
    display: block;
}

.chicken-hotspot {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 0 10px rgba(255, 255, 255, 0.35);
    transition: opacity 0.12s ease;
}

.chicken-hotspot.hovered {
    opacity: 1;
}

.envelope {
    position: absolute;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 2px;
    transition: background 0.15s ease;
}

.envelope:hover {
    background: rgba(255, 255, 255, 0.18);
    outline: 1.5px solid rgba(255, 255, 255, 0.45);
}

.spine-text {
    transform: rotate(90deg);
    white-space: nowrap;
    font-family: "Courier New", monospace;
    font-size: clamp(5px, 0.7vw, 10px);
    color: rgba(10, 5, 0, 0.92);
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.4s ease;
}

.envelope.revealed .spine-text {
    filter: none;
}

.closed-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    justify-content: center;
    align-items: center;
}

.closed-overlay.active {
    display: flex;
}

.closed-wrapper {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
    cursor: pointer;
}

.closed-name {
    position: absolute;
    left: 20%;
    top: 44%;
    width: 60%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Courier New", monospace;
    font-size: clamp(14px, 1.9vw, 26px);
    font-weight: bold;
    color: #453004;
    text-align: center;
    pointer-events: none;
}

.envelope-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 510;
    justify-content: center;
    align-items: center;
}

.envelope-overlay.active {
    display: flex;
}

.overlay-wrapper {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
}

.overlay-img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    display: block;
}

.overlay-name {
    position: absolute;
    left: 46%;
    top: 35%;
    width: 25%;
    height: 12.4%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Courier New", monospace;
    font-size: clamp(10px, 1.2vw, 16px);
    font-weight: bold;
    color: #453004;
    text-align: center;
    overflow: hidden;
    pointer-events: none;
    word-break: break-word;
}

/* clickable zone over the pixel-art scene (image area) */
.image-zone {
    display: none;
    position: absolute;
    left: 62.5%;
    top: 31.3%;
    width: 9.4%;
    height: 21.9%;
    cursor: pointer;
    z-index: 20;
    border-radius: 2px;
    transition: background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.image-zone:hover {
    background: rgba(255, 255, 255, 0.22);
    outline: 1.5px solid rgba(255, 255, 255, 0.5);
}

/* gallery overlay */
.gallery-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 515;
    justify-content: center;
    align-items: center;
}

.gallery-overlay.active {
    display: flex;
}

.gallery-frame {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
}

.gallery-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: auto;
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(20px, 3.5vw, 34px);
    height: clamp(20px, 3.5vw, 34px);
    background: #f5e6c8;
    color: #453004;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Courier New", monospace;
    font-size: clamp(10px, 1.6vw, 16px);
    font-weight: bold;
    image-rendering: pixelated;
    box-shadow:
        inset -2px -2px 0 0 #8b5e2a,
        inset  2px  2px 0 0 #fff8ee,
        0 0 0 2px #453004;
    z-index: 10;
    padding: 0;
    line-height: 1;
    user-select: none;
}

.gallery-arrow:hover {
    background: #ffe9a0;
}

.gallery-arrow:active {
    box-shadow:
        inset  2px  2px 0 0 #8b5e2a,
        inset -2px -2px 0 0 #fff8ee,
        0 0 0 2px #453004;
    transform: translateY(calc(-50% + 1px));
}

.gallery-prev { left: 2%; }
.gallery-next { right: 2%; }

/* clickable zone over the white letter in the envelope image */
.letter-zone {
    display: none;
    position: absolute;
    left: 28.1%;
    top: 37.5%;
    width: 34.3%;
    height: 27.5%;
    cursor: pointer;
    z-index: 20;
    border-radius: 2px;
    transition: background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.letter-zone:hover {
    background: rgba(255, 255, 255, 0.22);
    outline: 1.5px solid rgba(255, 255, 255, 0.5);
}

/* full letter view */
.letter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 600;
    justify-content: center;
    align-items: center;
}

.letter-overlay.active {
    display: flex;
}

.letter-wrapper {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
}

.letter-bg-img {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.letter-text {
    position: absolute;
    left: 15%;
    top: 9%;
    width: 70%;
    height: 82%;
    overflow-y: auto;
    font-family: "Courier New", monospace;
    font-size: clamp(8px, 1.1vw, 12px);
    color: #1a1a1a;
    line-height: 1.6;
    text-align: left;
}

.letter-text p {
    margin: 0 0 0.75em 0;
}

.letter-text p.gap {
    margin: 0 0 0.75em 0;
    min-height: 0;
    height: 0;
}

.letter-text .tab {
    text-indent: 2em;
}

.letter-imgs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0.5em 0;
}

.letter-img {
    flex: 1 1 45%;
    max-width: 100%;
    height: auto;
    display: block;
    image-rendering: auto;
    border-radius: 2px;
}

.letter-text::-webkit-scrollbar { width: 3px; }
.letter-text::-webkit-scrollbar-track { background: transparent; }
.letter-text::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-overlay.active {
    display: flex;
}

.popup {
    background: white;
    width: clamp(260px, 40vw, 480px);
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #555;
    line-height: 1;
}

.popup-close:hover {
    color: #111;
}

.popup-content {
    width: 90%;
    height: 85%;
}

.mailbag-scene {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
    z-index: 60;
}

.mailbag-scene.active {
    display: flex;
}

.mailbag-wrapper {
    position: relative;
    width: min(60vw, 600px);
    height: min(60vw, 600px);
    flex-shrink: 0;
    cursor: pointer;
}

.mailbag-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.bag-envelope {
    position: absolute;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 2px;
    transition: background 0.15s ease;
}

.bag-envelope:hover {
    background: rgba(255, 255, 255, 0.18);
    outline: 1.5px solid rgba(255, 255, 255, 0.45);
}

.bag-envelope .spine-text {
    transform: rotate(90deg);
    white-space: nowrap;
    font-family: "Courier New", monospace;
    font-size: clamp(5px, 0.7vw, 10px);
    color: rgba(10, 5, 0, 0.92);
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.4s ease;
}

.bag-envelope.revealed .spine-text {
    filter: none;
}