/* Keep the photograph, handwritten note and gestures comfortable on a phone. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.letter-open { position: fixed; inset-inline: 0; top: var(--page-scroll-top, 0); width: 100%; }
.letter-toolbar { position: sticky; top: 0; z-index: 4; height: 0; display: flex; justify-content: flex-end; pointer-events: none; }
.letter-toolbar .close-button { position: relative; float: none; pointer-events: auto; }

@media (max-width: 600px), (max-width: 950px) and (max-height: 500px) {
  body { background-attachment: scroll; }
  body::before { opacity: .025; }
  .site-header {
    height: calc(58px + env(safe-area-inset-top));
    max-width: 440px;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  }
  .dedication { font-size: clamp(25px, 7vw, 28px); }
  .sound-button { width: 48px; height: 48px; min-height: 48px; }
  .sound-icon svg { width: 21px; height: 21px; }
  .birthday { padding-top: clamp(4px, 2svh, 18px); }
  .intro { padding: 0 16px; }
  #birthday-heading { font-size: clamp(46px, 13vw, 55px); line-height: 1.12; }
  .cake-column {
    width: min(350px, calc(100vw - 48px), max(240px, calc(100svh - 300px)));
    margin: 24px auto 0;
  }
  .cake-stage::before { inset: -7px; border-width: 7px; }
  .candle { --candle-position: var(--mobile-x); width: 44px; }
  .interaction-panel {
    width: min(380px, calc(100vw - 32px)); max-width: none;
    position: relative; left: 50%; transform: translateX(-50%);
    margin: 16px 0 0; min-height: 128px;
    padding: 0 6px max(16px, env(safe-area-inset-bottom));
  }
  .match-tray { width: 156px; height: 68px; min-height: 68px; }
  .match-tray .match-art { width: 156px; height: 54px; }
  .letter-shortcut, .mic-control, .restart-button { width: 52px; min-height: 52px; }
  .letter-shortcut { margin-top: 0; }
  .letter-shortcut svg { width: 22px; height: 22px; }
  .interaction-panel h2:not(.sr-only) { font-size: 29px; margin: 4px 0; }
  .interaction-panel #silent-wish { min-height: 56px; font-size: 25px; padding: 0 24px; }
  .blow-touch { min-width: 98px; height: 64px; font-size: 36px; }
  .button-row { gap: 20px; }
  .envelope { margin-top: 25px; margin-bottom: 8px; }
  .toast { bottom: max(20px, env(safe-area-inset-bottom)); font-size: 13px; }

  .letter-dialog {
    position: fixed; inset: 0; margin: 0; width: 100%; max-width: none;
    height: 100vh; height: 100dvh; max-height: none;
    padding: 0; border-radius: 0; overflow: hidden;
  }
  .letter-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .letter-toolbar {
    position: relative; top: auto; height: calc(58px + env(safe-area-inset-top));
    padding: calc(5px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 5px 12px;
    background: #fbf7ec; align-items: center;
  }
  .letter-toolbar .close-button { width: 48px; height: 48px; flex: 0 0 48px; }
  .letter-paper {
    min-height: 0; overflow-y: auto; overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
    padding: 10px max(26px, env(safe-area-inset-right)) 24px max(26px, env(safe-area-inset-left));
  }
  .letter-paper h2 { font-size: 31px; line-height: 1.4; margin: 2px 0 26px; }
  .letter-body { font-size: clamp(25px, 6.8vw, 28px); line-height: 1.68; letter-spacing: 0; }
  .letter-body p { margin-bottom: 26px; }
  .letter-from { font-size: 27px; }
  .soup-gift { width: 64px; height: 64px; font-size: 32px; margin: 24px auto 8px; }
  .letter-back {
    width: 100%; margin: 0; min-height: calc(56px + env(safe-area-inset-bottom));
    padding: 8px 20px max(8px, env(safe-area-inset-bottom));
    background: #fbf7ec; border-top: 1px solid #8e765514; font-size: 25px;
  }
  .soup-dialog {
    position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: none;
    height: min(560px, calc(100vh - 48px - env(safe-area-inset-top)));
    height: min(560px, calc(100dvh - 48px - env(safe-area-inset-top)));
    max-height: none; padding: 0 0 max(20px, env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0; overflow: hidden;
  }
  .soup-dialog[open] { display: flex; flex-direction: column; }
  .soup-close {
    position: static; flex: 0 0 48px; align-self: flex-end;
    width: 48px; height: 48px; margin: 8px max(12px, env(safe-area-inset-right)) 0 0;
  }
  .soup-scene {
    flex: 0 0 auto;
    width: min(380px, calc(100% - 32px), calc(100vh - 160px));
    width: min(380px, calc(100% - 32px), calc(100dvh - 160px));
    margin: auto;
  }
  .soup-spoon::before { content: ''; position: absolute; inset: -8px; }
  .soup-dialog::backdrop { background: #62544455; backdrop-filter: blur(3px); }
}

@media (max-width: 350px) {
  .site-header { padding-left: 18px; padding-right: 12px; }
  .birthday { padding-top: 4px; }
  .cake-column { margin-top: 21px; }
  .letter-paper { padding-left: 22px; padding-right: 22px; }
}

@media (hover: none) {
  .match-tray:hover, .soup-gift:hover, .envelope:hover { transform: none; }
}

/* Small cues keep the page quiet while making its objects feel touchable. */
.match-tray { animation: match-invitation 1.4s ease-in-out 1.1s 1; }
.match-tray.armed { animation: none; }
@keyframes match-invitation {
  0%, 100% { transform: none; }
  45% { transform: translateY(-5px) rotate(-4deg); }
}
.match-active .candle:not(.lit) .wick { box-shadow: 0 0 8px 3px #c4975b55; }
.match-active .candle:not(.lit):focus-visible { outline: 1px dashed #907453; border-radius: 12px; }
.mic-control { border-radius: 50%; transition: background .2s, color .2s; }
.mic-control[aria-pressed="true"] { color: #714931; background: #b3946d29; }
.mic-control[aria-busy="true"] { background: #b3946d18; }
#silent-wish { text-decoration: underline; text-decoration-color: #90745366; text-underline-offset: 6px; text-decoration-thickness: 1px; }
.soup-scene.is-loading .soup-spoon, .soup-scene.is-loading .soup-steam { visibility: hidden; }
.soup-scene.is-loading::after { content: ''; position: absolute; left: calc(50% - 10px); top: calc(50% - 10px); width: 20px; height: 20px; border: 1px solid #90745330; border-top-color: #907453; border-radius: 50%; animation: soup-loading 1s linear infinite; }
@keyframes soup-loading { to { transform: rotate(360deg); } }
.soup-scene.load-failed::after { display: none; }
#soup-status.soup-error { position: static; width: auto; height: auto; clip-path: none; white-space: normal; margin: 0 24px 20px; text-align: center; font: 23px var(--hand); color: #625343; }
@media (max-width: 600px), (max-width: 950px) and (max-height: 500px) {
  .letter-dialog[open] { grid-template-rows: auto minmax(0, 1fr); }
  .letter-back { display: none; }
  .letter-paper { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
}
.match-active .cake-stage { cursor: grab; }
.match-active .candle { cursor: pointer; }

/* A little birthday note, with a favourite character tucked beneath it. */
#birthday-heading { font: 400 60px/1.2 var(--hand); letter-spacing: -1.2px; transform: rotate(-2.2deg); }
.intro { position: relative; }
#birthday-heading::after { content: ''; position: absolute; width: 63%; height: 7px; left: 18%; bottom: -4px; border-bottom: 1.5px solid #9e816244; border-radius: 50%; transform: rotate(-1deg); }
#light-panel { position: relative; width: 240px; margin: auto; }
.match-tray { width: 80px; height: 132px; min-height: 132px; transform: rotate(7deg); }
.match-tray .match-art { width: 80px; height: 132px; }
.match-tray:hover { transform: rotate(3deg) translateY(-3px); }
.lighter-note { position: absolute; left: -3px; top: 21px; font: 26px/1.1 var(--hand); color: #7e6851; transform: rotate(-9deg); pointer-events: none; }
.lighter-note svg { display: block; width: 70px; height: 42px; margin-left: 18px; transform: rotate(-3deg); }
.lighter-note path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.match-active .lighter-note { opacity: 0; transition: opacity .25s; }
.floating-match .match-art { width: 72px; height: 122px; left: -28px; top: -20px; transform: rotate(12deg); transform-origin: 28px 20px; }
.letter-shortcut { margin-top: 5px; }
.soup-bowl { overflow: visible; }
.soup-surface { position: absolute; inset: 0; clip-path: ellipse(41% 24% at 50% 46%); transform-origin: 50% 64%; transform: translateY(var(--soup-drop,0%)) scale(var(--soup-scale,1)); opacity: var(--soup-opacity,1); transition: transform .75s ease, opacity .65s; pointer-events: none; }
.soup-bowl .soup-surface img { filter: none; }
.soup-front { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; clip-path: polygon(0 70%, 100% 70%, 100% 100%, 0 100%); z-index: 4; pointer-events: none; }
.soup-spoon { z-index: 5; transition: filter .25s; }
.soup-spoon.is-dipped { z-index: 3; filter: drop-shadow(1px 1px 1px #493b2b22); }
.is-dipped svg { opacity: .65; }
.soup-steam { opacity: var(--steam-opacity,1); transition: opacity .8s; }
.soup-scene.is-empty .soup-spoon { visibility: hidden; }
.soup-refill { display: block; margin: 4px auto 0; border: 0; border-bottom: 1px solid #90745355; background: none; font: 26px var(--hand); color: #7e6851; min-height: 44px; }
@media(max-width:600px), (max-width:950px) and (max-height:500px) {
  #birthday-heading { font-size: 49px; }
  .birthday { padding-top: 4px; }
  .cake-column { width: min(340px,calc(100vw - 48px),max(218px,calc(100svh - 355px))); margin-top: 22px; }
  .interaction-panel { margin-top: 14px; }
  .match-tray { width: 72px; height: 116px; min-height: 116px; }
  .match-tray .match-art { width: 72px; height: 116px; }
  .lighter-note { font-size: 25px; left: 0; top: 17px; }
  .soup-refill { flex: 0 0 44px; }
}
@media(hover:none){.match-tray:hover{transform:rotate(7deg)}}
