/* KOMI & MOMO POP — 캔디처럼 밝은 합치기 퍼즐.
   기준 화면: 375×812 모바일 세로. 제목·점수·다음·게임판·진화표가 스크롤 없이 한 화면에 들어간다. */

:root {
  --pink: #FF5D9B;
  --pink-deep: #E22F76;
  --pink-soft: #FFD7E7;
  --pink-line: #FFDCEA;
  --cream: #FFF9F4;
  --ink: #3A2130;
  --ink-2: #8A5E75;
  --ink-3: #B98AA0;
  --shadow: 0 10px 30px rgba(226, 47, 118, .14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 12% 0%, #FFEAF4 0%, rgba(255, 234, 244, 0) 55%),
    radial-gradient(110% 70% at 92% 8%, #F1ECFF 0%, rgba(241, 236, 255, 0) 52%),
    radial-gradient(120% 90% at 50% 108%, #FFE7F2 0%, rgba(255, 231, 242, 0) 60%),
    #FFFCFF;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* 흐릿한 장식 방울 — 게임판 뒤 배경 */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(28px);
  opacity: .55;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 210px; height: 210px; left: -70px; top: 12%;
  background: radial-gradient(circle at 35% 35%, #FFC7DF, rgba(255, 199, 223, 0) 70%);
}
body::after {
  width: 240px; height: 240px; right: -90px; bottom: 8%;
  background: radial-gradient(circle at 60% 40%, #DCD2FF, rgba(220, 210, 255, 0) 70%);
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* ---------- 헤더 ---------- */
.top {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: clamp(15px, 4.5vw, 18px);
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.brand-paw {
  width: 20px; height: 20px;
  display: inline-flex;
  color: var(--pink);
  transform: rotate(-8deg);
}
.brand-paw svg { width: 100%; height: 100%; fill: currentColor; }
.brand-name { display: inline-flex; align-items: baseline; gap: 1px; }
.brand .amp {
  font-size: .78em;
  color: var(--pink);
  padding: 0 1px;
  transform: translateY(-1px);
}
.brand-pop {
  margin-left: 3px;
  padding: 3px 6px 3px 7px;
  border-radius: 8px 8px 8px 3px;
  background: linear-gradient(135deg, #FF7FB3, #FF4E92);
  color: #fff;
  font-size: .62em;
  font-weight: 900;
  letter-spacing: .06em;
  box-shadow: 0 3px 8px rgba(255, 78, 146, .35);
}

.tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid var(--pink-line);
  border-radius: 11px;
  background: #fff;
  color: var(--pink-deep);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(226, 47, 118, .07);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn .ico { width: 19px; height: 19px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; fill-rule: evenodd; }
.icon-btn .ico-on { display: none; }
.icon-btn[aria-pressed="true"] .ico-on { display: block; }
.icon-btn[aria-pressed="true"] .ico-off { display: none; }
.icon-btn .ico-on path:first-child { fill: currentColor; stroke: none; }
.icon-btn .ico-off path:first-child { fill: currentColor; stroke: none; }
.icon-btn .wave { fill: none; }

.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.lang-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 96px;
  max-width: 132px;
  height: 36px;
  padding: 0 26px 0 11px;
  border: 1px solid var(--pink-line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 2px 6px rgba(226, 47, 118, .07);
}
.lang-btn:active { transform: scale(.97); }
.lang-btn[aria-expanded="true"] { border-color: var(--pink); color: var(--pink-deep); }
.lang-cur {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lang-caret {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 11px; height: 11px;
  margin-top: -5.5px;
  pointer-events: none;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .16s ease;
}
.lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 198px;
  max-height: min(56vh, 336px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--pink-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(226, 47, 118, .2);
}
.lang-opt {
  display: block;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.lang-opt:active { background: #FFEFF6; }
.lang-opt[aria-selected="true"] {
  background: var(--pink-soft);
  color: var(--pink-deep);
  font-weight: 800;
}
.lang-opt:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }

/* ---------- 점수 / 다음 ---------- */
.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}
.hud-scores { display: flex; align-items: flex-end; gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 1px; line-height: 1; }
.stat-k {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .13em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.stat-v {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: transform .12s ease;
}
.stat-v.bump { animation: bump .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); color: var(--pink-deep); }
  100% { transform: scale(1); }
}
.stat-best .stat-v { font-size: 15px; color: var(--ink-2); padding-bottom: 2px; }

.next {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 11px;
  border: 1px solid var(--pink-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 3px 10px rgba(226, 47, 118, .08);
}
.next-k {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .13em;
  color: var(--ink-3);
  text-transform: uppercase;
}
#nextCv { width: 42px; height: 42px; display: block; }

/* ---------- 게임판 ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin-block: auto;   /* 높이를 제한했을 때 위아래 여백으로 가운데 */
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  border-radius: 26px;
}

/* ---------- 시작 / 결과 오버레이 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 26px;
  background: rgba(255, 247, 251, .72);
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
  transition: opacity .22s ease;
}
.overlay[hidden] { display: none; }

.panel {
  width: min(100%, 300px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  text-align: center;
}
.intro-art { width: 194px; height: 146px; display: block; margin-bottom: -8px; }

.panel-eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--pink-deep);
}
.panel-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  word-break: keep-all;
  max-width: 250px;
}
.panel-hint {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: -.01em;
}
.final-score {
  margin: 0;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -.04em;
  color: var(--pink-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.record {
  margin: 0;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #C98206;
  background: #FFF4D6;
  border: 1px solid #FFE3A3;
  border-radius: 999px;
  padding: 3px 10px;
}

.play-btn {
  margin-top: 4px;
  min-width: 156px;
  height: 46px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #FF7FB3, #FF4A8E);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 74, 142, .35), inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.play-btn:active { transform: translateY(1px) scale(.98); box-shadow: 0 4px 12px rgba(255, 74, 142, .3); }

.studio-link {
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid rgba(185, 138, 160, .35);
  padding-bottom: 1px;
}
.studio-link:hover { color: var(--pink-deep); border-bottom-color: var(--pink-soft); }

/* ---------- 진화표 ---------- */
.evo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 0;
  min-height: 30px;
}
.evo-k {
  white-space: nowrap;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--ink-3);
  text-transform: uppercase;
  flex: 0 0 auto;
}
.evo-track {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 1px;
}
.evo-item {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  min-width: 0;
}
.evo-cv { display: block; }
.evo-arrow {
  font-size: 8px;
  line-height: 1;
  color: #E7BFD1;
  padding-bottom: 4px;
  flex: 0 0 auto;
}

/* ---------- 데스크톱 ---------- */
@media (min-width: 720px) {
  body { align-items: center; }
  .app {
    height: min(900px, 94dvh);
    max-width: 440px;
    padding: 14px 16px 14px;
    border-radius: 32px;
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(255, 190, 218, .55);
    box-shadow: 0 30px 70px rgba(155, 60, 110, .16), 0 2px 0 #fff inset;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  .brand { font-size: 19px; }
  .stat-v { font-size: 25px; }
}

@media (max-height: 660px) {
  .brand { font-size: 15px; }
  .intro-art { width: 128px; height: 96px; }
  .panel { gap: 5px; }
  .final-score { font-size: 32px; }
  .play-btn { height: 42px; }
  .stat-v { font-size: 20px; }
  #nextCv { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .stat-v.bump { animation: none; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
