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

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  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: #150c2e;
}

/* ARCADE-FIT: #app 이 폰 프레임. 폰에선 화면 전체, 데스크톱에선 가운데 세로 프레임.
   ⚠️ 캔버스 내부 레터박스(위아래 띠)는 CSS 가 아니라 app.js resizeCanvas 가 맡는다 —
   띠 자리에 검정 대신 배경·벽돌을 이어 그리려면 그 픽셀도 캔버스여야 한다. */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

main { display: contents; }

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

#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); }
.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; }

#result-stats {
  color: #fff;
  margin: 1rem 0;
  display: grid;
  gap: .45rem;
}
.stat-main { font-size: 3.4rem; font-weight: 900; line-height: 1; color: var(--mint); }
.stat-main span { font-size: 1.2rem; margin-left: .15rem; color: #cfe9e2; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem .75rem;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .07);
  font-size: .95rem;
  color: var(--dim);
}
.stat-row b { color: #fff; font-size: 1.05rem; }

/* 부활을 강조한다 — 다시 하기는 조용한 버튼으로 내린다. */
#revive {
  background: linear-gradient(180deg, #b9ffef, var(--mint));
  color: #0b2a24;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .9), inset 0 -4px 0 #2fae95,
              0 .4rem 1.2rem rgba(92, 225, 198, .35);
  font-size: 1.05rem;
}
#again {
  background: rgba(255, 255, 255, .1);
  color: #d7ddff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

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

/* ── 홈 ─────────────────────────────────────────────
   시트의 판때기·검은 패널을 홈에서는 벗긴다. 배경(bg.webp) 위에 바로 올라가야
   "밤하늘에 서 있는 고양이"로 보인다. */
.home-sheet {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  align-items: center;
  text-align: center;
  max-width: 19rem;
  background: none;
  box-shadow: none;
  overflow: visible;
  padding: .5rem 0;
}
.home-sheet > div { background: none; padding: 0; }

.home-title {
  font-size: 2.9rem !important;
  font-weight: 900;
  letter-spacing: .04em;
  margin: 0 !important;
  background: linear-gradient(180deg, #fff 30%, var(--mint));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(20, 10, 50, .55)) drop-shadow(0 8px 18px rgba(0, 0, 0, .6));
}

#homeCat {
  width: 9.5rem;
  height: 9.5rem;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .55));
  animation: float 2.6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(-6px) rotate(-3deg); }
  50% { transform: translateY(8px) rotate(3deg); }
}

#tapToStart {
  display: block;
  width: 100%;
  padding: .95rem 1.6rem;
  border: 0;
  border-radius: 999px;
  font-size: 1.25rem;
  font-weight: 900;
  color: #0b2a24;
  background: linear-gradient(180deg, #b9ffef, var(--mint));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .9), inset 0 -4px 0 #2fae95,
              0 .5rem 1.4rem rgba(92, 225, 198, .35);
  cursor: pointer;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* 스킨 칩 — 고양이 실루엣에 스킨 색을 입힌 칩 */
.carousel {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: center;
}
.skin-chip {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35), 0 2px 6px rgba(0, 0, 0, .45);
}
.skin-chip::after {
  content: '';
  position: absolute;
  inset: 12%;
  background: url("../assets/cat.webp") center/contain no-repeat;
  mix-blend-mode: luminosity;
}
.skin-chip.on { box-shadow: inset 0 0 0 2px #fff, 0 0 0 3px var(--mint), 0 2px 8px rgba(0, 0, 0, .5); }

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

.tab-btn {
  flex: 1;
  padding: .7rem;
  border: 0;
  border-radius: .8rem;
  background: rgba(12, 18, 44, .55);
  color: #cdd6ff;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.tab-btn.active,
.tab-btn:hover { background: rgba(92, 225, 198, .22); color: #eafff9; }

.panel { width: 100%; display: grid; gap: .4rem; }
.shop-row, .mission-row {
  display: flex;
  justify-content: space-between;
  padding: .6rem .8rem;
  border-radius: .7rem;
  background: rgba(12, 18, 44, .6);
  font-size: .9rem;
}
button.back { margin-top: .8rem; }

/* 세로 전용 */
#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; }
}

/* ── 데스크톱 = 폰 프레임 ────────────────────────────
   넓은 화면에서 전체화면으로 늘어나 못 하겠다는 피드백. 9:16 프레임에 가둔다. */
@media (min-width: 768px) and (min-height: 600px) {
  body {
    gap: 14px;
    background:
      radial-gradient(120% 90% at 50% 0%, #3a2270 0%, #1a1038 45%, #0a0720 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;
    margin-top: 8px;
    color: #a9b2e0;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .7);
  }
}

/* 힉스필드 홈 배경(assets/bg.webp — 새벽 하늘). url 은 CSS 파일 기준 ../ (pipes 함정). */
#home {
  background-image:
    linear-gradient(180deg, rgba(12, 18, 40, 0.35), rgba(8, 12, 30, 0.7)),
    url("../assets/bg.webp");
  background-size: cover;
  background-position: center;
}
