@font-face {
  font-family: 'BAEMINWORK';
  src: url('../assets/shared/BAEMINWORK.otf') format('opentype');
}
@font-face {
  font-family: 'ACinema';
  src: url('../assets/a-normal/a-cinema-M.ttf') format('truetype');
  font-display: swap;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100dvh; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', sans-serif;
  background: #0cefd3;
  color: #303030;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  display: flex; align-items: center; justify-content: center;
}
#app-wrapper {
  width: min(100dvw, 430px); height: min(100dvh, 932px);
  position: relative;
  overflow: hidden;
  background: #0cefd3;
}

/* 공통 */
.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; flex-direction: column; align-items: center; }
.screen.active { display: flex; }

/* LOBBY */
#lobby {
  background: #0cefd3;
  padding: clamp(50px, 10vh, 83px) clamp(20px, 11.5vw, 45px) min(40px, 5vh);
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
}
#lobby h1 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: pre-line;
  margin-bottom: clamp(30px, 5vh, 50px);
  flex-shrink: 0;
}
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, min(140px, 36vw));
  grid-template-rows: repeat(3, min(156px, 18vh));
  gap: clamp(12px, 2.4vh, 20px) clamp(12px, 5vw, 20px);
  justify-content: center;
  align-content: start;
  flex-shrink: 0;
}
.team-item {
  display: flex; flex-direction: column; align-items: center;
  transition: opacity 0.3s;
  width: 100%; height: 100%;
}
.team-item.dimmed { opacity: 0.2; pointer-events: none; }
.team-item.selected { z-index: 10; }
.team-card {
  background: linear-gradient(162deg, #fff 75%, rgba(255,255,255,0.4) 100%);
  border-radius: 10px;
  width: 100%; height: 100%;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 4px 6px rgba(0, 187, 171, 0.35);
}
.team-card:active { transform: scale(0.96); }
.team-card img {
  width: 65%; height: auto; object-fit: contain;
}
.team-card .card-name {
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: clamp(14px, 4.6vw, 18px); font-weight: 700; color: #1b1b1b;
  margin-top: 12px;
  letter-spacing: -0.4px;
}
.team-item .select-gif { display: none; }
#floating-gif { display: none; }
#lobby-status { margin-top: 15px; color: #888; font-size: 13px; display: none; }

/* 팀 선택 완료 오버레이 */
#select-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: none; flex-direction: column; align-items: center;
  justify-content: flex-start; padding-top: clamp(60px, 12.6vh, 106px);
  z-index: 50;
}
#select-overlay.visible { display: flex; }
#select-overlay .select-title {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  color: #171717;
  text-align: center;
  margin-bottom: 0;
  margin-top: 0;
  line-height: 140%;
  letter-spacing: -0.6px;
}
#select-overlay .select-card {
  background: #fff;
  border-radius: 10px;
  width: clamp(160px, 50vw, 194px); height: auto; aspect-ratio: 194 / 229;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(78, 185, 176, 0.5);
  margin-top: clamp(80px, 17vh, 141px);
  animation: card-spin 1.2s ease-out;
}
@keyframes card-spin {
  0% { transform: scaleX(1); }
  5% { transform: scaleX(0); }
  10% { transform: scaleX(1); }
  15% { transform: scaleX(0); }
  20% { transform: scaleX(1); }
  25% { transform: scaleX(0); }
  30% { transform: scaleX(1); }
  35% { transform: scaleX(0); }
  40% { transform: scaleX(1); }
  45% { transform: scaleX(0); }
  50% { transform: scaleX(1); }
  56% { transform: scaleX(0); }
  62% { transform: scaleX(1); }
  70% { transform: scaleX(0); }
  78% { transform: scaleX(1); }
  88% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}
#select-overlay .select-card img {
  width: 90%; height: auto; object-fit: contain; margin-bottom: 8px; margin-top: -14px;
  opacity: 0; animation: content-reveal 0.3s ease forwards 1.1s;
}
#select-overlay .select-card .select-name {
  font-family: 'Pretendard', sans-serif;
  font-size: clamp(18px, 6.2vw, 24px); font-weight: 700; color: #1b1b1b;
  letter-spacing: -0.4px;
  opacity: 0; animation: content-reveal 0.3s ease forwards 1.1s;
}
@keyframes content-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* WAITING */
#waiting {
  background: transparent;
  justify-content: flex-start;
  padding-top: clamp(50px, 10vh, 83px);
  padding-bottom: clamp(60px, 16vh, 137px);
  align-items: center;
}
#waiting h1 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  margin-bottom: 0;
  white-space: pre-line;
  opacity: 0; animation: fade-in 1.5s ease forwards;
}
.waiting-my-team {
  display: flex; align-items: center; gap: 5px;
  margin-top: clamp(20px, 4.3vh, 36px);
  margin-bottom: clamp(16px, 3vh, 24px);
  opacity: 0; animation: fade-in 1.5s ease forwards;
}
.waiting-my-team img {
  width: clamp(40px, 13vw, 58px); height: auto; object-fit: contain;
}
.waiting-my-team img[src=""] {
  display: none;
}
.waiting-my-team span {
  font-family: 'Pretendard', sans-serif;
  font-size: clamp(18px, 6.2vw, 24px); font-weight: 700; color: #1b1b1b;
  letter-spacing: -0.4px;
}
.waiting-reselect-btn {
  margin-top: 56px;
  display: flex; align-items: center; gap: 4px;
  font-family: 'Pretendard', sans-serif;
  font-size: clamp(16px, 5.1vw, 20px); font-weight: 700; color: #1b1b1b;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: -0.4px;
  opacity: 0; animation: fade-in 1.5s ease forwards;
}
.waiting-reselect-btn:active {
  opacity: 0.6;
}
.waiting-loading-img {
  width: clamp(120px, 47vw, 184px); height: auto; max-height: 36vh;
  object-fit: contain; flex-shrink: 0;
  margin-top: clamp(30px, 6.3vh, 53px);
  opacity: 0; animation: float 2.5s ease-in-out infinite, fade-in 1.5s ease forwards;
}
.waiting-shadow {
  width: clamp(80px, 28vw, 109px); height: clamp(12px, 2.4vh, 20px);
  background: radial-gradient(ellipse, rgba(0,0,0,0.15) 0%, transparent 70%);
  border-radius: 50%;
  margin-top: 10px;
  flex-shrink: 0;
  opacity: 0; animation: shadow-pulse 2.5s ease-in-out infinite, fade-in 1.5s ease forwards;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shadow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(0.8); opacity: 0.5; }
}

/* PHASE1_INTRO: 1막 게임 설명 */
#phase1-intro { background: #282828; justify-content: flex-start; padding-top: clamp(60px, 12.6vh, 106px); align-items: center; overflow: hidden; }
#phase1-intro h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  color: #fff;
  text-align: center;
  margin-top: 0;
  margin-bottom: clamp(20px, 3vh, 32px);
  letter-spacing: -0.6px;
}
.intro-box {
  background: #1d1d1d;
  border-radius: 10px;
  padding: clamp(18px, 3vh, 25px) 15px;
  width: clamp(240px, 77vw, 300px);
  text-align: center;
  margin-top: clamp(16px, 3vh, 25px);
  flex: 1;
  display: flex; flex-direction: column; justify-content: flex-start;
  max-height: clamp(380px, 60vh, 508px);
  overflow: hidden;
  position: relative;
}
.intro-box .intro-subtitle {
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: clamp(16px, 5.1vw, 20px);
  font-weight: 800;
  color: #0cefd3;
  letter-spacing: -0.4px;
  margin-bottom: clamp(12px, 2vh, 20px);
}
.intro-box p {
  color: #fff;
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: clamp(13px, 4.1vw, 16px);
  font-weight: 500;
  line-height: 178%;
  letter-spacing: -0.4px;
  margin-bottom: clamp(16px, 2.5vh, 24px);
}
.intro-hint-text {
  color: #fff;
  transition: color 0.3s ease;
}
.intro-hint-text.highlight-green { color: #3DDD7F; }
.intro-hint-text.highlight-red { color: #FF5151; }
.intro-arrows {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 0 10px; margin-top: 44px; margin-bottom: 8px;
  height: 50px;
}
.intro-arrow {
  width: 80px; height: auto; opacity: 0;
  transition: opacity 0.3s ease;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}
.intro-arrow.active { opacity: 1; }
.intro-arrow-left.active { animation: nudge-left 0.75s ease-in-out infinite; }
.intro-arrow-right.active { animation: nudge-right 0.75s ease-in-out infinite; }
.intro-demo {
  position: absolute;
  bottom: 0; left: 0; width: 100%;
  height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  overflow: hidden;
}
.intro-demo .demo-item {
  position: absolute;
  object-fit: contain;
}
.intro-demo .demo-p1 { width: clamp(100px, 36vw, 140px); height: clamp(100px, 36vw, 140px); top: -156px; left: 50%; transform: translateX(-50%); transition: top 0.7s ease; opacity: 1; }
.intro-demo .demo-p3 { width: clamp(100px, 36vw, 140px); height: clamp(100px, 36vw, 140px); top: -156px; left: 50%; transform: translateX(-50%); transition: top 0.7s ease; opacity: 1; }
.intro-demo.tight-items .demo-p1,
.intro-demo.tight-items .demo-p3 {
  width: clamp(64px, 23vw, 90px);
  height: clamp(64px, 23vw, 90px);
}
.intro-demo .demo-hand { width: clamp(80px, 30vw, 118px); height: clamp(80px, 30vw, 118px); bottom: 10px; left: 50%; transform: translateX(-50%); transition: transform 0.5s ease; z-index: 5; }
.demo-p1.fall { top: 55%; transform: translateX(-50%) translateY(-50%); }
.demo-p3.fall { top: 55%; transform: translateX(-50%) translateY(-50%); }
.demo-hand.swipe-right { transform: translateX(calc(-50% + 50px)); }
.demo-hand.swipe-left { transform: translateX(calc(-50% - 50px)); }
.demo-item.fly-right { transform: translateX(calc(-50% + 100vw)) !important; opacity: 0; transition: transform 1s ease, opacity 0.6s ease 0.4s; }
.demo-item.fly-left { transform: translateX(calc(-50% - 100vw)) !important; opacity: 0; transition: transform 1s ease, opacity 0.6s ease 0.4s; }

#phase1 { background: #000; padding: 0; padding-top: env(safe-area-inset-top); align-items: center; justify-content: flex-start; position: relative; overflow: hidden; }
.phase1-conveyor-bg {
  position: absolute; top: 0; left: 50%;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 62%;
  transform: translate(-50%, -165px) scale(1.874);
  transform-origin: center 68%;
  z-index: 0;
  opacity: 1;
}
.phase1-iris {
  position: absolute;
  inset: -56px;
  z-index: 12;
  background: #000;
  pointer-events: none;
  overflow: hidden;
  filter: blur(48px);
}
.phase1-iris.open {
  background: transparent;
  animation: phase1-iris-fade 1s linear forwards;
}
.phase1-iris-hole {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 200vmax #000;
  transform: translate(-50%, -50%);
}
.phase1-iris.open .phase1-iris-hole {
  animation: phase1-iris-grow 1s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
@keyframes phase1-iris-grow {
  0%   { width: 0; height: 0; }
  100% { width: 160vmax; height: 160vmax; }
}
@keyframes phase1-iris-fade {
  0%, 85% { opacity: 1; }
  100%    { opacity: 0; }
}
.phase1-caption-stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  top: auto;
  transform: none;
  z-index: 10;
  pointer-events: none;
  height: 40px;
  overflow: visible;
}
.phase1-caption {
  position: absolute;
  left: 50%;
  top: 0;
  margin: 0;
  transform: translate(-50%, 36px);
  font-family: 'ACinema', sans-serif;
  font-size: 28px;
  line-height: 1.3;
  color: #171717;
  letter-spacing: -0.3px;
  white-space: nowrap;
  text-align: center;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow:
    -2px -2px 0 #fff,
     2px -2px 0 #fff,
    -2px  2px 0 #fff,
     2px  2px 0 #fff;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.phase1-caption.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.phase1-caption.out {
  opacity: 0;
  transform: translate(-50%, -36px);
}
.phase1-caption.fade {
  opacity: 0;
  transform: translate(-50%, 0);
}
.phase1-hak-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.phase1-hak {
  position: absolute;
  left: 50%;
  top: -280px;
  width: 100%;
  height: auto;
  --hak-x: 0px;
  transform: translateX(calc(-50% + var(--hak-x)));
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.phase1-hak.enter {
  opacity: 1;
  animation: hak-walk 5s linear forwards;
}
/* 겨울 학-front: 66%는 과대. 50%(작다)와 66%(크다) 사이.
   김 크롭 보정은 걷기 transform(--hak-x)로 유지. */
.phase1-hak.tight-front {
  width: 54%;
  --hak-x: -20px;
}
.phase1-hak.at-bottom {
  top: 528px;
  opacity: 1;
  animation: none;
  transform: translateX(calc(-50% + var(--hak-x)));
}
@keyframes hak-walk {
  0%   { top: -280px; transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  2.5% { top: -280px; transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  4.5% { top: -199px; transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  10%  { top: -199px; transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  12.5%{ top: -199px; transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  14.5%{ top: -118px; transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  20%  { top: -118px; transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  22.5%{ top: -118px; transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  24.5%{ top: -38px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  30%  { top: -38px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  32.5%{ top: -38px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  34.5%{ top: 43px;   transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  40%  { top: 43px;   transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  42.5%{ top: 43px;   transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  44.5%{ top: 124px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  50%  { top: 124px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  52.5%{ top: 124px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  54.5%{ top: 205px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  60%  { top: 205px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  62.5%{ top: 205px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  64.5%{ top: 286px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  70%  { top: 286px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  72.5%{ top: 286px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  74.5%{ top: 366px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  80%  { top: 366px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  82.5%{ top: 366px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  84.5%{ top: 447px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  90%  { top: 447px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  92.5%{ top: 447px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(-1.6px); }
  94.5%{ top: 528px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
  100% { top: 528px;  transform: translateX(calc(-50% + var(--hak-x))) translateY(0); }
}
#phase1-scale-wrapper {
  width: 390px; height: 844px;
  position: relative;
  transform-origin: top center;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 1;
}
.direction-hint {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: none; align-items: center; justify-content: space-between;
  padding: 0 15px;
  z-index: 30; pointer-events: none;
}
.direction-hint.visible { display: flex; }
.direction-hint .hint-left {
  width: 80px; height: auto;
  animation: hint-left-motion 0.5s ease-in-out 3;
}
.direction-hint .hint-right {
  width: 80px; height: auto;
  animation: hint-right-motion 0.5s ease-in-out 3;
}
@keyframes hint-left-motion {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(-15px); opacity: 0.7; }
}
@keyframes hint-right-motion {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(15px); opacity: 0.7; }
}
.phase1-header {
  position: absolute; top: 50px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 20px; z-index: 20;
  pointer-events: none;
}
.score-group {
  display: flex; flex-direction: column; align-items: flex-end;
}
/* 원형 타이머 — 68×68, stroke 5px */
.timer-ring {
  position: relative; width: 68px; height: 68px;
  box-sizing: border-box;
  border: 5px solid #171717;
  border-radius: 50%;
  background: #fff;
}
.timer-ring svg { display: none; }
.timer-ring .timer-num {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Pretendard', sans-serif;
  font-size: 30px; font-weight: 700; color: #171717;
  letter-spacing: -0.4px; line-height: 1;
}
.timer-ring.urgent {
  border-color: #ff4a4a;
  animation: timer-ring-shake 0.3s ease-in-out infinite;
}
.timer-ring .timer-num.urgent { color: #ff4a4a; }
@keyframes timer-ring-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-3px) rotate(-4deg); }
  40% { transform: translateX(3px) rotate(4deg); }
  60% { transform: translateX(-2px) rotate(-3deg); }
  80% { transform: translateX(2px) rotate(3deg); }
}
/* 점수 (우상단, BAEMIN WORK 우측정렬) */
.game-score {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 54px; font-weight: 900;
  color: #171717;
  text-align: right;
  letter-spacing: -1.08px;
  line-height: 1;
  transition: transform 0.1s;
}
.game-score.penalty {
  color: #ff4a4a;
  animation: score-bump 0.4s ease;
}
.combo-text {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 17px; font-weight: 900;
  color: #0cefd3 !important;
  letter-spacing: -0.3px;
  min-height: 20px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.combo-text.active {
  opacity: 1;
  transform: scale(1);
}
.combo-text.pop {
  animation: combo-pop 0.3s ease;
}
@keyframes combo-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@keyframes score-bump {
  0% { transform: scale(1); }
  15% { transform: scale(1.4); }
  30% { transform: scale(0.85); }
  45% { transform: scale(1.2); }
  60% { transform: scale(0.9); }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.timer { display: none; }
.timer.urgent { display: none; }
.gauge-bar { display: none; }
.gauge-fill { display: none; }

.ingredients-track {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 72%; height: 100%;
  overflow: visible;
  z-index: 2;
}
.ingredient-item {
  width: 65%; height: auto; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
  position: absolute;
  left: 50%; transform: translateX(-50%);
  transition: none;
}
.ingredients-track.tight-items .ingredient-item { width: 42%; }
.ingredient-item img { width: 100%; height: 100%; object-fit: contain; }
.ingredient-item.swiped-left { transform: translateX(-150%) rotate(-20deg) !important; opacity: 0; transition: transform 0.4s ease, opacity 0.4s ease; }
.ingredient-item.swiped-right { transform: translateX(100%) rotate(20deg) !important; opacity: 0; transition: transform 0.4s ease, opacity 0.4s ease; }

.phase1-buttons { display: none; }

/* 방향 힌트 (카운트다운 후, 게임 시작 전) */
.direction-hint {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(30px, 10vw, 44px);
  z-index: 15; pointer-events: none;
  opacity: 0;
}
.direction-hint.visible { opacity: 1; transition: opacity 0.3s ease; }
.direction-hint.fade-out { opacity: 0; transition: opacity 0.4s ease; }
.direction-hint img {
  width: clamp(80px, 28vw, 109px); height: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.direction-hint .arrow-left {
  animation: nudge-left 0.5s ease-in-out infinite;
}
.direction-hint .arrow-right {
  animation: nudge-right 0.5s ease-in-out infinite;
}
@keyframes nudge-left {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-12px); }
}
@keyframes nudge-right {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(12px); }
}

/* 글로벌 오버레이 (body 직하위, 뷰포트 전체) */
.global-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
.global-overlay.visible { opacity: 1; pointer-events: auto; }
.global-overlay.hidden { display: none; }
.global-overlay-text {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(60px, 19vw, 80px);
  color: #fff;
}
.global-overlay .timeover-text {
  font-size: clamp(30px, 10vw, 48px);
}
#timeover-overlay { flex-direction: column; gap: 8px; }
.timeover-score {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(40px, 13vw, 54px); font-weight: 900;
  color: #0cefd3;
}
.timeover-score .timeover-score-unit {
  font-size: 0.5em;
  color: #fff;
  vertical-align: 0.25em;
  margin-left: 0.15em;
}
.global-overlay .p4-timeover-text {
  font-size: clamp(30px, 10vw, 48px);
}
.global-overlay .countdown-num {
  animation: countdown-pop 1s ease infinite;
}
.global-overlay .p4-cd-num {
  animation: countdown-pop 1s ease infinite;
}

/* PHASE1_WAITING: 1막 대기 (별도 screen) */
#phase1-waiting {
  background: transparent;
  justify-content: flex-start;
  padding-top: clamp(50px, 10vh, 83px);
  align-items: center;
}
#phase1-waiting h1 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: pre-line;
  margin-bottom: clamp(24px, 5vh, 48px);
}
#phase1-waiting .waiting-loading-img {
  width: clamp(120px, 47vw, 184px); object-fit: contain;
  margin-top: clamp(30px, 6vh, 60px);
  opacity: 1;
  animation: float 2.5s ease-in-out infinite;
}
#phase1-waiting .waiting-shadow {
  width: clamp(80px, 28vw, 109px); height: clamp(12px, 2.4vh, 20px);
  background: radial-gradient(ellipse, rgba(0,0,0,0.15) 0%, transparent 70%);
  border-radius: 50%;
  margin-top: 10px;
  animation: shadow-pulse 2.5s ease-in-out infinite;
}

/* PHASE4_WAITING: 3막 대기 (성공/실패) */
#phase4-waiting {
  background: transparent;
  justify-content: flex-start;
  padding-top: clamp(60px, 12.6vh, 106px);
  align-items: center;
}
#phase4-waiting h1 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: pre-line;
  margin-bottom: 0;
}
.p4-waiting-pizza-wrap {
  width: 240px; height: 240px;
  margin-top: clamp(70px, 15vh, 120px);
  display: flex; align-items: center; justify-content: center;
}
.p4-waiting-pizza {
  width: 100%; height: 100%; object-fit: contain;
  animation: pizza-spin-then-float 3.5s ease forwards;
}
@keyframes pizza-spin-then-float {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(1800deg); }
  60% { transform: rotate(1800deg) translateY(0); }
  73% { transform: rotate(1800deg) translateY(-15px); }
  86% { transform: rotate(1800deg) translateY(0); }
  93% { transform: rotate(1800deg) translateY(-8px); }
  100% { transform: rotate(1800deg) translateY(0); }
}
.p4-waiting-pizza.floating {
  animation: pizza-float 2s ease-in-out infinite;
}
@keyframes pizza-float {
  0%, 100% { transform: rotate(1800deg) translateY(0); }
  50% { transform: rotate(1800deg) translateY(-15px); }
}

@keyframes countdown-pop {
  0% { transform: scale(1.3); opacity: 0; }
  15% { transform: scale(1); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  85% { transform: scale(0.95) rotate(-2deg); }
  90% { transform: scale(1.02) rotate(1deg); }
  95% { transform: scale(0.98) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); opacity: 0.8; }
}

/* PHASE1_RESULT: 1막 결과 */
#phase1-result { background: transparent; justify-content: flex-start; padding-top: clamp(60px, 12.6vh, 106px); align-items: center; }
#phase1-result h2, #phase1-result-personal h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px); color: #171717;
  letter-spacing: -0.6px;
  margin-top: 0; margin-bottom: clamp(12px, 2vh, 25px); text-align: center;
}
#phase1-result-personal { background: transparent; justify-content: flex-start; align-items: center; padding-top: 0; }
.winner-card-view {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; height: 100%;
  justify-content: flex-start;
  padding-top: clamp(50px, 10vh, 83px);
}
.winner-title {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px); font-weight: 900; color: #171717;
  text-align: center; line-height: 140%; letter-spacing: -0.6px;
  margin: 0 0 clamp(48px, 8vh, 70px) 0;
}
.winner-card {
  width: 220px; height: 280px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(78, 185, 176, 0.5);
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
.winner-card-gradient {
  position: absolute; top: 0; left: 0; width: 100%; height: 45%;
  border-radius: 10px 10px 0 0;
}
.winner-card-icon {
  width: 90%; height: auto; object-fit: contain;
  margin-top: 20px;
  position: relative; z-index: 1;
}
.winner-card-info {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px;
  margin-top: auto; margin-bottom: 24px;
  position: relative; z-index: 1;
}
.winner-card-nick {
  font-family: 'Pretendard', sans-serif;
  font-size: 24px; font-weight: 700; color: #1B1B1B;
  line-height: 140%; letter-spacing: -0.4px;
  text-align: center;
}
.winner-card-score {
  display: flex; align-items: baseline; gap: 3.4px;
}
.winner-card-score-num {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 32px; font-weight: 900; color: #171717;
  line-height: 140%; letter-spacing: -0.714px;
}
.winner-card-score-unit {
  font-family: 'Pretendard', sans-serif;
  font-size: 24px; font-weight: 700; color: #171717;
  line-height: 140%;
  position: relative; top: -3px;
}
.winner-capture {
  font-family: 'Pretendard', sans-serif;
  font-size: 18px; font-weight: 600; color: #171717;
  line-height: 140%;
  margin-top: clamp(24px, 4vh, 40px);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: #1B1B1B;
  text-decoration-thickness: 1.5px;
}
.winner-list-view {
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
  padding-top: clamp(60px, 12.6vh, 106px);
}
.rank-list { display: flex; flex-direction: column; gap: clamp(6px, 1vh, 9px); width: clamp(260px, 77vw, 300px); margin-top: clamp(16px, 3vh, 32px); }
.rank-row {
  width: 100%; height: clamp(60px, 9vh, 77px); border-radius: 10px;
  background: linear-gradient(176deg, #fff 75%, rgba(255,255,255,0.4) 100%);
  display: flex; align-items: center; position: relative; overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,187,171,0.35);
  opacity: 0; transform: translateY(20px);
  animation: rank-reveal 0.5s ease forwards;
}
.rank-row:nth-child(1) { animation-delay: 0.3s; }
.rank-row:nth-child(2) { animation-delay: 0.6s; }
.rank-row:nth-child(3) { animation-delay: 0.9s; }
.rank-row:nth-child(4) { animation-delay: 1.2s; }
.rank-row:nth-child(5) { animation-delay: 1.5s; }
.rank-row:nth-child(6) { animation-delay: 1.8s; }
@keyframes rank-reveal {
  to { opacity: 1; transform: translateY(0); }
}
.rank-row .rank-badge {
  width: 21px; height: 21px; border-radius: 50%;
  background: #0cefd3;
  display: flex; align-items: center; justify-content: center;
  margin-left: 14px; flex-shrink: 0;
  position: relative; z-index: 3;
}
.rank-row .rank-badge.rank-low { background: #b0b0b0; }
.rank-row .rank-badge span {
  font-family: 'Pretendard', -apple-system, sans-serif; font-size: 14px; font-weight: 700;
  color: #171717; line-height: 1;
}
.rank-row .rank-name {
  font-family: 'Pretendard', sans-serif; font-size: 19px; font-weight: 700;
  color: #303030; margin-left: 10px; flex-shrink: 0;
  position: relative; z-index: 3;
}
/* 개인 1등 전용 카드 레이아웃 */
.rank-row-personal {
  flex-wrap: wrap; align-content: center; padding: 8px 14px; padding-right: 70px;
}
.rank-row-personal .rank-personal-content {
  display: flex; flex-direction: column; margin-left: 10px; flex: 1; min-width: 0;
}
.rank-row-personal .rank-personal-nick {
  font-family: 'BAEMINWORK', sans-serif; font-size: clamp(11px, 3.2vw, 14px); font-weight: 900;
  color: #171717; line-height: 1.3; word-break: keep-all;
}
.rank-row-personal .rank-personal-score {
  font-family: 'BAEMINWORK', sans-serif; font-size: 18px; font-weight: 900;
  color: #171717; margin-top: 2px;
}
.rank-row .rank-score-group {
  display: flex; align-items: center; margin-left: 7px;
  white-space: nowrap; flex-shrink: 0; z-index: 3;
}
.rank-row .rank-score {
  font-family: 'BAEMINWORK', sans-serif; font-size: 20px; font-weight: 900;
  color: #171717;
  position: relative; top: -1px;
}
.rank-row .rank-unit {
  font-family: 'Pretendard', sans-serif; font-size: 16px; font-weight: 800;
  color: #171717; margin-left: 3px;
  position: relative; top: 0px;
}
.rank-row .rank-gradient {
  position: absolute; right: 0; top: 0; width: 40%; height: 100%;
  border-radius: 0 10px 10px 0;
  z-index: 1;
}
.rank-row .rank-icon {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: clamp(55px, 10vh, 77px); height: clamp(55px, 10vh, 77px); object-fit: contain; z-index: 2;
}

/* PHASE2: 2막 합체 연출 (대기화면) */
#phase2 { background: transparent; justify-content: center; align-items: center; gap: clamp(16px, 4vh, 32px); padding-bottom: 18vh; }
#phase2 h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: pre-line;
  margin: 0;
}
#phase2 .phase2-arrow {
  width: 47px; height: 69px;
  animation: arrow-poke-up 2.5s ease-in-out infinite;
}
@keyframes arrow-poke-up {
  0% { transform: translateY(0); }
  8% { transform: translateY(-10px); }
  16% { transform: translateY(0); }
  24% { transform: translateY(-10px); }
  32% { transform: translateY(0); }
  100% { transform: translateY(0); }
}

/* PHASE3_INTRO: 3막 게임 설명 */
#phase3-intro { background: #282828; justify-content: flex-start; padding-top: clamp(60px, 12.6vh, 106px); align-items: center; }
#phase3-intro h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  color: #fff;
  text-align: center;
  margin-top: 0;
  margin-bottom: clamp(20px, 3vh, 32px);
  letter-spacing: -0.6px;
}
.intro-box-p3 {
  background: #1d1d1d;
  border-radius: 10px;
  padding: clamp(18px, 3vh, 25px) 15px;
  width: clamp(240px, 77vw, 300px);
  text-align: center;
  margin-top: clamp(16px, 3vh, 25px);
  flex: 1;
  max-height: clamp(440px, 65vh, 508px);
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start;
  gap: clamp(12px, 2vh, 16px);
  overflow: hidden;
}
.intro-box-p3 .p3-subtitle {
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: clamp(16px, 5.1vw, 20px); font-weight: 800; color: #0cefd3;
  margin-bottom: 0;
  letter-spacing: -0.4px;
}
.intro-box-p3 p {
  color: #fff;
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: clamp(13px, 4.1vw, 16px);
  font-weight: 500;
  line-height: 178%;
  margin-bottom: 0;
  letter-spacing: -0.4px;
}
.intro-demo-p3 {
  margin-top: clamp(20px, 4vh, 40px);
  align-self: center;
  width: clamp(150px, 45vw, 185px);
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 2vw, 12px);
  position: relative;
  margin-bottom: clamp(15px, 3vh, 30px);
}
.intro-demo-p3 .demo-cell {
  width: 100%; aspect-ratio: 1; border-radius: 50%;
  overflow: hidden;
}
.intro-demo-p3 .demo-cell img {
  width: 100%; height: 100%; object-fit: cover;
}
.intro-demo-p3 .demo-hand-p3 {
  width: clamp(70px, 22vw, 100px); height: clamp(70px, 22vw, 100px); object-fit: contain;
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: left 0.3s ease, top 0.3s ease, opacity 0.2s ease;
}
@keyframes hand-tap {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  40% { transform: translateX(-50%) translateY(-15px); }
  55% { transform: translateX(-50%) translateY(0); }
  60% { transform: translateX(-50%) translateY(0); }
}
@keyframes pizza-press {
  0%, 100% { transform: scale(1); }
  55% { transform: scale(0.93); }
  65% { transform: scale(1.02); }
  75% { transform: scale(0.98); }
  85% { transform: scale(1); }
}

/* PHASE3_GAME: 3막 미니게임 */
#phase3-game { background: #282828; padding: 15px; justify-content: flex-start; padding-top: 127px; align-items: center; position: relative; }
.p3-timer-header {
  position: absolute; top: 15px; left: 0; right: 0;
  display: flex; justify-content: center; align-items: center;
  padding: 0 15px; z-index: 20;
}
.p3-timer {
  font-size: 21px; font-weight: bold; font-variant-numeric: tabular-nums;
  color: #303030; background: #fff; padding: 7px 10px;
  border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.p3-timer.urgent { color: #E63946; animation: timer-shake 0.3s infinite; }
#phase3-game h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 28px;
  line-height: 142%;
  letter-spacing: -1px;
  color: #fff;
  text-align: center;
  white-space: pre-line;
  margin-bottom: 32px;
  display: none;
}
#phase3-game .tap-count {
  font-family: 'Pretendard', sans-serif;
  font-size: 48px;
  font-weight: 900;
  background: linear-gradient(180deg, #A0F0FF 0%, #2EC4B6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 186px;
  margin-bottom: 0;
}
#phase3-game .tap-img {
  width: 260px; height: 260px; object-fit: contain;
  margin-top: 5px;
  transition: transform 0.1s ease;
}
#phase3-game .tap-img.tapped {
  transform: scale(0.92);
}
/* 3막 카운트다운 */
#phase3-game .p3-countdown-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 30; padding-bottom: 84px;
}
#phase3-game .p3-countdown-overlay .p3-cd-num {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 80px; color: #fff;
  animation: countdown-pop 1s ease infinite;
}
#phase3-game .p3-countdown-overlay.hidden { display: none; }
/* 3막 타임오버 */
#phase3-game .p3-timeover-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
  opacity: 0; transition: opacity 2s ease;
  pointer-events: none;
}
#phase3-game .p3-timeover-overlay.visible { opacity: 1; }
#phase3-game .p3-timeover-overlay .p3-timeover-text {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 40px; color: #fff;
}

/* PHASE3_RESULT: 3막 결과 */
#phase3-result { background: transparent; justify-content: flex-start; padding-top: clamp(50px, 10vh, 83px); align-items: center; }
#phase3-result h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: pre-line;
  margin-top: 0;
  margin-bottom: clamp(20px, 4vh, 32px);
}

/* PHASE3_GAME: 3막 게임 (scale 방식, 390×844 고정 캔버스) — 내부 식별자는 p4-* 유지 */
#phase4-game {
  background: #282828;
  align-items: center; justify-content: center;
  width: 100%; height: 100dvh;
  overflow: hidden;
  position: relative;
}
#phase4-scale-wrapper {
  width: 390px; height: 844px;
  position: relative;
  transform-origin: center center;
  flex-shrink: 0;
  overflow: hidden;
}
.p4-timer-header {
  position: absolute; top: 59px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 41px; z-index: 20;
}
.p4-timer { display: none; }
.p4-timer.urgent { display: none; }
.p4-gauge-track {
  display: flex; align-items: center; margin-left: 16px; margin-top: 10px;
}
.p4-score {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 54px; font-weight: 900;
  background: linear-gradient(180deg, #fff 0%, #a0f0ff 30%, #0cefd3 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1.08px;
  line-height: 1.4;
  filter: drop-shadow(0 2.7px 4px rgba(0,0,0,0.45));
  transition: transform 0.1s;
}
.p4-score.score-pop {
  animation: p4-score-pop 0.5s ease;
}
@keyframes p4-score-pop {
  0% { transform: scale(1) rotate(0); }
  15% { transform: scale(1.8) rotate(-3deg); }
  30% { transform: scale(0.8) rotate(2deg); }
  45% { transform: scale(1.3) rotate(-1deg); }
  60% { transform: scale(0.95) rotate(0); }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.p4-gauge-fill { display: none; }
.tap-gauge {
  position: absolute; top: 224px; left: 45px;
  width: 300px; height: 6px;
  display: flex; gap: 4px;
}
.tap-gauge-cell {
  flex: 1; height: 100%;
  background: #555; border-radius: 0;
  transition: background 0.15s ease;
}
.tap-gauge-cell:first-child { border-radius: 3px 0 0 3px; }
.tap-gauge-cell:last-child { border-radius: 0 3px 3px 0; }
.tap-gauge-cell.active {
  background: #ffffff;
}
.tap-gauge-cell.complete {
  background: #0cefd3;
}
.tap-gauge.gauge-shake {
  animation: gauge-shake 0.3s ease;
}
@keyframes gauge-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
.pizza-grid-box {
  position: absolute; top: 244px; left: 45px;
  width: 300px; height: 528px;
  box-sizing: border-box;
  background: #1d1d1d; border-radius: 10px; padding: 34px;
  display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(4, 1fr);
  gap: 14px;
  overflow: hidden;
  box-shadow: 0 4px 4px rgba(0,0,0,0.5);
  z-index: 95;
}
.pizza-grid-box.shake {
  animation: grid-shake 0.4s ease;
}
@keyframes grid-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}
.pizza-grid-box.abuse-shake {
  animation: abuse-shake 0.6s ease;
}
@keyframes abuse-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-10px, 2px) rotate(-1deg); }
  20% { transform: translate(10px, -2px) rotate(1deg); }
  30% { transform: translate(-8px, 3px) rotate(-1.5deg); }
  40% { transform: translate(8px, -1px) rotate(1.5deg); }
  50% { transform: translate(-6px, 2px) rotate(-1deg); }
  60% { transform: translate(6px, -2px) rotate(1deg); }
  70% { transform: translate(-4px, 1px) rotate(-0.5deg); }
  80% { transform: translate(4px, -1px) rotate(0.5deg); }
  90% { transform: translate(-2px, 0) rotate(0); }
}
.pizza-cell {
  min-height: 0; min-width: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.pizza-cell:active { transform: scale(0.9); }
.pizza-cell img { width: 100%; height: 100%; object-fit: contain; }

/* COMPLETE */
#complete {
  background: transparent;
  justify-content: flex-start; padding-top: clamp(50px, 10vh, 83px); align-items: center; text-align: center;
  position: relative; overflow: hidden;
}
#complete .complete-title {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px); font-weight: 900; color: #171717;
  letter-spacing: -0.6px;
  line-height: 140%;
  white-space: pre-line;
  margin-top: 0;
  margin-bottom: clamp(16px, 3vh, 24px);
  opacity: 0; animation: complete-fade-in 1.5s ease forwards 0.3s;
}
#complete .complete-sub {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  margin-bottom: 0;
}
#complete .complete-sub p {
  font-family: 'Pretendard', -apple-system, sans-serif;
  font-size: 20px; font-weight: 700; line-height: 160%; color: #171717;
  opacity: 0; animation: complete-line-in 1s ease forwards;
}
#complete .complete-sub p:nth-child(1) { animation-delay: 1.2s; }
#complete .complete-sub p:nth-child(2) { animation-delay: 1.8s; }
#complete .complete-sub p:nth-child(3) { animation-delay: 2.4s; }
@keyframes complete-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes complete-line-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
#complete .complete-images {
  position: relative; width: 75%;
  margin-top: clamp(50px, 10vh, 90px);
}
#complete .complete-ending-img {
  width: 100%; height: auto; object-fit: contain;
  opacity: 0; animation: complete-fade-in 1s ease forwards 3s;
}

/* ─── iPad/태블릿 대응 (모바일 불변) ─── */
@media (min-width: 768px) {
  #app-wrapper { width: min(100dvw, 700px); height: 100dvh; }

  /* lobby: 카드 크기 상향 */
  .team-grid {
    grid-template-columns: repeat(2, min(200px, 28vw));
    grid-template-rows: repeat(3, min(220px, 22vh));
    gap: min(20px, 3vh) min(20px, 3vw);
  }

  /* 1막 설명 박스 */
  .intro-box { width: clamp(300px, 60vw, 420px); }

  /* 3막 설명 박스 */
  .intro-box-p3 { width: clamp(300px, 60vw, 420px); }

  /* 1막 결과 순위 리스트 */
  .rank-list { width: clamp(300px, 60vw, 420px); }

  /* 대기 로딩 이미지 */
  .waiting-loading-img { width: clamp(184px, 30vw, 260px); }
  #phase1-waiting .waiting-loading-img { width: clamp(184px, 30vw, 260px); }

  /* 팀선택완료 카드 */
  #select-overlay .select-card { width: clamp(194px, 30vw, 260px); }

  /* 1막 컨베이어: 모바일 331.5px × cap 1.2 = 398px 고정 */
  .phase1-conveyor-bg { width: 100%; }
}

/* 닉네임 모달 */
#nickname-modal {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: url('../assets/shared/backgrounds/home.png') center/cover no-repeat #fff;
  display: block;
  z-index: 60;
}
#nickname-modal.hidden { display: none; }
.nickname-modal-box {
  position: relative;
  width: 390px; height: 844px;
  margin: 0 auto;
  max-width: 100%;
}
.nickname-title {
  position: absolute; top: 83px; left: 50%; transform: translateX(-50%);
  font-family: 'BAEMINWORK', sans-serif;
  font-size: 30px;
  line-height: 140%;
  letter-spacing: -0.6px;
  color: #171717;
  text-align: center;
  white-space: nowrap;
}
.nickname-sub {
  position: absolute; top: 183px; left: 50%; transform: translateX(-50%);
  font-family: 'Pretendard', sans-serif;
  font-size: 20px; font-weight: 500; color: #171717;
  letter-spacing: -0.4px;
  white-space: nowrap;
}
.nickname-input-row {
  position: absolute; top: 325px; left: 50%; transform: translateX(-50%);
  width: 300px; height: 84px;
  background: linear-gradient(175deg, #fff 75%, rgba(255,255,255,0.4) 100%);
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,187,171,0.35);
  display: flex; align-items: center;
}
#nickname-input {
  width: 100%;
  font-family: 'Pretendard', sans-serif;
  font-size: 20px; font-weight: 700;
  padding: 0 65px 0 65px;
  border: none;
  outline: none;
  text-align: center;
  background: transparent;
  color: #171717;
  letter-spacing: -0.4px;
  height: 100%;
}
#nickname-input::placeholder { color: #949494; font-weight: 600; }
.nickname-refresh {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  width: 39px; height: 39px;
  border: none; background: #0cefd3;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.nickname-refresh:active { transform: translateY(-50%) scale(0.9); }
.nickname-error {
  position: absolute; top: 415px; left: 50%; transform: translateX(-50%);
  font-family: 'Pretendard', sans-serif;
  font-size: 13px; color: #E63946;
  white-space: nowrap;
}
.nickname-confirm {
  position: absolute; top: 443px; left: 50%; transform: translateX(-50%);
  width: 128px; height: 46px;
  border: none; border-radius: 8px;
  background: #171717; color: #fff;
  box-shadow: 0 4px 6px rgba(0,187,171,0.35);
  font-family: 'Pretendard', sans-serif;
  font-size: 20px; font-weight: 600;
  letter-spacing: -0.4px;
  cursor: pointer; transition: transform 0.1s;
}
.nickname-confirm:active { transform: scale(0.97); }

/* ─── MEMORY GAME: 같은 그림 맞추기 (3-2) ─── */
#phase3-2-intro { background: #282828; justify-content: flex-start; padding-top: clamp(60px, 12.6vh, 106px); align-items: center; }
#phase3-2-intro h2 {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  color: #fff; text-align: center; letter-spacing: -0.6px;
  margin-bottom: clamp(16px, 3vh, 28px);
}
.mem-demo-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  grid-template-rows: repeat(2, 1fr) !important;
  position: relative;
  top: -10px;
}
#memory-game {
  background: #282828;
  align-items: center; justify-content: center;
  width: 100%; height: 100dvh;
  overflow: hidden;
  position: relative;
}
#memory-scale-wrapper {
  width: 390px; height: 844px;
  position: relative;
  transform-origin: center center;
  flex-shrink: 0;
  overflow: hidden;
}
#memory-game .memory-header { position: absolute; top: 59px; left: 0; right: 0; }
.memory-cell {
  min-height: 0; min-width: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent; outline: none;
  border-radius: 50%;
}
.memory-cell img { width: 100%; height: 100%; object-fit: contain; }
.memory-cell.flipped { pointer-events: none; }
.memory-cell.matched { pointer-events: none; opacity: 0.3; filter: grayscale(0.5); }
.memory-cell.wrong { animation: mem-wrong-shake 0.4s ease; }
@keyframes mem-wrong-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.mem-grid-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 50; pointer-events: none;
  transition: opacity 0.3s ease;
}
.mem-grid-overlay.hidden { opacity: 0; pointer-events: none; }
.mem-grid-overlay .mem-overlay-text {
  font-family: 'Pretendard', sans-serif; font-size: 24px; font-weight: 700;
  color: #fff;
  text-align: center; line-height: 150%;
  margin-bottom: 40%;
}
.mem-countdown {
  position: absolute; top: 144px; left: 50%; transform: translateX(-50%);
  z-index: 50; pointer-events: none;
}
.mem-countdown span {
  font-family: 'BAEMINWORK', sans-serif; font-size: 60px; font-weight: 900;
  color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: countdown-pop 0.85s ease infinite;
}
.mem-countdown.hidden { display: none; }

/* ─── THROWING: 피자 던지기 모바일 ─── */
#throwing { background: #282828; }
.throwing-mobile {
  display: flex; flex-direction: column; align-items: center;
  height: 100%; padding: 20px; text-align: center;
  justify-content: flex-start;
  padding-top: clamp(50px, 10vh, 83px);
  position: relative;
}
.throw-arrow {
  width: 47px; height: 69px;
  margin-bottom: 25px;
}
.throw-title {
  font-family: 'BAEMINWORK', sans-serif;
  font-size: clamp(24px, 7.7vw, 30px);
  font-weight: 900; color: #fff;
  line-height: 148%; letter-spacing: -0.6px;
  white-space: pre-line;
  margin-bottom: 0;
}
.throw-counter {
  display: flex; align-items: center; justify-content: center;
  margin-top: clamp(24px, 4vh, 40px);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: #fff;
  text-decoration-thickness: 1.5px;
}
.throw-counter-label {
  font-family: 'Pretendard', sans-serif;
  font-size: 18px; font-weight: 600; color: #fff;
}
.throw-counter-num {
  font-family: 'Pretendard', sans-serif;
  font-size: 18px; font-weight: 600; color: #fff;
}
.throw-pizza-wrap {
  width: 240px; height: 240px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-top: clamp(40px, 8vh, 70px);
  position: relative;
}
.throw-pizza-img {
  width: 100%; height: 100%; object-fit: contain;
  animation: throw-bounce 2s ease-in-out infinite;
}
@keyframes throw-bounce {
  0%, 100% { transform: translateY(0); }
  20% { transform: translateY(-40px); }
  35% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
  65% { transform: translateY(0); }
}
.throw-pizza-img.locked {
  animation: throw-locked-shake 1.8s ease-in-out infinite;
}
@keyframes throw-locked-shake {
  0%, 3% { transform: translateX(0); }
  5% { transform: translateX(-2px); }
  7% { transform: translateX(2px); }
  9% { transform: translateX(-2px); }
  11% { transform: translateX(2px); }
  13% { transform: translateX(-2px); }
  15% { transform: translateX(2px); }
  17% { transform: translateX(-1px); }
  19% { transform: translateX(1px); }
  21% { transform: translateX(-1px); }
  23% { transform: translateX(1px); }
  25% { transform: translateX(-1px); }
  27% { transform: translateX(1px); }
  29%, 55% { transform: translateX(0); }
  57% { transform: translateX(-2px); }
  59% { transform: translateX(2px); }
  61% { transform: translateX(-2px); }
  63% { transform: translateX(2px); }
  65% { transform: translateX(-1.5px); }
  67% { transform: translateX(1.5px); }
  69% { transform: translateX(-1px); }
  71% { transform: translateX(1px); }
  73% { transform: translateX(-1px); }
  75% { transform: translateX(1px); }
  77% { transform: translateX(-0.5px); }
  79% { transform: translateX(0.5px); }
  81%, 100% { transform: translateX(0); }
}
.throw-pizza-img.thrown {
  animation: throw-fly 0.5s ease-in forwards;
}
@keyframes throw-fly {
  0% { transform: translate(-50%, -50%); opacity: 1; filter: blur(0); }
  50% { filter: blur(3px); }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -550px); opacity: 0; filter: blur(6px); }
}
.throw-locked {
  font-size: 20px; color: #fff; line-height: 1.6;
  font-family: 'Pretendard', sans-serif;
  margin-top: clamp(24px, 4vh, 40px);
}

/* 노랑 방해: 각 셀 개별 흔들림 */
.shake-cells .pizza-cell {
  animation: cell-shake 0.15s ease-in-out infinite alternate;
}
.shake-cells .pizza-cell:nth-child(2) { animation-duration: 0.12s; animation-delay: 0.03s; }
.shake-cells .pizza-cell:nth-child(3) { animation-duration: 0.18s; animation-delay: 0.06s; }
.shake-cells .pizza-cell:nth-child(4) { animation-duration: 0.13s; animation-delay: 0.02s; }
.shake-cells .pizza-cell:nth-child(5) { animation-duration: 0.16s; animation-delay: 0.04s; }
.shake-cells .pizza-cell:nth-child(6) { animation-duration: 0.14s; animation-delay: 0.07s; }
.shake-cells .pizza-cell:nth-child(7) { animation-duration: 0.17s; animation-delay: 0.01s; }
.shake-cells .pizza-cell:nth-child(8) { animation-duration: 0.11s; animation-delay: 0.05s; }
@keyframes cell-shake {
  0% { transform: translateX(-14px) rotate(-2deg); }
  100% { transform: translateX(14px) rotate(2deg); }
}

/* 회색 방해: fog JS로 처리 */
.pizza-grid-box.fogged { position: relative; }
.fog-layer {
  position: absolute; pointer-events: none; z-index: 100;
  opacity: 0; transition: opacity 1s ease;
}
.fog-layer.visible { opacity: 1; }
.fog-layer img {
  width: 100%; height: auto;
}
.pizza-grid-box.fogged { position: relative; }
