/* 무한 계단 — 아케이드 게임. 캔버스 1장 + 오버레이 구조. */
:root {
  --bg: #0e1630;
  --pill: #d5dcf5;
  --pill-ink: #2a3050;
  --ink: #e6eaff;
  --dim: #9aa3cc;
  --accent: #8fa0ff;
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font: 700 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

/* ARCADE-FIT: 게임 화면 하나. 폰에선 뷰포트 전체, 데스크톱에선 폰 프레임(아래 미디어쿼리). */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

main { position: absolute; inset: 0; }

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
/* 남는 위아래 띠는 검정이 아니라 도장 배경 — app.js drawBackground 가 캔버스 경계까지 cover 로 채운다. */

#deskHint { display: none; }

.overlay {
  /* fixed 금지 — 데스크톱 폰 프레임 밖으로 새어 나간다. */
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.4rem;
  background: rgba(6, 9, 22, .82);
}
.overlay[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 22rem;
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #2a3157, #1b2140);
  border-radius: 1.4rem;
  padding: 1.5rem 1.3rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), 0 1rem 2rem rgba(0, 0, 0, .5);
}

.sheet h1 { font-size: 1.15rem; margin-bottom: 1rem; color: var(--ink); }
#result-stats {
  background: rgba(0, 0, 0, .28);
  border-radius: .9rem;
  padding: .6rem;
}

.sheet button {
  width: 100%;
  padding: .95rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #c3ccff, var(--accent));
  color: #171c38;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .8), inset 0 -3px 0 #6474d8;
  margin-top: .6rem;
}

.sheet button.ghost {
  background: linear-gradient(180deg, #eef1ff, var(--pill));
  color: var(--pill-ink);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .9), inset 0 -3px 0 #adb6dd;
}
.sheet button.ghost[hidden] { display: none; }

.result-sheet {
  text-align: center;
}
.result-sheet h1 { margin-bottom: .35rem; }

#result-stats {
  color: #fff;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 1rem 0;
}

#result-detail {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin: -.4rem 0 .9rem;
  font-size: .95rem;
}
#result-detail div {
  display: flex;
  justify-content: space-between;
  padding: .1rem .5rem;
  color: var(--dim);
}
#result-detail b { color: #fff; }

#result-why {
  margin-bottom: 1.1rem;
  color: var(--dim);
  font-size: .9rem;
  font-weight: 600;
}

/* 부활 버튼 강조 — 결과창에서 가장 눈에 띄어야 한다 */
.result-sheet button.ghost {
  background: linear-gradient(180deg, #ffe27a, #ffb020);
  color: #3a2400;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .9), inset 0 -3px 0 #c97d00,
    0 0 0 0 rgba(255, 176, 32, .55);
  font-size: 1.05rem;
  animation: reviveGlow 1.6s ease-out infinite;
}
@keyframes reviveGlow {
  0% { box-shadow: inset 0 2px 0 rgba(255,255,255,.9), inset 0 -3px 0 #c97d00, 0 0 0 0 rgba(255,176,32,.55); }
  70%, 100% { box-shadow: inset 0 2px 0 rgba(255,255,255,.9), inset 0 -3px 0 #c97d00, 0 0 0 .9rem rgba(255,176,32,0); }
}

/* ── 홈 ─────────────────────────────────────────────── */
.home-sheet {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
  max-width: 18rem;
  background: none;
  box-shadow: none;
  overflow: visible;
}

.game-title {
  font-size: 2.6rem !important;
  font-weight: 900;
  letter-spacing: .06em;
  margin: 0 !important;
  color: #fff5d6;
  text-shadow:
    0 2px 0 #a33b12, 0 4px 0 #7c2a0c,
    0 8px 18px rgba(0, 0, 0, .7);
}

.carousel {
  display: flex;
  gap: .55rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 14.6rem; /* 6개씩 두 줄로 딱 떨어진다 */
}
.skin-chip {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .28);
  cursor: pointer;
}
.skin-chip.on {
  border-color: #fff;
  transform: scale(1.18);
  box-shadow: 0 0 .6rem rgba(255, 255, 255, .6);
}

#tapToStart {
  display: block;
  width: 100%;
  padding: 1rem 2.2rem;
  border: 0;
  border-radius: 999px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0d2b12;
  background: linear-gradient(180deg, #8ef29a, #34c759);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .85), inset 0 -4px 0 #1e8f3d,
    0 .6rem 1.2rem rgba(0, 0, 0, .45);
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}
#tapToStart.back { font-size: 1.05rem; padding: .7rem 1.2rem; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.panel { display: flex; flex-direction: column; gap: .5rem; }
.shop-row, .mission-row {
  display: flex;
  justify-content: space-between;
  padding: .6rem .8rem;
  border-radius: .7rem;
  background: rgba(0, 0, 0, .4);
  font-size: .92rem;
}

/* 홈 배경에 떠다니는 과일 장식 */
#homeFruits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
#homeFruits img {
  position: absolute;
  width: 5.5rem;
  opacity: .5;
  filter: drop-shadow(0 .5rem 1rem rgba(0, 0, 0, .6));
  animation: floatUp 9s ease-in-out infinite;
}
#homeFruits img:nth-child(1) { left: 4%;  top: 12%; animation-duration: 8s; }
#homeFruits img:nth-child(2) { right: 5%; top: 22%; width: 4.4rem; animation-duration: 11s; animation-delay: -3s; }
#homeFruits img:nth-child(3) { left: 8%;  bottom: 12%; width: 4rem; animation-duration: 10s; animation-delay: -6s; }
#homeFruits img:nth-child(4) { right: 8%; bottom: 18%; width: 4.6rem; animation-duration: 12s; animation-delay: -1.5s; }

@keyframes floatUp {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50%      { transform: translateY(-1.6rem) rotate(8deg); }
}

#homeTabs {
  display: flex;
  gap: .6rem;
  width: 100%;
  margin-top: .4rem;
}

.tab-btn {
  flex: 1;
  padding: .7rem;
  border: 0;
  border-radius: .8rem;
  background: rgba(255, 255, 255, .1);
  color: var(--dim);
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  color: #171c38;
}

/* 데스크톱 = 폰 프레임 */
@media (min-width: 768px) and (min-height: 600px) {
  body {
    background:
      radial-gradient(120% 90% at 50% 0%, #1c2450 0%, #0e1630 45%, #060912 100%);
  }
  #app {
    width: min(420px, calc((100vh - 72px) * 360 / 640));
    height: min(calc(100vh - 72px), calc(420px * 640 / 360));
    border-radius: 32px;
    box-shadow: 0 0 0 10px #15182a, 0 0 0 12px #2b3050, 0 40px 90px rgba(0, 0, 0, .6);
  }
  #stage { border-radius: 32px; }
  #deskHint {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 16px;
    text-align: center;
    color: var(--dim);
    font-size: .9rem;
    font-weight: 600;
  }
}

/* 세로 전용 */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  #app, #deskHint { display: none !important; }
  #rotate {
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--dim);
    font-size: 1.05rem;
    line-height: 1.6;
  }
}

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

/* 힉스필드 홈 배경(assets/bg.webp — 도장 배경). url 은 CSS 파일 기준 ../ (pipes 함정). */
#home {
  background-image:
    linear-gradient(180deg, rgba(10, 14, 32, 0.25), rgba(6, 9, 24, 0.62)),
    url("../assets/bg.webp");
  background-size: cover;
  background-position: center;
}
