/* 스도쿠 template — slot 토큰 기반. spec_applier 가 :root 변수 치환. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #ffffff;
  --surface: #f0f0f0;
  --border-thin: #cccccc;
  --border-thick: #222222;
  --text: #191c1e;
  --text-dim: #666666;
  --accent: #0058be;
  --cell-bg: #ffffff;
  --cell-given: #f0f0f0;
  --cell-selected: #d0d0d0;
  --cell-highlight: #eeeeee;
  --cell-same: #dddddd;
  --cell-error: #ffe5e5;
  --note-color: #666666;
  --border: #45464d;
  --radius: 8px;
  --radius: 8px;
  --font-main: 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px;
  gap: 6px;
}

/* 헤더 */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  flex-shrink: 0;
  gap: 6px;
}
#header-left { display: flex; gap: 6px; }
#header-center { flex: 1; text-align: center; }
#header-right { display: flex; gap: 6px; }

#game-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text);
}

.header-btn {
  background: var(--surface);
  border: 1.5px solid var(--border-thick);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.4,0,0.2,1), transform 100ms;
}
.header-btn:active { background: var(--accent); color: var(--bg); transform: scale(0.96); }
.header-btn.icon { font-size: 18px; padding: 4px 8px; }

/* 정보 바 */
#info-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-thin);
  padding: 8px 0;
  flex-shrink: 0;
}
.info-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.info-label { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.info-value { font-size: 16px; font-weight: 800; color: var(--text); }

/* 캔버스 */
#canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
}
#sudoku-canvas {
  display: block;
  border: 2px solid var(--border-thick);
  border-radius: 4px;
  touch-action: none;
  background: var(--cell-bg);
}

/* 숫자 패드 */
#numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  flex-shrink: 0;
}
.num-btn {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1.5px solid var(--border-thick);
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  transition: background 150ms cubic-bezier(0.4,0,0.2,1), transform 100ms;
}
.num-btn:active { background: var(--accent); color: var(--bg); transform: scale(0.93); }
.num-btn.used { opacity: 0.35; }

/* 액션 바 */
#action-bar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-bottom: 8px;
}
.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--surface);
  border: 1.5px solid var(--border-thin);
  border-radius: var(--radius);
  padding: 8px 4px;
  color: var(--text);
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.4,0,0.2,1), transform 100ms;
}
.action-btn:active { background: var(--accent); color: var(--bg); transform: scale(0.95); }
.action-btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.action-btn.active .action-icon, .action-btn.active .action-label { color: var(--bg); }
.action-icon { font-size: 18px; }
.action-label { font-size: 11px; font-weight: 600; color: var(--text-dim); }

/* 모달 */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg);
  border: 2px solid var(--border-thick);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 82%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-title {
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text);
}
.modal-diff-btn {
  background: var(--surface);
  border: 1.5px solid var(--border-thin);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 150ms;
}
.modal-diff-btn:active { background: var(--accent); color: var(--bg); }
.modal-diff-btn.selected { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.modal-cancel-btn {
  background: none;
  border: 1.5px solid var(--border-thin);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 4px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.toggle-btn {
  background: var(--surface);
  border: 1.5px solid var(--border-thin);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  min-width: 56px;
}
.toggle-btn.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* 결과 오버레이 */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.overlay.hidden { display: none; }
.overlay-box {
  background: var(--bg);
  border: 2.5px solid var(--border-thick);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 80%;
  max-width: 300px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overlay-title { font-size: 24px; font-weight: 900; color: var(--text); }
.overlay-msg { font-size: 15px; color: var(--text-dim); }
.overlay-score { font-size: 20px; font-weight: 800; color: var(--text); }
.overlay-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}
