/* 그림자 암살 — 아케이드 게임. 캔버스 1장 + 오버레이 구조.
   색은 아이콘(assets/icon-1024.png)에서 그대로 가져왔다: 어두운 남색 바닥 · 붉은 경비 · 갈색 상자. */
:root {
  --bg: #0f121b;
  --panel: #1c2233;
  --pill: #cdd5ea;
  --pill-ink: #232a3d;
  --ink: #e8ecf8;
  --dim: #97a0bd;
  --accent: #e0403a;
  --gold: #ffb800;
}

* { 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;
}

/* ARCADE-FIT: 게임 프레임. 폰에선 화면 전체, 데스크톱에선 가운데 뜬 폰 모양(아래 미디어쿼리).
   오버레이는 전부 이 안에 `position:absolute` 로 갇힌다 — fixed 를 쓰면 프레임 밖으로 샌다. */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

main { position: absolute; inset: 0; }

/* 캔버스는 프레임을 꽉 채운다. 9:16 레터박스는 app.js 의 resizeCanvas 가
   setTransform 으로 가운데 정렬해 만들고, 남는 띠는 바닥을 이어 그린다. */
#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#kbdHint { display: none; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.4rem;
  background: rgba(6, 8, 14, .84);
}
.overlay[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 22rem;
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #262d42, #161b29);
  border-radius: 1.4rem;
  padding: 1.5rem 1.3rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .1), 0 1rem 2rem rgba(0, 0, 0, .6);
}

.sheet h1 { font-size: 1.15rem; margin-bottom: 1rem; color: var(--ink); }
.sheet > div {
  background: rgba(0, 0, 0, .3);
  border-radius: .9rem;
  padding: .6rem;
}

.sheet button {
  width: 100%;
  padding: .95rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f0776f, var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 #9c241f;
  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 #a5adc6;
}
.sheet button.ghost[hidden] { display: none; }

/* ── 결과창 ───────────────────────────────────────── */
.result-sheet { text-align: center; }
.result-sheet h1 { margin-bottom: .35rem; }

#result-stats {
  color: #fff;
  margin: .9rem 0;
  background: rgba(0, 0, 0, .32);
}
.score-big {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 .2rem .8rem rgba(0, 0, 0, .55);
}
.score-big span { font-size: 1.1rem; margin-left: .15rem; color: var(--dim); }
.score-best {
  margin-top: .35rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--dim);
}

#result-why {
  margin-bottom: 1.1rem;
  color: var(--dim);
  font-size: .9rem;
  font-weight: 600;
}

/* 부활은 결과창의 주인공 버튼이다 — 노란 금빛으로 강조. */
.sheet button#revive {
  background: linear-gradient(180deg, #ffe066, var(--gold));
  color: #4a3200;
  font-size: 1.05rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .85), inset 0 -3px 0 #c98a00,
    0 .35rem 1.1rem rgba(255, 179, 0, .45);
  animation: gold 1.8s ease-in-out infinite;
}
@keyframes gold {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

/* ── 홈 ───────────────────────────────────────────── */
.home-sheet {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  max-width: 20rem;
  height: 100%;
  background: none;
  box-shadow: none;
  padding: 1rem .6rem;
  overflow: visible;
}
.home-sheet > div { background: none; padding: 0; }

.home-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  line-height: 1;
  margin: 0;
  text-shadow: 0 .18rem 0 #191d2b, 0 .5rem 1.4rem rgba(0, 0, 0, .7);
  cursor: pointer;
}
.home-sheet h1.home-title { font-size: 2.5rem; margin-bottom: 0; }

#homeHero {
  /* vw 단위는 데스크톱 폰 프레임 안에서 깨진다 — 시트 폭 기준 % 로. */
  width: 48%;
  max-width: 10rem;
  height: auto;
  margin: -.2rem 0 -.4rem;
  cursor: pointer;
  filter: drop-shadow(0 .8rem 1.6rem rgba(0, 0, 0, .75)) contrast(1.05);
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 홈 히어로 옆 단검 슬래시 장식. img 에는 ::after 가 안 붙어서 래퍼를 하나 뒀다. */
#homeHeroWrap {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
}
#homeHeroWrap::after {
  content: '';
  position: absolute;
  right: 8%;
  top: 26%;
  width: 26%;
  max-width: 5.4rem;
  aspect-ratio: 253 / 256;
  background: url(../assets/slash.webp) center / contain no-repeat;
  /* slash.webp 는 초승달 **안쪽이 반투명 검정**이다(alpha 127). 캔버스 쪽은 'lighter' 로
     지우는데 CSS 는 screen 블렌드로 지운다 — 안 넣으면 어깨에 검은 덩어리가 얹힌다. */
  mix-blend-mode: screen;
  pointer-events: none;
  animation: heroSlash 3.6s ease-in-out infinite;
}
@keyframes heroSlash {
  0%, 64% { opacity: 0; transform: rotate(-42deg) scale(.45); }
  72%     { opacity: .88; transform: rotate(-16deg) scale(1.02); }
  88%, 100% { opacity: 0; transform: rotate(-2deg) scale(1.3); }
}
@media (prefers-reduced-motion: reduce) {
  #homeHeroWrap::after { animation: none; opacity: .5; }
}

#homeMain { width: 100%; }

#charLine {
  font-size: .82rem;
  font-weight: 700;
  color: #ffd7a0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  min-height: 1.1rem;
}

#tapToStart {
  display: block;
  width: 100%;
  padding: .95rem 1rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, var(--gold));
  color: #4a3200;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .85), inset 0 -4px 0 #c98a00,
    0 .4rem 1.2rem rgba(255, 179, 0, .35);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.carousel {
  display: flex;
  gap: .45rem;
  width: 100%;
  overflow-x: auto;
  padding: .3rem .1rem;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }

.home-sheet .skin-chip {
  flex: 0 0 auto;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--chip) 55%, #fff), var(--chip));
  cursor: pointer;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.home-sheet .skin-chip img { width: 112%; margin-top: 16%; }
.home-sheet .skin-chip.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 224, 102, .7); }
.home-sheet .skin-chip.locked { opacity: .36; }

#homeTabs {
  display: flex;
  gap: .5rem;
  width: 100%;
  margin-top: .3rem;
}

.home-sheet .tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .5rem .3rem;
  border: 0;
  border-radius: .9rem;
  background: rgba(22, 27, 41, .72);
  color: #dfe5ff;
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.home-sheet .tab-btn b { font-size: 1.1rem; line-height: 1; font-weight: 400; }
.home-sheet .tab-btn:active, .home-sheet .tab-btn.active { background: var(--gold); color: #4a3200; }

.panel { width: 100%; color: var(--ink); font-size: .9rem; }
.shop-row, .mission-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem .7rem;
  margin-bottom: .3rem;
  border-radius: .6rem;
  background: rgba(22, 27, 41, .72);
}
.sheet .panel .back {
  width: 100%;
  margin-top: .5rem;
  padding: .7rem;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: #4a3200;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

/* ── 데스크톱 = 가운데 뜬 폰 프레임 ─────────────────── */
@media (min-width: 768px) and (min-height: 600px) {
  body {
    background: radial-gradient(120% 90% at 50% 0%, #2a3350 0%, #131725 45%, #05070c 100%);
    gap: 1rem;
  }
  #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 #12141f, 0 0 0 12px #2a3046, 0 40px 90px rgba(0, 0, 0, .7);
  }
  #stage { border-radius: 32px; }
  #kbdHint {
    display: block;
    margin: 0;
    color: var(--dim);
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .01em;
  }
}

/* 세로 전용 */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  #app, #kbdHint { 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; }
}

/* 홈 배경 — 창고 바닥 타일을 어둡게 깔고 붉은 스포트라이트를 얹는다.
   url 은 CSS 파일 기준 ../ (pipes 함정). */
#home {
  background-image:
    radial-gradient(80% 55% at 50% 62%, rgba(224, 64, 58, .22), rgba(10, 12, 20, .93) 70%),
    linear-gradient(180deg, rgba(10, 12, 20, .72), rgba(6, 8, 14, .95)),
    url("../assets/floor-warehouse.webp");
  background-size: auto, auto, 220px 220px;
  background-repeat: no-repeat, no-repeat, repeat;
  background-position: center;
}
