:root {
  --night: #2A2358;
  --cream: #FFF6E2;
  --paper: #FFEBC4;
  --ink: #4A2B1E;
  --ink-soft: #8A6650;
  --coral: #FF6B57;
  --coral-deep: #D9483A;
  --gold: #FFBE45;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 폰에서 앱처럼: 화면 전체가 끌려 내려가거나(당겨서 새로고침) 튕기거나 확대되지 않게 */
html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  color: var(--ink);
  touch-action: none;           /* 화면 전체: 스크롤·핀치·두 번 탭 확대 없음 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body { position: fixed; inset: 0; }

/* 노치·상태 표시줄·아래 홈 바를 피한 안전 영역 안에만 게임을 그린다(바깥은 밤하늘 색) */
#game {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  touch-action: none;
}
#game canvas { display: block; touch-action: none; }

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding:
    calc(16px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(16px + env(safe-area-inset-left, 0px));
  background: rgba(32, 25, 72, .72);
  touch-action: pan-y;          /* 카드가 길면 위아래로만 밀린다(확대는 안 됨) */
  -webkit-overflow-scrolling: touch;
}
.btn, button { touch-action: manipulation; }
.screen[hidden] { display: none; }

.card {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 20px 20px 18px;
  text-align: center;
  background: var(--cream);
  border: 4px solid #E8B874;
  border-radius: 28px;
  box-shadow: 0 8px 0 #A9713F;
  animation: pop .28s cubic-bezier(.2, 1.4, .4, 1);
}
.card.small { max-width: 340px; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.hero { display: block; width: 46%; height: auto; margin: 0 auto 4px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-3deg); } }

.eyebrow { margin: 0; font-size: 14px; font-weight: 700; color: var(--coral-deep); }
h1 { margin: 2px 0 12px; font-size: 32px; line-height: 1.15; font-weight: 800; letter-spacing: -.5px; }
h2 { margin: 6px 0 16px; font-size: 21px; font-weight: 800; }

.challenge {
  margin: 0 0 12px;
  padding: 9px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--coral);
  border-radius: 14px;
}

.howto { display: flex; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.howto li {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 3px 8px;
  background: var(--paper);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.25;
}
.howto img { display: block; width: 78%; height: auto; margin: 0 auto 5px; }
.howto b { display: block; font-weight: 800; word-break: keep-all; }
.howto span { color: var(--coral-deep); font-weight: 700; }

.tip { margin: 0 0 14px; font-size: 14px; line-height: 1.45; color: var(--ink-soft); word-break: keep-all; }
.tip b { color: #C96312; }

.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 12px;
  font: 800 19px/1.2 var(--font);
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { color: #fff; background: var(--coral); box-shadow: 0 5px 0 var(--coral-deep); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-deep); }
.btn.primary:disabled { color: #fff; background: #C9B3A0; box-shadow: 0 5px 0 #A8917F; cursor: default; }
.btn.ghost { margin-top: 12px; color: var(--ink); background: var(--paper); }
.btn.ghost:active { background: #F8DDA8; }
.btn:focus-visible { outline: 3px solid var(--night); outline-offset: 2px; }

.money { margin: 0; font-size: clamp(42px, 13vw, 54px); font-weight: 900; line-height: 1.1; color: #D9731A; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.rank {
  display: inline-block;
  margin: 6px 0 10px;
  padding: 5px 14px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: var(--night);
  border-radius: 999px;
  word-break: keep-all;
}
.versus { margin: 0 0 10px; font-size: 15px; font-weight: 800; color: var(--coral-deep); word-break: keep-all; }
.versus[hidden] { display: none; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 8px; }
.stats div { padding: 7px 2px; background: var(--paper); border-radius: 12px; }
.stats dt { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.stats dd { margin: 1px 0 0; font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }

.note { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); word-break: keep-all; }
.note:empty { display: none; }

.brag {
  margin: 0 0 12px;
  padding: 11px 13px;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 600;
  text-align: left;
  word-break: keep-all;
  background: #fff;
  border: 2px dashed #E8B874;
  border-radius: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.best { margin: 10px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.toast { margin: 6px 0 0; min-height: 18px; font-size: 13.5px; font-weight: 800; color: #2C8A5B; word-break: keep-all; }
.toast:empty { display: none; }

.btn.install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 15.5px;
  color: var(--night);
  background: transparent;
  border: 2px dashed #C9A27A;
  word-break: keep-all;
}
.btn.install[hidden] { display: none; }
.btn.install img { flex: none; width: 28px; height: 28px; border-radius: 7px; }
.btn.install:active { background: var(--paper); }

/* 데모 녹화용 자동 탭 표시 */
.tap-mark {
  position: fixed;
  z-index: 50;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  pointer-events: none;
  animation: tapmark .7s ease-out forwards;
}
@keyframes tapmark {
  0% { transform: scale(.55); opacity: 1; }
  30% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

#rotate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--cream);
  background: var(--night);
}
@media (orientation: landscape) and (max-height: 480px) { #rotate { display: flex; } }

@media (max-width: 340px) {
  .howto li { font-size: 11.5px; }
  .btn.install { gap: 6px; padding: 8px; font-size: 14px; letter-spacing: -.3px; }
  .btn.install img { width: 24px; height: 24px; }
}

@media (max-height: 620px) {
  .hero { width: 30%; }
  h1 { font-size: 27px; margin-bottom: 8px; }
  .card { padding: 12px 16px; }
  .tip { font-size: 13px; margin-bottom: 10px; }
  .money { font-size: 38px; }
  .rank { margin: 3px 0 6px; font-size: 15px; }
  .versus { margin-bottom: 6px; font-size: 14px; }
  .stats { margin-bottom: 6px; }
  .stats div { padding: 4px 2px; }
  .stats dd { font-size: 18px; }
  .note { margin-bottom: 6px; }
  .brag { margin-bottom: 8px; padding: 8px 11px; font-size: 14px; line-height: 1.35; }
  .btn { min-height: 48px; padding: 8px; font-size: 17px; }
  .btn.ghost { margin-top: 10px; }
  .best { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero, .card { animation: none; }
}

/* 광고 자리 (ads.js가 채움). 버튼과 24px 이상 떨어뜨려 실수로 누르지 않게 한다 */
.ad-slot { margin-top: 24px; min-height: 0; }
.ad-slot .ad-label { display: block; font-size: 11px; opacity: .55; text-align: center; margin-bottom: 4px; }
