/* 모모쿠 커넥트 — 스타일
   브랜드 기준: 배경 #e7d5cd · 숫자 #fe3b5b(흰 테두리) · 한글 ONE Mobile POP · 숫자 Baloo 2 */

@font-face {
  font-family: 'OneMobilePop';
  src: url('../assets/font/ONE Mobile POP.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Baloo2';
  src: url('../assets/font/Baloo2-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Baloo2';
  src: url('../assets/font/Baloo2-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-display: swap;
}

:root {
  --bg: #e7d5cd;
  --bg-deep: #d8c0b5;
  --ink: #4a3a34;
  --ink-soft: #8a7368;
  --hot: #fe3b5b;
  --grape: #7960b0;
  --panel: #fffaf7;
  --line: rgba(122, 92, 78, .18);
  --shadow: 0 6px 0 rgba(122, 92, 78, .22);
}

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

html, body {
  height: 100%;
  /* 모바일 브라우저는 주소창이 접혔다 펴지면서 100% 가 실제 보이는 높이와
     어긋난다. dvh 는 그 변화를 따라가므로 판 아랫부분이 잘리지 않는다. */
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'OneMobilePop', 'Malgun Gothic', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 바탕은 모모쿠 머지의 장(腸) 배경을 가져다 쓴다.
   세로로 긴 그림이라 가로 화면에선 가운데가 잘리는데, 가장자리 장식은
   어차피 HUD 에 가려지므로 cover 로 채우고 위에 부드러운 막을 덮는다. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('../assets/ui/board-back.webp') center / cover no-repeat;
  opacity: .85;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 250, 247, .34), transparent 62%),
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, .32), transparent 42%);
  pointer-events: none;
}

/* 배치 — 모바일이 기본이다.
 *
 * 세로로 긴 화면에서는 위아래로 쌓는다.  HUD / 보드 / 도감
 * 넓은 화면에서는 보드를 왼쪽에 크게 두고 나머지를 오른쪽 기둥으로 세운다.
 * 아래쪽 min-width 미디어 쿼리에서 영역만 다시 그리면 된다.
 *
 * 보드 크기는 CSS 가 아니라 Render.layout() 이 stage-wrap 의 실제 크기를 재서
 * 정한다. 그래서 여기서 칸을 어떻게 나누든 판은 남는 자리에 맞춰 커진다. */
#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "hud"
    "stage"
    "dex";
  transition: filter .25s ease;
}
#app.dimmed { filter: blur(3px) saturate(.7); pointer-events: none; }

#hud { grid-area: hud; }
#stage-wrap { grid-area: stage; }
#dex { grid-area: dex; }

/* ── HUD ──────────────────────────────────────────────── */

/* index.html 이 viewport-fit=cover 라 노치와 홈 인디케이터 아래까지 그려진다.
   가장자리에 붙는 HUD 와 도감만 안전 영역만큼 밀어 준다. */
#hud {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: rgba(255, 250, 247, .72);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(6px);
}

.hud-title {
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
  letter-spacing: .5px;
  color: var(--hot);
}
.hud-title span { display: block; font-size: 13px; color: var(--grape); letter-spacing: 3px; }
.hud-sub { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }

.hud-stats { display: flex; gap: 10px; margin-left: auto; }

.stat {
  min-width: 74px;
  padding: 5px 12px;
  text-align: right;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
}
.stat-label { display: block; font-size: 10px; color: var(--ink-soft); letter-spacing: 1px; }
.stat-value {
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 20px;
  line-height: 1.1;
  color: var(--hot);
  -webkit-text-stroke: 3px #fff;
  paint-order: stroke fill;
}
.stat-tiles .stat-value { color: var(--grape); -webkit-text-stroke-width: 2px; }

/* 시간 보너스 — 스테이지 모드에만 붙는다(.has-bonus).
   "지금 깨면 받을 점수"가 0.1초마다 깎이는 걸 보여주는 게 이 게임의 재촉 장치라,
   HUD 에서 가장 크고 눈에 띄는 숫자여야 한다. 경과 시간은 그 아래로 물러난다. */
.stat-time { min-width: 104px; }
#stat-bonus { display: none; }
.stat-time.has-bonus #stat-bonus {
  display: block;
  font-size: 26px;
  letter-spacing: -.5px;
  -webkit-text-stroke: 4px #fff;
}
.stat-time.has-bonus #stat-time {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-soft);
  -webkit-text-stroke: 0;
}

/* 바닥나면 실패가 아니라 "더 받을 게 없다" 이므로, 빨간 경고가 아니라
   숫자를 흐려서 알린다. */
.stat-time.over #stat-bonus { color: var(--ink-soft); -webkit-text-stroke-width: 3px; }

.hud-right { display: flex; gap: 8px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(122, 92, 78, .18);
  transition: transform .1s ease, box-shadow .1s ease, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: default; }
.btn b { font-family: 'Baloo2', sans-serif; color: var(--hot); margin-left: 3px; }

.btn-primary {
  background: var(--hot);
  color: #fff;
  border-color: rgba(0, 0, 0, .08);
  font-size: 16px;
  padding: 13px 30px;
  box-shadow: 0 4px 0 #c22843;
}
.btn-primary:active { box-shadow: none; }
.btn-ghost { background: transparent; }
.btn-link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: 13px;
}

/* ── 콤보 ─────────────────────────────────────────────── */

/* stage-wrap 안에 있으므로 좌우 어느 배치에서든 보드 기준으로 가운데 잡힌다 */
#combo-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 30;
  padding: 6px 20px;
  border-radius: 999px;
  background: var(--grape);
  color: #fff;
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
}
#combo-banner.show { animation: comboPop 1.3s ease forwards; }
@keyframes comboPop {
  0%   { opacity: 0; transform: translate(-50%, 4px) scale(.7); }
  18%  { opacity: 1; transform: translate(-50%, -6px) scale(1.12); }
  32%  { transform: translate(-50%, -6px) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(1); }
}

/* ── 강아지 마스코트 ──────────────────────────────────── */

#mascot {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease;
}
#mascot.show { opacity: 1; transform: translateY(0); }

.mascot-bubble {
  min-width: 96px;
  max-width: 200px;
  min-height: 58px;
  padding: 14px 18px 20px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
  background: url('../assets/ui/bubble.png') center / 100% 100% no-repeat;
}
.mascot-dog {
  width: 54px;
  height: 54px;
  margin-left: 10px;
  background: url('../assets/ui/dog.png') center / contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(90, 60, 46, .3));
}
#mascot.pop .mascot-bubble { animation: bubblePop .4s cubic-bezier(.34, 1.5, .5, 1); }
#mascot.pop .mascot-dog { animation: dogHop .45s cubic-bezier(.34, 1.5, .5, 1); }
@keyframes bubblePop {
  0%   { transform: scale(.5) translateY(14px); }
  60%  { transform: scale(1.08) translateY(-2px); }
  100% { transform: scale(1); }
}
@keyframes dogHop {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-9px); }
}

/* ── 사운드 버튼 ──────────────────────────────────────── */

.sound-row { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; }
.sound-btn {
  width: 96px;
  height: 52px;
  border: none;
  padding: 0;
  background: center / contain no-repeat;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease;
}
.sound-btn:active { transform: translateY(3px); }
#btn-bgm { background-image: url('../assets/ui/bgm_on.png'); }
#btn-bgm.off { background-image: url('../assets/ui/bgm_off.png'); }
#btn-sfx { background-image: url('../assets/ui/sfx_on.png'); }
#btn-sfx.off { background-image: url('../assets/ui/sfx_off.png'); }
.sound-btn.off { filter: grayscale(.55) opacity(.75); }

/* ── 보드 ─────────────────────────────────────────────── */

#stage-wrap {
  position: relative;          /* 마스코트를 이 영역 기준으로 붙인다 */
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 8px;
}

#board {
  position: relative;
  border-radius: 18px;
  /* 장 배경 위에 얹히므로 살짝 불투명한 크림빛 판을 깔아 패를 읽기 쉽게 한다 */
  background: linear-gradient(rgba(255, 250, 247, .62), rgba(255, 244, 238, .42));
  backdrop-filter: blur(2px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6), 0 8px 30px rgba(122, 60, 70, .2);
  transition: box-shadow .3s ease;
}
#board::before {
  /* 패가 놓이는 안쪽 구역 표시 — 바깥은 경로가 도는 여백(BOARD_MARGIN) */
  content: '';
  position: absolute;
  inset: var(--margin, var(--cell));
  border-radius: 10px;
  background: rgba(216, 192, 181, .32);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45);
}
#board.danger {
  box-shadow: inset 0 0 0 3px rgba(254, 59, 91, .55), 0 8px 26px rgba(254, 59, 91, .3);
  animation: dangerPulse 1.1s ease-in-out infinite;
}
@keyframes dangerPulse { 50% { box-shadow: inset 0 0 0 5px rgba(254, 59, 91, .8), 0 8px 30px rgba(254, 59, 91, .45); } }

#tiles, #fx-layer { position: absolute; inset: 0; }
#fx-layer { pointer-events: none; z-index: 25; }
#link-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: visible; }

/* ── 패 ───────────────────────────────────────────────── */

.tile {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .22s cubic-bezier(.34, 1.4, .5, 1), opacity .3s ease;
}
.tile:focus-visible {
  outline: 3px solid var(--grape);
  outline-offset: -4px;
  border-radius: 14px;
}
/* idle 스프라이트 재생.
   시트는 8프레임이 가로로 이어진 한 장이다. background-size 를 800% 로 두면
   프레임 하나가 딱 요소 너비만큼 보이고, background-position-x 를 0%→100% 로
   밀면 첫 프레임에서 마지막 프레임까지 지나간다.
   steps(8, jump-none) 은 양 끝을 포함해 8칸으로 끊으므로 프레임에 정확히 맞는다. */
.sprite {
  background-repeat: no-repeat;
  background-size: 800% 100%;
  background-position: 0% 50%;
  filter: drop-shadow(0 2px 2px rgba(90, 60, 46, .3));
  animation: momoIdle var(--idle-dur, 1200ms) steps(8, jump-none) var(--idle-delay, 0ms) infinite;
  pointer-events: none;
}
@keyframes momoIdle {
  from { background-position-x: 0%; }
  to   { background-position-x: 100%; }
}

/* 단계 클래스가 붙기 전의 기본값일 뿐이다.
   실제로 화면에 나오는 크기는 아래 .tile.stage-N 세 줄이 정한다. */
.tile .sprite { width: 94%; height: 94%; }
.tile-ring {
  position: absolute;
  inset: 6%;
  border-radius: 14px;
  border: 3px solid transparent;
  transition: border-color .15s ease, background .15s ease;
  pointer-events: none;
}
.tile.selected .tile-ring {
  border-color: var(--hot);
  background: rgba(254, 59, 91, .14);
  animation: ringPulse .8s ease-in-out infinite;
}
@keyframes ringPulse { 50% { border-color: #ff92a8; } }

/* 단계가 높을수록 크고 진하게.
   여기가 판 위 모모쿠의 실제 크기다 — 위의 .tile .sprite 는 덮인다.
   한 눈에 단계를 구분할 수 있어야 하므로 이웃한 단계끼리 충분히 벌린다.
   2단계를 3단계와 구분되게 줄였더니(76%→68%) 이번엔 1단계가 붙어 보여서
   1단계도 같은 비율로 내렸다(62%→56%). 위로 갈수록 벌어지는 사다리다.

   누르는 영역은 이 크기와 무관하다 — .tile 이 칸 전체를 덮고 스프라이트는
   pointer-events: none 이라, 그림을 줄여도 손가락으로 누를 자리는 그대로다. */
.tile.stage-1 .sprite { width: 56%; height: 56%; }
.tile.stage-2 .sprite { width: 68%; height: 68%; }
.tile.stage-3 .sprite { width: 94%; height: 94%; }

.tile-in { animation: tileIn .32s cubic-bezier(.34, 1.5, .5, 1); }
@keyframes tileIn { from { opacity: 0; } }

.tile-pop { animation: tilePop .46s cubic-bezier(.34, 1.5, .5, 1); }
@keyframes tilePop {
  0%   { filter: brightness(2.2); }
  30%  { filter: brightness(1.4); }
  100% { filter: none; }
}
/* 승급 팝. idle 재생을 멈추면 안 되므로 두 애니메이션을 함께 건다.
   하나는 background-position, 하나는 transform 이라 서로 안 부딪힌다. */
.tile-pop .sprite {
  animation:
    momoIdle var(--idle-dur, 1200ms) steps(8, jump-none) var(--idle-delay, 0ms) infinite,
    tilePopImg .46s cubic-bezier(.34, 1.6, .5, 1);
}
@keyframes tilePopImg {
  0%   { transform: scale(.55) rotate(-8deg); }
  55%  { transform: scale(1.28) rotate(4deg); }
  100% { transform: scale(1); }
}

.tile-out { opacity: 0; pointer-events: none; }

.tile-nope { animation: nope .38s ease; }
@keyframes nope {
  0%, 100% { margin-left: 0; }
  20% { margin-left: -6px; }
  50% { margin-left: 6px; }
  80% { margin-left: -3px; }
}

/* ── 연결선 ───────────────────────────────────────────── */

.link { transition: opacity .2s ease; }
.link.link-fade { opacity: 0; }
.link polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.link-under { stroke: #fff; stroke-width: 11; }
.link-core { stroke: var(--hot); stroke-width: 5; }
.link-turn { fill: #fff; stroke: var(--hot); stroke-width: 3; }
.link-hint .link-core { stroke: var(--grape); stroke-dasharray: 9 7; animation: dash 1s linear infinite; }
.link-hint .link-turn { stroke: var(--grape); }
@keyframes dash { to { stroke-dashoffset: -32; } }

/* ── 이펙트 ───────────────────────────────────────────── */

.float-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Baloo2', 'OneMobilePop', sans-serif;
  font-weight: 800;
  white-space: nowrap;
  animation: floatUp 1.1s ease-out forwards;
}
.ft-gain { font-size: 20px; color: var(--hot); -webkit-text-stroke: 4px #fff; paint-order: stroke fill; }
.ft-birth { font-size: 17px; color: var(--grape); -webkit-text-stroke: 4px #fff; paint-order: stroke fill; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  22%  { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  35%  { transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

.birth-burst {
  position: absolute;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .95), rgba(255, 214, 102, .55) 45%, transparent 70%);
  animation: burst .9s ease-out forwards;
}
@keyframes burst {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.birth-momoku {
  position: absolute;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px rgba(90, 60, 46, .35));
  /* 떠오르면서 계속 움직인다 — 태어난 순간이라 idle 을 빠르게 돌린다 */
  animation:
    momoIdle 620ms steps(8, jump-none) infinite,
    birthRise 1.4s cubic-bezier(.2, 1.2, .4, 1) forwards;
}
@keyframes birthRise {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.3) rotate(-14deg); }
  25%  { opacity: 1; transform: translate(-50%, -70%) scale(1.15) rotate(4deg); }
  45%  { transform: translate(-50%, -78%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(.9); }
}

/* ── 도감 ─────────────────────────────────────────────── */

#dex {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  background: rgba(255, 250, 247, .72);
  border-top: 2px solid var(--line);
}
.dex-label { font-size: 13px; color: var(--ink); line-height: 1.35; }
.dex-label small { display: block; font-size: 10px; color: var(--ink-soft); }
.dex-list { display: flex; gap: 8px; flex-wrap: wrap; }

.dex-item {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(216, 192, 181, .35);
  border: 2px solid var(--line);
}
.dex-item .sprite { width: 74%; height: 74%; opacity: .3; filter: grayscale(1) opacity(.5); transition: .25s; }
.dex-item.got .sprite { opacity: 1; filter: drop-shadow(0 2px 2px rgba(90, 60, 46, .3)); }
.dex-count {
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 20px;
  padding: 0 4px;
  text-align: center;
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: #c6c6c6;
  background: #fff;
  border-radius: 8px;
  border: 2px solid var(--line);
}
.dex-item.got .dex-count { color: var(--grape); }

/* 어떤 먹이에서 태어난 모모쿠인지 — 머지 쪽 설정을 그대로 따른다 */
.dex-food {
  position: absolute;
  left: -5px;
  top: -6px;
  font-size: 13px;
  line-height: 1;
  opacity: .35;
  filter: grayscale(1);
  transition: .25s;
}
.dex-item.got .dex-food { opacity: 1; filter: none; }

/* ── 오버레이 화면 ────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(74, 58, 52, .3);
  overflow: auto;
}
.screen.show { display: grid; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } }

.panel {
  width: min(560px, 100%);
  padding: 30px 28px;
  text-align: center;
  background: var(--panel);
  border-radius: 24px;
  border: 3px solid rgba(122, 92, 78, .16);
  box-shadow: 0 14px 40px rgba(74, 58, 52, .3);
  animation: panelIn .3s cubic-bezier(.3, 1.3, .5, 1);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }

.title-logo {
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 42px;
  line-height: .95;
  color: var(--hot);
  -webkit-text-stroke: 6px #fff;
  paint-order: stroke fill;
}
.title-logo span { display: block; font-size: 26px; color: var(--grape); letter-spacing: 8px; }
.title-tag { margin: 14px 0 22px; font-size: 14px; color: var(--ink-soft); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card {
  padding: 20px 14px;
  font-family: inherit;
  text-align: center;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .15s;
}
.mode-card:hover { border-color: var(--hot); }
.mode-card:active { transform: translateY(5px); box-shadow: none; }
.mode-name { font-size: 22px; color: var(--hot); margin-bottom: 6px; }
.mode-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }

.best-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 20px 0 8px; }
.best-item {
  padding: 6px 12px;
  background: rgba(216, 192, 181, .3);
  border-radius: 10px;
  font-size: 11px;
  color: var(--ink-soft);
}
.best-item b {
  display: block;
  font-family: 'Baloo2', sans-serif;
  font-size: 18px;
  color: var(--hot);
}

/* 방법 설명 */
.panel-howto { text-align: left; }
.panel-howto h2 { text-align: center; font-size: 24px; color: var(--hot); margin-bottom: 18px; }
.howto-list { padding-left: 22px; font-size: 14px; line-height: 1.85; color: var(--ink); }
.howto-list li { margin-bottom: 8px; }
.howto-list b { color: var(--hot); }
.howto-chain { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 20px 0; }
.chain-step { text-align: center; font-size: 10px; color: var(--ink-soft); }
.chain-step .sprite { width: 46px; height: 46px; margin-bottom: 3px; }
.chain-step b { display: block; font-size: 11px; color: var(--ink); }
.chain-arrow { color: var(--ink-soft); font-size: 18px; }
.panel-howto .btn-primary { display: block; margin: 0 auto; }

/* 결과 */
.result-badge {
  font-family: 'Baloo2', sans-serif;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 2px;
  -webkit-text-stroke: 5px #fff;
  paint-order: stroke fill;
}
.result-badge.ok { color: var(--hot); }
.result-badge.over { color: var(--grape); }
.result-momoku { width: 96px; height: 96px; margin: 10px auto; }

/* 결과 화면의 강아지 한마디 */
.result-say {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 2px;
  font-size: 14px;
  color: var(--ink-soft);
}
.result-say::before {
  content: '';
  width: 40px;
  height: 40px;
  flex: none;
  background: url('../assets/ui/dog.png') center / contain no-repeat;
}
.result-say span {
  padding: 8px 16px;
  border-radius: 14px;
  background: rgba(216, 192, 181, .3);
}
.result-stats { margin: 16px 0 22px; }
.rstat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px dashed var(--line);
}
.rstat small { display: block; font-size: 10px; opacity: .75; }
.rstat b { font-family: 'Baloo2', sans-serif; font-size: 20px; color: var(--ink); }
.rstat.total b { font-size: 26px; color: var(--hot); }
.rstat.fresh { justify-content: center; color: var(--hot); font-size: 15px; border: none; }
.rstat.reason { justify-content: center; font-size: 12px; border: none; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 200;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(74, 58, 52, .9);
  color: #fff;
  font-size: 13px;
  transition: opacity .4s ease, transform .4s ease;
}
.toast.out { opacity: 0; transform: translate(-50%, -10px); }

/* ── 모션 최소화 ──────────────────────────────────────── */

/* 움직임을 줄여 달라고 한 사용자에게는 첫 프레임에서 멈춰 세운다.
   스프라이트 시트라서 재생만 끄면 정지 그림이 그대로 나온다. */
@media (prefers-reduced-motion: reduce) {
  .sprite { animation-play-state: paused !important; }
  #combo-banner, .tile-in, .tile-pop, .link-hint .link-core { animation-duration: .01ms !important; }
  #board.danger { animation: none; }
}

/* ── 좁은 화면 ────────────────────────────────────────── */

/* 폰에서는 세로가 병목이다. 판이 세로로 길어서 위아래를 HUD 와 도감이
   가져가는 만큼 패가 그대로 작아진다. 그래서 이 둘을 최대한 얇게 깐다. */
@media (max-width: 720px) {
  #hud { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .hud-stats { order: 3; width: 100%; margin-left: 0; justify-content: space-between; gap: 6px; }
  .stat { min-width: 0; flex: 1; padding: 2px 6px; border-radius: 10px; }
  .stat-label { font-size: 9px; letter-spacing: 0; }
  .stat-value { font-size: 15px; -webkit-text-stroke-width: 2px; }
  /* 좁아져도 시간 보너스는 크게 남긴다 — 이게 줄어드는 걸 봐야 서두르게 된다 */
  .stat-time { flex: 1.5; }
  .stat-time.has-bonus #stat-bonus { font-size: 21px; -webkit-text-stroke-width: 3px; }
  .stat-time.has-bonus #stat-time { font-size: 10px; }
  .hud-title { font-size: 16px; }
  .hud-sub { margin-top: 2px; }
  .btn { padding: 7px 12px; }
  .dex-label { display: none; }
  #dex { justify-content: center; padding: 4px 10px; }
  .dex-item { width: 34px; height: 34px; }
  .dex-count { font-size: 11px; min-width: 17px; bottom: -4px; }
  .mode-grid { grid-template-columns: 1fr; }
  .title-logo { font-size: 32px; }
  .sound-btn { width: 82px; height: 44px; }
  /* 좁은 화면에선 말풍선이 판을 가린다. 강아지만 남기고 작게. */
  #mascot { left: 8px; bottom: 6px; transform-origin: left bottom; scale: .82; }
  .mascot-bubble { max-width: 150px; font-size: 12px; }

  /* 판에 한 뼘이라도 더 준다 */
  #stage-wrap { padding: 4px; }
  #combo-banner { top: 4px; font-size: 16px; padding: 5px 16px; }
}

/* ── 넓은 화면 — 좌우 배치 ────────────────────────────── */

/* 세로로 쌓으면 보드가 위아래로 눌리고 좌우는 텅 빈다.
   가로가 넉넉해지는 순간부터 보드를 왼쪽에 몰고 나머지를 오른쪽 기둥으로 세운다.
   보드가 정사각형에 가까워서 이쪽이 같은 화면에서 판을 훨씬 크게 준다. */
@media (min-width: 900px) {
  #app {
    grid-template-columns: 1fr clamp(240px, 23vw, 320px);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "stage hud"
      "stage dex";
  }

  #stage-wrap { padding: 18px; }

  /* HUD — 가로 줄에서 세로 기둥으로 */
  #hud {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px 16px;
    padding-top: max(18px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    border-left: 2px solid var(--line);
  }
  .hud-left { text-align: center; }
  .hud-title { font-size: 26px; }
  .hud-title span { font-size: 15px; }
  .hud-sub { margin-top: 6px; font-size: 13px; }

  /* 넷을 한 줄로 늘어놓으면 기둥 폭에서 숫자가 잘린다. 2×2 로 접는다. */
  .hud-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-left: 0;
  }
  .stat { min-width: 0; }

  .hud-right { flex-direction: column; }
  .hud-right .btn { width: 100%; }

  /* 도감 — 기둥 아래쪽을 채운다 */
  #dex {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    padding-right: max(16px, env(safe-area-inset-right));
    border-top: none;                /* 위 HUD 의 아래 테두리와 겹친다 */
    border-left: 2px solid var(--line);
  }
  .dex-label { text-align: center; }
  .dex-list { justify-content: center; }
}
