/* 레이아웃: 한 열 가운데 정렬. 제목 → HUD → 하늘(판) → 조작 → 설명.
   아트: 체스 × 모뉴먼트 밸리. 파스텔 바탕, 얇은 세리프 제목, 선은 가늘게, 그림자는 거의 없이. */
:root {
  --bg: #f4efe7;          /* 상아색 종이 */
  --fg: #2a2634;          /* 먹색 */
  --muted: #7d7588;
  --panel: #fbf8f3;
  --line: #e3dbcf;
  --accent: #c98b7b;      /* 탑의 분홍빛 테라코타 */
  --accent-ink: #fff8f2;
  --fwd: #4fbf87;         /* 앞 칸 민트 */
  --back: #5b9ee6;        /* 뒤 칸 하늘 */
  --font-display: 'Gowun Batang', 'Noto Serif KR', Georgia, serif;
  --font-body: 'Noto Sans KR', system-ui, -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1927; --fg: #ece6f0; --muted: #9d96ad; --panel: #262436; --line: #39354d;
    --accent: #e0a090; --accent-ink: #1b1927; --fwd: #4fbf87; --back: #5b9ee6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1927; --fg: #ece6f0; --muted: #9d96ad; --panel: #262436; --line: #39354d;
  --accent: #e0a090; --accent-ink: #1b1927; --fwd: #4fbf87; --back: #5b9ee6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 22px 44px;
}
.app { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }

.top { display: grid; gap: 2px; }
.top h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
  margin: 0;
  letter-spacing: 0.08em;
  text-wrap: balance;
}
.top .tagline { margin: 0; color: var(--muted); letter-spacing: 0.02em; }

.hud {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  font-variant-numeric: tabular-nums;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.hud-level { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-level button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--fg); cursor: pointer; font-size: 12px;
}
.hud-level button:disabled { opacity: 0.3; cursor: default; }
.hud-level span { font-weight: 400; letter-spacing: 0.02em; }
.hud-time { font-family: var(--font-display); font-size: 28px; line-height: 1; letter-spacing: 0.12em; }
.hud-moves { color: var(--muted); }
.hud-moves span { color: var(--fg); font-weight: 500; font-size: 18px; }

.sky {
  position: relative;
  border-radius: 26px;
  padding: 10px 10px 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #f2c3a2 0%, #f9e7d4 100%);
}
canvas#board { display: block; width: 100%; height: auto; margin: 0 auto; touch-action: manipulation; }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(42,38,52,0.42); padding: 16px;
}
.overlay .card {
  background: var(--panel); color: var(--fg);
  border-radius: 20px; padding: 26px 30px; display: grid; gap: 12px; text-align: center;
  min-width: min(100%, 260px);
  box-shadow: 0 16px 48px rgba(30,20,50,0.25);
}
.overlay h2 { font-family: var(--font-display); font-weight: 400; font-size: 32px; margin: 0; line-height: 1; letter-spacing: 0.1em; }
.overlay p { margin: 0; color: var(--muted); }
.overlay .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

button.btn {
  font-family: var(--font-body);
  font-size: 15px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer;
  touch-action: manipulation;
}
button.btn.primary { background: var(--fg); color: var(--bg); border-color: transparent; }

.pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  width: 100%; max-width: 400px; margin: 0 auto;
}
.pad button {
  font-family: var(--font-body);
  display: grid; justify-items: center; gap: 2px;
  padding: 11px 0 9px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.pad button .k { font-size: 24px; line-height: 1; }
.pad button .l { font-size: 12px; color: var(--muted); }
.pad button.fwd { background: var(--fwd); color: #fff; border-color: transparent; }
.pad button.back { background: var(--back); color: #fff; border-color: transparent; }
.pad button.fwd .l, .pad button.back .l { color: #fff; opacity: 0.92; }
.pad button:active { transform: translateY(1px); }

button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.keys { margin: 0; text-align: center; color: var(--muted); font-size: 12px; letter-spacing: 0.02em; }
.keys kbd {
  font-family: var(--font-body); font-size: 11px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 0 5px; background: var(--panel); color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  .pad button:active { transform: none; }
}
