/* The desktop keeps its poster layout; phones get a native, snapping story. */
.story-only { display: none; }
.wish-slide > .wish-card { width: 100%; height: 100%; }
.cake-inner { grid-template-rows: auto 1fr; }
.cake-copy { grid-area: 1 / 1; }
.cake-scene { grid-area: 1 / 2 / 3 / 3; }
.cake-action { grid-area: 2 / 1; }
.birthday-message { background: #e9e0ee; }
.committee .site-footer { margin: 35px 0 0; padding-bottom: 0; }

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  :root {
    --screen-height: 100vh;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --slide-top: calc(var(--safe-top) + 101px);
    --slide-bottom: calc(var(--safe-bottom) + 80px);
  }
  @supports (height: 100dvh) { :root { --screen-height: 100dvh; } }
  html { height: 100%; scroll-padding: 0; scroll-behavior: auto; overflow: hidden; }
  body { height: 100%; overflow: hidden; }
  .story-only { display: flex; }
  .story {
    height: var(--screen-height);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  .story::-webkit-scrollbar { display: none; }
  .story-slide {
    width: 100%; max-width: none;
    height: var(--screen-height); min-height: 0;
    margin: 0;
    padding: var(--slide-top) max(24px, env(safe-area-inset-left)) var(--slide-bottom);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    scroll-margin: 0;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    border: 0;
  }
  .story-slide::-webkit-scrollbar { display: none; }
  .site-header {
    position: fixed; z-index: 15;
    top: 0; left: 0; width: 100%; max-width: none;
    height: calc(var(--safe-top) + 60px);
    padding: var(--safe-top) max(22px, env(safe-area-inset-left)) 0;
    border: 0;
    background: var(--paper);
  }
  .site-header .brand { font-size: 8px; letter-spacing: 1px; }
  .site-header .brand svg { width: 25px; height: 25px; }
  .site-header .header-link { min-height: 44px; display: flex; align-items: center; border: 0; font-size: 11px; }
  .header-note { display: none; }
  .story-progress {
    position: fixed; z-index: 15;
    top: calc(var(--safe-top) + 60px); left: 0; right: 0;
    padding: 0 20px; gap: 5px; height: 28px;
    background: var(--paper);
  }
  .story-progress button { flex: 1; min-width: 0; height: 44px; margin-top: -8px; padding: 0; position: relative; background: transparent; }
  .story-progress button::after { content: ''; position: absolute; top: 17px; height: 3px; inset-inline: 0; border-radius: 5px; background: #33232424; transition: background .2s; }
  .story-progress button.is-past::after { background: #a9343c66; }
  .story-progress button[aria-current="step"]::after { background: var(--red); }
  .story-nav {
    position: fixed; z-index: 15;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--safe-bottom) + 67px);
    padding: 9px max(24px, env(safe-area-inset-left)) calc(var(--safe-bottom) + 10px);
    justify-content: space-between; align-items: center;
    background: var(--paper);
    border-top: 1px solid #33232412;
  }
  .story-nav > button { width: 44px; height: 44px; border: 1px solid #33232440; background: transparent; border-radius: 50%; font-size: 23px; }
  .story-nav > button:last-child { background: var(--ink); color: var(--paper); }
  .story-nav > button:disabled { opacity: .28; }
  .story-nav > div { text-align: center; display: flex; flex-direction: column; gap: 4px; }
  #slide-count { font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: 2px; }
  #slide-hint { font: italic 12px Georgia, serif; color: #807168; }
  .ticker, .wishes > .section-heading, .wishes-footnote { display: none; }
  .wishes, .wish-grid { display: contents; }

  .hero { display: flex; flex-direction: column; align-items: center; gap: 14px; }
  .hero .eyebrow { flex: 0 0 auto; font-size: 8px; letter-spacing: 1px; padding: 8px 10px; }
  .hero-stage { flex: 1 0 260px; width: 100%; position: relative; }
  .hero h1 { margin: 0; height: 100%; position: relative; font-size: clamp(28px, 4.5vh, 35px); }
  #hero-intro { padding-top: 3px; }
  .age { font-size: clamp(173px, calc(var(--screen-height) * .30), 265px); line-height: .94; letter-spacing: -24px; margin: 8px auto 0; }
  .hero-last { position: absolute; bottom: 0; left: -12px; right: -12px; font-size: clamp(24px, 6.4vw, 29px); letter-spacing: -1.2px; }
  .hero-cat-left { top: auto; bottom: 53px; left: calc(50% - 172px); width: clamp(130px, calc(var(--screen-height) * .215), 180px); }
  .hero-cat-right { top: auto; bottom: 40px; right: calc(50% - 166px); width: clamp(137px, calc(var(--screen-height) * .23), 190px); }
  .cat-caption { left: 27px; top: -27px; font-size: 12px; }
  .drawn-arrow { width: 30px; height: 30px; top: -22px; }
  .cat-tag { font-size: 6px; padding: 7px 9px; }
  .speech { font-size: 24px; right: 9px; top: -10px; }
  .spark-one { top: 53px; left: 0; width: 25px; height: 25px; }
  .spark-two { top: 100px; right: 4px; width: 23px; height: 23px; }
  .hero-doodle, .round-stamp { display: none; }
  .hero-bottom { margin: 0; flex: 0 0 auto; width: 100%; }
  .hero-bottom p { font-size: 13px; line-height: 1.5; }
  .hero-bottom .button { min-height: 49px; margin-top: 15px; width: min(100%, 300px); }
  .fine-print { margin-top: 9px; font-size: 11px; }

  .wish-slide { display: flex; flex-direction: column; gap: 18px; }
  .wish-slide-heading { justify-content: center; flex: 0 0 auto; font-size: 9px; letter-spacing: 2px; color: #75695f; }
  .wish-slide > .wish-card {
    flex: 1 0 360px; height: auto; min-height: 0;
    max-width: 480px; width: 100%; margin-inline: auto;
    padding: 25px 26px 0;
    transform: rotate(-1.3deg);
  }
  .wish-slide > .wish-lilac { transform: rotate(1.2deg); }
  .wish-slide > .wish-card:hover { transform: rotate(-1.3deg); box-shadow: none; }
  .card-top { font-size: 9px; padding-bottom: 18px; }
  .wish-card h3 { padding-top: 25px; font-size: clamp(30px, 8.5vw, 39px); letter-spacing: -1.6px; line-height: 1.1; }
  .wish-short { font-size: 14px; line-height: 1.5; max-width: 100%; padding-top: 17px; }
  .wish-card img { position: absolute; height: min(34vh, 285px); width: 75%; bottom: 48px; right: 0; margin: 0; object-position: bottom right; opacity: 1; }
  .wish-lilac img { width: 88%; height: min(32vh, 260px); right: -8px; }
  .wish-peach img { width: 73%; height: min(34vh, 280px); right: 5px; }
  .wish-card:hover img { transform: rotate(3deg); }
  .wish-open { width: calc(100% + 52px); margin: auto -26px 0; padding: 18px 26px; font-size: 10px; min-height: 49px; }
  .wish-detail { inset: auto 15px 67px; font-size: 22px; padding: 25px; }

  .cake-section { background: #e9e0ee; }
  .cake-inner { width: 100%; max-width: 480px; height: 100%; padding: 0; margin: 0 auto; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
  .cake-copy { flex: 0 0 auto; }
  .cake-copy .section-index { margin-bottom: 13px; }
  .cake-copy h2 { font-size: clamp(42px, 11.5vw, 57px); line-height: .99; letter-spacing: -2px; margin-bottom: 14px; }
  .cake-copy h2 br { display: initial; }
  .cake-copy > p:not(.candle-hint):not(.sr-only) { font-size: 13px; line-height: 1.5; }
  .cake-scene { flex: 1 1 230px; min-height: 150px; margin: 0; container-type: size; container-name: cake-illustration; }
  .cake-art { top: 50%; left: 50%; scale: none; transform: translate(-50%, -50%) rotate(-4deg) scale(.87); transform-origin: center; }
  .cake-note { top: auto; right: auto; bottom: 0; left: 0; font-size: 14px; z-index: 5; transform: rotate(-4deg); }
  .cake-spark { top: 15px; left: 3px; width: 28px; height: 28px; }
  .cake-guard { bottom: -7px; right: -10px; width: 104px; height: 104px; }
  .guard-caption { bottom: -10px; right: 0; font-size: 11px; }
  .cake-action { flex: 0 0 auto; text-align: center; padding-top: 5px; }
  .cake-action .button { width: min(100%, 300px); min-height: 49px; margin-top: 0; }
  .candle-hint { margin-top: 10px; font-size: 11px; }

  .birthday-message { display: flex; flex-direction: column; justify-content: center; align-items: center; background: #e9e0ee; animation: none; }
  .birthday-message .section-index { font-size: 8px; letter-spacing: 1.3px; }
  .birthday-message h2 { font-size: clamp(40px, 11.8vw, 55px); line-height: 1; letter-spacing: -2px; margin: 18px 0 25px; }
  .birthday-message > p { font-size: 16px; line-height: 1.65; }
  .birthday-message > .message-last { font-size: 26px; line-height: 1.25; margin-top: 22px; }
  .birthday-message .message-signature { font-size: 8px; gap: 8px; margin: 28px 0 17px; }
  .birthday-message .text-button { min-height: 44px; }

  .committee { display: flex; flex-direction: column; gap: 16px; }
  .committee .section-heading { flex: 0 0 auto; margin: 0; }
  .committee h2 { font-size: clamp(31px, 8vw, 38px); max-width: 330px; }
  .committee .section-heading > .scribble { font-size: 16px; margin-top: 12px; }
  .committee-line { flex: 1 1 240px; min-height: 180px; container-type: size; container-name: committee-people; display: grid; grid-template-columns: 1fr 1fr; align-content: center; align-items: center; gap: 10px 15px; }
  .committee-member { padding: 5px 0; }
  .committee-member img, .committee-member video { height: min(18vh, 160px); width: 100%; margin-bottom: 12px; }
  .committee-member > span, .video-control { font-size: 9px; line-height: 1.35; }
  .video-control { min-height: 44px; padding: 6px 10px; }
  .special-guest { grid-column: 1 / -1; width: 215px; justify-self: center; }
  .special-guest img { height: min(14vh, 120px); width: 105px; margin-bottom: 12px; }
  .committee .site-footer { flex: 0 0 auto; margin: 0; padding: 12px 0 0; gap: 10px; }
  .committee .site-footer .brand { font-size: 7px; }
  .committee .site-footer > span { display: none; }
  .footer-party { min-height: 44px; }
  .toast { bottom: calc(var(--safe-bottom) + 82px); max-height: calc(var(--screen-height) - var(--slide-top) - var(--slide-bottom)); overflow-y: auto; }
  .toast > button { min-width: 40px; min-height: 44px; }
}

@media (max-width: 760px) and (max-height: 740px) {
  :root { --slide-top: calc(var(--safe-top) + 94px); --slide-bottom: calc(var(--safe-bottom) + 76px); }
  .hero { gap: 10px; }
  .hero-stage { flex-basis: 238px; }
  .hero h1 { font-size: 28px; }
  .hero-bottom p { font-size: 12px; }
  .hero-bottom .button { margin-top: 10px; }
  .fine-print { margin-top: 6px; }
  .wish-slide { gap: 12px; }
  .wish-slide > .wish-card { flex-basis: 345px; padding: 21px 23px 0; }
  .wish-card h3 { padding-top: 19px; font-size: 32px; }
  .wish-short { padding-top: 12px; font-size: 13px; }
  .wish-card img, .wish-lilac img, .wish-peach img { height: 170px; width: 57%; }
  .wish-open { width: calc(100% + 46px); margin-inline: -23px; padding-inline: 23px; }
  .wish-detail { font-size: 20px; padding: 20px; }
  .cake-inner { gap: 10px; }
  .cake-copy h2 { font-size: 44px; margin-bottom: 10px; }
  .cake-copy .section-index { margin-bottom: 10px; }
  .cake-copy > p:not(.candle-hint):not(.sr-only) { font-size: 12px; }
  .cake-scene { flex-basis: 180px; }
  .cake-art { transform: translate(-50%, -50%) rotate(-4deg) scale(.72); }
  .cake-guard { width: 80px; height: 80px; bottom: -5px; }
  .cake-note { font-size: 13px; }
  .cake-spark { width: 22px; height: 22px; }
  .birthday-message h2 { margin: 12px 0 18px; font-size: 42px; }
  .birthday-message > p { font-size: 14px; line-height: 1.55; }
  .birthday-message > .message-last { margin-top: 16px; font-size: 23px; }
  .birthday-message .message-signature { margin: 20px 0 9px; }
  .committee { gap: 10px; }
  .committee h2 { font-size: 30px; }
  .committee .section-heading > .scribble { margin-top: 8px; font-size: 15px; }
  .committee-member img, .committee-member video { height: 100px; margin-bottom: 7px; }
  .special-guest img { height: 83px; }
  .committee-line { gap: 4px 12px; }
}
@media (max-width: 370px) {
  .hero-cat-left { left: calc(50% - 141px); width: 135px; }
  .hero-cat-right { right: calc(50% - 139px); width: 143px; }
  .hero-last { font-size: 23px; }
  .cat-caption { font-size: 11px; left: 21px; }
  .wish-card h3 { font-size: 28px; }
  .wish-card img { width: 49%; }
}
@media (max-height: 590px) and (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  /* Retain reachable content for landscape, browser chrome and enlarged text. */
  .story-slide { overflow-y: auto; }
  .hero-stage { flex-shrink: 0; }
  .birthday-message { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .story { scroll-behavior: auto; } }
@container cake-illustration (max-height: 225px) {
  .cake-art { transform: translate(-50%, -50%) rotate(-4deg) scale(.65); }
  .cake-guard { width: 72px; height: 72px; }
  .cake-note { font-size: 11px; }
}
@container cake-illustration (max-height: 185px) {
  .cake-art { transform: translate(-50%, -50%) rotate(-4deg) scale(.55); }
  .cake-note { display: none; }
  .cake-guard { width: 60px; height: 60px; }
}
@container committee-people (max-height: 240px) {
  .committee-member { padding: 0; }
  .committee-member img, .committee-member video { height: 70px; margin-bottom: 5px; }
  .special-guest img { height: 60px; }
}
@container committee-people (max-height: 220px) {
  .committee-member img, .committee-member video { height: 60px; }
  .special-guest img { height: 50px; }
}
