/* =====================================================
   한자·한글 스도쿠 — 책나무 그린 × 인디고 × TOSS 스타일
   ===================================================== */

:root {
  /* 한자 모드 — 책나무 그린 */
  --hanja-900: #1B4332;
  --hanja-700: #2D7D4E;
  --hanja-600: #2E7D32;
  --hanja-500: #388E3C;
  --hanja-400: #4CAF50;
  --hanja-200: #A5D6A7;
  --hanja-100: #C8E6C9;
  --hanja-50:  #E8F5E9;
  --hanja-10:  #F1F8E9;

  /* 한글 모드 — 인디고/블루 */
  --hangul-900: #1E1B4B;
  --hangul-700: #3730A3;
  --hangul-600: #4338CA;
  --hangul-500: #6366F1;
  --hangul-400: #818CF8;
  --hangul-200: #C7D2FE;
  --hangul-100: #E0E7FF;
  --hangul-50:  #EEF2FF;
  --hangul-10:  #F5F3FF;

  /* 공통 */
  --amber: #F59E0B;
  --red:   #EF4444;
  --blue:  #3B82F6;
  --text-900: #111827;
  --text-700: #374151;
  --text-500: #6B7280;
  --text-300: #D1D5DB;
  --white: #FFFFFF;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 14px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.13);
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --font: 'Apple SD Gothic Neo','Noto Sans KR','Malgun Gothic',sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: #F8F9FA; color: var(--text-900); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }

/* ===== 화면 전환 ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: fadeIn .18s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake  { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse  { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ===== 공통 컴포넌트 ===== */
.app-header {
  background: var(--white);
  border-bottom: 1px solid #E5E7EB;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 520px; margin: 0 auto;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
}
.header-back {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-700);
  flex-shrink: 0; transition: background .14s;
}
.header-back:hover { background: #F3F4F6; }
.header-center { flex: 1; min-width: 0; }
.header-title { font-size: 17px; font-weight: 700; color: var(--text-900); }
.header-sub { font-size: 12px; color: var(--text-500); margin-top: 1px; }

/* ===== 로그인 ===== */
#screen-login {
  background: linear-gradient(150deg, var(--hanja-700) 0%, var(--hanja-500) 55%, var(--hanja-400) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px;
}
#screen-login.active { display: flex; }

.login-logo { text-align: center; margin-bottom: 36px; color: var(--white); }
.logo-icon  { font-size: 60px; margin-bottom: 10px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)); }
.logo-title { font-size: 30px; font-weight: 900; letter-spacing: -0.5px; }
.logo-subtitle { font-size: 14px; opacity: .9; margin-top: 6px; }

.login-card {
  background: var(--white); border-radius: var(--radius-xl);
  padding: 30px 26px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-card p  { font-size: 13px; color: var(--text-500); margin-bottom: 24px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-700); margin-bottom: 7px; }
.form-input {
  width: 100%; padding: 13px 15px;
  border: 2px solid var(--hanja-100); border-radius: var(--radius);
  font-size: 16px; color: var(--text-900); background: var(--hanja-10);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.form-input:focus { border-color: var(--hanja-400); box-shadow: 0 0 0 3px rgba(76,175,80,.15); background: var(--white); }
.input-hint { font-size: 11px; color: var(--text-500); margin-top: 5px; }
.login-error { min-height: 18px; font-size: 12px; color: var(--red); text-align: center; margin-bottom: 14px; font-weight: 500; }
.login-error.shake { animation: shake .3s ease; }
.btn-primary {
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, var(--hanja-600), var(--hanja-400));
  color: var(--white); border-radius: var(--radius); font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(46,125,50,.35); transition: transform .14s, box-shadow .14s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(46,125,50,.4); }

/* ===== 홈 ===== */
#screen-home { background: #F8F9FA; }

.home-header {
  background: linear-gradient(130deg, var(--hanja-700), var(--hanja-500));
  padding: 28px 20px 32px;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.home-greeting h2 { font-size: 22px; font-weight: 800; color: var(--white); }
.home-greeting p  { font-size: 13px; color: rgba(255,255,255,.85); margin-top: 3px; }
.home-logout-btn {
  padding: 7px 13px; border-radius: 99px;
  background: rgba(255,255,255,.2); color: var(--white);
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  transition: background .15s;
}
.home-logout-btn:hover { background: rgba(255,255,255,.3); }

.home-body { padding: 0 16px 40px; max-width: 520px; margin: 0 auto; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -18px 0 18px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); text-align: center;
}
.stat-num   { font-size: 28px; font-weight: 900; color: var(--hanja-600); }
.stat-label { font-size: 11px; color: var(--text-500); margin-top: 2px; }

.time-setting-row {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.time-label { font-size: 14px; font-weight: 600; color: var(--text-700); }
.select-time {
  padding: 9px 13px; border: 2px solid #E5E7EB;
  border-radius: var(--radius-sm); font-size: 13px;
  color: var(--text-700); background: #F9FAFB;
  cursor: pointer; outline: none; min-width: 100px;
}
.select-time:focus { border-color: var(--hanja-400); }

.section-title { font-size: 15px; font-weight: 700; color: var(--text-700); margin-bottom: 12px; }

/* 모드 카드 */
.mode-card {
  background: var(--white); border-radius: var(--radius-lg);
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
  cursor: pointer; overflow: hidden;
  border: 2px solid transparent; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.mode-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.mode-card.hanja:hover  { border-color: var(--hanja-200); }
.mode-card.hangul:hover { border-color: var(--hangul-200); }

.mode-card-top {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 14px;
}
.mode-big-badge {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; flex-shrink: 0;
}
.mode-big-badge.hanja  { background: var(--hanja-50);  color: var(--hanja-700); }
.mode-big-badge.hangul { background: var(--hangul-50); color: var(--hangul-700); }

.mode-card-info { flex: 1; }
.mode-card-title { font-size: 18px; font-weight: 800; color: var(--text-900); }
.mode-card-desc  { font-size: 12px; color: var(--text-500); margin-top: 3px; line-height: 1.5; }

.mode-card-arrow { font-size: 20px; color: var(--text-300); flex-shrink: 0; }

.mode-card-bottom { padding: 0 18px 16px; }
.mode-card-stat-row { display: flex; justify-content: space-between; margin-bottom: 7px; }
.mode-card-completed { font-size: 12px; color: var(--text-500); }
.mode-card-score     { font-size: 12px; font-weight: 700; }
.mode-card.hanja  .mode-card-score { color: var(--hanja-600); }
.mode-card.hangul .mode-card-score { color: var(--hangul-600); }

.mode-progress-bar {
  height: 5px; border-radius: 99px; overflow: hidden;
}
.mode-progress-bar.hanja  { background: var(--hanja-100); }
.mode-progress-bar.hangul { background: var(--hangul-100); }
.mode-progress-fill {
  height: 100%; border-radius: 99px; transition: width .5s ease;
}
.mode-progress-fill.hanja  { background: linear-gradient(90deg, var(--hanja-600), var(--hanja-400)); }
.mode-progress-fill.hangul { background: linear-gradient(90deg, var(--hangul-600), var(--hangul-400)); }

/* ===== 난이도 선택 ===== */
#screen-difficulty { background: #F8F9FA; }

/* 난이도 화면 헤더 배지 */
.diff-badge {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; flex-shrink: 0;
}
.diff-badge.hanja  { background: var(--hanja-50);  color: var(--hanja-700); }
.diff-badge.hangul { background: var(--hangul-50); color: var(--hangul-700); }

.diff-body { padding: 20px 16px 40px; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

.diff-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 18px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm); cursor: pointer; border: 2px solid transparent;
  transition: transform .13s, box-shadow .13s, border-color .13s;
}
.diff-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--text-300); }

.diff-card-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.diff-icon { font-size: 30px; flex-shrink: 0; }
.diff-name { font-size: 18px; font-weight: 800; }
.diff-name.beginner    { color: var(--hanja-600); }
.diff-name.intermediate{ color: var(--amber); }
.diff-name.advanced    { color: var(--red); }
.diff-desc { font-size: 12px; color: var(--text-500); margin-top: 2px; }

.diff-card-right { flex-shrink: 0; min-width: 80px; text-align: right; }
.diff-stats { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 7px; align-items: baseline; }
.diff-card-prog  { font-size: 13px; font-weight: 800; color: var(--text-700); }
.diff-card-score { font-size: 11px; color: var(--text-500); }
.diff-bar { height: 5px; background: #E5E7EB; border-radius: 99px; overflow: hidden; width: 80px; }
.diff-bar-fill {
  height: 100%; border-radius: 99px; transition: width .5s ease;
}
.diff-bar-fill.beginner     { background: var(--hanja-400); }
.diff-bar-fill.intermediate { background: var(--amber); }
.diff-bar-fill.advanced     { background: var(--red); }

/* ===== 스테이지 선택 ===== */
#screen-levels { background: #F8F9FA; }

.level-badge-pill {
  padding: 5px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.level-badge-pill.hanja  { background: var(--hanja-50);  color: var(--hanja-700); }
.level-badge-pill.hangul { background: var(--hangul-50); color: var(--hangul-700); }

.stages-container { padding: 16px; max-width: 520px; margin: 0 auto; padding-bottom: 40px; }

.set-label {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 99px; margin: 14px 0 7px; display: inline-block;
}
.set-label.hanja  { background: var(--hanja-100);  color: var(--hanja-700); }
.set-label.hangul { background: var(--hangul-100); color: var(--hangul-700); }

/* 스테이지 그리드: 4열, 버튼 2배 크기 */
.stage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.stage-btn {
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; gap: 5px; transition: transform .12s, box-shadow .12s;
  min-height: 72px; padding: 10px 6px;
}
.stage-btn.available { background: var(--white); color: var(--text-700); box-shadow: var(--shadow-sm); border: 2px solid #E5E7EB; }
.stage-btn.available:hover { transform: scale(1.05); box-shadow: var(--shadow); }
.stage-btn.available.hanja  { border-color: var(--hanja-200);  color: var(--hanja-700); }
.stage-btn.available.hangul { border-color: var(--hangul-200); color: var(--hangul-700); }
.stage-btn.completed { color: var(--white); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.stage-btn.completed.hanja  { background: linear-gradient(135deg, var(--hanja-600),  var(--hanja-400)); }
.stage-btn.completed.hangul { background: linear-gradient(135deg, var(--hangul-600), var(--hangul-400)); }
.stage-btn.completed:hover { transform: scale(1.05); }
.stage-btn.locked { background: #F3F4F6; color: var(--text-300); cursor: not-allowed; }
.stage-num   { font-size: 24px; font-weight: 900; line-height: 1; }
.stage-stars { font-size: 14px; letter-spacing: 2px; }
.lock-icon   { font-size: 18px; }

/* ===== 게임 화면 ===== */
#screen-game { background: #F8F9FA; }

.game-top-bar {
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.game-top-bar.mode-hanja  { background: var(--hanja-700); }
.game-top-bar.mode-hangul { background: var(--hangul-700); }

.game-top-inner {
  max-width: 520px; margin: 0 auto;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.game-back {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: rgba(255,255,255,.9); flex-shrink: 0;
}
.game-back:hover { background: rgba(255,255,255,.15); }
.game-info { flex: 1; min-width: 0; }
.game-stage-label { font-size: 14px; font-weight: 800; color: var(--white); }
.game-set-theme   { font-size: 11px; color: rgba(255,255,255,.75); }
.game-stats { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.game-stat-badge {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.9); background: rgba(255,255,255,.18);
  padding: 3px 8px; border-radius: 99px;
}
.game-timer {
  font-size: 18px; font-weight: 800; color: var(--white);
  font-variant-numeric: tabular-nums; min-width: 50px; text-align: right;
}
.game-timer.timer-warning { color: #FCA5A5; animation: pulse 1s ease-in-out infinite; }

.game-body { max-width: 520px; margin: 0 auto; padding: 10px 14px 40px; }

/* 참고 패널 */
.ref-panel {
  background: var(--white); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
}
.ref-panel-title { font-size: 11px; font-weight: 700; color: var(--text-500); margin-bottom: 8px; letter-spacing: .3px; }
.hanja-reference { display: flex; flex-wrap: wrap; gap: 5px; }

.ref-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: #F9FAFB; border: 1px solid transparent;
  cursor: default; transition: all .14s;
  flex: 1; min-width: calc(33% - 4px);
}
.ref-item.active { background: var(--hanja-100); border-color: var(--hanja-300); }
.mode-hangul .ref-item.active { background: var(--hangul-100); border-color: var(--hangul-300); }

.ref-char {
  font-size: 22px; font-weight: 900; color: var(--hanja-700);
  line-height: 1; min-width: 26px; text-align: center;
}
.ref-char-hangul { font-size: 14px; font-weight: 800; color: var(--hangul-700); min-width: 36px; }
.ref-info { min-width: 0; }
.ref-reading { display: block; font-size: 10px; font-weight: 700; color: var(--hanja-600); }
.ref-meaning { display: block; font-size: 9px; color: var(--text-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-hangul .ref-reading { color: var(--hangul-600); }

/* 보드 */
.board-wrapper {
  background: var(--white); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); margin-bottom: 10px;
}
/* 기본: 한자 9×9 정사각형 보드 */
#sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  width: 100%;
  aspect-ratio: 1;
}
/* 한글 2칸 보드: aspect-ratio 자동, 18열로 전환 */
#sudoku-board.board-2cell {
  grid-template-columns: repeat(18, 1fr) !important;
  aspect-ratio: auto !important;
  gap: 2px;
}
.cell {
  border: 1px solid #E5E7EB; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; background: var(--white);
  transition: background .1s; position: relative;
}
.cell:hover { background: #F9FAFB; }
.cell.box-top    { border-top:    2px solid var(--hanja-400); }
.cell.box-left   { border-left:   2px solid var(--hanja-400); }
.cell.box-bottom { border-bottom: 2px solid var(--hanja-400); }
.cell.box-right  { border-right:  2px solid var(--hanja-400); }
.board-hangul .cell.box-top    { border-top:    2px solid var(--hangul-400); }
.board-hangul .cell.box-left   { border-left:   2px solid var(--hangul-400); }
.board-hangul .cell.box-bottom { border-bottom: 2px solid var(--hangul-400); }
.board-hangul .cell.box-right  { border-right:  2px solid var(--hangul-400); }

.cell.initial { background: var(--hanja-10); }
.cell.initial .cell-char { color: var(--hanja-800); font-weight: 900; }
.board-hangul .cell.initial { background: var(--hangul-10); }
.board-hangul .cell.initial .cell-char { color: var(--hangul-800); }

.cell.selected.hanja  { background: var(--hanja-200) !important;  border-color: var(--hanja-500)  !important; z-index: 2; }
.cell.selected.hangul { background: var(--hangul-200) !important; border-color: var(--hangul-500) !important; z-index: 2; }
.cell.related    { background: #F3F4F6; }
.cell.same-value { background: var(--hanja-50); }
.board-hangul .cell.same-value { background: var(--hangul-50); }
.cell.error { background: #FEE2E2; }
.cell.error .cell-char { color: var(--red) !important; }

.cell-char {
  font-size: clamp(12px, 3.5vw, 22px); font-weight: 700;
  color: var(--hanja-700); line-height: 1;
}
.cell-char-hangul {
  font-size: clamp(9px, 2.5vw, 14px); font-weight: 800;
  color: var(--hangul-700);
}
.cell-sub {
  font-size: clamp(6px, 1.4vw, 9px); color: var(--text-500);
  line-height: 1; max-width: 100%; overflow: hidden; text-align: center;
}

/* 메모 */
.note-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; width: 100%; height: 100%; padding: 1px; }
.note-dot  { font-size: clamp(5px, 1.2vw, 8px); color: transparent; display: flex; align-items: center; justify-content: center; }
.note-dot.visible { color: var(--hanja-500); font-weight: 700; }
.board-hangul .note-dot.visible { color: var(--hangul-500); }

/* 입력 패드 */
.pad-section {
  background: var(--white); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow-sm); margin-bottom: 10px;
}
.pad-title { font-size: 11px; font-weight: 700; color: var(--text-500); margin-bottom: 10px; }
#hanja-pad { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; }

.pad-btn {
  padding: 8px 3px; border-radius: var(--radius-sm);
  background: #F9FAFB; border: 1.5px solid #E5E7EB;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; transition: all .12s;
}
.pad-btn.hanja:hover  { background: var(--hanja-50);  border-color: var(--hanja-200); }
.pad-btn.hangul:hover { background: var(--hangul-50); border-color: var(--hangul-200); }
.pad-btn.hanja.active  { background: var(--hanja-500);  border-color: var(--hanja-600); }
.pad-btn.hangul.active { background: var(--hangul-500); border-color: var(--hangul-600); }
.pad-btn.active .pad-char, .pad-btn.active .pad-ko { color: var(--white); }
.pad-erase { background: #FEF2F2; border-color: #FECACA; }
.pad-erase .pad-char { color: var(--red); }
.pad-erase .pad-ko   { color: #F87171; }
.pad-erase:hover { background: #FEE2E2; }

.pad-char { font-size: clamp(16px,4vw,22px); font-weight: 900; color: var(--hanja-700); line-height: 1; }
.pad-char-hangul { font-size: clamp(11px,2.8vw,15px); font-weight: 800; color: var(--hangul-700); }
.pad-btn.hangul .pad-char { color: var(--hangul-700); }
.pad-ko   { font-size: 9px; color: var(--text-500); font-weight: 600; line-height: 1; }

/* 컨트롤 */
.game-controls { display: flex; gap: 8px; }
.ctrl-btn {
  flex: 1; padding: 12px 6px; border-radius: var(--radius);
  font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: all .14s;
}
.ctrl-icon { font-size: 20px; }
.ctrl-hint    { background: #EFF6FF; color: var(--blue);  border: 1.5px solid #BFDBFE; }
.ctrl-hint:hover { background: #DBEAFE; }
.ctrl-note    { background: #F0FDF4; color: var(--hanja-600); border: 1.5px solid var(--hanja-200); }
.ctrl-note.active { background: var(--hanja-500); color: var(--white); border-color: var(--hanja-600); }
.ctrl-restart { background: #FFF7ED; color: #D97706; border: 1.5px solid #FDE68A; }
.ctrl-restart:hover { background: #FEF3C7; }

/* ===== 완성 모달 ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal-sheet {
  background: var(--white); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 22px 40px; width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.34,1.56,.64,1);
}
.modal-stars  { text-align: center; font-size: 38px; color: var(--amber); letter-spacing: 4px; margin-bottom: 6px; }
.modal-title  { text-align: center; font-size: 20px; font-weight: 800; color: var(--hanja-700); margin-bottom: 18px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.result-item { background: #F9FAFB; border-radius: var(--radius); padding: 13px 14px; text-align: center; }
.result-item .r-label { font-size: 11px; color: var(--text-500); margin-bottom: 4px; }
.result-item .r-value { font-size: 20px; font-weight: 900; color: var(--hanja-700); }
.result-item.score { grid-column: 1 / -1; background: var(--hanja-50); }
.result-item.score .r-value { font-size: 30px; color: var(--hanja-600); }

.hanja-learn-panel {
  background: var(--hanja-10); border: 1px solid var(--hanja-100);
  border-radius: var(--radius); padding: 13px;
  margin-bottom: 18px; max-height: 200px; overflow-y: auto;
}
.learn-title { font-size: 12px; font-weight: 700; color: var(--hanja-700); margin-bottom: 10px; }
.learn-item  {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--hanja-100);
}
.learn-item:last-child { border-bottom: none; }
.learn-char { font-size: 24px; font-weight: 900; color: var(--hanja-700); min-width: 30px; text-align: center; line-height: 1.2; }
.learn-char-hangul { font-size: 15px; font-weight: 800; color: var(--hangul-700); min-width: 38px; }
.learn-text-wrap { min-width: 0; }
.learn-hanja { display: block; font-size: 12px; font-weight: 700; color: var(--hanja-600); }
.learn-text  { display: block; font-size: 11px; color: var(--text-500); line-height: 1.4; }

.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-modal-primary {
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, var(--hanja-600), var(--hanja-400));
  color: var(--white); border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(46,125,50,.3); transition: transform .12s;
}
.btn-modal-primary:hover { transform: translateY(-1px); }
.btn-modal-secondary {
  width: 100%; padding: 13px;
  background: #F9FAFB; color: var(--text-700); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; transition: background .14s;
}
.btn-modal-secondary:hover { background: #F3F4F6; }

/* =====================================================
   한글 2칸 보드 (18열 그리드)
   ===================================================== */

/* 2칸 셀 공통 (grid-column: span 2 는 JS에서 인라인으로 설정) */
.cell-word {
  flex-direction: row !important;
  justify-content: center;
  align-items: center;
  gap: 0 !important;
  min-height: 40px;
}

/* 각 글자 */
.word-c1, .word-c2 {
  font-size: clamp(13px, 3.2vw, 20px);
  font-weight: 800;
  color: var(--hangul-700);
  line-height: 1;
  width: 50%;
  text-align: center;
  padding: 0 1px;
}

/* 초기값 (주어진 셀) */
.board-2cell .cell.initial .word-c1,
.board-2cell .cell.initial .word-c2 { color: var(--hangul-900); font-weight: 900; }

/* 오답 */
.board-2cell .cell.error .word-c1,
.board-2cell .cell.error .word-c2 { color: var(--red) !important; }

/* 빈 칸 ? */
.word-q {
  font-size: clamp(14px, 3.5vw, 22px);
  font-weight: 900;
  color: var(--text-300);
}

/* 박스 경계선 (한글 모드) */
.board-2cell .cell.box-top    { border-top:    2px solid var(--hangul-400); }
.board-2cell .cell.box-left   { border-left:   2px solid var(--hangul-400); }
.board-2cell .cell.box-bottom { border-bottom: 2px solid var(--hangul-400); }
.board-2cell .cell.box-right  { border-right:  2px solid var(--hangul-400); }

/* 선택/관련/같은값 (한글 모드) */
.board-2cell .cell.same-value { background: var(--hangul-50); }

/* =====================================================
   한글 퀴즈 패널 (Bottom Sheet)
   ===================================================== */

.quiz-panel {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 300;
  transform: translateY(105%);
  transition: transform .36s cubic-bezier(.32,.72,0,1);
}
.quiz-panel.active { transform: translateY(0); }

.quiz-panel-inner {
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 20px 36px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.18);
}

/* 핸들 + 닫기 */
.quiz-header {
  display: flex; align-items: center; justify-content: center;
  position: relative; padding: 6px 0 12px;
}
.quiz-handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: var(--text-300);
}
.quiz-cancel {
  position: absolute; right: 0; top: 4px;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 14px; color: var(--text-500);
  display: flex; align-items: center; justify-content: center;
  background: #F3F4F6; transition: background .14s;
}
.quiz-cancel:hover { background: #E5E7EB; }

/* 질문 박스 */
.quiz-question-box {
  background: var(--hangul-50);
  border: 2px solid var(--hangul-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  text-align: center;
}
.quiz-q-label {
  font-size: 12px; font-weight: 700;
  color: var(--hangul-600); margin-bottom: 8px;
  letter-spacing: .3px;
}
.quiz-meaning-text {
  font-size: 20px; font-weight: 800;
  color: var(--text-900); line-height: 1.4;
  margin-bottom: 6px;
}
.quiz-hanja-hint {
  font-size: 12px; color: var(--hangul-600);
  font-weight: 600;
}

/* 입력창 */
.quiz-input-row {
  display: flex; gap: 10px; margin-bottom: 10px;
}
.quiz-input-field {
  flex: 1; padding: 14px 16px;
  border: 2px solid var(--hangul-200);
  border-radius: var(--radius);
  font-size: 20px; font-weight: 800;
  color: var(--hangul-700);
  background: var(--hangul-10);
  outline: none; letter-spacing: 4px;
  text-align: center;
  transition: border-color .2s, box-shadow .2s;
}
.quiz-input-field:focus {
  border-color: var(--hangul-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
  background: var(--white);
}
.quiz-input-field.shake { animation: shake .35s ease; }
.quiz-submit-btn {
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--hangul-600), var(--hangul-400));
  color: var(--white); border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
  transition: transform .12s;
  white-space: nowrap;
}
.quiz-submit-btn:hover { transform: translateY(-1px); }

/* 피드백 메시지 */
.quiz-feedback {
  min-height: 20px;
  font-size: 13px; font-weight: 600;
  line-height: 1.5; white-space: pre-line;
  margin-bottom: 12px; border-radius: var(--radius-sm);
  padding: 0;
  transition: all .2s;
}
.quiz-feedback:not(:empty) { padding: 10px 14px; }
.quiz-feedback-success {
  background: #F0FDF4; color: #166534;
  border: 1px solid #BBF7D0;
}
.quiz-feedback-error {
  background: #FEF2F2; color: #991B1B;
  border: 1px solid #FECACA;
}
.quiz-feedback-warn {
  background: #FFFBEB; color: #92400E;
  border: 1px solid #FDE68A;
}

/* 단어 목록 */
.quiz-words-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-500); margin-bottom: 8px;
}
.quiz-word-list {
  display: flex; flex-wrap: wrap; gap: 7px;
}
.quiz-word-btn {
  padding: 8px 14px;
  background: var(--hangul-50);
  border: 1.5px solid var(--hangul-200);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 800;
  color: var(--hangul-700);
  transition: all .12s;
}
.quiz-word-btn:hover {
  background: var(--hangul-100);
  border-color: var(--hangul-400);
  transform: scale(1.04);
}

/* ===== 반응형 ===== */
@media (max-width: 380px) {
  .ref-item { min-width: calc(50% - 3px); }
  #hanja-pad { gap: 3px; }
  .pad-char { font-size: 15px; }
  .pad-char-hangul { font-size: 10px; }
}
@media (min-width: 520px) {
  .cell-char { font-size: 22px; }
  .cell-char-hangul { font-size: 14px; }
  .pad-char { font-size: 22px; }
}

/* 스크롤바 */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 99px; }
