/*!
 * 영어타임즈어학원 학습 앱
 * Copyright (c) 2025 Joe
 * All Rights Reserved - 무단 복제 및 배포 금지
 */

:root {
  --bg: #2a2d33;
  --fg: #e8eef6;
  --muted: #9aa6b2;
  --accent: #ffb3d9;
  --ok: #7ee3a2;
  --warn: #ffb84d;
  --err: #ff6b6b;
  --hl: #ffb3d9;
}

/* 라이트 모드 - 가독성 좋은 컬러 */
body.light-mode {
  --bg: #f5f7fa;
  --fg: #2c3e50;
  --muted: #6c757d;
  --accent: #ff6b9d;
  --ok: #28a745;
  --warn: #fd7e14;
  --err: #dc3545;
  --hl: #ff6b9d;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Pretendard, Noto Sans, Arial,
    sans-serif;
  overflow-x: hidden;
}
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px;
}
/* ======================================= */
/* ★ 재수정된 부분: h1 마진 복구 */
h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px; /* ⬅️ 기존 마진 복구 */
  text-align: left;
}
/* ======================================= */
#titleHeader {
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
#titleHeader:hover {
  opacity: 0.8;
}
.themeToggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #2a3447;
  background: #1b2433;
  color: #e8eef6;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  margin-left: auto;
}
.themeToggle:hover {
  background: #212c3e;
}
body.light-mode .themeToggle {
  border-color: #ced4da;
  background: #ffffff;
  color: #1a1d23;
}
body.light-mode .themeToggle:hover {
  background: #f8f9fa;
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #2a3447;
  background: #0f1319;
  margin-left: 6px;
  font-size: 11px;
}
body.light-mode .badge {
  border-color: #dee2e6;
  background: #ffffff;
}
.card {
  background: #101318;
  border: 1px solid #1a1f27;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  margin-bottom: 12px;
  overflow: hidden;
}
body.light-mode .card {
  background: #ffffff;
  border-color: #dee2e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: start;
}
.row2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-items: start;
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
input[type="number"],
input[type="color"],
select {
  width: 100%;
  background: #0f1319;
  color: var(--fg);
  border: 1px solid #202634;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}
body.light-mode input[type="number"],
body.light-mode input[type="color"],
body.light-mode select {
  background: #ffffff;
  border-color: #ced4da;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
button {
  background: #1b2433;
  color: #fff;
  border: 1px solid #2a3447;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}
body.light-mode button {
  background: #ffffff;
  color: #1a1d23;
  border-color: #ced4da;
}
button:hover:not(:disabled) {
  background: #212c3e;
  transform: translateY(-1px);
}
body.light-mode button:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: #adb5bd;
}
button:active:not(:disabled) {
  transform: translateY(0);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary {
  background: linear-gradient(135deg, var(--accent), #ff8ec7);
  border-color: var(--accent);
}
button.ok {
  background: linear-gradient(135deg, var(--ok), #5bc98b);
  border-color: var(--ok);
  color: #fff;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* 접기/펼치기 */
.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0f1319;
  border-bottom: 1px solid #1a1f27;
}
body.light-mode .collapsible {
  background: #f8f9fa;
  border-bottom-color: #dee2e6;
}
.collapsible:active {
  background: #1a1f27;
}
body.light-mode .collapsible:active {
  background: #e9ecef;
}
.collapsible h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex; /* 뱃지 정렬용 */
  align-items: center;
}
.collapsible .arrow {
  transition: transform 0.3s;
  font-size: 14px;
}
.collapsible.collapsed .arrow {
  transform: rotate(-90deg);
}
.collapseContent {
  padding: 16px;
  max-height: 9999px;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}
.collapseContent.collapsed {
  padding: 0 16px;
  max-height: 0 !important;
  opacity: 0;
}
/* 로딩 상태 */
.loading {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.loading .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #1a1f27;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
body.light-mode .loading .spinner {
  border-color: #dee2e6;
  border-top-color: var(--accent);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stageWrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 12px;
  margin-bottom: 12px;
}

/* 재생 중일 때 모든 여백 완전 제거 */
body.playing .wrap {
  padding: 0;
}

body.playing h1 {
  margin-bottom: 0;
}

body.playing .stageWrap {
  margin-top: 0;
  margin-bottom: 0;
}

.stage {
  position: relative;
  aspect-ratio: 21/9;
  width: 100%;
  max-width: 1200px;
  border: 1px solid #1a1f27;
  border-radius: 12px;
  background: radial-gradient(
    circle,
    rgba(12, 25, 51, 1) 0%,
    rgba(5, 8, 13, 1) 100%
  ) !important;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(41, 48, 71, 0.6);
}
body.light-mode .stage {
  border-color: #dee2e6;
  /* 수정된 부분: 그라데이션 대신 단색 #fee6e6 적용 */
  background: #fee6e6 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.stageInner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.titleL {
  position: absolute;
  top: 8px;
  left: 12px;
  font-weight: 600;
  font-size: 25px;
}
.titleL .hl {
  color: #ff6b9d;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(255, 107, 157, 0.4);
}
.titleR {
  position: absolute;
  top: 8px;
  right: 12px;
  font-weight: 300;
  font-size: 25px;
}
.modeLabel {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  font-size: 18px;
  padding: 8px 24px;
  border-radius: 8px;
  background: rgba(13, 15, 18, 0.8);
  color: #ffffff;
  white-space: nowrap;
  z-index: 10;
}
body.light-mode .modeLabel {
  background: rgba(255, 255, 255, 0.9);
  color: #1a1d23;
}
/* 라이트 모드에서 titleL, titleR 가독성 개선 */
body.light-mode .titleL,
body.light-mode .titleR {
  color: #495057 !important;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
body.light-mode .titleL .hl {
  color: #e91e63 !important;
  text-shadow: 0 0 8px rgba(233, 30, 99, 0.3);
}
.enLine {
  max-width: 90%;
  text-align: center;
  font-weight: 900;
  line-height: 1.18;
  font-size: clamp(24px, 5vw, 48px);
}

/* 정지 메시지 스타일 */
.stopMessage {
  font-size: clamp(16px, 3vw, 24px) !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  display: block;
}

/* 준비 완료 메시지 스타일 */
.readyMessage {
  font-size: clamp(18px, 3.5vw, 28px) !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  display: block;
}

body.light-mode .enLine {
  color: #2c3e50;
}
.krLine {
  max-width: 90%;
  text-align: center;
  font-weight: 500;
  line-height: 1.32;
  margin-top: 12px;
  font-size: clamp(18px, 3.5vw, 34px);
  color: #ffffff;
}
body.light-mode .krLine {
  color: #1a1d23;
}
.bar {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  height: 8px;
  background: #1a1f27;
  border-radius: 999px;
  overflow: visible;
  cursor: pointer;
  transition: height 0.15s ease-out;
}
.bar:hover {
  height: 10px;
}
.bar:active,
.bar.dragging {
  height: 10px;
}
/* 모바일에서 더 얇게 */
@media (max-width: 768px) {
  .bar {
    height: 6px;
  }
  .bar:hover,
  .bar:active,
  .bar.dragging {
    height: 8px;
  }
}
body.light-mode .bar {
  background: #dee2e6;
  border: 1px solid #adb5bd;
}
.fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b9d, #c44569);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 999px;
  position: relative;
}
body.light-mode .fill {
  background: linear-gradient(90deg, #e91e63, #c2185b);
}
.fill::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #ff6b9d;
  border-radius: 50%;
  opacity: 1;
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.bar:hover .fill::after,
.bar.dragging .fill::after {
  transform: translateY(-50%) scale(1.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
body.light-mode .fill::after {
  background: #fff;
  border-color: #e91e63;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
body.light-mode .bar:hover .fill::after,
body.light-mode .bar.dragging .fill::after {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.hl {
  color: var(--hl);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  background: #0f1319;
  border: 1px solid #243044;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  display: none;
  color: #cfe7ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  max-width: calc(100vw - 24px);
}
body.light-mode .toast {
  background: #ffffff;
  border-color: #dee2e6;
  color: #1a1d23;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.toast.ok {
  border-color: var(--ok);
  color: var(--ok);
}
.toast.err {
  border-color: var(--err);
  color: var(--err);
}
.toast.warn {
  border-color: var(--warn);
  color: var(--warn);
}

/* Bottom Copyright - 가독성 개선 */
.bottom {
  text-align: center;
  padding: 24px 12px;
  margin-top: 32px;
  border-top: 1px solid #1a1f27;
  color: var(--muted);
  font-size: 13px;
}
.bottom p {
  margin-bottom: 8px; /* 단락 간격 추가 */
}
.bottom p:last-child {
  margin-bottom: 0;
}
.bottom a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
.bottom a:hover {
  color: var(--fg);
}
.bottom a.tel {
  /* 전화번호 강조 */
  color: var(--accent);
  font-size: 13px !important;
}

/* 라이트 모드에서 border-top 색상을 부드럽게 조정 */
body.light-mode .bottom {
  border-top-color: #dee2e6;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  .wrap {
    padding: 8px;
  }
  h1 {
    font-size: 16px;
  }
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  .card {
    margin-bottom: 8px;
    border-radius: 12px;
  }
  .collapsible {
    padding: 12px;
  }
  .collapsible h2 {
    font-size: 14px;
  }
  .collapseContent {
    padding: 12px;
  }
  button {
    padding: 16px 12px;
    font-size: 15px;
    font-weight: 700;
  }
  
  .masteredBtn {
    padding: 16px 12px;
    font-size: 15px;
  }
  
  .masteredIcon {
    font-size: 20px;
  }
  
  .masteredText {
    font-size: 15px;
  }
  
  .controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  /* 이전/다음 버튼도 같은 크기로 통일 */
  #prev,
  #next {
    font-size: 15px;
    padding: 16px 12px;
  }
  .titleL,
  .titleR {
    font-size: 15px;
    top: 6px;
  }
  .titleL {
    left: 8px;
  }
  .titleR {
    right: 8px;
  }
  .bar {
    left: 12px;
    right: 12px;
    bottom: 8px;
    height: 5px;
  }
  input[type="number"],
  input[type="color"],
  select {
    padding: 8px 10px;
    font-size: 13px;
  }
  /* bottom 영역 모바일 최적화 */
  .bottom {
    padding: 16px 12px;
    margin-top: 20px;
    font-size: 12px;
  }
  .bottom p {
    margin-bottom: 4px;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 6px;
  }
  h1 {
    font-size: 15px;
    margin-bottom: 8px;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  button {
    padding: 14px 10px;
    font-size: 14px;
    font-weight: 700;
  }
  
  .masteredBtn {
    padding: 14px 10px;
    font-size: 14px;
  }
  
  .masteredIcon {
    font-size: 16px;
  }
  
  .masteredText {
    font-size: 14px;
  }
  
  .masteredCount {
    font-size: 12px;
  }
  
  #prev,
  #next {
    font-size: 14px;
    padding: 14px 10px;
  }
  .stage {
    border-radius: 8px;
  }
  .titleL,
  .titleR {
    font-size: 14px;
    top: 5px;
  }
  .modeLabel {
    font-size: 14px;
    padding: 6px 16px;
    top: 8px;
  }
  /* 모바일 메뉴 UX 개선 */
  .titleMenuList li {
    padding: 10px 12px; /* 터치 영역 확보 (수정됨) */
    font-size: 14px; /* 글자 크기 증가 (수정됨) */
  }
  /* bottom 영역 작은 모바일 최적화 */
  .bottom {
    padding: 12px 8px;
    margin-top: 16px;
    font-size: 11px;
  }
  .bottom p {
    margin-bottom: 3px;
  }
}

/* wrap 상단: 제목 + 우측 학습모드 메뉴 */
.wrapHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

/* 제목 우측 드롭다운 메뉴 - [균형 여백 추가] */
.titleMenu {
  position: relative;
  font-size: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.titleMenuWrapper {
  position: relative;
}

.titleMenuBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #2a3447;
  background: #1b2433;
  color: #e8eef6;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s; /* 추가: 버튼 호버 효과 부드럽게 */
}
body.light-mode .titleMenuBtn {
  border-color: #ced4da;
  background: #ffffff;
  color: #1a1d23;
}
.titleMenuBtn:hover {
  background: #212c3e;
}
body.light-mode .titleMenuBtn:hover {
  background: #f8f9fa;
}
.titleMenuText {
  display: inline;
}
.titleMenuHamburger {
  display: none;
  font-size: 14px;
}
.titleMenuArrow {
  font-size: 10px;
  opacity: 0.8;
}
/* 드롭다운 메뉴 리스트 컨테이너 */
.titleMenuList {
  position: absolute;
  right: 0;
  margin-top: 4px;
  background: #0f1319;
  border: 1px solid #1a1f27;
  border-radius: 10px;
  list-style: none;

  /* ★수정 1: 메뉴 컨테이너 패딩 증가 및 스크롤 추가 (가독성/UX) */
  padding: 8px 0;
  min-width: 180px; /* 약간 넓게 조정 */
  z-index: 100;
  display: none;

  /* ★수정 2: 그림자 추가 및 최대 높이 설정 (UX) */
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-height: 70vh;
  overflow-y: auto;
  transition: opacity 0.2s, transform 0.2s; /* 애니메이션 준비 */
}
body.light-mode .titleMenuList {
  background: #ffffff;
  border-color: #dee2e6;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); /* 라이트 모드 그림자 */
}
.titleMenuList.show {
  display: block;
}
/* 드롭다운 메뉴 개별 항목 */
.titleMenuList li {
  /* ★수정 3: 항목 패딩 및 글자 크기 증가 (가독성/터치 영역) */
  padding: 10px 15px;
  font-size: 14px;

  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s; /* 추가: 호버 효과 부드럽게 */
}
.titleMenuList li:hover {
  background: #1b2433;
  color: var(--accent); /* ★수정 4: 호버 시 텍스트 강조 (시각적 피드백) */
}
body.light-mode .titleMenuList li:hover {
  background: #f0f0f0; /* 라이트 모드 호버 시 배경색 약간 변경 */
  color: var(--accent); /* 라이트 모드 호버 시 텍스트 강조 */
}
.titleMenuList li.active {
  background: linear-gradient(
    135deg,
    rgba(255, 179, 217, 0.15),
    rgba(255, 142, 199, 0.15)
  );
  color: var(--accent);
  font-weight: 600;
  border-left: 3px solid var(--accent);
}

/* 모바일에서는 햄버거 아이콘만 보이게 */
@media (max-width: 480px) {
  /* 테마 버튼: 아이콘만 표시 */
  #themeText {
    display: none;
  }
  
  .themeToggle {
    padding: 4px 8px;
    min-width: auto;
  }
  
  /* 학습 모드 버튼: PC 버전처럼 표시 */
  .titleMenuBtn {
    padding: 4px 10px;
    background: #1b2433;
    border: 1px solid #2a3447;
    border-radius: 999px;
  }
  
  .titleMenuBtn:hover {
    background: #212c3e;
  }
  
  body.light-mode .titleMenuBtn {
    background: #ffffff;
    border-color: #ced4da;
  }
  
  body.light-mode .titleMenuBtn:hover {
    background: #f8f9fa;
  }
  
  .titleMenuText {
    display: inline;
  }
  
  .titleMenuArrow {
    display: inline;
  }
  
  .titleMenuHamburger {
    display: none;
  }
  .titleMenuList li {
    padding: 10px 12px; /* 모바일 터치 영역 확장 (수정됨) */
    font-size: 14px; /* 글자 크기 증가 (수정됨) */
  }
}

/* 공지사항 배너 스타일 */
.noticeBanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1a2332 0%, #0f1620 100%);
  border: 1px solid #2a3447;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  gap: 12px;
}
body.light-mode .noticeBanner {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-color: #dee2e6;
}
.noticeContent {
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
  color: #e8eef6;
}
body.light-mode .noticeContent {
  color: #1a1d23;
}

/* PC: 줄바꿈 숨김 */
.mobile-br {
  display: none;
}

/* 모바일: 줄바꿈 표시 */
@media (max-width: 768px) {
  .mobile-br {
    display: block;
  }
}
.noticeContent .line1 {
  font-weight: 600;
  color: var(--accent);
}
.noticeContent .line2 {
  color: var(--muted);
  margin-top: 2px;
}
.noticeClose {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: all 0.2s;
  flex-shrink: 0;
}
.noticeClose:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

/* ★★★ 학습 모드 설명 영역 스타일 (modeDescriptionArea) ★★★ */
.modeDescriptionArea {
  /* .card 클래스를 이미 사용하고 있으므로 패딩만 추가 */
  padding: 16px;
}

/* 개별 학습 모드 설명 스타일 (modeDesc) */
.modeDesc h4 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: var(--accent); /* 강조 색상 적용 */
}

.modeDesc p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg);
  margin: 0 0 8px 0;
}

.modeDesc p:last-child {
  margin-bottom: 0;
}

/* 난이도 배지 스타일 */
.difficulty {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
  white-space: nowrap;
  vertical-align: middle;
}

.difficulty-easy {
  background: linear-gradient(135deg, #7ee3a2, #5ec784);
  color: #0d3d26;
  box-shadow: 0 2px 6px rgba(126, 227, 162, 0.4);
}

.difficulty-medium {
  background: linear-gradient(135deg, #ffb84d, #ff9f1c);
  color: #4d3100;
  box-shadow: 0 2px 6px rgba(255, 184, 77, 0.4);
}

.difficulty-hard {
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color: #4d0000;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

/* 라이트 모드에서도 가독성 유지 */
body.light-mode .difficulty-easy {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: #fff;
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.4);
}

body.light-mode .difficulty-medium {
  background: linear-gradient(135deg, #fd7e14, #ffc107);
  color: #fff;
  box-shadow: 0 2px 6px rgba(253, 126, 20, 0.4);
}

body.light-mode .difficulty-hard {
  background: linear-gradient(135deg, #dc3545, #e91e63);
  color: #fff;
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
}

/* 모바일 최적화 */
@media (max-width: 480px) {
  .modeDescriptionArea {
    padding: 12px;
  }
  .modeDesc h3 {
    font-size: 16px;
  }
  .modeDesc p {
    font-size: 13px;
  }
  .difficulty {
    display: block;
    font-size: 11px;
    padding: 3px 10px;
    margin-left: 0;
    margin-top: 6px;
    width: fit-content;
  }
}
/* ★★★ 학습 모드 설명 영역 스타일 끝 ★★★ */
/* ========================================= */
/* ★★★ NEW: 퀴즈 모드 카운트다운 스타일 ★★★ */
/* ========================================= */
.countdown-number {
  font-size: 6vh; /* 화면 높이에 비례하여 크기 설정 */
  font-weight: bold;
  color: var(--hl);
  line-height: 1; /* 높이를 줄여서 가운데 정렬 효과 */
  display: block; /* 블록 요소로 만들어 mainLine 중앙에 위치 */
}

/* 작은 화면(모바일)에서는 폰트 크기를 조금 더 줄임 */
@media (max-width: 600px) {
  .countdown-number {
    font-size: 4vh;
  }
}
/* ========================================= */
/* ★★★ END: 퀴즈 모드 카운트다운 스타일 ★★★ */
/* ========================================= */

/* ========================================= */
/* ★★★ 외움 기능 스타일 시작 ★★★ */
/* ========================================= */

/* 외움 바 (controls 위에 배치) */
.masteredBar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #1e2a3a, #1b2433);
  border: 1px solid #2a3447;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.light-mode .masteredBar {
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  border-color: #dee2e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 외운 카운트 */
.masteredCount {
  font-size: 14px;
  color: var(--fg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.masteredCount::before {
  content: "📚";
  font-size: 18px;
}

body.light-mode .masteredCount {
  color: #1a1d23;
}

/* 외움 버튼 */
.masteredBtn {
  width: 100%;
  background: linear-gradient(135deg, #4ecdc4, #44a8a0);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  line-height: 1.5;
  min-height: 44px;
}

.masteredIcon {
  font-size: 19px;
  color: #fff;
}

.masteredText {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.masteredCount {
  font-size: 14px;
  opacity: 0.9;
  font-weight: 600;
  color: #fff;
}

.masteredBtn:hover:not(.already-mastered) {
  background: linear-gradient(135deg, #44a8a0, #3d9990);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.5);
}

.masteredBtn:active:not(.already-mastered) {
  transform: translateY(0);
}

.masteredBtn.already-mastered {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
  cursor: default;
  opacity: 0.7;
  box-shadow: 0 2px 6px rgba(149, 165, 166, 0.3);
}

.masteredBtn.already-mastered .masteredText,
.masteredBtn.already-mastered .masteredCount,
.masteredBtn.already-mastered .masteredIcon {
  color: #fff;
}

.masteredBtn.already-mastered .masteredText::before {
  content: "✓ ";
}

/* 모달 배경 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 모달 콘텐츠 */
.modalContent {
  background: #0d0f12;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s;
}

body.light-mode .modalContent {
  background: #ffffff;
}

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

/* 모달 헤더 */
.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #2a3447;
  background: linear-gradient(135deg, #1a2332, #151d2b);
}

body.light-mode .modalHeader {
  background: linear-gradient(135deg, #e8f4f8, #d4e9f0);
  border-bottom: 1px solid #b8d4e0;
}

.modalTitle {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.light-mode .modalTitle {
  color: #2c3e50;
}

.modalHeader h3 {
  margin: 0;
  font-size: 18px;
  color: var(--fg);
}

.modalClose {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #8b95a5;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

body.light-mode .modalClose {
  background: rgba(0, 0, 0, 0.05);
  color: #6c757d;
}

.modalClose:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

body.light-mode .modalClose:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #2c3e50;
}
  transition: all 0.2s;
}

.modalClose:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--fg);
}

body.light-mode .modalClose:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* 모달 바디 */
.modalBody {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* 통계 */
.masteredStats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.statItem {
  background: linear-gradient(135deg, #1e2a3a, #1b2433);
  padding: 16px 12px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #2a3447;
  transition: all 0.2s;
}

.statItem:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.light-mode .statItem {
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  border-color: #dee2e6;
}

body.light-mode .statItem:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.statLabel {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.statValue {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

/* 외운 문장 리스트 */
.masteredList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.masteredItem {
  background: #1b2433;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #2a3447;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

body.light-mode .masteredItem {
  background: #f8f9fa;
  border-color: #dee2e6;
}

.masteredItem:hover {
  background: #212c3e;
  border-color: var(--accent);
}

body.light-mode .masteredItem:hover {
  background: #e9ecef;
}

.masteredItemText {
  flex: 1;
  margin-right: 12px;
}

.masteredItemTitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.masteredItemSentence {
  font-size: 12px;
  color: var(--muted);
}

.masteredItemActions {
  display: flex;
  gap: 4px;
}

.masteredItemBtn {
  background: none;
  border: 1px solid #2a3447;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

body.light-mode .masteredItemBtn {
  border-color: #dee2e6;
}

.masteredItemBtn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.masteredItemBtn.deleteBtn:hover {
  background: #e74c3c;
  border-color: #e74c3c;
}

/* 모달 푸터 */
.modalFooter {
  padding: 16px 20px;
  border-top: 1px solid #1a1f27;
  display: flex;
  justify-content: center;
}

body.light-mode .modalFooter {
  border-top-color: #dee2e6;
}

.dangerBtn {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.clearAllBtn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

.clearAllBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5);
}
  transition: all 0.2s;
}

.dangerBtn:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.dangerBtn:active {
  transform: translateY(0);
}

/* 빈 상태 */
.emptyState {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.emptyState svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.emptyState p {
  font-size: 14px;
  margin: 8px 0;
}

/* 모바일 최적화 */
@media (max-width: 480px) {
  .masteredBar {
    padding: 8px 12px;
  }

  .masteredCount {
    font-size: 13px;
  }

  .masteredCount::before {
    font-size: 16px;
  }

  .masteredBtn {
    padding: 8px 16px;
    font-size: 13px;
  }

  .modalContent {
    width: 95%;
    max-height: 90vh;
  }

  .masteredStats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .statItem {
    padding: 10px;
  }

  .statValue {
    font-size: 18px;
  }

  .masteredItem {
    padding: 10px;
  }

  .masteredItemTitle {
    font-size: 13px;
  }

  .masteredItemSentence {
    font-size: 11px;
  }
}

/* ========================================= */
/* ★★★ Light 모드 외움 기능 스타일 ★★★ */
/* ========================================= */

body.light-mode .masteredBar {
  background: linear-gradient(135deg, #e8f4f8, #d4e9f0) !important;
  border: 1px solid #b8d4e0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .masteredCount {
  color: #2c3e50 !important;
}

body.light-mode .masteredBtn {
  background: linear-gradient(135deg, #4ecdc4, #44a8a0) !important;
  color: #1a1d23 !important;
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3) !important;
}

body.light-mode .masteredBtn .masteredText,
body.light-mode .masteredBtn .masteredCount,
body.light-mode .masteredBtn .masteredIcon {
  color: #1a1d23 !important;
}

body.light-mode .masteredBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4) !important;
}

body.light-mode .masteredBtn.already-mastered {
  background: linear-gradient(135deg, #bdc3c7, #95a5a6) !important;
  opacity: 0.8 !important;
}

body.light-mode .masteredBtn.already-mastered .masteredText,
body.light-mode .masteredBtn.already-mastered .masteredCount,
body.light-mode .masteredBtn.already-mastered .masteredIcon {
  color: #fff !important;
}

body.light-mode #masteredModal {
  background: rgba(255, 255, 255, 0.95) !important;
}

body.light-mode .modalHeader {
  background: linear-gradient(135deg, #e8f4f8, #d4e9f0) !important;
  color: #2c3e50 !important;
  border-bottom: 1px solid #b8d4e0 !important;
}

body.light-mode .masteredStats {
  background: none !important;
}

body.light-mode .statItem {
  background: linear-gradient(135deg, #ffffff, #f8f9fa) !important;
  border: 1px solid #dee2e6 !important;
}

body.light-mode .statItem:hover {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .statLabel {
  color: #6c757d !important;
}

body.light-mode .statValue {
  color: #2c3e50 !important;
}

body.light-mode .modalFooter {
  background: #f8f9fa !important;
  border-top: 1px solid #dee2e6 !important;
}

body.light-mode .clearAllBtn {
  background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
  color: #fff !important;
}

body.light-mode .clearAllBtn:hover {
  background: linear-gradient(135deg, #c0392b, #a93226) !important;
}

body.light-mode .masteredItem {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef) !important;
  border: 1px solid #dee2e6 !important;
}

body.light-mode .masteredItem:hover {
  background: linear-gradient(135deg, #e9ecef, #dee2e6) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .masteredItemTitle {
  color: #2c3e50 !important;
}

body.light-mode .masteredItemSentence {
  color: #6c757d !important;
}

body.light-mode .masteredItemBtn {
  border: 1px solid #dee2e6 !important;
  color: #6c757d !important;
}

body.light-mode .masteredItemBtn:hover {
  background: #e9ecef !important;
  color: #2c3e50 !important;
}

body.light-mode .clearAllBtn {
  background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
  color: #fff !important;
}

body.light-mode .clearAllBtn:hover {
  background: linear-gradient(135deg, #c0392b, #a93226) !important;
}

/* ========================================= */
/* ★★★ 외움 기능 스타일 끝 ★★★ */
/* ========================================= */


/* 로그인 UI */
.authButtons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.loginBtn, .logoutBtn {
  padding: 4px 10px;
  background: #4ecdc4;
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.loginBtn:hover, .logoutBtn:hover {
  background: #45b8af;
}

.userInfo {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(78, 205, 196, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
}

#userId {
  color: #4ecdc4;
  font-weight: 600;
  font-size: 11px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
}

.logoutBtn {
  padding: 3px 8px;
  font-size: 10px;
}

/* 로그인 모달 */
.loginModal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.loginModalContent {
  background: white;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.loginModalContent h2 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 22px;
}

.loginModalContent p {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 14px;
}

.closeModal {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
}

.closeModal:hover {
  color: #333;
}

.loginInput {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.loginInput:focus {
  outline: none;
  border-color: #4ecdc4;
}

.loginError {
  color: #ff6b6b;
  font-size: 14px;
  margin-bottom: 10px;
  padding: 8px;
  background: #ffe0e0;
  border-radius: 6px;
}

.loginSubmitBtn {
  width: 100%;
  padding: 12px;
  background: #4ecdc4;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 15px;
}

.loginSubmitBtn:hover {
  background: #45b8af;
}

.loginInfo {
  margin: 0 !important;
  padding: 12px;
  background: rgba(78, 205, 196, 0.15);
  border-radius: 6px;
  color: #2c9b93 !important;
  font-size: 12px !important;
  text-align: center;
  line-height: 1.6;
  font-weight: 500;
}

.loginInfoExample {
  font-weight: 700;
  color: #ff6b9d;
  background: rgba(255, 107, 157, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

/* 토스트 메시지 */
.toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 10001;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  font-size: 14px;
}

.toast.show {
  visibility: visible;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}

/* 다크 모드 */
body.dark-mode .loginModalContent {
  background: #2d2d2d;
  color: #fff;
}

body.dark-mode .loginModalContent h2 {
  color: #fff;
}

body.dark-mode .loginModalContent p {
  color: #ccc;
}

body.dark-mode .loginInput {
  background: #1a1a1a;
  border-color: #444;
  color: #fff;
}

body.dark-mode .loginInput:focus {
  border-color: #4ecdc4;
}

body.dark-mode .loginInfo {
  background: rgba(78, 205, 196, 0.25);
  color: #5fd9c7 !important;
}

body.dark-mode .loginInfoExample {
  color: #ffb3d9;
  background: rgba(255, 179, 217, 0.15);
}

/* 환영 팝업 */
.welcomePopup {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
}

.welcomePopup.show {
  display: flex;
}

.welcomePopupContent {
  background: white;
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcomePopupClose {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 32px;
  font-weight: bold;
  color: #aaa;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.welcomePopupClose:hover {
  background: #f0f0f0;
  color: #333;
}

.welcomePopupContent h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 20px;
  padding-right: 30px;
}

.welcomePopupBody {
  margin-bottom: 20px;
  line-height: 1.6;
}

.welcomePopupBody p {
  margin: 0 0 12px 0;
  color: #555;
  font-size: 15px;
}

.welcomePopupBody strong {
  color: #4ecdc4;
  font-weight: 700;
}

.welcomePopupFooter {
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: center;
}

.dontShowButton {
  padding: 10px 20px;
  background: #4ecdc4;
  border: 1px solid #4ecdc4;
  border-radius: 6px;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.dontShowButton:hover {
  background: #45b8af;
  border-color: #45b8af;
  color: #ffffff;
}

/* 다크 모드 */
body.dark-mode .welcomePopupContent {
  background: #2d2d2d;
}

body.dark-mode .welcomePopupContent h3 {
  color: #fff;
}

body.dark-mode .welcomePopupBody p {
  color: #ccc;
}

body.dark-mode .welcomePopupBody strong {
  color: #7ee3c3;
}

body.dark-mode .welcomePopupFooter {
  border-top-color: #444;
}

body.dark-mode .dontShowButton {
  background: #4ecdc4;
  border-color: #4ecdc4;
  color: #ffffff;
}

body.dark-mode .dontShowButton:hover {
  background: #45b8af;
  border-color: #45b8af;
  color: #ffffff;
}

body.dark-mode .welcomePopupClose:hover {
  background: #444;
  color: #fff;
}
