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

:root {
  --pink: #fe49ce;
  --pink-deep: #c80d96;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

body {
  background: #000;
  color: #fff;
  font-family: GalmuriMono11, monospace;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; /* iOS 길게 누르기 메뉴도 막음 */
  -webkit-font-smoothing: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: max(env(safe-area-inset-top), 16px);
}

.top {
  position: relative;
  z-index: 4; /* 로고는 CRT 효과 위 */
  padding: 4px 15px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: block;
}
.home {
  display: block;
  width: fit-content; /* 로고 크기만 눌림 */
}

/* 오른쪽 위 메뉴: 누르면 아래로 펼침 */
.menu-btn {
  display: block;
  position: relative;
  transition: transform 160ms var(--ease-out);
}
.menu-btn img {
  display: block;
}
.menu-btn::before {
  content: "";
  position: absolute;
  inset: -11px;
} /* 누르는 영역 44px */
.menu-btn:active {
  transform: scale(0.92);
}
.menu-btn:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 4px;
}
.menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 15px;
  min-width: 140px;
  padding: 6px;
  background: #000;
  border: 2px solid var(--pink);
}
.menu:not([hidden]) {
  animation: menu-drop 220ms var(--ease-out);
}
.menu.closing {
  animation: menu-fold 160ms var(--ease-out) forwards; /* 닫힐 땐 아래에서 위로 접힘 */
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.menu-item[hidden] {
  display: none;
}
.menu-item:active {
  background: var(--pink-deep);
}
.menu-item:focus-visible {
  outline: 2px solid var(--pink);
}
@media (hover: hover) {
  .menu-item:hover {
    color: var(--pink);
  }
}
@keyframes menu-drop {
  from {
    clip-path: inset(0 0 100% 0); /* 위에서 아래로 펼쳐짐 */
  }
  to {
    clip-path: inset(0);
  }
}
@keyframes menu-fold {
  from {
    clip-path: inset(
      0
    ); /* 시작값이 없으면 none→inset 이 보간 안 돼서 툭 사라짐 */
  }
  to {
    clip-path: inset(0 0 100% 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .menu:not([hidden]) {
    animation: fade-in 120ms;
  }
  .menu.closing {
    animation: fade-out 120ms forwards;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}

/* 피그마 Frame 63 — 402×565, 세로 가운데 */
.insert {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

.title img {
  display: block;
  width: 379px;
  max-width: calc(100vw - 23px);
  height: auto;
}

.label,
.month,
.note,
.next {
  text-transform: uppercase;
  text-box: trim-both cap alphabetic;
}

.label {
  margin-top: 10px;
  font-size: 24.918px;
  letter-spacing: 1.2459px;
  animation: insert-blink 1.2s steps(1) infinite; /* 오락실 INSERT COIN 처럼 딱딱 깜빡 */
}
@keyframes insert-blink {
  70% {
    opacity: 0;
  }
}

/* 메인 화면 CRT: 04 화면과 같은 주사선·비네트·깜빡임·굴러가는 띠. 카트리지(.slots)·버튼(.bottom)은 위에 올려 영향 없음 */
.app:not([data-screen])::before,
.app:not([data-screen])::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
/* 검은 배경엔 어두운 줄이 안 보여서 → 밝은 줄 + 가운데만 살짝 켜진 화면 빛(켜진 브라운관처럼) */
.app:not([data-screen])::after {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.05) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(
      ellipse at center,
      rgba(255, 255, 255, 0.04),
      transparent 70%
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
  animation:
    crt-flicker 120ms steps(2) infinite,
    scan-crawl 400ms linear infinite;
}
/* 하단 검은 바가 줄무늬를 가려 네모로 보여서 메인에선 투명 (ponytail: 아주 작은 화면에서 스크롤되면 내용이 버튼 뒤로 비침) */
.app:not([data-screen]) .bottom {
  background: none;
}
.app:not([data-screen])::before {
  inset: -30% 0 auto;
  height: 30%;
  background: linear-gradient(
    transparent,
    rgba(255, 255, 255, 0.06) 40%,
    rgba(0, 0, 0, 0.18) 60%,
    transparent
  );
  animation: crt-roll 7s linear infinite reverse;
}

.slots {
  position: relative;
  z-index: 4; /* CRT 효과 위 */
  list-style: none;
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(4, 64.549px);
  column-gap: 8.17px;
  row-gap: 11.44px;
}

.slot {
  width: 64.549px;
  height: 81.707px;
}

.cart {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  transition: transform 160ms var(--ease-out);
}
.cart:active {
  transform: scale(0.96);
}
.cart:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

.shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.shell path {
  fill: var(--c, #383838);
  transition: fill 300ms var(--ease-out);
}

.face {
  position: absolute;
  left: 4.9px;
  top: 5.72px;
  width: 54.744px;
  height: 61.28px;
  border-radius: 5.72px;
  background: #212121;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.face img,
.face video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-in 220ms var(--ease-out);
}

.slot.filled .face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.month {
  position: relative;
  z-index: 1;
  font-size: 17.443px;
  letter-spacing: 0.8721px;
  color: #484848;
}
.slot.filled .month {
  color: rgba(255, 255, 255, 0.7);
}

/* 드래그 순서 바꾸기 */
.slot.filled .cart {
  touch-action: none;
}
.slot.lifted .cart {
  opacity: 0.35;
}
.slot.target .cart {
  transform: scale(1.06);
}
.ghost-cart {
  position: fixed;
  z-index: 10;
  width: 64.549px;
  height: 81.707px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08) rotate(-3deg);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.note {
  margin-top: 30px;
  font-size: 13.349px;
  letter-spacing: 0.6675px;
  line-height: 1.25;
  text-align: center;
  color: var(--pink);
}

/* 기기 하단 고정 — 창이 낮아도 항상 보이고, 내용이 그 아래로 스크롤된다 */
.bottom {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 25px 0; /* 아래 여백·홈 바 자리는 저작권 줄이 맡음 */
  background: #000;
}

.next {
  display: block;
  width: 100%;
  max-width: 352px;
  height: 63px;
  margin: 0 auto;
  background: #191919;
  color: #545454;
  font-size: 24.918px;
  letter-spacing: 1.2459px;
  transition:
    background-color 200ms var(--ease-out),
    color 200ms var(--ease-out),
    transform 160ms var(--ease-out);
}
.next:disabled {
  cursor: default;
}
.next:not(:disabled) {
  background: var(--pink-deep);
  color: #fff;
}
.next:not(:disabled):active {
  transform: scale(0.97);
}

/* 03 저장 중 — NEXT 누르면 업로드 화면과 교체 */
.saving {
  display: none;
}
.app[data-screen="saving"] .insert,
.app[data-screen="saving"] .bottom {
  display: none;
}
.app[data-screen="saving"] .saving {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 로고 높이만큼 아래도 비워서 화면 정중앙에 */
  padding-bottom: calc(max(env(safe-area-inset-top), 16px) + 27px);
  animation: fade-in 240ms var(--ease-out);
}

.saving-label {
  font-size: 24.918px;
  letter-spacing: 1.2459px;
  text-transform: uppercase;
  text-box: trim-both cap alphabetic;
  color: var(--pink);
}

.bar {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 20px;
  width: 317px;
  height: 48px;
  border: 4px solid var(--pink);
  padding: 4px;
}
/* 4px 칸 + 3px 틈, 칸 단위로만 차오른다. 안쪽 301px = 43칸 */
.bar-track {
  width: 100%;
  height: 100%;
}
.bar-fill {
  display: block;
  height: 100%;
  width: calc(var(--n, 0) * 7px);
  background: repeating-linear-gradient(
    90deg,
    var(--pink) 0 4px,
    transparent 4px 7px
  );
}
/* % 는 네모 바깥 아래 오른쪽 */
.bar-pct {
  position: absolute;
  right: -4px;
  top: calc(100% + 14px);
  font-family: Galmuri11, monospace;
  font-weight: 700;
  font-size: 22px;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

/* 04 게임기 — 저장이 끝나면 교체. 좌표는 template.png(2000px) 기준 % */
.result {
  display: none;
}
.app[data-screen="result"] .insert,
.app[data-screen="result"] .bottom,
.app[data-screen="result"] .saving {
  display: none;
}
.app[data-screen="result"] .result {
  flex: 1;
  display: grid;
  place-items: center;
  padding-bottom: calc(max(env(safe-area-inset-top), 16px) + 27px);
}
.app {
  overflow-x: clip;
} /* 게임기 이미지의 투명 여백이 화면 밖으로 나가도 가로 스크롤 없게 */

.stage {
  position: relative;
  width: 100%;
  translate: 0 -5vh;
} /* 작은 타이틀 빠져 위가 비어 보여서 화면 높이 5%만큼 위로 */

.device {
  width: min(459.533px, 114vw);
  /* 화면보다 넓어도 양쪽으로 똑같이 넘치게 가운데 정렬 */
  margin-left: calc(50% - min(229.767px, 57vw));
  aspect-ratio: 1;
  container-type: inline-size;
}
/* 튀어나오듯 등장: 작게 시작해 살짝 넘쳤다가 제자리 */
/* 04 진입 0.2초 뒤 타이틀+게임기가 한 덩어리로 튀어나옴 */
.app[data-screen="result"] .stage {
  animation: pop-in 380ms cubic-bezier(0.34, 1.56, 0.64, 1) 200ms both;
}
/* 자리 잡은 뒤(0.6초)부터 천천히 둥둥 */
.app[data-screen="result"] .device {
  animation: float 3.2s ease-in-out 600ms infinite alternate;
}

.device-tilt {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotate(2.23deg);
}
.body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 메인 화면 — 투명 구멍 뒤에 사진, 가장자리 틈 없게 1%씩 크게 */
.scr {
  position: absolute;
  left: 19.4%;
  top: 17.2%;
  width: 60.5%;
  height: 42.1%;
  overflow: hidden;
  background: #000;
  z-index: 0; /* 안쪽 효과 층까지 전부 게임기 이미지 뒤에 가둠 */
}
.scr img,
.scr video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* CRT 모니터 느낌: 색을 살짝 쨍하게 + 주사선·비네트·깜빡임·지나가는 밝은 띠 */
.scr img,
.scr video {
  filter: saturate(1.2) contrast(1.08) brightness(1.04);
}
.scr::before,
.scr::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.scr::after {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.28) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.08);
  /* 주사선이 위로 타고 올라감 + 아주 약한 깜빡임 */
  animation:
    crt-flicker 120ms steps(2) infinite,
    scan-crawl 400ms linear infinite;
}
.scr::before {
  inset: -30% 0 auto;
  height: 30%;
  /* 밝은 띠 + 아래 어두운 그림자가 아래에서 위로 굴러감 */
  background: linear-gradient(
    transparent,
    rgba(255, 255, 255, 0.1) 40%,
    rgba(0, 0, 0, 0.22) 60%,
    transparent
  );
  animation: crt-roll 5s linear infinite reverse;
}
@keyframes crt-flicker {
  50% {
    opacity: 0.95;
  }
}
@keyframes scan-crawl {
  to {
    background-position:
      0 -3px,
      0 0,
      0 0;
  }
}
@keyframes crt-roll {
  to {
    transform: translateY(433%);
  }
}

/* 옛날 TV 채널 돌리듯 지지직: 노이즈 + 화면 흔들림 */
.scr .noise {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  image-rendering: pixelated;
  pointer-events: none;
}
.scr.static img,
.scr.static video {
  animation: tv-jitter 300ms steps(1) both;
}
@keyframes tv-jitter {
  0% {
    transform: translateX(-1%) skewX(1deg);
    filter: brightness(1.6) saturate(0.4);
  }
  25% {
    transform: translateX(0.6%);
  }
  50% {
    transform: translateX(-0.3%);
    filter: brightness(1.3) contrast(1.4);
  }
  75% {
    filter: none;
  }
  100% {
    transform: none;
  }
}

/* 알약 서브 화면 — 월 이름이 계속 흘러감 */
.sub {
  position: absolute;
  left: 19.65%;
  top: 74.75%;
  width: 36.2%;
  height: 11.25%;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
}
.sub {
  cursor: text;
} /* 눌러서 그 달 이름 바꾸기 */
.marquee {
  position: relative;
  top: 3px; /* 알약 화면 안에서 3px 아래로 */
  display: flex;
  flex: none;
  white-space: nowrap;
  font-size: 7.31cqw;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fe49cd;
  /* 8bit 전광판처럼 칸칸이 끊겨 흐름 (steps) */
  animation: marquee var(--dur, 8s) steps(var(--steps, 64)) infinite;
}
.marquee span {
  padding-right: 0.6em;
}
.marquee.custom {
  text-transform: none;
}

.arrow {
  position: absolute;
  top: 73.5%;
  width: 11%;
  height: 13%;
  border-radius: 30%;
}
.arrow.prev {
  left: 59.85%;
}
.arrow.next-month {
  left: 71.6%;
}
.arrow:focus-visible {
  outline: 2px solid var(--pink);
}
/* 누르면 버튼 삼각형이 하얗게 한 번 깜빡. 잘라 낸 뒤에 흐리게 해야 테두리가 부드러워서 블러는 바깥(버튼)에 */
.arrow.flash {
  filter: blur(2.5px);
  mix-blend-mode: screen;
}
.arrow.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  animation: arrow-flash 200ms steps(1) forwards;
}
.arrow.prev.flash::after {
  clip-path: polygon(14% 50%, 82% 14%, 82% 86%);
}
.arrow.next-month.flash::after {
  clip-path: polygon(86% 50%, 18% 14%, 18% 86%);
}
@keyframes arrow-flash {
  0% {
    opacity: 0.75;
  }
  60%,
  100% {
    opacity: 0;
  }
}

/* 아래에서 솟아올라 살짝 넘쳤다가 제자리 */
/* 색 바꾸기: 게임기 몸체 이미지에만 hue-rotate */
.body {
  filter: hue-rotate(var(--hue, 0deg));
  transition: filter 300ms var(--ease-out);
}
/* 게임기 아래에 붙여 둠 — 패널이 열리고 접혀도 게임기는 안 움직임 */
.tools {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  /* 1줄 COLOR · BG · EFFECT / 2줄 INSERT MUSIC — 줄마다 따로 가운데 / 음악 패널 / 저장 버튼 */
  display: grid;
  justify-items: center;
  margin-top: -6px;
}
.tool-row {
  display: flex;
  gap: 8px;
} /* 버튼 좌우 여백 6px씩 더해 글자 사이 20px */
#soundBtn .off,
#soundBtn[aria-pressed="false"] .on {
  display: none;
}
#soundBtn[aria-pressed="false"] .off {
  display: inline;
}
#soundBtn[aria-pressed="false"] {
  color: #777;
}
.tools .copy {
  padding-bottom: max(env(safe-area-inset-bottom), 25px);
}
/* 저작권 표시: 01 은 NEXT 바 밖 페이지 맨 아래, 04 는 저장 버튼 아래 */
.app > .copy {
  margin-top: 19px;
  padding-bottom: max(env(safe-area-inset-bottom), 16px);
} /* NEXT 아래 → 화면 끝 50px */
.app[data-screen] > .copy {
  display: none;
} /* 03·04 에선 04 쪽 표시만 */
.copy {
  margin-top: 64px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #888;
}
.tool-btn {
  display: inline-flex;
  white-space: nowrap; /* 100px 칸보다 길어도 한 줄로, 양옆으로 고르게 넘침 */
  align-items: center;
  position: relative;
  gap: 8px;
  height: 22px;
  padding: 0 6px;
  font-size: 14px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: #fff;
  transition:
    transform 160ms var(--ease-out),
    color 160ms var(--ease-out);
}
.tool-btn::before {
  content: "";
  position: absolute;
  inset: -6px 0;
} /* 누르는 영역 34px */
.tool-btn:active {
  transform: scale(0.92);
}
.tool-btn[aria-expanded="true"] {
  color: #feb649;
} /* 열린 메뉴 표시 */
.tool-btn:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

/* 배경음악: 링크 입력칸. 닫혀도 자리 유지 */
.music {
  display: grid;
  grid-template-columns: 1fr auto auto; /* 입력칸 · PLAY · STOP, 미니 플레이어는 아래 줄 */
  gap: 6px;
  width: 300px;
  margin: 8px 0 10px;
}
/* 배경 바꾸기: CHANGE BG 누르면 무작위 배경. 지금은 하트 하나 */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
}
.app[data-bg="hearts"] .bg-fx {
  opacity: 0.6; /* 하트색 #5627a2, 투명도 60% */
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2048%2048%22%20shape-rendering%3D%22crispEdges%22%20fill%3D%22%235627a2%22%3E%3Crect%20x%3D%222%22%20y%3D%222%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%227%22%20y%3D%222%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%221%22%20y%3D%223%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%226%22%20y%3D%223%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%221%22%20y%3D%224%22%20width%3D%2210%22%20height%3D%221%22/%3E%3Crect%20x%3D%221%22%20y%3D%225%22%20width%3D%2210%22%20height%3D%221%22/%3E%3Crect%20x%3D%222%22%20y%3D%226%22%20width%3D%228%22%20height%3D%221%22/%3E%3Crect%20x%3D%223%22%20y%3D%227%22%20width%3D%226%22%20height%3D%221%22/%3E%3Crect%20x%3D%224%22%20y%3D%228%22%20width%3D%224%22%20height%3D%221%22/%3E%3Crect%20x%3D%225%22%20y%3D%229%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%2226%22%20y%3D%2226%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%2231%22%20y%3D%2226%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%2225%22%20y%3D%2227%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%2230%22%20y%3D%2227%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%2225%22%20y%3D%2228%22%20width%3D%2210%22%20height%3D%221%22/%3E%3Crect%20x%3D%2225%22%20y%3D%2229%22%20width%3D%2210%22%20height%3D%221%22/%3E%3Crect%20x%3D%2226%22%20y%3D%2230%22%20width%3D%228%22%20height%3D%221%22/%3E%3Crect%20x%3D%2227%22%20y%3D%2231%22%20width%3D%226%22%20height%3D%221%22/%3E%3Crect%20x%3D%2228%22%20y%3D%2232%22%20width%3D%224%22%20height%3D%221%22/%3E%3Crect%20x%3D%2229%22%20y%3D%2233%22%20width%3D%222%22%20height%3D%221%22/%3E%3C/svg%3E");
  background-size: 96px 96px; /* 하트 1픽셀 = 2px, 드문드문 */
  /* 8bit처럼 칸칸이 끊기며 대각선으로 흐름: 4px씩 4번/초 */
  animation: hearts-drift 6s steps(24) infinite;
}
/* 별 타일: 하트 배경의 별 버전, 파란 8bit 별이 같은 방식으로 대각선 흐름 */
.app[data-bg="star-drift"] .bg-fx {
  opacity: 0.6;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2048%2048%22%20shape-rendering%3D%22crispEdges%22%20fill%3D%22%233f6fe0%22%3E%3Crect%20x%3D%225%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%225%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%224%22%20y%3D%224%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%221%22%20y%3D%225%22%20width%3D%229%22%20height%3D%221%22/%3E%3Crect%20x%3D%222%22%20y%3D%226%22%20width%3D%227%22%20height%3D%221%22/%3E%3Crect%20x%3D%223%22%20y%3D%227%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%223%22%20y%3D%228%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%226%22%20y%3D%228%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%222%22%20y%3D%229%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%227%22%20y%3D%229%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%222%22%20y%3D%2210%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%228%22%20y%3D%2210%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%2229%22%20y%3D%2226%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%2229%22%20y%3D%2227%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%2228%22%20y%3D%2228%22%20width%3D%223%22%20height%3D%221%22/%3E%3Crect%20x%3D%2225%22%20y%3D%2229%22%20width%3D%229%22%20height%3D%221%22/%3E%3Crect%20x%3D%2226%22%20y%3D%2230%22%20width%3D%227%22%20height%3D%221%22/%3E%3Crect%20x%3D%2227%22%20y%3D%2231%22%20width%3D%225%22%20height%3D%221%22/%3E%3Crect%20x%3D%2227%22%20y%3D%2232%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%2230%22%20y%3D%2232%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%2226%22%20y%3D%2233%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%2231%22%20y%3D%2233%22%20width%3D%222%22%20height%3D%221%22/%3E%3Crect%20x%3D%2226%22%20y%3D%2234%22%20width%3D%221%22%20height%3D%221%22/%3E%3Crect%20x%3D%2232%22%20y%3D%2234%22%20width%3D%221%22%20height%3D%221%22/%3E%3C/svg%3E");
  background-size: 96px 96px;
  animation: hearts-drift 6s steps(24) infinite;
}
/* 별: LED 점으로 찍은 금빛 별이 크기 제각각 흩어져 칸칸이 떠오름 */
.app[data-bg="stars"] .bg-fx,
.app[data-bg="heart-rise"] .bg-fx {
  opacity: 1;
  overflow: hidden;
}
/* 떠오르는 하트: 별과 같은 움직임, 핑크 LED 점 하트 */
.star.heart-led {
  filter: drop-shadow(0 0 4px rgba(254, 73, 206, 0.8));
}
.star {
  position: absolute;
  bottom: 0;
  filter: drop-shadow(0 0 4px rgba(200, 168, 24, 0.8)); /* 별색 #c8a818 번짐 */
  /* 4fps 로 끊겨 올라가고, 반짝임도 딱딱하게 */
  animation:
    star-rise var(--dur) steps(var(--steps)) var(--delay) infinite,
    star-blink 1.6s steps(1) var(--delay) infinite;
}
@keyframes star-rise {
  from {
    transform: translateY(20vh);
  }
  to {
    transform: translateY(-110vh);
  }
}
/* 반짝이: 제자리에서 픽셀 프레임으로 반짝반짝 (영상 참고) */
.app[data-bg="sparkle"] .bg-fx {
  opacity: 1;
  overflow: hidden;
}
.sparkle {
  position: absolute;
  width: calc(var(--px) * 9);
  height: calc(var(--px) * 9);
  background: var(--sparkle) 0 0 / calc(var(--px) * 144) 100% no-repeat; /* 스프라이트는 main.js 에서 만듦 */
  translate: -50% -50%;
  animation: sparkle var(--dur) steps(16) var(--delay) infinite;
}
@keyframes sparkle {
  to {
    background-position-x: calc(var(--px) * -144);
  }
}
.sparkle-dots {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  opacity: 0.7;
}
@keyframes star-blink {
  50% {
    opacity: 0.55;
  }
}
@keyframes hearts-drift {
  to {
    background-position: 96px -96px;
  }
}

/* 아코디언: 닫히면 접히고, 열릴 때 살짝 내려오며 나타남 */
.music[hidden] {
  display: none;
}
.music:not([hidden]) {
  animation: panel-in 180ms var(--ease-out);
}
@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.music input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border: 2px solid #333;
  border-radius: 0;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: 16px; /* iOS 입력 시 확대 방지 */
}
.music input::placeholder {
  color: #555;
  font-size: 13px;
  letter-spacing: 0.6px;
}
.music input:focus {
  outline: none;
  border-color: var(--pink);
}
.music input[aria-invalid="true"] {
  border-color: #ff4a4a;
  animation: shake 240ms var(--ease-out);
}
.music button {
  height: 36px;
  padding: 0 10px;
  background: var(--pink-deep);
  color: #fff;
  font-size: 13px;
  text-transform: uppercase;
}
.music button:active {
  transform: scale(0.96);
}
.music #musicStop {
  background: #222;
}
.music #musicStop[hidden] {
  display: none;
}
/* 미니 플레이어: INSERT MUSIC 패널 안, 재생 중일 때만. 패널 접으면 같이 안 보이고 음악은 계속 (사용자 결정, 유튜브 약관 위반 소지 안내함) */
#ytPlayer {
  display: none;
  grid-column: 1 / -1;
  justify-self: center;
  width: 200px;
  height: 200px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
}
#musicBtn[data-playing="true"] ~ .music #ytPlayer {
  display: block;
}
/* 패널이 열려 있으면 오른쪽에 CLOSE (누르면 접힘) */
#musicBtn[aria-expanded="true"] span::after {
  content: "close";
  margin-left: 10px;
  color: #777;
}
@keyframes shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(90px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes float {
  to {
    transform: translateY(-16px);
  }
}
@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

/* 04 저장 버튼: IMG · VIDEO — 메뉴 아래 페이지 흐름 안, 흰 바탕 검은 글씨, NEXT 의 절반 크기 */
.dock {
  display: none;
}
/* 1줄 HOME · IMG SHARE(핑크), 2줄 IMG · VIDEO */
.app[data-screen="result"] .dock {
  display: grid;
  grid-template-columns: repeat(2, 100px);
  justify-content: center;
  gap: 8px;
  padding: 12px 25px 0;
}
.dock .next {
  width: 100px;
  height: 32px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  letter-spacing: 0.6px;
  background: #fff;
  color: #000;
}
.dock .next svg {
  width: 10px;
  height: 10px;
}
.dock .next:disabled {
  background: #555;
  color: #222;
}
/* 영상 만드는 중: 저장 아이콘 대신 8bit 로딩 (점 8개가 칸칸이 돈다) */
.dock .next.busy {
  color: #000;
}
.dock .next.busy svg {
  display: none;
}
.dock .next.busy::before {
  content: "";
  width: 2px;
  height: 2px;
  margin: 4px;
  box-shadow:
    0 -4px 0 #000,
    3px -3px 0 rgba(0, 0, 0, 0.85),
    4px 0 0 rgba(0, 0, 0, 0.7),
    3px 3px 0 rgba(0, 0, 0, 0.55),
    0 4px 0 rgba(0, 0, 0, 0.4),
    -3px 3px 0 rgba(0, 0, 0, 0.3),
    -4px 0 0 rgba(0, 0, 0, 0.2),
    -3px -3px 0 rgba(0, 0, 0, 0.12);
  animation: spin8 800ms steps(8) infinite;
}
@keyframes spin8 {
  to {
    transform: rotate(360deg);
  }
}

/* 사진 고른 뒤 불러오는 동안: 8bit 로딩 */
.uploading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 14px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.uploading[hidden] {
  display: none;
}
.uploading p {
  margin: 0;
}
.uploading button {
  margin-top: 6px;
  width: 84px;
  height: 32px;
  background: #fff;
  color: #000;
  font-size: 12.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.uploading .spin {
  width: 4px;
  height: 4px;
  margin: 7px;
  box-shadow:
    0 -7px 0 #fff,
    5px -5px 0 rgba(255, 255, 255, 0.85),
    7px 0 0 rgba(255, 255, 255, 0.7),
    5px 5px 0 rgba(255, 255, 255, 0.55),
    0 7px 0 rgba(255, 255, 255, 0.4),
    -5px 5px 0 rgba(255, 255, 255, 0.3),
    -7px 0 0 rgba(255, 255, 255, 0.2),
    -5px -5px 0 rgba(255, 255, 255, 0.12);
  animation: spin8 800ms steps(8) infinite;
}
/* 영상 다 만들었는데 한 번 더 눌러야 할 때: 핑크로 눈에 띄게 */
.dock .next.ready {
  background: var(--pink);
  color: #fff;
}
.dock #shareBtn {
  background: #fff41c;
  color: #000;
}
.dock #shareBtn.ready {
  background: #fff98a;
}
.dock .next:not(:disabled):active {
  transform: scale(0.97);
}

/* 변경/삭제 메뉴 */
.sheet {
  /* 하단 바 자리를 통째로 덮어 NEXT가 비치지 않게 */
  margin: auto auto 0;
  width: 100%;
  max-width: 430px;
  padding: 16px 25px max(env(safe-area-inset-bottom), 25px);
  background: #000;
  border: 0;
  color: #fff;
}
.sheet:focus {
  outline: none;
}
.sheet::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.sheet[open] {
  animation: sheet-in 240ms var(--ease-out);
}
.sheet form {
  display: grid;
  gap: 8px;
}
.sheet button {
  height: 56px;
  background: #191919;
  font-size: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sheet button[value="delete"] {
  color: var(--pink);
}
.sheet button.ghost {
  background: none;
  color: #545454;
}

/* 월 이름 입력창: 검은 바탕, 전부 가운데, 입력칸은 밑줄만 */
.edit {
  margin: auto;
  width: min(320px, calc(100vw - 32px));
  padding: 22px 20px 18px;
  background: #000;
  color: #fff;
  border: 0;
  text-align: center;
}
.edit::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.edit[open] {
  animation: sheet-in 200ms var(--ease-out);
}
.edit form {
  display: grid;
  gap: 14px;
}
.edit h2 {
  font-size: 18px;
  font-weight: normal;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--pink);
}
.edit input {
  min-width: 0; /* 아이폰 입력칸 기본 폭이 커서 팝업 밖으로 삐져나오던 것 */
  height: 40px;
  padding: 0 4px;
  border: 0;
  border-bottom: 2px solid #fff;
  border-radius: 0;
  background: none;
  text-align: center;
  color: #fff;
  font: inherit;
  font-size: 16px; /* iOS 입력 시 확대 방지 */
}
.edit input::placeholder {
  color: #555;
  font-size: 13px;
  letter-spacing: 0.6px;
}
.edit input:focus {
  outline: none;
  border-color: var(--pink);
}
.edit form > div {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.edit button {
  height: 32px;
  padding: 0 14px;
  background: var(--pink-deep);
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.edit button.ghost {
  background: #222;
  color: #aaa;
}
.edit button:active {
  transform: scale(0.96);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@media (hover: hover) {
  .cart:hover .shell path {
    filter: brightness(1.2);
  }
  .next:not(:disabled):hover {
    filter: brightness(1.1);
  }
}

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