/* 무한 계단 — 아케이드 게임. 캔버스 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;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0d18;
}

/* 폰에서는 화면 전체. 데스크톱에서는 아래 미디어쿼리가 폰 프레임으로 줄인다. */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

main { position: absolute; inset: 0; }

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 데스크톱 안내 — 프레임 아래. 폰에서는 숨긴다. */
#deskHint { display: none; }

@media (min-width: 768px) and (min-height: 600px) {
  body {
    gap: 18px;
    background:
      radial-gradient(90% 70% at 50% 22%, #232a4d, #0a0d18 72%);
  }
  #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;
    color: var(--dim);
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .01em;
  }
}

.overlay {
  /* fixed 금지 — #app 안에 갇혀야 폰 프레임 밖으로 안 샌다. */
  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); }
.sheet > div {
  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; font-size: 1.5rem; }

#result-stats {
  display: flex;
  gap: .6rem;
  margin: 1rem 0 .9rem;
  background: none;
  padding: 0;
}
#result-stats .stat {
  flex: 1;
  background: rgba(0, 0, 0, .3);
  border-radius: 1rem;
  padding: .8rem .4rem .6rem;
}
#result-stats .stat b {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.05;
}
#result-stats .stat span {
  font-size: .72rem;
  font-weight: 700;
  color: var(--dim);
}

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

/* 부활을 강조 — 코발트 채움, "다시 하기"는 조용한 고스트 */
#revive {
  background: linear-gradient(180deg, #5b8bff, #2F6BFF);
  color: #fff;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 #1c47b8, 0 .5rem 1rem rgba(47, 107, 255, .45);
  font-size: 1.05rem;
  animation: pulse 1.6s infinite;
}
#again {
  background: rgba(255, 255, 255, .12);
  color: var(--ink);
  box-shadow: none;
  font-weight: 700;
}

/* ── 홈 ── */
.home-sheet {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
  text-align: center;
  max-width: 20rem;
  height: 100%;
  background: none;
  box-shadow: none;
  padding: 1.2rem .6rem;
  overflow: visible;
}
.home-sheet > div { background: none; padding: 0; }

#homeMain {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  flex: 1;
  width: 100%;
}

#homeTitle {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: .06em;
  color: #fff;
  text-shadow: 0 .18rem 0 rgba(20, 30, 70, .55), 0 .8rem 1.6rem rgba(0, 0, 0, .5);
}

#homeCube {
  width: 46%;
  max-width: 11rem;
  height: auto;
  margin: .2rem 0 .6rem;
  filter: drop-shadow(0 1.1rem 1.1rem rgba(0, 0, 0, .45));
  animation: float 3.4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(-.35rem) rotate(-5deg); }
  50% { transform: translateY(.35rem) rotate(5deg); }
}

#tapToStart {
  padding: .95rem 2.2rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #5b8bff, #2F6BFF);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 #1c47b8, 0 .7rem 1.4rem rgba(47, 107, 255, .5);
  cursor: pointer;
  animation: pulse 1.5s infinite;
}
#tapToStart.back { width: auto; }

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

.carousel {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: .1rem 0 .3rem;
}

.skin-chip {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: .5rem;
  display: inline-block;
  box-shadow: inset 0 -.25rem 0 rgba(0, 0, 0, .25), 0 .15rem .3rem rgba(0, 0, 0, .4);
}
.skin-chip.on {
  outline: 2px solid #fff;
  outline-offset: 2px;
  transform: scale(1.12);
}

.panel { color: var(--ink); font-size: .95rem; }
.shop-row, .mission-row {
  display: flex;
  justify-content: space-between;
  background: rgba(8, 12, 30, .55);
  border-radius: .7rem;
  padding: .6rem .8rem;
  margin-bottom: .4rem;
}

#homeTabs {
  display: flex;
  gap: .6rem;
  width: 100%;
}

.sheet .tab-btn {
  flex: 1;
  margin: 0;
  padding: .7rem;
  border: 0;
  border-radius: .9rem;
  background: rgba(255, 255, 255, .14);
  backdrop-filter: blur(6px);
  color: #eaf0ff;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
}

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

/* 세로 전용 */
#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:
    radial-gradient(120% 60% at 50% 34%, rgba(90, 130, 255, .30), transparent 70%),
    linear-gradient(180deg, rgba(12, 18, 40, 0.30), rgba(6, 10, 26, 0.82)),
    url("../assets/bg.webp");
  background-size: cover;
  background-position: center;
  padding: 0;
}
