/* =========================================================
   스마트폰 컨설턴트 · 미캔의 첫수업
   A two-scene, storybook opening — responsive build
   ========================================================= */

:root {
  --paper: #f2e4c2;
  --paper-hi: #fbf3e0;
  --ink: #3a2a1d;
  --ink-2: rgba(58, 42, 29, 0.64);
  --ink-3: rgba(58, 42, 29, 0.38);
  --persimmon: #cf4a22;
  --ochre: #d99a3d;
  --ui: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --display: "Jua", var(--ui);
  --hand: "Gaegu", "Nanum Pen Script", var(--ui);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow-wrap: break-word;
}

img { max-width: 100%; }
a { color: inherit; }

::selection { background: var(--persimmon); color: #fff6e6; }

:focus-visible {
  outline: 2px solid var(--persimmon);
  outline-offset: 4px;
  border-radius: 4px;
}

.sr-only,
.sprite {
  position: absolute;
  width: 0; height: 0;
  overflow: hidden;
}

.skip {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-hi);
  font-size: 13px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.3s var(--ease);
}
.skip:focus-visible { transform: none; }

/* ---------- progress ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 90;
  pointer-events: none;
}
.progress__bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--persimmon), var(--ochre));
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ---------- topbar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(10px, 2.2vh, 22px) clamp(12px, 2.6vw, 36px);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand,
.datepill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.74);
  border: 1px solid rgba(80, 50, 25, 0.1);
  box-shadow: 0 12px 34px -16px rgba(70, 40, 15, 0.6);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  backdrop-filter: blur(12px) saturate(1.15);
}

.brand {
  gap: 11px;
  padding: 6px 18px 6px 6px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.brand:hover { background: rgba(255, 252, 245, 0.9); transform: translateY(-1px); }

.brand__badge {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: #fff7e8;
  background: linear-gradient(145deg, #e2703a, #bd3f1c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.brand__badge svg { width: 21px; height: 21px; fill: currentColor; }

.brand__copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand__copy strong {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand__copy span {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

.datepill {
  gap: 9px;
  padding: 10px 15px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.datepill__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--persimmon);
  box-shadow: 0 0 0 3px rgba(207, 74, 34, 0.14);
}
.datepill__day {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(58, 42, 29, 0.08);
  font-size: 10.5px;
  color: var(--ink-2);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
.soundlink {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.74);
  border: 1px solid rgba(80, 50, 25, 0.1);
  box-shadow: 0 12px 34px -16px rgba(70, 40, 15, 0.6);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  backdrop-filter: blur(12px) saturate(1.15);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.soundlink svg { width: 19px; height: 19px; }
.soundlink:hover { background: #fffaf0; transform: translateY(-1px); }

/* ---------- side dots ---------- */
.dots {
  position: fixed;
  top: 50%;
  right: clamp(12px, 2.2vw, 30px);
  translate: 0 -50%;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 15px;
}
.dots a {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.dots span {
  display: block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(58, 42, 29, 0.3);
  box-shadow: 0 0 0 1px rgba(255, 250, 240, 0.75);
  transition: background 0.35s var(--ease), transform 0.35s var(--ease);
}
.dots a:hover span { background: rgba(58, 42, 29, 0.62); }
.dots a[aria-current="true"] span {
  background: var(--persimmon);
  transform: scale(1.5);
  box-shadow: 0 0 0 1.5px rgba(255, 250, 240, 0.95), 0 0 0 6px rgba(207, 74, 34, 0.14);
}
.dots em {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.82);
  opacity: 0;
  translate: 6px 0;
  transition: opacity 0.25s var(--ease), translate 0.25s var(--ease);
}
.dots a:hover em,
.dots a:focus-visible em { opacity: 1; translate: 0 0; }

/* ---------- scenes ---------- */
.scene {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  isolation: isolate;
}
.scene--autumn { background: #efe0bd; }
.scene--rain { background: #79c3dc; }

.scene__paper {
  position: absolute;
  inset: -3%;
  z-index: 0;
  background: url("assets/paper.webp") center / cover no-repeat;
}
.scene__grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  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)'/%3E%3C/svg%3E");
}

.garland {
  position: absolute;
  top: -1%;
  left: 50%;
  translate: -50% 0;
  width: min(101%, 182svh);
  max-width: none;
  height: auto;
  z-index: 2;
  pointer-events: none;
}

.scene__meadow {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("assets/meadow.webp") center / cover no-repeat;
}

.rain-still {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.66;
  pointer-events: none;
  background: url("assets/rain-overlay.webp") center / cover no-repeat;
}
@supports (background-image: image-set(url("a") type("image/webp"))) {
  .rain-still {
    background-image: image-set(
      url("assets/rain-overlay.avif") type("image/avif"),
      url("assets/rain-overlay.webp") type("image/webp")
    );
  }
}

/* ---------- animated rain ---------- */
.rain {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.rain__sheet {
  position: absolute;
  left: -15%;
  right: -15%;
  top: -60%;
  height: 230%;
  background-repeat: repeat;
  will-change: transform;
}
.rain__sheet--a {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='360'%3E%3Cg stroke='%23ffffff' stroke-width='2' stroke-linecap='round' opacity='.5'%3E%3Cpath d='M20 10 8 62M88 70 76 122M150 30 138 82M52 180 40 232M120 210 108 262M10 250-2 302M170 270 158 322'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 180px 360px;
  opacity: 0.32;
  animation: rainfall 1.1s linear infinite;
}
.rain__sheet--b {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='480'%3E%3Cg stroke='%23eaf7ff' stroke-width='3' stroke-linecap='round' opacity='.55'%3E%3Cpath d='M30 20 10 100M120 90 100 170M210 40 190 120M70 250 50 330M170 290 150 370M20 380 0 460M230 400 210 480'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 240px 480px;
  opacity: 0.18;
  animation: rainfall-b 1.7s linear infinite;
}
@keyframes rainfall {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 360px, 0); }
}
@keyframes rainfall-b {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 480px, 0); }
}

/* ---------- floating leaves ---------- */
.leaves {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.leaf-frame { display: none; }

.leaf {
  position: absolute;
  top: -10%;
  left: var(--x);
  width: var(--s);
  height: auto;
  opacity: 0;
  animation: leaf-fall var(--dur) linear var(--delay) infinite;
  will-change: transform;
  filter: drop-shadow(0 6px 6px rgba(90, 45, 15, 0.12));
}
@keyframes leaf-fall {
  0% { transform: translate3d(0, -14vh, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.9; }
  50% { transform: translate3d(var(--drift), 52vh, 0) rotate(190deg); opacity: 0.9; }
  88% { opacity: 0.85; }
  100% { transform: translate3d(calc(var(--drift) * -0.7), 112vh, 0) rotate(380deg); opacity: 0; }
}

/* ---------- artwork layers ---------- */
.art {
  position: absolute;
  z-index: 4;
  transform: translate3d(0, var(--py, 0px), 0);
}
.art img { display: block; width: 100%; height: auto; }

.art__in {
  display: block;
  opacity: 1;
  transform: rotate(var(--rot, 0deg));
}
.js .art__in {
  opacity: 0;
  transform: translate3d(0, 46px, 0) rotate(var(--rot, 0deg)) scale(0.97);
  transition: opacity 1s var(--ease) var(--d, 0s), transform 1.3s var(--ease-out) var(--d, 0s);
}
.js .scene.is-seen .art__in {
  opacity: 1;
  transform: translate3d(0, 0, 0) rotate(var(--rot, 0deg)) scale(1);
}

.art--title-autumn {
  left: 18.2%;
  top: 59.3%;
  width: 31.8%;
  z-index: 5;
}
.art--child-autumn {
  left: 54.2%;
  top: 41.5%;
  width: 26.5%;
}
.art--title-rain {
  left: 6%;
  top: 33.3%;
  width: 49.9%;
  z-index: 5;
}
.art--child-rain {
  left: 64.5%;
  top: 14.4%;
  width: 34.7%;
}
.art--frog {
  left: 21.2%;
  top: 55.5%;
  width: 22.7%;
}

.art--child-autumn img {
  transform-origin: 50% 92%;
  animation: sway 7.5s ease-in-out infinite;
}
.art--child-rain img {
  transform-origin: 50% 95%;
  animation: sway 6s ease-in-out infinite;
}
.art--frog img {
  transform-origin: 50% 100%;
  animation: bob 3.8s ease-in-out infinite;
}
@keyframes sway {
  0%, 100% { transform: rotate(-1.1deg) translateY(0); }
  50% { transform: rotate(1.1deg) translateY(-6px); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-7px) scale(1.012, 0.988); }
}

.scene:not(.is-seen) .leaf,
.scene:not(.is-seen) .rain__sheet,
.scene:not(.is-seen) .art img { animation-play-state: paused; }

.scene__vignette {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  box-shadow: inset 0 0 140px 24px rgba(120, 70, 25, 0.16);
}
.scene__vignette--cool {
  box-shadow: inset 0 0 150px 30px rgba(20, 70, 60, 0.2);
}

/* ---------- scene furniture ---------- */
.scene__index {
  position: absolute;
  left: clamp(16px, 4vw, 54px);
  bottom: clamp(18px, 4.4vh, 42px);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--ink-2);
}
.scene__index b { font-weight: 700; color: var(--persimmon); }
.scene__index i {
  display: block;
  width: 26px; height: 1px;
  background: currentColor;
  opacity: 0.45;
}
.scene__index--cool { color: rgba(16, 62, 50, 0.72); }
.scene__index--cool b { color: #1c6a52; }

.cue {
  position: absolute;
  right: clamp(16px, 3vw, 40px);
  bottom: clamp(18px, 4.4vh, 40px);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.3s var(--ease);
}
.cue:hover { color: var(--ink); }
.cue__label {
  writing-mode: vertical-rl;
  font-size: 9px;
  letter-spacing: 0.34em;
}
.cue__line {
  position: relative;
  width: 1px;
  height: 46px;
  overflow: hidden;
  background: linear-gradient(rgba(58, 42, 29, 0.35), rgba(58, 42, 29, 0.04));
}
.cue__line i {
  position: absolute;
  left: 0; top: -14px;
  width: 1px; height: 14px;
  background: var(--persimmon);
  animation: cue 2.4s var(--ease) infinite;
}
@keyframes cue {
  0% { transform: translateY(0); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(58px); opacity: 0; }
}

/* ---------- outro ---------- */
.outro {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 100svh;
  overflow: hidden;
  background: #efe0bd;
  padding: clamp(70px, 13vh, 140px) clamp(20px, 6vw, 90px) clamp(36px, 6vh, 64px);
  isolation: isolate;
}
.outro__paper {
  position: absolute;
  inset: -3%;
  z-index: 0;
  background: url("assets/paper.webp") center / cover no-repeat;
}
.outro__leaf {
  position: absolute;
  z-index: 0;
  top: 6%;
  right: -3%;
  width: clamp(180px, 26vw, 420px);
  height: clamp(180px, 26vw, 420px);
  fill: var(--persimmon);
  opacity: 0.07;
  rotate: 14deg;
}
.outro__inner {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
}

.outro__eyebrow {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(58, 42, 29, 0.18);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
}
.outro__eyebrow span:last-child {
  color: var(--persimmon);
  font-weight: 600;
}

.outro__grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: end;
  gap: clamp(26px, 5vw, 80px);
  padding: clamp(34px, 7vh, 70px) 0 clamp(20px, 4vh, 44px);
}

.outro h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(46px, 8.6vw, 138px);
  line-height: 0.92;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.outro__sub {
  margin: 20px 0 0;
  font-family: var(--hand);
  font-size: clamp(22px, 2.6vw, 34px);
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(58, 42, 29, 0.2);
}
.chapters a {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 2px;
  border-bottom: 1px solid rgba(58, 42, 29, 0.2);
  text-decoration: none;
  color: inherit;
  transition: padding 0.35s var(--ease), background 0.35s var(--ease);
}
.chapters a:hover { padding-left: 12px; background: rgba(255, 250, 240, 0.38); }
.chapters__num {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--persimmon);
}
.chapters__name {
  font-size: clamp(17px, 1.55vw, 22px);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.chapters__go {
  font-size: 17px;
  color: var(--ink-3);
  transition: transform 0.35s var(--ease), color 0.35s var(--ease);
}
.chapters a:hover .chapters__go { transform: translate(3px, -3px); color: var(--persimmon); }

.outro__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: clamp(26px, 5vh, 52px);
}
.totop {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(58, 42, 29, 0.25);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: background 0.35s var(--ease), color 0.35s var(--ease), border-color 0.35s var(--ease);
}
.totop:hover { background: var(--ink); color: var(--paper-hi); border-color: var(--ink); }
.outro__mark {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}

/* =========================================================
   Marimba — ivory keys, walnut frame, two small players
   ========================================================= */
.scene--marimba { background: #ece0c6; }
.scene--marimba::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(70% 55% at 50% 6%, rgba(255, 249, 233, 0.6), rgba(255, 249, 233, 0) 72%);
}
.scene--marimba::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 6%;
  height: 70px;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(80, 45, 15, 0.22), transparent 70%);
  filter: blur(16px);
}

.marimba {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: clamp(84px, 11vh, 110px) clamp(16px, 3.2vw, 48px) clamp(12px, 2vh, 20px);
}

.marimba__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}
.marimba__title { min-width: 0; }
.marimba__eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--ink-2);
}
.marimba__eyebrow b { color: var(--persimmon); font-weight: 700; }
.marimba__eyebrow i {
  display: block;
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
}
.marimba h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(38px, 4.4vw, 58px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.marimba__sub {
  margin: 9px 0 0;
  font-family: var(--hand);
  font-size: clamp(16px, 1.5vw, 21px);
  line-height: 1.2;
  color: var(--ink-2);
}
.marimba__lead {
  max-width: 31ch;
  margin: 0 0 4px;
  text-align: right;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* the two players, standing at either end of the instrument */
.players {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 0;
  z-index: 3;
  pointer-events: none;
}
.player {
  position: absolute;
  bottom: 0;
  transition: transform 0.38s var(--ease);
}
.player img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 100%;
}
.player--child {
  left: clamp(4px, 0.8vw, 12px);
  width: clamp(120px, 13.2vw, 190px);
}
.player--child img { animation: player-sway 7.5s ease-in-out infinite; }
.player--frog {
  right: clamp(12px, 1.4vw, 22px);
  width: clamp(84px, 9vw, 128px);
}
.player--frog img { animation: player-bob 4.6s ease-in-out infinite; }
.players.is-dancing .player { transform: translateY(-9px) rotate(-1.4deg); }
.marimba.is-playing .player--child img { animation-duration: 4.4s; }
.marimba.is-playing .player--frog img { animation-duration: 2.6s; }

@keyframes player-sway {
  0%, 100% { transform: rotate(-1.4deg); }
  50% { transform: rotate(1.4deg); }
}
@keyframes player-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.keys {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 7px;
  margin: clamp(18px, 2.6vh, 30px) clamp(64px, 7.6vw, 122px) 0;
  padding: 11px 11px 13px;
  background: linear-gradient(180deg, #4d3624 0%, #3a281a 55%, #2c1d12 100%);
  border-radius: 20px;
  box-shadow: 0 46px 72px -46px rgba(45, 22, 6, 0.95),
    inset 0 1px 0 rgba(255, 238, 205, 0.22),
    inset 0 0 0 1px rgba(24, 14, 7, 0.55);
}
.keys::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 16px;
  border: 1px solid rgba(199, 157, 101, 0.3);
  pointer-events: none;
}

.key {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  font-family: var(--ui);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  background: linear-gradient(180deg, #fdf8ec 0%, #f6ecd8 56%, #eddfc4 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 40, 0.14),
    inset 0 -12px 18px -14px rgba(95, 60, 28, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.35s var(--ease), background 0.35s var(--ease),
    box-shadow 0.35s var(--ease), opacity 0.35s var(--ease);
}
.key::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 9px 9px 0 0;
  background: var(--tint);
  opacity: 0.92;
  transition: height 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.key:hover,
.key:focus-visible {
  transform: translateY(-7px);
  background: linear-gradient(180deg, #fffdf7 0%, #f9f1e0 56%, #f2e6cf 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 40, 0.2),
    0 20px 30px -22px rgba(60, 30, 10, 0.55),
    inset 0 -10px 18px -14px rgba(95, 60, 28, 0.35);
}
.key:hover::before,
.key.is-playing::before { height: 6px; }
.key:focus-visible { outline: 2px solid var(--ink); outline-offset: -5px; }

.key::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(130% 55% at 50% 6%, color-mix(in srgb, var(--tint) 38%, transparent), transparent 62%);
}
.key.is-struck::after { animation: keystrike 0.38s var(--ease) both; }
@keyframes keystrike {
  0% { opacity: 0.9; transform: scaleY(0.96); }
  100% { opacity: 0; transform: scaleY(1); }
}

.key__num {
  position: absolute;
  top: 15px;
  left: 50%;
  translate: -50% 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(70, 48, 28, 0.52);
  font-variant-numeric: tabular-nums;
}
.key__word {
  position: absolute;
  width: max-content;
  max-width: 100%;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  writing-mode: vertical-rl;
  font-family: var(--display);
  font-size: clamp(16px, 1.95vw, 26px);
  letter-spacing: 0.09em;
  line-height: 1.1;
  color: var(--ink);
  transition: color 0.3s var(--ease);
}
.key__eq {
  position: absolute;
  left: 50%;
  bottom: 13px;
  translate: -50% 0;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.key__eq i {
  width: 2.5px;
  height: 100%;
  border-radius: 2px;
  background: color-mix(in srgb, var(--tint) 72%, #46301d);
  transform: scaleY(0.2);
  transform-origin: 50% 100%;
}
.key.is-playing .key__eq { opacity: 1; }
.key.is-playing .key__eq i { animation: keyeq 0.9s ease-in-out infinite; }
.key.is-playing .key__eq i:nth-child(2) { animation-delay: 0.15s; }
.key.is-playing .key__eq i:nth-child(3) { animation-delay: 0.3s; }
@keyframes keyeq {
  0%, 100% { transform: scaleY(0.2); }
  50% { transform: scaleY(1); }
}

.key.is-playing {
  transform: translateY(-7px);
  background: linear-gradient(180deg, #fffdf7 0%, #f8efdc 56%, #f1e3c9 100%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 55%, transparent),
    0 0 0 5px color-mix(in srgb, var(--tint) 13%, transparent),
    0 24px 36px -24px rgba(60, 30, 10, 0.6);
}
.key.is-playing::before { box-shadow: 0 2px 10px color-mix(in srgb, var(--tint) 55%, transparent); }
.keys.has-playing .key:not(.is-playing) { filter: saturate(0.72) brightness(0.96); }
.keys.has-playing .key:not(.is-playing):hover { opacity: 1; }

.marimba__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 12px clamp(64px, 7.6vw, 122px) 0;
  padding-top: 12px;
  border-top: 1px solid rgba(90, 60, 30, 0.16);
}
.now {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  transition: color 0.3s var(--ease);
}
.marimba.is-playing .now { color: var(--ink); }
.now__eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
  opacity: 0.3;
}
.now__eq i {
  width: 2px;
  height: 100%;
  background: var(--persimmon);
  transform: scaleY(0.35);
  transform-origin: 50% 100%;
}
.marimba.is-playing .now__eq { opacity: 1; }
.marimba.is-playing .now__eq i { animation: keyeq 0.8s ease-in-out infinite; }
.marimba.is-playing .now__eq i:nth-child(2) { animation-delay: 0.12s; }
.marimba.is-playing .now__eq i:nth-child(3) { animation-delay: 0.24s; }

.marimba__actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}
.snd,
.stop {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(58, 42, 29, 0.22);
  background: rgba(255, 250, 240, 0.6);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.snd svg { width: 15px; height: 15px; }
.snd:hover,
.stop:hover { background: #fffaf0; border-color: rgba(58, 42, 29, 0.42); }
.snd.is-muted { color: var(--ink-3); border-style: dashed; }
.stop { color: var(--persimmon); border-color: rgba(207, 74, 34, 0.35); }
.stop[hidden] { display: none; }

/* =========================================================
   Portrait phones — recompose the scenes
   ========================================================= */
@media (max-aspect-ratio: 4/5) and (max-width: 599px) {
  .garland { display: none; }
  .leaf-frame {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
  }
  .leaf-frame img { position: absolute; height: auto; }
  .leaf-frame__a { width: 148px; top: -44px; left: -40px; rotate: -22deg; }
  .leaf-frame__b { width: 156px; top: -46px; right: -44px; rotate: 24deg; }
  .leaf-frame__c { width: 62px; top: 116px; right: -14px; rotate: 72deg; }
  .leaf-frame__d { width: 50px; top: 146px; left: -12px; rotate: -64deg; }

  .art--title-autumn {
    left: 5%;
    top: 24%;
    width: min(88vw, 44vh);
  }
  .art--child-autumn {
    left: auto;
    right: 0;
    top: auto;
    bottom: 7%;
    width: min(64vw, 40vh);
  }

  .art--title-rain {
    left: 5%;
    top: 31%;
    width: min(90vw, 48vh);
  }
  .art--child-rain {
    left: auto;
    right: -3%;
    top: auto;
    bottom: 6%;
    width: min(62vw, 38vh);
  }
  .art--frog {
    left: 3%;
    top: auto;
    bottom: 11%;
    width: min(44vw, 26vh);
  }

  .scene__index { font-size: 10px; letter-spacing: 0.2em; }
  .cue { display: none; }

  .dots {
    top: auto;
    bottom: 12px;
    right: auto;
    left: 50%;
    translate: -50% 0;
    flex-direction: row;
    align-items: center;
    gap: 9px;
    padding: 8px 13px;
    border-radius: 999px;
    background: rgba(255, 250, 240, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  .dots a { flex-direction: column; gap: 0; }
  .dots em { display: none; }
  .dots span { width: 7px; height: 7px; }

  .topbar { padding: 10px 12px; }
  .brand { padding: 5px 14px 5px 5px; gap: 9px; }
  .brand__badge { width: 32px; height: 32px; }
  .brand__badge svg { width: 19px; height: 19px; }
  .brand__copy strong { font-size: 12.5px; }
  .brand__copy span { font-size: 10px; }
  .datepill { padding: 9px 12px; font-size: 11.5px; gap: 7px; }
  .datepill__day { width: 18px; height: 18px; font-size: 10px; }

  .outro__grid { grid-template-columns: 1fr; align-items: start; gap: 34px; }
  .outro h2 { font-size: clamp(46px, 15vw, 76px); }
  .outro__eyebrow { font-size: 10.5px; letter-spacing: 0.16em; }
  .outro__foot { flex-direction: column; align-items: flex-start; gap: 18px; }
}

/* Short phones — lift the artwork so the two tiers never collide */
@media (max-aspect-ratio: 4/5) and (max-width: 599px) and (max-height: 740px) {
  .art--title-autumn { top: 21%; }
  .art--title-rain { top: 27%; }
  .art--child-autumn { bottom: 8%; }
  .art--child-rain { bottom: 7%; }
}

/* Portrait tablets — keep the two-tier stack shallow */
@media (max-aspect-ratio: 4/5) and (min-width: 600px) {
  .garland { width: 112%; top: -2%; }

  .art--title-autumn {
    left: 6%;
    top: 20%;
    width: min(78vw, 46vh);
  }
  .art--child-autumn {
    left: auto;
    right: 3%;
    top: auto;
    bottom: 5%;
    width: min(46vw, 36vh);
  }

  .art--title-rain {
    left: 6%;
    top: 22%;
    width: min(88vw, 58vh);
  }
  .art--child-rain {
    left: auto;
    right: -2%;
    top: auto;
    bottom: 3%;
    width: min(50vw, 36vh);
  }
  .art--frog {
    left: 5%;
    top: auto;
    bottom: 8%;
    width: min(34vw, 24vh);
  }

  .dots { gap: 16px; }
  .dots em { display: none; }
}

/* Short landscape (phones on their side) */
@media (max-height: 560px) and (min-aspect-ratio: 4/5) {
  .art--title-autumn { top: 50%; width: 25%; left: 20%; }
  .art--child-autumn { top: 28%; width: 21%; left: 57%; }
  .art--title-rain { top: 24%; width: 40%; }
  .art--child-rain { top: 4%; width: 27%; }
  .art--frog { top: 52%; width: 18%; }
  .cue { display: none; }
  .garland { width: min(101%, 200svh); }
  .scene__index { bottom: 14px; }
}

/* ---------- wide screens ---------- */
@media (min-width: 1900px) {
  .art--title-autumn { max-width: 700px; }
  .art--child-autumn { max-width: 580px; }
  .art--title-rain { max-width: 1050px; }
  .art--child-rain { max-width: 760px; }
  .art--frog { max-width: 500px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .leaf, .rain { display: none; }
  .js .art__in { opacity: 1; transform: rotate(var(--rot, 0deg)); }
}

/* ---------- small phones: compact masthead ---------- */
@media (max-width: 430px) {
  .topbar { padding: 10px 10px; }
  .brand { gap: 8px; padding: 5px 13px 5px 5px; }
  .brand__badge { width: 30px; height: 30px; }
  .brand__badge svg { width: 18px; height: 18px; }
  .brand__copy span { display: none; }
  .brand__copy strong { font-size: 12px; }
  .datepill { padding: 8px 11px; gap: 6px; font-size: 11px; }
  .datepill__day { width: 17px; height: 17px; font-size: 9.5px; }
}

/* ---------- very small phones ---------- */
@media (max-width: 360px) {
  .brand__copy strong { font-size: 11.5px; }
  .datepill { padding: 8px 10px; font-size: 10.5px; }
  .datepill__day { display: none; }
}

/* ---------- marimba: compact screens ---------- */
@media (max-width: 899px) {
  .marimba { padding: 78px 12px 58px; }
  .marimba__head { flex-direction: column; align-items: flex-start; gap: 7px; }
  .marimba__lead { max-width: 48ch; margin-top: 22px; text-align: left; font-size: 11.5px; line-height: 1.7; }
  .marimba h2 { font-size: clamp(30px, 8vw, 40px); }
  .marimba__sub { margin-top: 5px; font-size: 15px; }
  .marimba__eyebrow { margin-bottom: 4px; font-size: 10px; }
  .keys {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    margin: 12px 0 0;
    padding: 8px;
    border-radius: 16px;
  }
  .key { border-radius: 8px; }
  .key__word { writing-mode: horizontal-tb; font-size: clamp(14px, 4.1vw, 18px); letter-spacing: 0; }
  .key__num { top: 10px; font-size: 8.5px; }
  .key__eq { bottom: 9px; height: 11px; }
  .players {
    top: 76px;
    right: 10px;
    bottom: auto;
    left: auto;
    height: auto;
    display: flex;
    align-items: flex-end;
  }
  .player { position: static; }
  .player--child { width: 66px; }
  .player--frog { width: 46px; margin-left: -10px; }
  .marimba__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
    margin: 8px 0 0;
    padding-top: 10px;
  }
  .marimba__actions { width: 100%; justify-content: space-between; }
  .now { font-size: 11px; }
}

@media (max-width: 379px) {
  .soundlink { display: none; }
}

@media (max-height: 620px) and (min-width: 900px) {
  .marimba { padding-top: 72px; }
  .marimba h2 { font-size: 34px; }
  .marimba__sub,
  .marimba__lead { display: none; }
  .keys { margin-top: 10px; }
  .players { bottom: 62px; }
}
