:root {
  --bg: #f5f3ee;
  --fg: #2c3138;
  --muted: #7e858d;
  --line: #d6d2c8;
  --room: #fbfaf6;
  --lit: #fbe8a6;
  --wall: #2f3a44;
  --bulb: #e8a317;
  --bulb-base: #5b646d;
  --mark: #9aa3ab;
  --grid: #d8d2c4;
  --frame: #2f3a44;
  --clue: #f5f3ee;
  --clue-done: #7f8a94;
  --bad: #d4452f;
  --hint: #bfe0c8;
  --btn-bg: #3f4750;
  --btn-fg: #f7f8f9;
  --sheet-bg: #ffffff;

  --pad-x: clamp(10px, 4vmin, 28px);
  --app-max: 460px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --fg: #dfe3e7;
    --muted: #848b93;
    --line: #2d3136;
    --room: #23272b;
    --lit: #5a4c1e;
    --wall: #0c0e10;
    --bulb: #f2bb3c;
    --bulb-base: #9aa3ab;
    --mark: #6d757c;
    --grid: #33383d;
    --frame: #8a939b;
    --clue: #e6e9ec;
    --clue-done: #5b6167;
    --bad: #e8634e;
    --hint: #2f5a3c;
    --btn-bg: #353d45;
    --sheet-bg: #1f2327;
  }
}

* { 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);
}

/* 헤더 배치는 모든 게임이 같다. */
.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(20px, 5.2vmin, 30px);
  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 { font-size: 12px; font-weight: 600; color: var(--muted); }

.timer {
  margin-inline-start: auto;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.board-wrap { position: relative; display: flex; justify-content: center; }

/* 끌어서 점을 찍는 판이라 스크롤·확대에 넘기지 않는다. 이 자리에는 click으로 도는
   조작을 두지 않는다 — shared/base.js가 touchend를 취소해 click이 나지 않는다. */
.board {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.board svg { display: block; overflow: visible; }

/* 칸마다 바탕·전구·점을 미리 그려 두고 보이기만 바꾼다. 손가락 밑의 요소를 갈아 끼우지
   않는다(저장소 규칙). */
.room { fill: var(--room); }
.room.lit { fill: var(--lit); }
.room.hinted { fill: var(--hint); }
.wall { fill: var(--wall); }
.bulb { visibility: hidden; }
.bulb.on { visibility: visible; }
.bulb-glass { fill: var(--bulb); }
.bulb-base { fill: var(--bulb-base); }
.bulb.bad .bulb-glass { fill: var(--bad); }
.nobulb { fill: var(--mark); visibility: hidden; }
.nobulb.on { visibility: visible; }
.grid { stroke: var(--grid); fill: none; }
.frame { stroke: var(--frame); fill: none; }

.clue {
  fill: var(--clue);
  font-family: inherit;
  font-weight: 700;
  text-anchor: middle;
}
.clue.done { fill: var(--clue-done); }
.clue.over { fill: var(--bad); }

.toast {
  margin: 0;
  min-height: 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}
.toast b { color: var(--fg); }

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

.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: 8px 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; }
.btn {
  flex: 1;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* 도움말 시트. 껍데기는 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; }

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