:root {
  --bg: #f4f7f8;
  --fg: #23343a;
  --muted: #6f838b;
  --line: #ccd8dc;
  --board-bg: #e6eef0;
  --island: #ffffff;
  --island-line: #7d949c;
  --bridge: #4a6a74;
  --guide: #bccdd2;
  --done: #2f7d8c;
  --done-soft: #d5eaee;
  --wrong: #c2567a;
  --pick: #d98324;
  --btn-bg: #3f5a63;
  --btn-fg: #f2f7f8;
  --sheet-bg: #ffffff;
  --pad-x: clamp(10px, 4vmin, 28px);
  --app-max: 440px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151b1d;
    --fg: #dde7ea;
    --muted: #7f9299;
    --line: #2e3a3e;
    --board-bg: #1d2528;
    --island: #2a3438;
    --island-line: #5d7178;
    --bridge: #93aab3;
    --guide: #33434a;
    --done: #5fb9c9;
    --done-soft: #22383e;
    --wrong: #e07a9c;
    --pick: #eda340;
    --btn-bg: #3a4e56;
    --sheet-bg: #212a2d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  display: flex;
  justify-content: center;
  padding: clamp(10px, 3vmin, 24px) var(--pad-x);
}

.app {
  width: min(100%, var(--app-max));
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vmin, 14px);
}

/* 헤더 배치는 모든 게임이 같다. 양옆을 1fr로 묶으면 좌우 폭이 달라도 이름이
   가운데에 온다. */
.title-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.title-row h1 { text-align: center; }
.title-row .head-nav { justify-self: start; }
.head-nav { display: flex; align-items: center; gap: 14px; }
.title-row .head-actions { justify-self: end; }

h1 {
  margin: 0;
  font-size: clamp(24px, 6vmin, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.head-actions { display: flex; align-items: baseline; gap: 14px; }

.toggle {
  border: 0; background: none; padding: 0;
  color: inherit; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; opacity: 0.6;
}
.toggle:hover { opacity: 1; }
.toggle.sound { font-size: 12px; }
.toggle.sound[aria-pressed="false"] { opacity: 0.38; text-decoration: line-through; }

.back {
  color: inherit; opacity: 0.6; text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.back:hover { opacity: 1; }

.picker-row { display: flex; align-items: center; gap: 10px; }
.picker { display: flex; gap: 4px; }

.pick {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}

.pick[aria-pressed="true"] {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}

.best { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); }
.timer { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.board-wrap { position: relative; }

.board {
  display: block;
  width: 100%;
  height: auto;
  background: var(--board-bg);
  border-radius: 14px;
}

/* 다리. 두 개는 나란한 두 줄로 그린다 — 굵기로 가르면 하나인지 둘인지 세어야 한다. */
.bridge { stroke: var(--bridge); stroke-width: 5; stroke-linecap: round; }

/* 다리를 놓을 수 있는 자리. 아무것도 없는 판은 섬만 떠 있어 어디를 눌러야 하는지가
   보이지 않는다 — 누를 곳을 점선으로 깔아 두면 첫 수를 설명 없이 찾는다. 다리가
   놓이거나 양쪽 섬이 다 차면 감춰, 남은 자리만 눈에 들어오게 한다. */
.guide { stroke: var(--guide); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0 13; }

/* 누르는 자리. 두 섬 사이의 좁은 통로라 손가락이 닿게 칸 하나만큼 넓게 깐다. */
.hit { fill: transparent; cursor: pointer; }

.island { fill: var(--island); stroke: var(--island-line); stroke-width: 3; }
/* 숫자를 다 채운 섬. 색이 바뀌면 남은 섬만 눈에 들어온다. */
.island.done { fill: var(--done-soft); stroke: var(--done); }

/* 고른 섬과 거기서 이을 수 있는 섬. 다 채운 섬(--done)과 다른 색을 쓴다 — 같은 색이면
   고른 것인지 다 채운 것인지 갈리지 않는다. */
.island.picked { stroke: var(--pick); stroke-width: 5; }
.island.near { stroke: var(--pick); stroke-dasharray: 4 4; }
.guide.hot { stroke: var(--pick); stroke-dasharray: 0 9; }

.count {
  font-size: 42px; font-weight: 800;
  text-anchor: middle; dominant-baseline: central;
  fill: var(--fg);
  pointer-events: none;
}
.count.done { fill: var(--done); }

.toast {
  margin: 0; min-height: 18px;
  font-size: 13px; font-weight: 600; text-align: center; color: var(--muted);
}

.pad { display: flex; flex-direction: column; gap: 8px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.tool {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: none;
  color: inherit;
  font-family: inherit;
  padding: 9px 4px;
  cursor: pointer;
}
.tool-icon { display: block; }
.tool-icon svg { width: 19px; height: 19px; }
.tool-label { font-size: 11px; font-weight: 600; opacity: 0.8; }
.tool:disabled { opacity: 0.35; cursor: default; }

/* 도움말 시트. 껍데기는 shared/sheet.css, 결과 덮개는 shared/result.css. */
.sheet {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sheet-bg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet[hidden] { display: none; }

.sheet-title { margin: 0; font-size: 19px; font-weight: 800; }
.sheet-note { margin: 0; font-size: 14px; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; }

.btn {
  flex: 1;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.help-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.help-list li { margin-bottom: 6px; }
