/* =========================================================
   Ngày Nhà giáo Việt Nam 20/11 — Thiệp tri ân thầy cô
   ========================================================= */

:root {
    --cream: #f8eeda;
    --cream-2: #f1e0c3;
    --cream-3: #e6cda6;
    --ink: #3a2a20;
    --ink-soft: #6f5644;
    --board: #24463a;
    --board-deep: #17312a;
    --chalk: #f3efe2;
    --wood: #a4713f;
    --wood-deep: #6e4527;
    --red: #b23a35;
    --red-deep: #8e2621;
    --gold: #d8a84e;
    --green: #4f7a63;
    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-script: 'Dancing Script', 'Segoe Script', cursive;
    --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
    --desk-h: clamp(190px, 27vh, 340px);
}

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

html {
    height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    font-family: var(--font-sans);
    color: var(--ink);
    background: #e6cda6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
a {
    font-family: inherit;
}

button {
    color: inherit;
}

img,
svg {
    max-width: 100%;
}

/* ---------------------------------------------------------
   Khung cảnh lớp học
   --------------------------------------------------------- */

.scene {
    position: relative;
    min-height: 100svh;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(120% 85% at 50% -12%, #fff9ec 0%, #f8e9cf 38%, rgba(248, 233, 207, 0) 72%),
        radial-gradient(70% 55% at 12% 18%, rgba(255, 255, 255, .55), transparent 65%),
        linear-gradient(180deg, #f1dfc0 0%, #ead4b1 52%, #dcbf97 100%);
}

.scene::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(90deg, rgba(120, 80, 40, .05) 0 1px, transparent 1px 78px),
        repeating-linear-gradient(0deg, rgba(120, 80, 40, .035) 0 1px, transparent 1px 78px);
    -webkit-mask-image: radial-gradient(ellipse at 50% 32%, #000 25%, transparent 82%);
    mask-image: radial-gradient(ellipse at 50% 32%, #000 25%, transparent 82%);
}

.scene::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 44%, transparent 52%, rgba(84, 52, 26, .16) 100%),
        linear-gradient(180deg, transparent 82%, rgba(84, 52, 26, .08) 100%);
    z-index: 30;
}

.ambient {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.ambient__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    opacity: .8;
}

.ambient__glow--left {
    width: 46vw;
    height: 46vw;
    left: -18vw;
    top: -12vw;
    background: radial-gradient(circle, rgba(255, 249, 227, .95), rgba(255, 240, 203, 0) 68%);
}

.ambient__glow--right {
    width: 38vw;
    height: 38vw;
    right: -14vw;
    top: 16vh;
    background: radial-gradient(circle, rgba(255, 228, 174, .55), rgba(255, 228, 174, 0) 70%);
}

.ambient__beam {
    position: absolute;
    top: -20vh;
    right: 8vw;
    width: 32vw;
    height: 90vh;
    transform: rotate(18deg);
    background: linear-gradient(180deg, rgba(255, 247, 219, .38), rgba(255, 247, 219, 0) 75%);
    filter: blur(18px);
    opacity: .7;
}

.ambient__dust,
.ambient__leaves {
    position: absolute;
    inset: 0;
    display: block;
}

.mote {
    position: absolute;
    bottom: -12px;
    left: var(--x, 50%);
    width: var(--size, 4px);
    height: var(--size, 4px);
    border-radius: 50%;
    background: #fff7dc;
    box-shadow: 0 0 6px rgba(255, 246, 210, .9);
    opacity: 0;
    animation: mote-float var(--dur, 14s) linear var(--delay, 0s) infinite;
}

@keyframes mote-float {
    0% {
        transform: translate3d(0, 30px, 0) scale(.5);
        opacity: 0;
    }
    12% {
        opacity: var(--op, .7);
    }
    78% {
        opacity: var(--op, .7);
    }
    100% {
        transform: translate3d(var(--drift, 24px), -92vh, 0) scale(1);
        opacity: 0;
    }
}

.leaf {
    position: absolute;
    top: -30px;
    left: var(--x, 50%);
    width: var(--w, 13px);
    height: var(--h, 20px);
    border-radius: 2px 100% 2px 100%;
    background: linear-gradient(135deg, var(--leaf-a, #c68a4b), var(--leaf-b, #a35f2e));
    opacity: 0;
    animation: leaf-fall var(--dur, 16s) linear var(--delay, 0s) infinite;
}

@keyframes leaf-fall {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
        opacity: 0;
    }
    8% {
        opacity: .8;
    }
    50% {
        transform: translate3d(var(--sway, 42px), 50vh, 0) rotate(190deg);
    }
    100% {
        transform: translate3d(calc(var(--sway, 42px) * -0.6), 106vh, 0) rotate(380deg);
        opacity: 0;
    }
}

.vignette {
    position: absolute;
    inset: 0;
    z-index: 25;
    pointer-events: none;
    box-shadow: inset 0 0 18vmin rgba(92, 58, 28, .16);
}

/* ---------------------------------------------------------
   Sân khấu
   --------------------------------------------------------- */

.stage {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100svh;
    padding: clamp(18px, 4vh, 40px) 16px 0;
}

.board-area {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* ---------------------------------------------------------
   Bảng đen
   --------------------------------------------------------- */

.board {
    position: relative;
    width: min(860px, 86vw);
    padding: clamp(9px, 1.2vw, 15px);
    border-radius: 18px;
    background:
        linear-gradient(135deg, #c38d57 0%, #8a5a32 32%, #6e4527 68%, #9c6a3d 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 236, 206, .5),
        inset 0 -4px 10px rgba(40, 20, 8, .45),
        0 26px 54px -18px rgba(70, 40, 18, .55),
        0 8px 22px rgba(70, 40, 18, .22);
    animation: board-arrive 1s cubic-bezier(.2, .8, .2, 1) both;
}

.board::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        repeating-linear-gradient(90deg, rgba(60, 30, 10, .09) 0 2px, transparent 2px 11px),
        repeating-linear-gradient(0deg, rgba(255, 230, 190, .05) 0 1px, transparent 1px 6px);
    opacity: .8;
}

.board::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 14px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 231, 195, .18);
}

@keyframes board-arrive {
    from {
        opacity: 0;
        transform: translateY(-18px) scale(.985);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.board__surface {
    position: relative;
    aspect-ratio: 16 / 8.7;
    overflow: hidden;
    border-radius: 9px;
    background:
        radial-gradient(ellipse at 28% 18%, rgba(255, 255, 255, .1), transparent 42%),
        radial-gradient(ellipse at 76% 86%, rgba(0, 0, 0, .28), transparent 62%),
        linear-gradient(155deg, #2f5949 0%, #234438 50%, #183229 100%);
    box-shadow:
        inset 0 0 0 2px rgba(0, 0, 0, .38),
        inset 0 0 42px rgba(0, 0, 0, .36),
        inset 0 0 110px rgba(5, 20, 15, .55);
}

.board__surface::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 32% 18% at 20% 72%, rgba(255, 255, 255, .06), transparent 72%),
        radial-gradient(ellipse 26% 16% at 80% 28%, rgba(255, 255, 255, .05), transparent 72%),
        radial-gradient(ellipse 42% 12% at 54% 92%, rgba(255, 255, 255, .045), transparent 72%);
}

.board__surface::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .16;
    mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.board__grain {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: .22;
    mix-blend-mode: screen;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23m)' opacity='.25'/%3E%3C/svg%3E");
}

.board__content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: clamp(16px, 2.8vw, 30px) clamp(18px, 4vw, 52px);
    text-align: center;
    color: var(--chalk);
}

.board__date {
    display: flex;
    align-items: baseline;
    gap: .08em;
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(38px, 5.4vw, 66px);
    font-weight: 700;
    line-height: .9;
    letter-spacing: .08em;
    text-shadow:
        0 0 1px rgba(255, 255, 255, .55),
        0 0 16px rgba(255, 255, 255, .16);
    animation: chalk-in .9s .25s both;
}

.board__date span {
    font-size: .48em;
    opacity: .72;
    transform: translateY(-.16em);
}

.board__title {
    display: flex;
    flex-direction: column;
    gap: clamp(3px, .5vh, 6px);
    margin: 0;
}

.board__title-top {
    font-family: var(--font-sans);
    font-size: clamp(10px, 1.15vw, 15px);
    font-weight: 500;
    letter-spacing: .58em;
    text-indent: .58em;
    text-transform: uppercase;
    opacity: .8;
    animation: chalk-in .9s .42s both;
}

.board__title-main {
    font-family: var(--font-serif);
    font-size: clamp(23px, 3.1vw, 40px);
    font-style: italic;
    font-weight: 600;
    line-height: 1.16;
    letter-spacing: .01em;
    animation: chalk-in .9s .56s both;
}

.nowrap {
    white-space: nowrap;
}

.board__underline {
    width: clamp(150px, 22vw, 270px);
    height: auto;
    margin: clamp(2px, .6vh, 8px) 0 0;
    color: var(--chalk);
    opacity: .55;
    overflow: visible;
}

.board__underline path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: chalk-draw 1.1s 1.1s ease forwards;
}

.board__sub {
    margin: clamp(3px, .7vh, 8px) 0 0;
    font-family: var(--font-script);
    font-size: clamp(17px, 2vw, 26px);
    font-weight: 600;
    opacity: .78;
    animation: chalk-in .9s .72s both;
}

@keyframes chalk-in {
    from {
        opacity: 0;
        filter: blur(6px);
        transform: translateY(7px);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: none;
    }
}

@keyframes chalk-draw {
    to {
        stroke-dashoffset: 0;
    }
}

.board__doodle {
    position: absolute;
    color: var(--chalk);
    opacity: .5;
    pointer-events: none;
    overflow: visible;
}

.board__doodle g {
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, .25));
}

.board__doodle path,
.board__doodle circle {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: chalk-draw 1.4s 1.35s ease forwards;
}

.board__doodle--flower {
    width: clamp(54px, 9vw, 94px);
    left: 4.2%;
    bottom: 5%;
}

.board__doodle--book {
    width: clamp(66px, 12vw, 122px);
    right: 4.2%;
    bottom: 5%;
}

.board__doodle--stars {
    width: clamp(64px, 10vw, 104px);
    right: 5%;
    top: 6%;
    opacity: .4;
}

.board__tray {
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: calc(clamp(8px, 1vw, 12px) * -1);
    height: clamp(9px, 1.1vw, 13px);
    border-radius: 4px;
    background: linear-gradient(180deg, #b57e4c 0%, #7c4d2b 60%, #5c3720 100%);
    box-shadow:
        0 4px 8px rgba(50, 25, 8, .35),
        inset 0 1px 0 rgba(255, 231, 195, .35);
}

.chalk {
    position: absolute;
    bottom: 100%;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, #fbf7ea, #dcd4c0);
    box-shadow: 0 2px 2px rgba(0, 0, 0, .28);
}

.chalk--1 {
    left: 16%;
    width: 34px;
    transform: rotate(-2deg);
}

.chalk--2 {
    left: 23%;
    width: 22px;
    background: linear-gradient(180deg, #f3c5c1, #cf8b85);
    transform: rotate(1.5deg);
}

.chalk--3 {
    right: 17%;
    width: 28px;
    transform: rotate(2deg);
}

.board__eraser {
    position: absolute;
    right: 22%;
    bottom: calc(100% + 3px);
    width: 34px;
    height: 11px;
    border-radius: 2px;
    background:
        linear-gradient(180deg, #6d4a2d 0 55%, #d9cbb2 55% 100%);
    box-shadow: 0 2px 3px rgba(0, 0, 0, .28);
    transform: rotate(-1deg);
}

/* ---------------------------------------------------------
   Bàn giáo viên
   --------------------------------------------------------- */

.desk {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 6;
    height: var(--desk-h);
    pointer-events: none;
    animation: desk-rise 1.1s .15s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes desk-rise {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.desk__top {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 30%;
    background:
        repeating-linear-gradient(90deg, rgba(80, 45, 18, .09) 0 2px, transparent 2px 14px),
        linear-gradient(180deg, #cb9461 0%, #b47c4b 55%, #a36a3d 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 236, 206, .42),
        inset 0 -10px 18px rgba(80, 40, 15, .18);
}

.desk__top::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 6px;
    background: linear-gradient(180deg, #8d5a32, #6e4527);
    box-shadow: inset 0 1px 0 rgba(255, 220, 180, .18);
}

.desk__front {
    position: absolute;
    top: 30%;
    right: 0;
    bottom: 0;
    left: 0;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, .2), transparent 12%, transparent 88%, rgba(0, 0, 0, .22)),
        repeating-linear-gradient(90deg, rgba(40, 20, 8, .12) 0 2px, transparent 2px 120px),
        linear-gradient(180deg, #85512c 0%, #6c3f22 55%, #57311a 100%);
    box-shadow: inset 0 8px 14px rgba(30, 15, 5, .35);
}

.desk__front::before {
    content: "";
    position: absolute;
    inset: 12% 8% 10%;
    border: 2px solid rgba(255, 220, 180, .1);
    border-radius: 6px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, .22);
}

.desk__drawer {
    position: absolute;
    top: 32%;
    width: 17%;
    height: 38%;
    border: 1px solid rgba(255, 220, 180, .1);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(255, 220, 180, .06), rgba(0, 0, 0, .08));
    box-shadow: inset 0 0 18px rgba(0, 0, 0, .18);
}

.desk__drawer::after {
    content: "";
    position: absolute;
    top: 46%;
    left: 50%;
    width: 18px;
    height: 5px;
    border-radius: 3px;
    background: #3e2412;
    box-shadow: 0 1px 0 rgba(255, 220, 180, .16);
    transform: translate(-50%, -50%);
}

.desk__drawer--left {
    left: 16%;
}

.desk__drawer--right {
    right: 16%;
}

.desk__items {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 0;
    z-index: 2;
}

.still {
    position: absolute;
    bottom: 0;
}

/* Sách + táo */

.still--books {
    left: clamp(7%, 11vw, 15%);
    width: clamp(112px, 13vw, 172px);
    height: clamp(68px, 8.6vw, 108px);
}

.book {
    position: absolute;
    left: 0;
    width: 100%;
    border-radius: 3px 5px 5px 3px;
    box-shadow:
        0 5px 10px rgba(45, 24, 8, .22),
        inset 0 1px 0 rgba(255, 255, 255, .22);
}

.book::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 11%;
    border-radius: inherit;
    background: rgba(0, 0, 0, .18);
}

.book::after {
    content: "";
    position: absolute;
    top: 12%;
    right: 2px;
    bottom: 12%;
    width: 5px;
    border-radius: 0 2px 2px 0;
    background: repeating-linear-gradient(180deg, #f6e8cb 0 2px, #d9c5a1 2px 3px);
}

.book--bottom {
    bottom: 0;
    height: 30%;
    background: linear-gradient(180deg, #5b8a72, #3f6b56);
    transform: rotate(-2deg);
}

.book--middle {
    bottom: 30%;
    left: 4%;
    height: 31%;
    background: linear-gradient(180deg, #c14a42, #9d2f2a);
    transform: rotate(1.5deg);
}

.book--top {
    bottom: 61%;
    left: 2%;
    height: 33%;
    background: linear-gradient(180deg, #e0b15c, #c3913c);
    transform: rotate(-1deg);
}

.apple {
    position: absolute;
    bottom: 92%;
    left: 56%;
    width: clamp(28px, 3.2vw, 42px);
    aspect-ratio: 1;
    border-radius: 48% 52% 50% 50% / 46% 46% 54% 54%;
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .55) 0 9%, transparent 24%),
        radial-gradient(circle at 40% 38%, #d65a4d, #b23a35 55%, #8e2621 100%);
    box-shadow:
        inset -5px -6px 10px rgba(90, 20, 15, .35),
        0 5px 10px rgba(45, 24, 8, .25);
    transform: rotate(-4deg);
}

.apple__stem {
    position: absolute;
    bottom: 92%;
    left: 48%;
    width: 3px;
    height: 28%;
    border-radius: 3px;
    background: #5d3a1e;
    transform: rotate(8deg);
}

.apple__leaf {
    position: absolute;
    bottom: 104%;
    left: 54%;
    width: 42%;
    height: 24%;
    border-radius: 0 100% 0 100%;
    background: linear-gradient(135deg, #6f9a6a, #3f6b4a);
    transform: rotate(-14deg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}

/* Cốc */

.still--mug {
    right: 23%;
    width: clamp(46px, 5.4vw, 70px);
    height: clamp(48px, 5.6vw, 74px);
}

.mug__body {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 76%;
    border-radius: 6px 6px 12px 12px;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, .1), transparent 30%, transparent 72%, rgba(0, 0, 0, .12)),
        linear-gradient(180deg, #fffaf0, #e9d8bc);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, .6),
        0 6px 10px rgba(45, 24, 8, .2);
}

.mug__band {
    position: absolute;
    right: 0;
    bottom: 26%;
    left: 0;
    height: 22%;
    background: linear-gradient(180deg, #c14a42, #a92f2b);
}

.mug__band::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f6e6c9;
    transform: translate(-50%, -50%);
}

.mug__handle {
    position: absolute;
    right: -18%;
    bottom: 16%;
    width: 36%;
    height: 44%;
    border: 5px solid #e6d3b4;
    border-left: 0;
    border-radius: 0 50% 50% 0;
    box-shadow: 2px 0 0 rgba(120, 80, 40, .12);
}

.mug__steam {
    position: absolute;
    bottom: 82%;
    left: 32%;
    width: 7px;
    height: 34%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .7));
    filter: blur(3px);
    opacity: 0;
    animation: steam-rise 3.6s ease-in-out infinite;
}

.mug__steam--2 {
    left: 58%;
    height: 42%;
    animation-delay: 1.6s;
}

@keyframes steam-rise {
    0% {
        transform: translateY(6px) scaleX(.8);
        opacity: 0;
    }
    30% {
        opacity: .55;
    }
    70% {
        opacity: .25;
    }
    100% {
        transform: translateY(-24px) scaleX(1.4);
        opacity: 0;
    }
}

/* Bình hoa hồng */

.still--bouquet {
    right: clamp(4%, 6vw, 8%);
    width: clamp(108px, 13.5vw, 182px);
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 10px 12px rgba(45, 24, 8, .22));
}

.bouquet__flowers {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: bouquet-sway 7s ease-in-out infinite;
}

@keyframes bouquet-sway {
    0%, 100% {
        transform: rotate(-1.2deg);
    }
    50% {
        transform: rotate(1.4deg);
    }
}

/* ---------------------------------------------------------
   Phong thư
   --------------------------------------------------------- */

.letter {
    position: absolute;
    bottom: calc(var(--desk-h) - 5vh);
    left: 50%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.2vh, 14px);
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transform: translateX(-50%);
    -webkit-tap-highlight-color: transparent;
    animation: letter-in 1s .75s cubic-bezier(.2, .9, .25, 1.15) both;
}

@keyframes letter-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(26px) scale(.94);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.letter:focus-visible {
    outline: none;
}

.letter:focus-visible .letter__envelope {
    filter: drop-shadow(0 0 0 4px rgba(255, 250, 235, .8)) drop-shadow(0 22px 28px rgba(50, 25, 8, .35));
}

.letter__envelope {
    position: relative;
    display: block;
    width: clamp(250px, 25vw, 322px);
    aspect-ratio: 1.6 / 1;
    filter: drop-shadow(0 18px 24px rgba(50, 25, 8, .35));
    transition: transform .5s cubic-bezier(.2, .8, .2, 1), filter .5s;
}

.letter:hover .letter__envelope,
.letter:focus-visible .letter__envelope {
    transform: translateY(-8px) rotate(-1deg);
    filter: drop-shadow(0 26px 32px rgba(50, 25, 8, .42));
}

.letter__shadow {
    position: absolute;
    right: 8%;
    bottom: -6%;
    left: 8%;
    height: 14%;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(40, 20, 8, .4), transparent 70%);
    filter: blur(5px);
    transition: transform .5s, opacity .5s;
}

.letter:hover .letter__shadow {
    transform: scaleX(.94);
    opacity: .8;
}

.envelope__float {
    position: absolute;
    inset: 0;
    display: block;
    animation: envelope-float 5.5s 1.8s ease-in-out infinite;
}

@keyframes envelope-float {
    0%, 100% {
        transform: translateY(0) rotate(-.4deg);
    }
    50% {
        transform: translateY(-7px) rotate(.4deg);
    }
}

.envelope__back {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(160deg, #f7ead2, #ecd6b2);
    box-shadow: inset 0 0 0 1px rgba(120, 80, 40, .18);
}

.envelope__paper {
    position: absolute;
    top: 4%;
    right: 7%;
    left: 7%;
    height: 70%;
    border-radius: 4px 4px 2px 2px;
    background-color: #fffaf0;
    background-image: repeating-linear-gradient(180deg, transparent 0 13px, rgba(120, 90, 60, .14) 13px 14px);
    background-position: 0 8px;
    box-shadow: 0 4px 10px rgba(80, 45, 20, .18);
    transform: translateY(-12%);
    transition: transform .55s cubic-bezier(.2, .8, .2, 1);
}

.letter:hover .envelope__paper,
.letter:focus-visible .envelope__paper {
    transform: translateY(-26%);
}

.envelope__front {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background:
        linear-gradient(to bottom right, transparent 49.5%, rgba(120, 80, 40, .16) 50%, transparent 50.5%),
        linear-gradient(to bottom left, transparent 49.5%, rgba(120, 80, 40, .16) 50%, transparent 50.5%),
        linear-gradient(160deg, #f6e7c9, #e8cfa8);
    clip-path: polygon(0 6%, 50% 55%, 100% 6%, 100% 100%, 0 100%);
    filter: drop-shadow(0 -1px 1px rgba(255, 255, 255, .35));
}

.envelope__flap {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 62%;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #f8ebd3 0%, #eed9b7 70%, #e4c9a2 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    filter: drop-shadow(0 3px 3px rgba(90, 55, 25, .16));
}

.envelope__seal {
    position: absolute;
    top: 52%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(46px, 5vw, 62px);
    aspect-ratio: 1;
    border-radius: 46% 54% 50% 50% / 52% 48% 52% 48%;
    background:
        radial-gradient(circle at 34% 28%, #d85f56 0%, #b23a35 45%, #8e2621 78%, #7a1e1a 100%);
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, .28),
        inset 0 -5px 9px rgba(0, 0, 0, .3),
        0 4px 8px rgba(80, 20, 10, .32);
    color: #f9e9d1;
    font-family: var(--font-serif);
    font-size: clamp(11px, 1.1vw, 14px);
    font-weight: 700;
    letter-spacing: .02em;
    transform: translate(-50%, -50%) rotate(-3deg);
    text-shadow: 0 1px 2px rgba(80, 20, 10, .5);
}

.seal__text {
    white-space: nowrap;
}

.envelope__seal .seal__text > span {
    opacity: .55;
    margin: 0 1px;
}

.letter__hint {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border: 1px solid rgba(120, 80, 40, .16);
    border-radius: 999px;
    background: rgba(255, 248, 232, .94);
    box-shadow: 0 5px 14px rgba(80, 45, 20, .18);
    color: #7a4a28;
    font-size: clamp(10.5px, .95vw, 12.5px);
    font-weight: 500;
    letter-spacing: .02em;
    white-space: nowrap;
    animation: hint-pulse 2.6s 2.2s ease-in-out infinite;
}

.letter__hint svg {
    flex: none;
    opacity: .8;
}

@keyframes hint-pulse {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 0 5px 14px rgba(80, 45, 20, .18);
    }
    50% {
        transform: translateY(-2px);
        box-shadow: 0 8px 18px rgba(80, 45, 20, .24);
    }
}

/* Cánh hoa khi mở thư */

.petal {
    position: fixed;
    z-index: 150;
    width: 11px;
    height: 15px;
    border-radius: 2px 100% 2px 100%;
    background: linear-gradient(135deg, #d85f56, #a92f2b);
    pointer-events: none;
    animation: petal-burst 1.1s cubic-bezier(.15, .6, .3, 1) both;
}

@keyframes petal-burst {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(.6);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--px)), calc(-50% + var(--py))) rotate(var(--rot)) scale(1);
        opacity: 0;
    }
}

/* ---------------------------------------------------------
   Lá thư (modal)
   --------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: clamp(14px, 3vw, 40px);
    visibility: hidden;
    opacity: 0;
    transition: opacity .35s ease, visibility .35s;
}

.modal.show {
    visibility: visible;
    opacity: 1;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 38%, rgba(36, 70, 58, .72), rgba(18, 27, 23, .92));
    -webkit-backdrop-filter: blur(9px);
    backdrop-filter: blur(9px);
}

.letter-card {
    position: relative;
    z-index: 1;
    width: min(860px, 94vw);
    max-height: 90svh;
    overflow-y: auto;
    padding: clamp(24px, 3.4vw, 46px);
    border-radius: 10px;
    background-color: #fffaf0;
    background-image:
        repeating-linear-gradient(180deg, transparent 0 31px, rgba(160, 120, 80, .12) 31px 32px),
        linear-gradient(160deg, #fffaf0 0%, #f9efdc 60%, #f2e2c8 100%);
    box-shadow:
        0 40px 80px -20px rgba(8, 14, 11, .6),
        0 0 0 1px rgba(120, 80, 40, .18);
    transform: translateY(24px) scale(.96) rotate(-.5deg);
    opacity: 0;
    transition: transform .45s cubic-bezier(.2, .8, .2, 1), opacity .35s;
    scrollbar-width: thin;
    scrollbar-color: rgba(178, 58, 53, .35) transparent;
}

.modal.show .letter-card {
    transform: none;
    opacity: 1;
}

.letter-card::-webkit-scrollbar {
    width: 8px;
}

.letter-card::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: rgba(178, 58, 53, .3);
}

.letter-card__tape {
    position: absolute;
    top: -13px;
    left: 50%;
    width: 132px;
    height: 30px;
    background: rgba(216, 168, 78, .55);
    clip-path: polygon(2% 5%, 98% 0, 100% 95%, 0 100%);
    transform: translateX(-50%) rotate(-1.5deg);
    box-shadow: 0 3px 8px rgba(90, 55, 25, .12);
}

.letter-card__stamp {
    position: absolute;
    top: 22px;
    right: 72px;
    display: grid;
    place-items: center;
    width: 62px;
    height: 72px;
    border: 2px dashed rgba(178, 58, 53, .45);
    border-radius: 3px;
    color: rgba(178, 58, 53, .72);
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .02em;
    transform: rotate(6deg);
    pointer-events: none;
}

.letter-card__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, #c85048, #a92f2b 55%, #8e2621 100%);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, .25),
        0 6px 14px rgba(120, 30, 20, .3);
    color: #f9e9d1;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s;
}

.letter-card__close:hover,
.letter-card__close:focus-visible {
    transform: rotate(90deg) scale(1.06);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, .25),
        0 8px 20px rgba(120, 30, 20, .4);
    outline: none;
}

.letter-card__inner {
    display: grid;
    grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
    gap: clamp(24px, 3.2vw, 42px);
    align-items: center;
}

.letter-card__photo {
    position: relative;
    margin: 0;
    transform: rotate(-1.5deg);
}

.letter-card__photo::before {
    content: "";
    position: absolute;
    top: -13px;
    left: 50%;
    z-index: 2;
    width: 88px;
    height: 26px;
    background: rgba(216, 168, 78, .5);
    clip-path: polygon(2% 6%, 98% 0, 100% 94%, 0 100%);
    transform: translateX(-50%) rotate(2deg);
}

.letter-card__photo img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 52svh;
    margin: 0 auto;
    border: 8px solid #fffdf8;
    border-radius: 5px;
    background: #fffdf8;
    box-shadow: 0 14px 32px rgba(80, 50, 25, .26);
}

.letter-card__photo figcaption {
    margin-top: 9px;
    color: var(--ink-soft);
    font-family: var(--font-script);
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.letter-card__content {
    min-width: 0;
    padding-top: 8px;
}

.letter-card__eyebrow {
    margin: 0 0 7px;
    color: var(--red);
    font-size: clamp(9.5px, .9vw, 11px);
    font-weight: 600;
    letter-spacing: .26em;
    text-transform: uppercase;
}

.letter-card__title {
    margin: 0;
    color: #6f2a22;
    font-family: var(--font-serif);
    font-size: clamp(25px, 3vw, 39px);
    font-weight: 600;
    line-height: 1.18;
    text-wrap: balance;
}

.letter-card__rule {
    width: 74px;
    height: 2px;
    margin: clamp(14px, 2vh, 20px) 0 clamp(14px, 2vh, 18px);
    border-radius: 2px;
    background: linear-gradient(90deg, var(--red), rgba(178, 58, 53, 0));
}

.typewriter-text {
    margin: 0;
    min-height: 7.6em;
    color: #4a372a;
    font-size: clamp(12.5px, 1.2vw, 15px);
    font-weight: 400;
    line-height: 1.9;
    white-space: pre-line;
}

.typewriter-text:not(.done)::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    border-radius: 1px;
    background: var(--red);
    vertical-align: -.12em;
    animation: cursor-blink .75s step-end infinite;
}

@keyframes cursor-blink {
    0%, 100% {
        border-color: var(--red);
    }
    50% {
        border-color: transparent;
    }
}

.letter-card__sign {
    margin: clamp(14px, 2vh, 20px) 0 0;
    color: var(--red-deep);
    font-family: var(--font-script);
    font-size: clamp(20px, 2.2vw, 27px);
    font-weight: 600;
    text-align: right;
}

.letter-card__sign span {
    color: var(--red);
}

/* ---------------------------------------------------------
   Nút nhạc + nút xem trước
   --------------------------------------------------------- */

.music-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 90;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid rgba(255, 248, 232, .85);
    border-radius: 50%;
    background: linear-gradient(145deg, #c85048 0%, #a92f2b 55%, #8e2621 100%);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, .25),
        0 10px 24px rgba(110, 35, 25, .32);
    color: #fff6e6;
    cursor: pointer;
    transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s;
}

.music-toggle:hover {
    transform: scale(1.07) rotate(4deg);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, .25),
        0 14px 30px rgba(110, 35, 25, .4);
}

.music-toggle:focus-visible {
    outline: 3px solid rgba(255, 248, 232, .8);
    outline-offset: 3px;
}

.music-toggle.is-playing {
    animation: music-pulse 2.4s ease-in-out infinite;
}

@keyframes music-pulse {
    0%, 100% {
        box-shadow:
            inset 0 2px 3px rgba(255, 255, 255, .25),
            0 10px 24px rgba(110, 35, 25, .32);
    }
    50% {
        box-shadow:
            inset 0 2px 3px rgba(255, 255, 255, .25),
            0 14px 34px rgba(110, 35, 25, .5),
            0 0 0 7px rgba(178, 58, 53, .12);
    }
}

.music-icon {
    width: 32px;
    height: 26px;
    overflow: visible;
}

.music-icon .wave {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.music-toggle.is-playing .wave {
    opacity: 1;
    animation: sound-wave 1s ease-in-out infinite;
}

.music-toggle.is-playing .wave-1 {
    animation-delay: 0s;
}

.music-toggle.is-playing .wave-2 {
    animation-delay: .18s;
}

.music-toggle.is-playing .wave-3 {
    animation-delay: .36s;
}

@keyframes sound-wave {
    0%, 100% {
        transform: scaleY(.55);
        opacity: .55;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.preview-btn {
    position: fixed;
    bottom: 28px;
    left: 26px;
    z-index: 90;
    padding: 10px 19px;
    border: 1px solid rgba(120, 80, 40, .16);
    border-radius: 999px;
    background: rgba(255, 248, 232, .94);
    box-shadow: 0 6px 18px rgba(80, 45, 20, .2);
    color: var(--red-deep);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .01em;
    text-decoration: none;
    transition: transform .3s, box-shadow .3s, background .3s;
}

.preview-btn:hover {
    background: #fffdf6;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(80, 45, 20, .26);
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 1100px) {
    .still--mug {
        right: 22%;
    }
}

@media (max-width: 860px) {
    .board {
        width: min(760px, 90vw);
    }

    .board__doodle--flower {
        left: 3%;
        bottom: 4%;
    }

    .board__doodle--book {
        right: 3%;
        bottom: 4%;
    }

    .still--books {
        left: 5%;
    }

    .still--bouquet {
        right: 3%;
    }

    .still--mug {
        right: 20%;
    }
}

@media (min-width: 701px) and (max-width: 1024px) and (orientation: portrait) {
    .board {
        width: min(630px, 82vw);
    }

    .board__surface {
        aspect-ratio: 4 / 3;
    }

    .board__date {
        font-size: clamp(48px, 6.4vw, 58px);
    }

    .board__title-main {
        font-size: clamp(27px, 3.8vw, 34px);
    }

    .board__sub {
        font-size: clamp(19px, 2.4vw, 24px);
    }

    .letter__envelope {
        width: clamp(290px, 42vw, 350px);
    }

    .still--books {
        left: 7%;
        width: clamp(130px, 18vw, 160px);
        height: clamp(82px, 11vw, 100px);
    }

    .still--bouquet {
        right: 4%;
        width: clamp(130px, 18vw, 165px);
    }

    .still--mug {
        display: none;
    }
}

@media (min-width: 701px) and (min-height: 1050px) {
    .board {
        width: min(800px, 82vw);
    }

    .board__surface {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 700px) {
    :root {
        --desk-h: clamp(180px, 26vh, 230px);
    }

    .stage {
        padding-top: clamp(18px, 3vh, 30px);
    }

    .board {
        width: min(430px, 90vw);
        border-radius: 14px;
    }

    .board__surface {
        aspect-ratio: 1 / 1;
    }

    .board__content {
        padding: 22px 22px 30px;
    }

    .board__date {
        font-size: clamp(46px, 15vw, 62px);
    }

    .board__title-main {
        font-size: clamp(25px, 7.2vw, 34px);
    }

    .board__title-top {
        font-size: 10px;
        letter-spacing: .42em;
        text-indent: .42em;
    }

    .board__sub {
        font-size: clamp(17px, 5vw, 21px);
    }

    .board__underline {
        width: 46%;
    }

    .board__doodle--flower {
        width: 64px;
        left: 5%;
        bottom: 5%;
    }

    .board__doodle--book {
        width: 78px;
        right: 5%;
        bottom: 5%;
    }

    .board__doodle--stars {
        width: 68px;
        right: 6%;
        top: 7%;
    }

    .letter__envelope {
        width: clamp(246px, 66vw, 320px);
    }

    .still--mug {
        display: none;
    }

    .still--books {
        left: 4%;
        width: clamp(100px, 24vw, 140px);
        height: clamp(62px, 15vw, 88px);
    }

    .still--bouquet {
        right: 3%;
        width: clamp(96px, 23vw, 138px);
    }

    .letter-card__inner {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .letter-card__photo {
        max-width: 260px;
        margin: 0 auto;
        transform: rotate(-1deg);
    }

    .letter-card__photo img {
        max-height: 30svh;
    }

    .letter-card__content {
        padding-top: 0;
    }

    .letter-card__title {
        font-size: clamp(24px, 6.4vw, 31px);
    }

    .letter-card__stamp {
        display: none;
    }

    .typewriter-text {
        min-height: 6.2em;
    }

    .letter-card__close {
        top: 10px;
        right: 10px;
        width: 38px;
        height: 38px;
        font-size: 23px;
    }
}

@media (max-width: 520px) {
    .stage {
        padding-right: 12px;
        padding-left: 12px;
    }

    .board {
        width: min(400px, 92vw);
    }

    .board__content {
        padding: 18px 16px 26px;
    }

    .board__title-main {
        font-size: clamp(23px, 7vw, 30px);
    }

    .board__sub {
        font-size: clamp(15px, 4.6vw, 19px);
    }

    .board__doodle--flower {
        width: 54px;
        opacity: .42;
    }

    .board__doodle--book {
        width: 66px;
        opacity: .42;
    }

    .board__doodle--stars {
        width: 56px;
        opacity: .32;
    }

    .chalk--2,
    .chalk--3 {
        display: none;
    }

    .letter__envelope {
        width: min(78vw, 300px);
    }

    .letter__hint {
        padding: 6px 12px;
        font-size: 10.5px;
    }

    .still--books {
        left: 2%;
        width: clamp(92px, 26vw, 118px);
        height: clamp(58px, 16vw, 74px);
    }

    .still--bouquet {
        right: 2%;
        width: clamp(88px, 25vw, 112px);
    }

    .music-toggle {
        right: 16px;
        bottom: 16px;
        width: 50px;
        height: 50px;
    }

    .music-icon {
        width: 28px;
        height: 23px;
    }

    .preview-btn {
        bottom: 18px;
        left: 16px;
        padding: 9px 15px;
        font-size: 12px;
    }

    .modal {
        padding: 10px;
    }

    .letter-card {
        width: 96vw;
        max-height: 92svh;
        padding: 26px 18px 22px;
    }

    .letter-card__photo {
        max-width: 215px;
    }

    .letter-card__photo img {
        border-width: 6px;
        max-height: 26svh;
    }

    .letter-card__eyebrow {
        font-size: 9px;
        letter-spacing: .2em;
    }

    .letter-card__title {
        font-size: clamp(22px, 6.4vw, 28px);
    }

    .typewriter-text {
        font-size: 12.5px;
        line-height: 1.8;
        min-height: 7.4em;
    }

    .letter-card__sign {
        font-size: 21px;
    }

    .letter-card__tape {
        width: 104px;
        height: 26px;
    }
}

/* Màn hình thấp */
@media (max-height: 820px) and (min-width: 701px) {
    :root {
        --desk-h: clamp(160px, 26vh, 210px);
    }

    .board {
        width: min(720px, 86vw, 84vh);
    }

    .board__date {
        font-size: clamp(34px, 4.6vw, 52px);
    }

    .board__title-main {
        font-size: clamp(21px, 2.7vw, 32px);
    }

    .letter__envelope {
        width: clamp(230px, 24vw, 300px);
    }
}

@media (max-height: 640px) and (max-width: 700px) {
    :root {
        --desk-h: 170px;
    }

    .board {
        width: min(360px, 82vw);
    }

    .letter__envelope {
        width: min(62vw, 260px);
    }

    .board__sub {
        display: none;
    }
}

/* Tôn trọng cài đặt giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }

    .mote,
    .leaf,
    .mug__steam {
        display: none;
    }
}
