@font-face {
  font-family: 'Paperlogy';
  src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/2408-3@1.0/Paperlogy-5Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Paperlogy';
  src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/2408-3@1.0/Paperlogy-6SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

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

html, body {
  height: 100%;
}

body {
  background: #1a1a1a;
  font-family: 'Paperlogy', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

/* ===== 데스크톱: 확정된 390x844 디자인을 그대로, 화면 중앙에 배치만 함
   (반응형을 이유로 디자인 자체를 바꾸지 않음) ===== */
.app-shell {
  display: flex;
  justify-content: center;
  align-items: center;
}

.bezel {
  width: 410px;
  height: 864px;
  border-radius: 54px;
  background: #0c0c0c;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.device {
  width: 390px;
  height: 844px;
  border-radius: 44px;
  overflow: hidden;
  position: relative;
  background: #000;
  isolation: isolate;
}

.notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 26px;
  background: #0c0c0c;
  border-radius: 16px;
  z-index: 50;
}

.screen {
  width: 100%;
  height: 100%;
  position: relative;
  background-image: url('../assets/background/bg_mobile.png');
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* 너무 작은 화면(360px 미만)에서만 최소한으로 축소 대응.
   390x844 디자인 비율은 유지한다. */
@media (max-width: 430px) {
  .bezel { width: 100vw; height: 100vh; border-radius: 0; box-shadow: none; }
  .device { width: 100%; height: 100%; border-radius: 0; }
  body { padding: 0; }
}

/* ===== 화면 상태 전환 (SCREEN A <-> SCREEN B) =====
   레이아웃/좌표는 변경하지 않고 표시 여부만 토글 */
.view {
  position: absolute;
  inset: 0;
  opacity: 1;
  visibility: visible;
}
.view[hidden] {
  display: none;
}

/* ===== 카드 스테이지 (SCREEN A의 back.png ↔ SCREEN B 결과 카드를
   같은 위치·같은 요소로 이어서 사용) =====
   top:160px 고정 / idle 60%(234x312) -> result 70%(273x364) 로 확대만 함 */
.card-stage {
  position: absolute;
  top: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: 234px;
  height: 312px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  transition: width 350ms ease, height 350ms ease, border-radius 350ms ease, box-shadow 350ms ease;
}
.card-stage.is-result-size {
  width: 273px;       /* 70% of 390 */
  height: 364px;       /* 3:4 */
  border-radius: 10px;
  box-shadow: none;
}
/* 공유 결과 URL로 접속 시 확대 트랜지션 없이 즉시 결과 크기로 표시하기 위한 예외 처리 */
.card-stage.no-transition {
  transition: none !important;
}

.card-visual {
  position: absolute;
  inset: 0;
}

.card-back,
.card-char {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-back.is-hidden,
.card-char.is-hidden {
  display: none;
}

.card-frame {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: contain;
  pointer-events: none;
  display: none; /* opacity가 아니라 실제로 렌더링에서 제거 */
}
.card-frame.is-visible {
  display: block;
}

/* ---- GLITCH: 카드 영역 내부에서만, NORMAL<->ALT 전환 순간에만 재생 ---- */
.card-visual.is-glitching {
  animation: cardGlitchJitter var(--glitch-ms, 220ms) steps(6, end);
}
@keyframes cardGlitchJitter {
  0%   { transform: translateX(0);    filter: brightness(1)   saturate(1); }
  15%  { transform: translateX(-3px); filter: brightness(1.35) saturate(1.5); }
  30%  { transform: translateX(3px);  filter: brightness(0.7); }
  45%  { transform: translateX(-2px); filter: brightness(1.2); }
  60%  { transform: translateX(2px);  filter: brightness(0.8); }
  75%  { transform: translateX(-1px); filter: brightness(1.1); }
  100% { transform: translateX(0);    filter: brightness(1)   saturate(1); }
}

.glitch-bands {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.glitch-bands::before,
.glitch-bands::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 7%;
  mix-blend-mode: screen;
}
.glitch-bands::before {
  top: 22%;
  background: rgba(255, 0, 140, 0.55);
  transform: translateX(-6%);
}
.glitch-bands::after {
  top: 58%;
  background: rgba(0, 220, 255, 0.5);
  transform: translateX(6%);
}
.glitch-bands.is-active {
  animation: glitchBandsFlicker var(--glitch-ms, 220ms) steps(4, end);
}
@keyframes glitchBandsFlicker {
  0%   { opacity: 0; }
  20%  { opacity: 0.9; }
  45%  { opacity: 0.25; }
  70%  { opacity: 0.85; }
  100% { opacity: 0; }
}

.sub-copy {
  position: absolute;
  top: 490px;
  left: 0;
  right: 0;
  color: #ffffff;
  font-family: 'Paperlogy', sans-serif;
  font-weight: 500;
  font-size: 16px;
  text-align: center;
}
.sub-copy.is-hidden { display: none; }

.main-btn {
  position: absolute;
  top: 608px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  max-width: 420px;
  height: 52px;
  background: #E85097;
  color: #ffffff;
  font-family: 'Paperlogy', sans-serif;
  font-weight: 600;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.main-btn.is-hidden { display: none; }

/* ===== 버튼 터치 인터랙션(공통) — 가벼운 밝기 변화 + scale(0.98) ===== */
.main-btn.is-pressed {
  filter: brightness(0.94);
  transform: translateX(-50%) scale(0.98);
}

.main-btn[disabled] {
  pointer-events: none;
  opacity: 0.75;
}


.quote {
  position: absolute;
  top: 548px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  max-width: 420px;
  color: #ffffff;
  font-family: 'Paperlogy', sans-serif;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.45;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.btn-group {
  position: absolute;
  top: 612px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  opacity: 0;
  pointer-events: none;
}

.result-ui-in {
  animation: uiFadeIn var(--ui-fade-ms, 350ms) ease-out forwards;
}
@keyframes uiFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.btn-group.result-ui-in {
  pointer-events: auto;
}

.btn-row {
  display: flex;
  gap: 11px;
}

.btn-secondary {
  flex: 1;
  height: 48px;
  background: rgba(38, 18, 46, 0.55);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  color: #ffffff;
  font-family: 'Paperlogy', sans-serif;
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.btn-secondary.is-pressed {
  filter: brightness(0.9);
  transform: scale(0.98);
}

.btn-secondary svg { width: 16px; height: 16px; }

.btn-primary {
  width: 100%;
  height: 52px;
  background: #E85097;
  color: #ffffff;
  font-family: 'Paperlogy', sans-serif;
  font-weight: 600;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.btn-primary.is-pressed {
  filter: brightness(0.94);
  transform: scale(0.98);
}

/* ===== 저장/공유 피드백 토스트 (하단 작품명 영역을 침범하지 않는 선에서) ===== */
.toast {
  position: absolute;
  left: 50%;
  top: 108px;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(20, 10, 24, 0.92);
  color: #fff;
  font-size: 12.5px;
  font-family: 'Paperlogy', sans-serif;
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  max-width: 85%;
  text-align: center;
}
.toast.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 접근성: reduced motion 존중 */
@media (prefers-reduced-motion: reduce) {
  .card-visual, .card-stage, .glitch-bands, .quote, .btn-group {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
