/* Blossom Burst G0 — 논리 360×800 무대(#stage)를 JS가 배율로 맞춘다. 좌표는 G0 계약 1장. */
:root {
  --ink: #2f2a24;
  --ink-soft: #6b6258;
  --paper: #fffaf1;
  --accent: #e9577a;
  --sun: #f5b82e;
  --sky: #3e95e6;
  --letterbox: #cfdcbf;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--letterbox);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#safe-probe {
  position: fixed;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 360px;
  height: 800px;
  transform-origin: 0 0;
  overflow: hidden;
  background: #e3edd4;
  box-shadow: 0 0 24px rgba(60, 80, 40, 0.18);
}

#game-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 360px;
  height: 800px;
  touch-action: none;
  display: block;
}

/* HUD는 판 입력을 가리지 않게 기본 pointer-events 없음, 버튼만 받는다 */
#top-bar, #goal-panel, #guide-text, #bottom-bar, #wave-badge { position: absolute; pointer-events: none; }
button, .overlay, input, label { pointer-events: auto; }

#top-bar { left: 12px; right: 12px; top: 12px; height: 48px; display: flex; align-items: center; justify-content: space-between; }
#level-name { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
#btn-settings {
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: rgba(255, 255, 255, 0.75); color: var(--ink); font-size: 14px; cursor: pointer;
}

#goal-panel { left: 0; top: 0; width: 360px; height: 180px; }
#goal-list { list-style: none; margin: 0; padding: 0; }
.goal { position: absolute; width: 28px; height: 28px; }
.goal .icon { width: 28px; height: 28px; display: block; }
.goal .count {
  position: absolute; left: 32px; top: 0; height: 28px; line-height: 28px;
  font-size: 22px; font-weight: 800; min-width: 28px; font-variant-numeric: tabular-nums;
}
.goal.done .count { color: #4f8f3c; }
.goal .icon { transition: transform 50ms ease-out; }
.goal.bump .icon { transform: scale(1.08); }
.goal.flash .icon { outline: 1px solid #426F61; border-radius: 6px; }
#moves-box {
  position: absolute; width: 80px; height: 68px;
  display: grid; grid-template-columns: 28px 1fr; grid-template-rows: 44px 20px; align-items: center; justify-items: center;
}
#moves-box .icon { width: 28px; height: 28px; grid-row: 1; grid-column: 1; }
#moves-count { grid-row: 1; grid-column: 2; font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; }
#moves-box small { grid-row: 2; grid-column: 1 / span 2; font-size: 12px; color: var(--ink-soft); }
#moves-box.low #moves-count { color: #c0453f; }
/* 연쇄 재생 중 이동 0: 경고 빨강 대신 잉크색 + "연쇄 진행 중"(계약 v3 8항) */
#moves-box.chain #moves-count { color: #344F48; }
#moves-box.chain small { font-size: 13px; font-weight: 600; color: #426F61; white-space: nowrap; }

#wave-badge {
  left: 0; right: 0; top: 160px; margin: 0 auto; width: 96px; text-align: center;
  font-size: 15px; font-weight: 800; color: #9a5d00; background: rgba(255, 236, 170, 0.92);
  border-radius: 12px; padding: 3px 0;
}

#guide-text {
  left: 24px; right: 24px; top: 540px; height: 64px; margin: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 17px; font-weight: 600; color: var(--ink);
  white-space: pre-line;
}
#guide-text.multi { font-size: 15px; line-height: 1.35; }

#bottom-bar { left: 18px; right: 18px; top: 704px; height: 72px; display: flex; gap: 12px; }
#bottom-bar button {
  flex: 1; height: 56px; margin-top: 8px; border: 0; border-radius: 18px;
  background: rgba(255, 255, 255, 0.82); color: var(--ink); font: inherit; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
#bottom-bar .icon { width: 24px; height: 24px; }

button:focus-visible { outline: 3px solid #3e95e6; outline-offset: 2px; }

.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(46, 58, 36, 0.42);
}
.overlay[hidden] { display: none; }
#settings-screen { z-index: 12; }
#levels-screen { z-index: 14; }
.card {
  width: 300px; max-height: 720px; overflow: auto;
  background: var(--paper); border-radius: 22px; padding: 22px 20px 18px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.card.wide { width: 330px; }
.card h2 { margin: 0 0 4px; font-size: 24px; }
.card p { margin: 0 0 6px; color: var(--ink-soft); }
.card button {
  height: 48px; border-radius: 14px; border: 0; background: #ece4d6; color: var(--ink);
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
}
.card button.primary { background: var(--accent); color: #fff; }
.card .note { color: var(--ink-soft); font-size: 12px; }
.opt { display: flex; align-items: center; gap: 10px; justify-content: flex-start; padding: 6px 4px; font-size: 16px; }
.opt input { width: 22px; height: 22px; }

#level-list { display: flex; flex-direction: column; gap: 8px; }
.level-item {
  height: auto !important; text-align: left; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.level-item b { font-size: 16px; }
.level-item span { font-size: 13px; color: var(--ink-soft); }
.level-item small { font-size: 12px; font-weight: 500; color: var(--ink-soft); }

#result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 8px; }
#result-stats div { background: #f3ecdf; border-radius: 12px; padding: 8px 4px; }
#result-stats dt { font-size: 12px; color: var(--ink-soft); }
#result-stats dd { margin: 0; font-size: 22px; font-weight: 800; }
#result-screen[data-result="win"] h2 { color: #4f8f3c; }

#error-banner {
  position: absolute; left: 12px; right: 12px; top: 612px; z-index: 20;
  background: #fde2e1; color: #8a1f1b; border-radius: 12px; padding: 8px 10px; font-size: 13px;
}
#error-banner[hidden] { display: none; }

#debug-panel {
  position: absolute; left: 6px; bottom: 98px; z-index: 30; margin: 0;
  font: 10px/1.35 ui-monospace, Consolas, monospace; color: #fff; background: rgba(0, 0, 0, 0.62);
  padding: 5px 7px; border-radius: 8px; pointer-events: none; white-space: pre; max-width: 348px; overflow: hidden;
}
#debug-panel[hidden] { display: none; }

#fx-top {
  position: absolute; left: 0; top: 0; width: 360px; height: 800px;
  pointer-events: none; z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .goal .icon { transition: none; }
}
