:root {
  color-scheme: dark;
  --back: #100c18;
  --front: #f6edf9;
  --muted: #bdb1cd;
  --dim: #a397b5;
  --lilac: #d9bafa;
  --border: #f3dcff24;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "STSong", "SimSun", serif;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 76% 47%, #241833 0%, transparent 55%),
    radial-gradient(ellipse at 5% -12%, #251831 0%, transparent 49%),
    var(--back);
  color: var(--front);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid #f2bdff; outline-offset: 5px; }
p, h1, h2 { margin: 0; }

.page {
  width: min(100%, 1120px);
  margin: auto;
  padding: env(safe-area-inset-top) max(36px, env(safe-area-inset-right))
    env(safe-area-inset-bottom) max(36px, env(safe-area-inset-left));
}

.topbar {
  min-height: 84px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f4dcff15;
}

.brand, .tools, .tool {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: .12em;
  white-space: nowrap;
}

.brand-symbol {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, #9570bd, #533985 69%, #45285d);
  box-shadow: inset 0 1px 0 #f3d2fe65, 0 3px 12px #0a061a5c;
}

.brand-symbol::before, .brand-symbol::after {
  content: "";
  display: block;
  grid-area: 1 / 1;
  background: #fff0fe;
  clip-path: polygon(50% 0%, 63% 36%, 100% 50%, 63% 64%, 50% 100%, 37% 64%, 0 50%, 37% 36%);
}

.brand-symbol::before { width: 18px; height: 18px; }
.brand-symbol::after { width: 7px; height: 7px; transform: translate(9px, -8px); }

.tools { gap: 9px; }

.tool {
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f1d8ff0b;
  color: #eee0f6;
  font-size: .875rem;
  font-weight: 550;
  white-space: nowrap;
}

@media (hover: hover) {
  .tool:hover { background: #f1d8ff1c; }
}

.album-count { color: var(--lilac); font-variant-numeric: tabular-nums; }

.book-symbol {
  display: inline-block;
  width: 15px;
  height: 12px;
  border: 1.25px solid #d9bee9;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent 44%, #d9bee9 44% 54%, transparent 54%);
  box-shadow: 0 2px #d9bee933;
}

.sound { padding: 0; color: #a99bb8; }
.sound[aria-pressed="true"] { color: #e7cdfc; }

.sound-symbol {
  position: relative;
  width: 20px;
  height: 18px;
}

.sound-symbol::before {
  position: absolute;
  content: "";
  inset: 2px 8px 2px 1px;
  background: currentColor;
  clip-path: polygon(0 33%, 35% 33%, 92% 0, 92% 100%, 35% 67%, 0 67%);
}

.sound-symbol::after {
  content: "";
  position: absolute;
  inset: 2px 1px 2px 13px;
  border-right: 1.5px solid currentColor;
  border-radius: 0 50% 50% 0;
}

.sound[aria-pressed="false"] .sound-symbol::after {
  inset: 2px 2px 1px 12px;
  border-radius: 0;
  transform: rotate(-42deg);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(38px, 7vw, 92px);
  padding: clamp(38px, 7.5vh, 86px) 0 37px;
}

.intro { padding-bottom: 34px; }

h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(54px, 6.6vw, 86px);
  line-height: 1.13;
  letter-spacing: -.055em;
  white-space: nowrap;
}

h1 > span {
  display: block;
  color: var(--lilac);
  text-shadow: 0 5px 36px #ad78de38;
}

.period { color: #c69ce8; }

.instructions {
  margin-top: 25px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.9;
  letter-spacing: .035em;
}

.dedication {
  width: fit-content;
  max-width: 100%;
  margin-top: 24px;
  padding: 9px 14px;
  border-left: 1px solid #c998f795;
  background: linear-gradient(90deg, #d2a8fa16, transparent);
  color: #e0bff2;
  font-size: .9375rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.play-area { min-width: 0; }

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(465px, 64vh, 580px);
  height: clamp(465px, 64svh, 580px);
  border: 1px solid #d9b7f140;
  border-radius: 28px;
  background: #191329;
  box-shadow: 0 28px 85px #09061179, inset 0 0 0 4px #dfc8ff08;
}

.sky {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
  pointer-events: none;
}

.stage-top {
  position: relative;
  z-index: 1;
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 9px;
  padding: 0 22px;
  border-bottom: 1px solid #e9caff18;
  background: linear-gradient(#281c3dba, #1a1329a3);
}

.stage-label {
  display: flex;
  gap: 7px;
  align-items: center;
  color: #e8d7f2;
  font-size: .875rem;
  letter-spacing: .065em;
  white-space: nowrap;
}

.stage-label > span { color: #ddb5ff; }

.progress-wrap { display: flex; align-items: center; gap: 13px; }

.progress-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #af99ca59;
}

.progress-dot.lit {
  background: #edd1ff;
  box-shadow: 0 0 9px 2px #bd87fd74;
}

.progress {
  color: #c3afd1;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress strong { color: #fcf3ff; }

.activity {
  position: absolute;
  right: 0;
  bottom: 17px;
  left: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.activity button { pointer-events: auto; }

.cloud {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(72%, 286px);
  padding: 8px 8px 0;
  border: 0;
  border-radius: 45px;
  background: none;
  appearance: none;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
}

.cloud-art {
  display: block;
  width: 100%;
  max-width: 252px;
  aspect-ratio: 560 / 362;
  transform-origin: 50% 70%;
  transform: translate(var(--pull-x, 0px), var(--pull-y, 0px))
    rotate(var(--tilt, 0deg)) scale(var(--stretch, 1), var(--squish, 1));
  transition: transform 440ms cubic-bezier(.19, 1.75, .40, 1), filter 180ms ease;
  filter: drop-shadow(0 4px 24px #b681ff60);
  pointer-events: none;
}

.cloud-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cloud.holding .cloud-art {
  transition: filter 160ms linear;
  filter: drop-shadow(0 0 28px #dc98ff9c) brightness(var(--brightness, 1.12));
}

.cloud-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 124px;
  min-height: 43px;
  padding: 0 14px;
  gap: 8px;
  border: 1px solid #e6c2fd40;
  border-radius: 99px;
  background: #8f65bd23;
  color: #f3e5fb;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .1em;
  white-space: nowrap;
  pointer-events: none;
}

.cloud-label > span:first-child { color: #ddb4ff; font-size: .78rem; }
.cloud.holding .cloud-label { background: #9b61c845; }
.cloud[aria-disabled="true"] { cursor: default; }

.activity-label {
  display: block;
  color: #f2e2fc;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .08em;
}

.swipe-pad, .rain-pad {
  position: relative;
  width: min(84%, 340px);
  margin: 0;
  border-radius: 23px;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.swipe-pad {
  height: 144px;
  border: 1px dashed #d9b6ff76;
  background: radial-gradient(ellipse at 50% 50%, #b189df28, #8f65bd1c 61%, #1b14262e);
  box-shadow: inset 0 0 27px #c492f513;
  cursor: grab;
}

.swipe-pad.tracing { cursor: grabbing; background: #be8ffb0a; }
.swipe-pad.tracing .swipe-guide { opacity: .18; }
.swipe-pad.nudge { border-color: #f3d5ff; }

.swipe-guide {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(55%, 152px);
  height: 42px;
  margin: auto auto 11px;
  transform: rotate(-13deg);
  color: #eacaff;
  text-shadow: 0 0 14px #dca0ff;
  pointer-events: none;
}

.swipe-guide::before {
  content: "";
  position: absolute;
  right: 6px;
  left: 6px;
  border-top: 1px dashed #e4b8faa6;
}

.swipe-guide span { z-index: 1; font-size: 17px; }
.swipe-guide span:nth-child(2) { font-size: 22px; }
.swipe-guide span:nth-child(3) { font-size: 31px; }

.bubbles-zone {
  flex-direction: column;
  align-items: center;
  gap: 11px;
  padding-bottom: 8px;
}

.bubble-tray {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(10px, 3vw, 23px);
  height: 109px;
}

.bubble {
  --bubble-hue: 276;
  width: 63px;
  height: 63px;
  margin-top: 27px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  touch-action: manipulation;
}

.bubble:nth-child(2) { --bubble-hue: 324; width: 72px; height: 72px; margin-top: 8px; }
.bubble:nth-child(3) { --bubble-hue: 207; margin-top: 34px; }

.bubble-art {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px solid hsl(var(--bubble-hue) 92% 88% / .72);
  border-radius: 50%;
  background: radial-gradient(circle at 29% 23%, #ffedffda 0 3%, transparent 16%),
    radial-gradient(circle at 43% 33%, hsl(var(--bubble-hue) 84% 77% / .74), transparent 73%),
    linear-gradient(152deg, #dfbbff24, hsl(var(--bubble-hue) 75% 48% / .44));
  box-shadow: inset 0 -3px 12px hsl(var(--bubble-hue) 96% 78% / .68),
    0 0 19px hsl(var(--bubble-hue) 81% 71% / .34);
  text-shadow: 0 0 10px #ffd9ff;
  transition: transform 170ms ease-in, opacity 170ms linear;
}

.bubble:active .bubble-art { transform: scale(.87); }
.bubble.popped { pointer-events: none; }
.bubble.popped .bubble-art { transform: scale(1.45); opacity: 0; }

.rain-pad {
  height: 153px;
  border: 0;
  background: linear-gradient(90deg, transparent, #b18ce515, transparent);
  cursor: ew-resize;
}

.rain-pad > * { pointer-events: none; }
.rain-pad .activity-label { position: absolute; inset: auto 0 4px; }

.rain-star, .rain-basket {
  position: absolute;
  transform: translateX(-50%);
}

.rain-star {
  top: var(--drop-y, 9px);
  left: var(--drop-x, 26%);
  color: #ffefca;
  font-size: 25px;
  line-height: 1;
  text-shadow: 0 0 7px #ffd686, 0 0 25px #ffbd6a;
}

.rain-track {
  position: absolute;
  inset: 98px 4% auto;
  border-top: 1px dashed #e6c5ff74;
  box-shadow: 0 0 11px #c081ffaa;
}

.rain-basket {
  top: 82px;
  left: var(--basket-x, 50%);
  width: 63px;
  height: auto;
  filter: drop-shadow(0 0 10px #c38bff91);
}

.tip {
  margin-top: 16px;
  color: var(--dim);
  font-size: .8125rem;
  line-height: 1.65;
  text-align: center;
  text-wrap: pretty;
}

.tip > span[aria-hidden] { margin-right: 4px; color: #d6aaf3; }

.result {
  position: absolute;
  right: 14px;
  bottom: 22px;
  left: 14px;
  display: grid;
  justify-items: center;
  text-align: center;
  animation: arrive 420ms ease-out both;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-eyebrow {
  font-size: .8125rem;
  letter-spacing: .14em;
  color: #d6adef;
}

.result-title {
  margin-top: 6px;
  font: 700 clamp(31px, 4.2vw, 48px) / 1.2 var(--serif);
  color: #f8eaff;
}

.result-note {
  margin-top: 7px;
  color: #d7c5e3;
  font-size: .875rem;
  line-height: 1.6;
}

.next-sky {
  min-height: 44px;
  margin-top: 14px;
  padding: 0 20px;
  border: 1px solid #f0ccff85;
  border-radius: 99px;
  background: linear-gradient(135deg, #ead0fc, #cfa9f2);
  color: #2c1740;
  font-weight: 700;
  font-size: .875rem;
  box-shadow: 0 4px 22px #b784e53d;
}

.next-sky:active { transform: scale(.97); }

.album {
  width: min(calc(100% - 32px), 555px);
  max-height: calc(100% - 32px);
  overflow: hidden;
  padding: 22px;
  border: 1px solid #c8a1e45c;
  border-radius: 24px;
  background: #22182f;
  color: var(--front);
  box-shadow: 0 24px 100px #07040be0;
}

.album::backdrop { background: #0b0712bb; backdrop-filter: blur(5px); }

.album-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.album-header h2 { font: 700 2rem / 1.2 var(--serif); }
.album-subtitle { margin-top: 6px; font-size: .875rem; color: var(--muted); }
.close-album { padding: 0; font-size: 1.5rem; line-height: 1; }

.album-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
  padding-right: 4px;
  max-height: min(500px, calc(100svh - 155px));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

@media (max-width: 480px) {
  .album { padding: 17px; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.album-card {
  padding: 6px 8px 12px;
  border: 1px solid #e4bdff25;
  border-radius: 14px;
  background: radial-gradient(ellipse at 50% 40%, #39264f, #1d152b 76%);
  text-align: center;
}

.album-card canvas { display: block; width: 100%; max-width: 160px; height: auto; margin-inline: auto; }
.album-card h3 { margin: 0; color: #f1dcfb; font-size: .875rem; font-weight: 600; }
.album-card.locked h3 { color: #b5a5c3; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 855px) {
  .page {
    width: min(100%, 580px);
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }

  .topbar { min-height: 64px; }
  .layout { display: block; padding: 22px 0 24px; }
  .intro { padding: 0; margin-bottom: 17px; }
  h1 { font-size: clamp(29px, 9.5vw, 58px); letter-spacing: -.05em; }
  h1 > span { display: inline; }
  .instructions { margin-top: 9px; font-size: .9375rem; line-height: 1.6; }
  .dedication { margin-top: 9px; padding: 4px 8px; font-size: .8125rem; }
  .stage {
    height: clamp(380px, 60vh, 525px);
    height: clamp(380px, 60svh, 525px);
    border-radius: 23px;
  }
  .stage-top { min-height: 51px; padding: 0 15px; }
  .activity { bottom: 15px; }
  .cloud-art { max-width: 216px; }
  .tip { margin: 12px auto 0; max-width: 31em; }
}

@media (max-width: 370px) {
  .brand { gap: 7px; letter-spacing: .05em; font-size: .94rem; }
  .brand-symbol { width: 30px; height: 30px; }
  .tools { gap: 6px; }
  .album-toggle { padding-inline: 10px; }
  .album-count { display: none; }
  .stage-top { padding-inline: 11px; }
  .progress-wrap { gap: 8px; }
  .progress-dots { gap: 4px; }
}

@media (max-width: 855px) and (max-height: 690px) {
  .layout { padding-top: 16px; }
  .intro { margin-bottom: 13px; }
  .stage { height: clamp(350px, 59svh, 420px); }
  .cloud-art { max-width: clamp(155px, 28svh, 195px); }
  .result { bottom: 16px; }
  .result-note { margin-top: 4px; }
  .next-sky { margin-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
