/**
 * 말솜씨 타자 (Malsomsi Typing) - 통합 스타일시트
 * 디자인 토큰을 :root에 일원화하여 유지보수와 테마 확장을 용이하게 구성
 */

:root {
  /* ================= 색상 토큰 (Color Tokens) ================= */
  /* 배경 & 서페이스 (따뜻하고 정갈한 미색 종이 질감) */
  --color-bg: #F7F5F0;
  --color-surface: #FFFFFF;
  --color-surface-soft: #F1ECE4;
  --color-surface-hover: #E8E2D7;
  --color-border: #E2DBD0;
  --color-border-light: #ECE7DF;

  /* 텍스트 & 먹색 계열 */
  --color-text-main: #24292E;
  --color-text-body: #4A5568;
  --color-text-muted: #718096;
  --color-text-subtle: #A0AEC0;
  --color-text-inverse: #FFFFFF;

  /* 주 색상 (단정하고 맑은 비취 청록 먹색 - 한옥의 기와와 소나무 느낌) */
  --color-primary: #1F6F5A;
  --color-primary-hover: #175444;
  --color-primary-active: #113E32;
  --color-primary-light: #EBF5F1;
  --color-primary-soft: #D7EDE5;

  /* 보조/악센트 (따뜻한 감나무 주홍/호박색) */
  --color-accent: #D96B27;
  --color-accent-hover: #BF5718;
  --color-accent-light: #FEF4EC;

  /* 피드백 상태 (아이들에게 자극적이지 않은 조용하고 차분한 색감) */
  --color-char-correct: #1F6F5A;
  --color-char-incorrect: #C53030;
  --color-char-incorrect-bg: #FFE3E3;
  --color-char-pending: #A0AEC0;
  --color-char-current: #2B6CB0;
  --color-char-current-bg: #EBF8FF;

  --color-success: #288052;
  --color-success-bg: #EDF7F1;

  /* ================= 글꼴 토큰 (Typography Tokens) ================= */
  --font-family-sans: "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", "맑은 고딕", sans-serif;
  --font-family-serif: "Noto Serif KR", "Batang", "바탕", serif;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;

  /* ================= 여백 및 간격 (Spacing Tokens) ================= */
  --space-2xs: 0.25rem; /* 4px */
  --space-xs: 0.5rem;   /* 8px */
  --space-sm: 0.75rem;  /* 12px */
  --space-md: 1rem;     /* 16px */
  --space-lg: 1.5rem;   /* 24px */
  --space-xl: 2rem;     /* 32px */
  --space-2xl: 3rem;    /* 48px */

  /* ================= 모서리 둥글기 (Border Radius) ================= */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ================= 그림자 토큰 (Shadow Tokens) ================= */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(45, 55, 72, 0.08);
  --shadow-lg: 0 10px 25px -3px rgba(45, 55, 72, 0.1), 0 4px 6px -2px rgba(45, 55, 72, 0.05);
  --shadow-card: 0 8px 30px rgba(50, 40, 30, 0.06);

  /* ================= 전환 효과 (Transitions) ================= */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================= 리셋 및 전역 스타일 ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: var(--line-height-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(31, 111, 90, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(217, 107, 39, 0.03) 0%, transparent 40%);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

input {
  font-family: inherit;
}

/* 스크린 리더 전용 숨김 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ================= 앱 레이아웃 ================= */
.app-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ================= 상단 헤더 ================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  box-shadow: 0 4px 10px rgba(31, 111, 90, 0.25);
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

.brand-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* 헤더 배지 & 버튼 */
.today-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-body);
  box-shadow: var(--shadow-sm);
}

.today-count {
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-body);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-text-main);
  border-color: var(--color-text-subtle);
}

.icon-btn.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary-soft);
}

/* ================= 뷰 영역 ================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.view-section.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= 1. 홈 뷰 (시작 화면) ================= */
.home-hero {
  text-align: center;
  padding: var(--space-xl) var(--space-sm) var(--space-lg);
}

.hero-tagline {
  display: inline-block;
  padding: 4px 14px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-sm);
}

.hero-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-xs);
  color: var(--color-text-main);
}

.hero-desc {
  font-size: var(--font-size-lg);
  color: var(--color-text-body);
  max-width: 580px;
  margin: 0 auto;
  line-height: var(--line-height-relaxed);
}

/* 모드 선택 카드 그리드 */
.mode-selection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

@media (max-width: 900px) and (min-width: 601px) {
  .mode-selection-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mode-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all var(--transition-bounce);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background-color: transparent;
  transition: background-color var(--transition-fast);
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
}

.mode-card:hover::before {
  background-color: var(--color-primary);
}

.mode-card-icon {
  font-size: 2.8rem;
  margin-bottom: var(--space-sm);
}

.mode-card-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  margin-bottom: var(--space-2xs);
}

.mode-card-meta {
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
  background-color: var(--color-primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-sm);
}

.mode-card-sample {
  font-size: var(--font-size-sm);
  color: var(--color-text-body);
  line-height: 1.4;
  margin-bottom: var(--space-md);
  word-break: keep-all;
}

.mode-start-btn {
  margin-top: auto;
  width: 100%;
  padding: 12px 16px;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.mode-card:hover .mode-start-btn {
  background-color: var(--color-primary-hover);
}

/* 홈 하단 옵션 바 (난이도 선택 & 오답 바로가기) */
.home-options-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-top: var(--space-sm);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.option-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.option-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-body);
}

.segmented-control {
  display: inline-flex;
  background-color: var(--color-surface-soft);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.segment-btn {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-body);
  transition: all var(--transition-fast);
}

.segment-btn.active {
  background-color: var(--color-surface);
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
  box-shadow: var(--shadow-sm);
}

.mistake-shortcut-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  background-color: var(--color-accent-light);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(217, 107, 39, 0.25);
  transition: all var(--transition-fast);
}

.mistake-shortcut-btn:hover {
  background-color: var(--color-accent);
  color: var(--color-text-inverse);
}

.mistake-shortcut-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= 2. 연습 뷰 (핵심 타자 화면) ================= */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.practice-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.round-counter {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
}

.round-counter .current-num {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
}

.practice-stats-live {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.stat-chip strong {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  font-variant-numeric: tabular-nums;
}

/* 진행도 게이지 바 */
.progress-container {
  width: 100%;
  height: 8px;
  background-color: var(--color-surface-soft);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
}

.progress-bar-fill {
  height: 100%;
  width: 10%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

/* 메인 타자 카드 */
.typing-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  position: relative;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition-fast);
}

.typing-card:focus-within {
  border-color: var(--color-primary);
}

/* 사자성어 한자 뱃지 */
.hanja-display {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-family: var(--font-family-serif);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  background-color: var(--color-accent-light);
  padding: 4px 14px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  letter-spacing: 0.15em;
  border: 1px solid rgba(217, 107, 39, 0.2);
}

/* 타자 칠 원본 문장 */
.target-sentence-wrap {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.01em;
  line-height: 1.6;
  margin-bottom: var(--space-lg);
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  user-select: none;
  word-break: keep-all;
}

/* 각 글자 상태 스타일 */
.char-item {
  position: relative;
  transition: color 0.1s ease, background-color 0.1s ease;
  padding: 0 1px;
  border-radius: 4px;
}

/* 맞힌 글자: 진하고 단정한 청록 먹색 */
.char-item.correct {
  color: var(--color-char-correct);
}

/* 틀린 글자: 너무 쏘아붙이지 않는 부드러운 붉은 밑줄과 배경 */
.char-item.incorrect {
  color: var(--color-char-incorrect);
  background-color: var(--color-char-incorrect-bg);
  text-decoration: underline wavy var(--color-char-incorrect);
  text-underline-offset: 4px;
}

/* 현재 입력 중인 글자 */
.char-item.current {
  color: var(--color-text-main);
  background-color: var(--color-char-current-bg);
  box-shadow: 0 0 0 2px var(--color-char-current);
}

/* 아직 치지 않은 대기 글자 */
.char-item.pending {
  color: var(--color-char-pending);
}

/* 공백 표시 */
.char-item.is-space {
  display: inline-block;
  min-width: 0.45em;
}

.char-item.is-space.incorrect {
  background-color: var(--color-char-incorrect-bg);
  border-bottom: 2px solid var(--color-char-incorrect);
}

/* 입력 필드 */
.typing-input-wrap {
  position: relative;
  margin-bottom: var(--space-md);
}

.typing-input {
  width: 100%;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-medium);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--color-surface-soft);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-main);
  outline: none;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}

.typing-input:focus {
  background-color: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

.typing-input::placeholder {
  color: var(--color-text-subtle);
  font-weight: var(--font-weight-regular);
  font-size: var(--font-size-xl);
}

/* 입력창 아래 힌트/가이드 */
.typing-guide-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  padding: 0 var(--space-xs);
}

/* ================= 문장 완료 뜻풀이 카드 ================= */
.meaning-card {
  display: none;
  margin-top: var(--space-md);
  background-color: var(--color-primary-light);
  border: 1.5px solid var(--color-primary-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  animation: slideUpMeaning 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.meaning-card.show {
  display: block;
}

@keyframes slideUpMeaning {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.meaning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.meaning-text {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  margin-bottom: var(--space-xs);
  line-height: var(--line-height-normal);
}

.usage-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background-color: rgba(255, 255, 255, 0.7);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text-body);
  margin-bottom: var(--space-md);
}

.usage-label {
  display: inline-block;
  white-space: nowrap;
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
}

.meaning-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding-top: var(--space-xs);
  border-top: 1px dashed rgba(31, 111, 90, 0.2);
}

.advance-timer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.advance-progress-pill {
  width: 80px;
  height: 6px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.advance-progress-pill-fill {
  width: 0%;
  height: 100%;
  background-color: var(--color-primary);
}

.next-sentence-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  box-shadow: 0 4px 10px rgba(31, 111, 90, 0.2);
}

.next-sentence-btn:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* ================= 3. 결과 뷰 (한 판 완료 화면) ================= */
.result-container {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  padding: var(--space-lg) 0;
  text-align: center;
}

.result-celebration {
  margin-bottom: var(--space-xl);
}

.celebration-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-xs);
  animation: bounceCelebration 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounceCelebration {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  margin-bottom: var(--space-2xs);
}

.result-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-body);
}

/* 결과 통계 3단 카드 그리드 */
.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.result-stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-stat-icon {
  font-size: 1.6rem;
  margin-bottom: var(--space-xs);
}

.result-stat-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xs);
}

.result-stat-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  font-variant-numeric: tabular-nums;
}

.result-stat-unit {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-normal);
  margin-left: 2px;
}

/* 틀린 문장 복습 섹션 */
.result-mistakes-section {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: left;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.result-mistakes-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-mistakes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.result-mistake-item {
  background-color: var(--color-surface-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  border-left: 4px solid var(--color-accent);
}

.result-mistake-text {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  margin-bottom: 4px;
}

.result-mistake-meaning {
  font-size: var(--font-size-sm);
  color: var(--color-text-body);
}

/* 결과 액션 버튼군 */
.result-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.btn-primary {
  padding: 14px 28px;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px rgba(31, 111, 90, 0.3);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(31, 111, 90, 0.35);
}

.btn-secondary {
  padding: 14px 24px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-text-subtle);
}

.btn-accent {
  padding: 14px 24px;
  background-color: var(--color-accent-light);
  border: 1px solid rgba(217, 107, 39, 0.3);
  color: var(--color-accent);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.btn-accent:hover {
  background-color: var(--color-accent);
  color: var(--color-text-inverse);
}

/* ================= 4. 내 기록 및 오답 모달 ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(36, 41, 46, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background-color: var(--color-surface);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  transform: translateY(20px);
  transition: transform var(--transition-bounce);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  font-size: var(--font-size-2xl);
  line-height: 1;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.close-btn:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-text-main);
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-surface);
}

.modal-tab-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.modal-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

.history-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.history-summary-item {
  background-color: var(--color-surface-soft);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.history-summary-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.history-summary-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

.history-list, .mistakes-modal-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.history-item-left {
  display: flex;
  flex-direction: column;
}

.history-item-mode {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
}

.history-item-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.history-item-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.history-item-stat {
  text-align: right;
}

.history-item-stat .stat-val {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.empty-state-icon {
  font-size: 2.4rem;
  margin-bottom: var(--space-xs);
}

/* ================= 하단 푸터 ================= */
.app-footer {
  margin-top: auto;
  padding-top: var(--space-xl);
  padding-bottom: var(--space-md);
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-relaxed);
}

/* ================= 반응형 대응 (Mobile & Tablet) ================= */
@media (max-width: 768px) {
  .app-container {
    padding: var(--space-xs) var(--space-sm);
  }

  .app-header {
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-sm);
    gap: var(--space-xs);
  }

  .brand {
    gap: 8px;
    flex-shrink: 0;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: var(--font-size-base);
    border-radius: var(--radius-sm);
  }

  .brand-title {
    font-size: 1.15rem;
    white-space: nowrap;
  }

  .brand-subtitle {
    display: none; /* 모바일 헤더 간소화 */
  }

  .header-actions {
    gap: 6px;
    flex-shrink: 1;
  }

  .header-actions .btn-text {
    display: none; /* 모바일에서는 텍스트 숨기고 아이콘만 노출 */
  }

  .today-badge {
    padding: 4px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .icon-btn {
    height: 32px;
    padding: 0 8px;
    font-size: var(--font-size-xs);
  }

  .hero-tagline {
    font-size: var(--font-size-xs);
    padding: 3px 10px;
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .hero-desc {
    font-size: var(--font-size-base);
  }

  .mode-selection-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
  }

  .mode-card {
    padding: var(--space-md);
  }

  .mode-card-icon {
    font-size: 2.2rem;
    margin-bottom: var(--space-2xs);
  }

  /* 연습 화면 모바일 최적화 */
  .practice-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-xs);
  }

  .practice-info {
    gap: 8px;
  }

  .practice-stats-live {
    gap: 8px;
    white-space: nowrap;
  }

  .stat-chip {
    font-size: 0.75rem;
  }

  .stat-chip strong {
    font-size: 1rem;
  }

  .typing-card {
    padding: var(--space-md) var(--space-sm);
  }

  .target-sentence-wrap {
    font-size: 1.45rem;
    min-height: 48px;
    margin-bottom: var(--space-md);
    line-height: 1.5;
  }

  .typing-input {
    font-size: 1.25rem;
    padding: 10px 12px;
  }

  .typing-input::placeholder {
    font-size: 1rem;
  }

  .meaning-text {
    font-size: 1.05rem;
  }

  .usage-box {
    font-size: 0.9rem;
    padding: 8px 10px;
  }

  .meaning-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .next-sentence-btn {
    width: 100%;
    justify-content: center;
  }

  .result-stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .home-options-bar {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-sm);
  }

  .segmented-control {
    width: 100%;
    justify-content: space-around;
  }
}

/* ================= 5. 기본자리 연습 (Keyboard Practice) 스타일 ================= */
/* 상단 메인 모드 탭 (기본자리 연습 vs 문장 연습) */
.main-nav-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background-color: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.nav-tab-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-text-main);
}

.nav-tab-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: 0 4px 12px rgba(31, 111, 90, 0.25);
}

/* 자리 연습 코스 선택 그리드 */
.key-course-section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-courses-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

@media (max-width: 900px) and (min-width: 601px) {
  .key-courses-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .key-courses-grid {
    grid-template-columns: 1fr;
  }
}

.key-course-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-bounce);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
}

.key-course-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.key-course-level {
  display: inline-block;
  align-self: flex-start;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-2xs);
}

.key-course-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  margin-bottom: 4px;
}

.key-course-keys {
  font-family: var(--font-family-sans);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.15em;
  color: var(--color-accent);
  background-color: var(--color-accent-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin: var(--space-xs) 0;
  text-align: center;
  word-break: break-all;
}

.key-course-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-body);
  line-height: 1.4;
  margin-bottom: var(--space-sm);
}

.key-course-start-btn {
  margin-top: auto;
  width: 100%;
  padding: 8px 12px;
  background-color: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-main);
  transition: all var(--transition-fast);
}

.key-course-card:hover .key-course-start-btn {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ================= 자리 연습 무대 (Practice Stage) ================= */
.key-stage-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.key-target-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md);
  width: 100%;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.current-target-char {
  width: 84px;
  height: 84px;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: 2.8rem;
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(31, 111, 90, 0.35);
  animation: pulseTarget 1.2s infinite ease-in-out;
}

@keyframes pulseTarget {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.upcoming-conveyor-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conveyor-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
}

.upcoming-keys-belt {
  display: flex;
  gap: 8px;
}

.upcoming-key-item {
  width: 44px;
  height: 44px;
  background-color: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
}

/* 손가락 가이드 카드 */
.finger-guide-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: var(--color-accent-light);
  border: 1.5px solid rgba(217, 107, 39, 0.3);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.finger-guide-tip {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-normal);
  margin-top: 2px;
}

/* ================= 온스크린 가상 키보드 (Virtual Keyboard) ================= */
.virtual-keyboard-wrap {
  width: 100%;
  background-color: #2D3748;
  padding: 16px;
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
  overflow-x: auto;
}

.kb-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.kb-key {
  position: relative;
  min-width: 42px;
  height: 48px;
  background: linear-gradient(180deg, #FFFFFF 0%, #E2E8F0 100%);
  border: 1px solid #CBD5E0;
  border-bottom: 4px solid #A0AEC0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: #2D3748;
  transition: all 0.08s ease;
  box-sizing: border-box;
  padding: 2px 4px;
}

.kb-key .key-main {
  font-size: 1.05rem;
  line-height: 1;
}

.kb-key .key-sub {
  font-size: 0.65rem;
  color: #718096;
  line-height: 1;
  margin-top: 2px;
}

/* 특수 키 너비 */
.kb-key.width-backspace { min-width: 66px; font-size: 0.8rem; }
.kb-key.width-tab { min-width: 60px; font-size: 0.8rem; }
.kb-key.width-caps { min-width: 68px; font-size: 0.8rem; }
.kb-key.width-enter { min-width: 76px; font-size: 0.8rem; }
.kb-key.width-shift-left { min-width: 88px; font-size: 0.8rem; }
.kb-key.width-shift-right { min-width: 88px; font-size: 0.8rem; }
.kb-key.width-space { min-width: 260px; font-size: 0.8rem; }

/* 기준 자리 F, J 돌출 돌기 (Bump) */
.kb-key.has-bump::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 10px;
  height: 2px;
  background-color: #718096;
  border-radius: 1px;
}

/* 현재 쳐야 할 타겟 키 하이라이트 */
.kb-key.key-target {
  background: linear-gradient(180deg, #FBD38D 0%, #ED8936 100%) !important;
  border-color: #DD6B20 !important;
  border-bottom: 4px solid #C05621 !important;
  color: #FFFFFF !important;
  transform: translateY(-2px);
  box-shadow: 0 0 16px rgba(237, 137, 54, 0.8);
  animation: keyGlow 0.8s infinite alternate ease-in-out;
}

@keyframes keyGlow {
  from { filter: brightness(1); }
  to { filter: brightness(1.2); }
}

.kb-key.key-target .key-sub {
  color: #FFFFFF;
}

/* 키를 눌렀을 때의 반응 (Pressed) */
.kb-key.key-pressed {
  border-bottom-width: 1px !important;
  transform: translateY(3px) !important;
  background: #CBD5E0 !important;
}

.kb-key.key-target.key-pressed {
  background: #C05621 !important;
}

/* 모바일 가상 키보드 스케일링 */
@media (max-width: 768px) {
  .virtual-keyboard-wrap {
    padding: 10px 6px;
    gap: 4px;
  }
  .kb-row {
    gap: 3px;
  }
  .kb-key {
    min-width: 26px;
    height: 38px;
    border-radius: 5px;
    border-bottom-width: 2px;
    padding: 1px 2px;
  }
  .kb-key .key-main { font-size: 0.8rem; }
  .kb-key .key-sub { font-size: 0.55rem; }
  .kb-key.width-space { min-width: 140px; }
  .kb-key.width-shift-left, .kb-key.width-shift-right { min-width: 44px; }
  .kb-key.width-enter { min-width: 44px; }
  .current-target-char { width: 64px; height: 64px; font-size: 2.2rem; }
}
