/* 오디씨 키우기 — 게임 화면 레이아웃 (2026-11-19 다시 짬)
   방향: 다마고치 기기가 주인공. 라일락→분홍 하늘, 뒤에 흐르는 큰 글씨, 도트 글꼴의 작은 HUD.
   행동 버튼은 기기에 있는 것만 써요(화면에 따로 두지 않아요). 장식은 적게. */
:root {
  --ink: #323329;
  --lilac: #BFADFF;
  --lilac-deep: #9F8BFF;
  --lilac-soft: #E6DEFF;
  --pink: #FFC4D0;
  --pink-deep: #FF9DBA;
  --cream: #FFFDF8;
  --px: "Galmuri11", "Pretendard Variable", Pretendard, system-ui, sans-serif;
  --px-big: "Galmuri14", "Galmuri11", "Pretendard Variable", sans-serif;
  --gut: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  font-family: "Pretendard Variable", Pretendard, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  position: relative; /* 배경(.sky)을 화면이 아니라 본문 상자에 맞춰요 */
  background: linear-gradient(180deg, #C9B9FF 0%, #E2D6FF 36%, #FBE3F0 74%, #FFF0F6 100%);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── 배경 ── */
.sky { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; transition: opacity .6s; }
/* 옅은 격자: 가운데만 보이고 가장자리로 사라져요 */
.sky::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.34) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.34) 1px, transparent 1px);
  background-size: 30px 30px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 46%, #000 20%, transparent 78%); mask-image: radial-gradient(ellipse 80% 60% at 50% 46%, #000 20%, transparent 78%);
}
/* 기기 뒤의 부드러운 빛 */
.sky::after { content: ""; position: absolute; left: 50%; top: 46%; width: min(120vw, 620px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,255,255,.85), rgba(255,255,255,.35) 55%, rgba(255,255,255,0)); }
.bigword { position: absolute; left: 0; white-space: nowrap; transform: translateY(-50%); }
.bigword.a { top: 27%; }
.bigword.b { top: 80%; }
/* 로고처럼 통통하고 말랑한 소문자(Modak). 기기 위아래로 한 줄씩, 서로 반대로 천천히 흘러요 */
.bigword span { display: inline-block; font-family: "Modak", "Pretendard Variable", sans-serif; font-weight: 400; font-size: clamp(96px, 29vw, 180px); letter-spacing: -.035em; line-height: 1; color: rgba(255,255,255,.55); animation: drift 70s linear infinite; }
.bigword.b span { animation-direction: reverse; animation-duration: 85s; color: rgba(255,255,255,.62); }
.bigword i { font-style: normal; font-family: system-ui, sans-serif; font-size: .42em; vertical-align: .32em; color: rgba(255,255,255,.75); }
@keyframes drift { to { transform: translateX(-50%); } }

/* 반짝이: 네 갈래 별, 작은 빛 알갱이, 천천히 떠오르는 가루 (위치·크기는 app.js가 뿌려요) */
.sparks i { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); pointer-events: none; }
.sparks .star { background: var(--c, #fff); clip-path: polygon(50% 0, 59% 41%, 100% 50%, 59% 59%, 50% 100%, 41% 59%, 0 50%, 41% 41%); filter: drop-shadow(0 0 6px rgba(255,255,255,.9)); animation: twinkle var(--d) steps(4) var(--delay) infinite; }
.sparks .dot { border-radius: 50%; background: radial-gradient(closest-side, #fff, rgba(255,255,255,.7) 40%, rgba(255,255,255,0)); animation: glint var(--d) ease-in-out var(--delay) infinite; }
.sparks .dust { border-radius: 50%; background: #fff; opacity: 0; animation: rise var(--d) linear var(--delay) infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(.35) rotate(0deg); opacity: .35; } 50% { transform: scale(1) rotate(20deg); opacity: 1; } }
@keyframes glint { 0%, 100% { transform: scale(.4); opacity: .2; } 50% { transform: scale(1.25); opacity: 1; } }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateY(-140px); opacity: 0; } }
/* 재웠을 때: 하늘이 살짝 저물어요 */
body.night { background: linear-gradient(180deg, #8E82D6 0%, #B5A4EE 40%, #E7CFEA 100%); }
body.night .bigword span { color: rgba(255,255,255,.2); }

/* ── 위쪽 ── */
.top { position: relative; z-index: 3; width: 100%; max-width: 480px; display: flex; align-items: center; gap: 8px; padding: 12px var(--gut) 4px; }
.logo img { display: block; height: 24px; width: auto; }
.chip { font-family: var(--px); font-size: 11px; letter-spacing: .08em; padding: 2px 8px 1px; background: var(--cream); border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); }
.menu-btn { margin-left: auto; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; background: var(--cream); border: 2px solid var(--ink); border-radius: 50%; box-shadow: 0 3px 0 var(--ink); }
.menu-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.menu { position: absolute; top: 54px; right: max(var(--gut), calc(50vw - 224px)); z-index: 10; display: flex; flex-direction: column; min-width: 170px; overflow: hidden;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); font-family: var(--px); font-size: 13px; }
.menu > button, .menu > a { padding: 11px 14px; text-align: left; background: none; border: 0; border-top: 1.5px solid rgba(50,51,41,.14); text-decoration: none; cursor: pointer; }
.menu > :first-child { border-top: 0; }
.menu .danger { color: #B23A48; }
.debug { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 10px 12px; background: var(--lilac-soft); font-size: 11px; }
.debug span { width: 100%; opacity: .7; }
.debug button { padding: 3px 7px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--cream); font-size: 11px; cursor: pointer; }

/* ── 본문 ── */
.stage { position: relative; z-index: 2; flex: 1; width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; padding: 0 var(--gut); min-height: 0; }

/* 게이지 HUD: 캡슐 3개 */
.hud { width: 100%; padding-top: 8px; }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 0; } /* 캡슐 아래 그림자(3px)만큼 더 띄워요 */
.g-pill { width: 100%; display: flex; align-items: center; gap: 5px; padding: 4px 8px 4px 5px; background: rgba(255,253,248,.86); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.g-ico { width: 17px; height: 17px; flex: none; }
.g-bar { position: relative; flex: 1; height: 10px; min-width: 0; border: 1.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.g-bar i { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 999px; background: linear-gradient(180deg, #D9CEFF 0 38%, var(--lilac) 38% 100%); transition: width .4s steps(5); }
.gauge.low .g-bar i { background: linear-gradient(180deg, #FFDCE6 0 38%, var(--pink-deep) 38% 100%); }
.g-num { font-family: var(--px); font-size: 11px; min-width: 19px; text-align: right; font-variant-numeric: tabular-nums; }
.g-label { font-family: var(--px); font-size: 10px; letter-spacing: .04em; opacity: .7; }
.gauge.low .g-label { color: #B23A48; opacity: 1; }
.gauge.low .g-pill { animation: nudge 1.2s steps(2) infinite; }
@keyframes nudge { 50% { transform: translateY(-2px); } }

/* 게임 제목(로그인 전) */
.game-title { display: none; margin: 14px 0 0; text-align: center; font-family: var(--px-big); font-weight: 400; font-size: 42px; line-height: 1.14; letter-spacing: .02em; color: var(--ink);
  /* 스티커처럼: 먹색 글자 + 흰 테두리 + 아래 분홍 그림자 */
  text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 3px 3px #fff, -3px 3px #fff, 3px -3px #fff, -3px -3px #fff, 0 8px 0 var(--pink-deep), 3px 8px 0 var(--pink-deep), -3px 8px 0 var(--pink-deep); }
body.title .game-title { display: block; }

/* 기기 */
.play { position: relative; flex: 1; width: 100%; min-height: 300px; display: flex; flex-direction: column; }
.viewport { position: relative; flex: 1; min-height: 0; width: 100%; touch-action: none; cursor: grab; }
.viewport:active { cursor: grabbing; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.viewport:not(.ready)::before { content: "오디씨 데려오는 중…"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--px); font-size: 13px; opacity: .7; }
/* 버튼을 누르면 터지는 작은 별 */
.burst { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.burst i { position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px; background: var(--c, #fff); clip-path: polygon(50% 0, 59% 41%, 100% 50%, 59% 59%, 50% 100%, 41% 59%, 0 50%, 41% 41%); filter: drop-shadow(0 0 4px #fff); animation: pop .6s steps(6) forwards; }
@keyframes pop { 0% { transform: translate(var(--x0), var(--y0)) scale(.3); opacity: 1; } 100% { transform: translate(var(--x1), var(--y1)) scale(1.2) rotate(40deg); opacity: 0; } }
/* 버튼 이름표: 기기 버튼 바로 아래에 붙어요 (위치는 app.js가 잡아요) */
.tags span { position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; font-family: var(--px); font-size: 11px; line-height: 1; padding: 3px 7px 2px; white-space: nowrap;
  background: var(--cream); border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); will-change: transform; }
.tags span.hit { background: var(--pink); }
body.title .tags { display: none; }
.hint { margin: 0; text-align: center; font-family: var(--px); font-size: 10px; letter-spacing: .04em; opacity: 0; animation: hint 7s 1.5s both; pointer-events: none; }
@keyframes hint { 10%, 75% { opacity: .6; } 100% { opacity: 0; } }

/* 말풍선 */
/* 말풍선은 기기 고리 바로 위에 붙어요(세로 위치는 app.js가 기기 위치에 맞춰 잡아요) */
.bubble { position: absolute; left: 50%; top: 64px; z-index: 3; transform: translate(-50%, -100%); max-width: min(86%, 300px); width: max-content; padding: 8px 14px 7px; text-align: center;
  font-family: var(--px); font-size: 14px; line-height: 1.35; background: var(--cream); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 0 3px 0 var(--ink);
  opacity: 0; transition: opacity .15s steps(2); pointer-events: none; }
.bubble.on { opacity: 1; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: var(--cream); border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateX(-50%) rotate(45deg); }

/* 돌본 횟수 */
.since { margin: 4px 0 0; min-height: 22px; font-family: var(--px); font-size: 11px; letter-spacing: .03em; }
.since:not(:empty) { padding: 3px 10px 2px; background: rgba(255,253,248,.7); border: 1.5px solid var(--ink); border-radius: 999px; }
.since:not(:empty)::before { content: "♥ "; color: var(--pink-deep); }
body.title .since { display: none; }

/* 로그인(시작 화면) */
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 4px; }
.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.5; padding: 8px 12px; background: rgba(255,253,248,.72); border-radius: 14px; cursor: pointer; }
.agree input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); flex: none; }
.play-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 13px 18px 12px; text-decoration: none;
  font-family: var(--px-big); font-size: 17px; letter-spacing: .02em; color: var(--ink);
  background: linear-gradient(180deg, #FFE1EA 0 44%, var(--pink) 44% 100%); border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: 0 5px 0 var(--ink); }
.play-btn svg { background: #fff; padding: 3px; width: 26px; height: 26px; border: 1.5px solid var(--ink); border-radius: 50%; }
.play-btn b { font-weight: 400; animation: nudge 1s steps(2) infinite; }
.play-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.play-btn[aria-disabled="true"] { background: linear-gradient(180deg, #F4F1FA 0 44%, #E4DFF0 44% 100%); color: rgba(50,51,41,.55); box-shadow: 0 3px 0 rgba(50,51,41,.55); border-color: rgba(50,51,41,.55); }
.play-btn[aria-disabled="true"] b { animation: none; }
.inapp { width: 100%; padding: 12px 14px; background: #FFFDF8; border: 2px solid var(--ink); border-radius: 16px; box-shadow: 0 3px 0 var(--ink); font-size: 13px; line-height: 1.55; text-align: center; }
.inapp p { margin: 0 0 10px; }
.inapp-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.inapp-open, .inapp-copy { font: inherit; font-family: var(--px); font-size: 13px; color: var(--ink); text-decoration: none; padding: 8px 14px; border: 1.5px solid var(--ink); border-radius: 999px; background: #BFADFF; cursor: pointer; }
.inapp-copy { background: #fff; }
.login-note { margin: 0; min-height: 1.4em; font-family: var(--px); font-size: 12px; color: #B23A48; text-align: center; }

.foot { position: relative; z-index: 2; padding: 8px var(--gut) calc(12px + env(safe-area-inset-bottom)); font-size: 11px; color: rgba(50,51,41,.6); text-align: center; }

@media (prefers-reduced-motion: reduce) { .bigword span, .sparks i, .play-btn b, .gauge.low .g-pill { animation: none; } .sparks .dust { display: none; } }
@media (max-height: 640px) { .game-title { font-size: 28px; margin-top: 6px; } .play { min-height: 240px; } }
