/* 한국사 기억탐험 - 스타일
   컨셉: 역사 탐험 지도 + 기억 게임. 은은한 색, 큰 버튼/카드, 반응형. */

:root {
  --bg: #f6f1e7;
  --bg-alt: #efe6d4;
  --ink: #33291c;
  --ink-soft: #6b5d47;
  --paper: #fffaf0;
  --accent: #c07b3f;
  --accent-dark: #9c5f2c;
  --accent-soft: #f0dcc0;
  --blue: #5a6f9c;
  --green: #4f9d69;
  --green-bg: #e3f2e6;
  --yellow: #c99a2e;
  --yellow-bg: #fbf1d8;
  --red: #c0563f;
  --red-bg: #fbe4dd;
  --gray: #9a8f7a;
  --shadow: 0 3px 10px rgba(90, 70, 40, 0.12);
  --radius: 18px;
  font-size: 17px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#appShell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ---------- 헤더 ---------- */
#appHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--paper);
  border-bottom: 3px solid var(--accent-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
#headerTitle {
  flex: 1;
  text-align: center;
  font-size: 1.15rem;
  margin: 0;
  color: var(--accent-dark);
}
#headerSpacer { width: 40px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--accent-soft);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--accent-dark);
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }
.student-badge {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: none;
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
  font-family: inherit;
}
.student-badge:active { transform: scale(0.94); }

/* ---------- 본문 ---------- */
#screenContent {
  flex: 1;
  padding: 18px 16px 30px;
  overflow-y: auto;
}

/* ---------- 하단 네비 ---------- */
#bottomNav {
  display: flex;
  background: var(--paper);
  border-top: 3px solid var(--accent-soft);
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.nav-item {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
.nav-item .nav-icon { font-size: 1.35rem; }
.nav-item.active { color: var(--accent-dark); font-weight: 700; }
.nav-item:active { transform: scale(0.96); }

/* ---------- 공통 요소 ---------- */
h2.screen-title {
  font-size: 1.3rem;
  margin: 0 0 6px;
  color: var(--accent-dark);
}
p.screen-sub {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--paper); color: var(--accent-dark); border: 2px solid var(--accent-soft); }
.btn-block { display: block; width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }
.btn:disabled { opacity: 0.5; cursor: default; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.big-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.big-card .big-icon { font-size: 2.1rem; }
.big-card .big-label { font-weight: 700; font-size: 1rem; }
.big-card:active { transform: scale(0.97); }
.big-card.locked { opacity: 0.55; cursor: default; }
.big-card .status-dot { font-size: 0.9rem; }

/* 개념 카드 (뒤집기) */
.concept-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.concept-card .card-icon { font-size: 1.8rem; }
.concept-card .card-label { font-weight: 700; }
.concept-card .card-desc { font-size: 0.82rem; color: var(--ink-soft); display: none; margin-top: 4px; }
.concept-card.flipped .card-desc { display: block; }
.concept-card.flipped { background: var(--accent-soft); }

/* 흐름도 */
.flow-diagram {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  text-align: center;
}
.flow-step {
  font-weight: 700;
  color: var(--accent-dark);
  padding: 6px 0;
}
.flow-arrow { color: var(--gray); }

/* 상태 배지 */
.status-badge { font-size: 1rem; }
.status-green { color: var(--green); }
.status-yellow { color: var(--yellow); }
.status-red { color: var(--red); }
.status-new { color: var(--gray); }

/* 홈: 오늘의 복습 배너 */
.review-banner {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.review-banner h3 { margin: 0 0 8px; font-size: 1.25rem; }
.review-banner p { margin: 0 0 16px; opacity: 0.95; }
.review-banner .btn-primary { background: #fff; color: var(--accent-dark); }

.mini-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* 게임 공통 */
.game-instruction { color: var(--ink-soft); margin-bottom: 14px; line-height: 1.5; }
.game-status { min-height: 1.4em; color: var(--accent-dark); font-weight: 700; margin: 10px 0; }

.recall-grid, .compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.recall-card, .compare-card {
  background: var(--paper);
  border: 2px solid var(--accent-soft);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.recall-card.selected, .compare-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.compare-card.correct { border-color: var(--green); background: var(--green-bg); }
.compare-card.wrong { border-color: var(--red); background: var(--red-bg); }

.compare-target-row { display: flex; gap: 10px; margin: 14px 0; }
.compare-target {
  flex: 1;
  background: var(--bg-alt);
  border: 2px dashed var(--gray);
  border-radius: 14px;
  padding: 16px 8px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
}
.compare-target:active { transform: scale(0.98); }

.feedback-list { margin: 14px 0; }
.feedback-line {
  background: var(--bg-alt);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.connect-columns { display: flex; gap: 12px; }
.connect-col { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.connect-card {
  background: var(--paper);
  border: 2px solid var(--accent-soft);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.connect-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.connect-card.matched { border-color: var(--green); background: var(--green-bg); opacity: 0.75; }
.match-desc-card { padding: 10px 8px; }
.match-desc-text { font-size: 0.8rem; line-height: 1.4; }

/* 플래시카드 학습 */
.flashcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 220px;
  background: var(--paper);
  border: 2px solid var(--accent-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 16px;
}
.flashcard.revealed { background: var(--accent-soft); border-color: var(--accent); }
.flashcard-icon { font-size: 2.6rem; }
.flashcard-name { font-size: 1.3rem; font-weight: 800; color: var(--ink); }
.flashcard-hint { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }
.flashcard-desc { font-size: 1rem; color: var(--ink); line-height: 1.5; margin: 0; }

/* 매칭 게임 범위 선택 */
.scope-unit-block {
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.scope-unit-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
}
.scope-unit-header input { width: 18px; height: 18px; }
.scope-era-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-left: 26px;
}
.scope-era-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.scope-era-item input { width: 16px; height: 16px; }

.timeline-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 2px solid var(--accent-soft);
  border-radius: 14px;
  padding: 10px 12px;
}
.timeline-row.correct { border-color: var(--green); background: var(--green-bg); }
.timeline-row.wrong { border-color: var(--red); background: var(--red-bg); }
.timeline-index {
  width: 26px; height: 26px;
  background: var(--accent-soft);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.timeline-row .card-label { flex: 1; font-weight: 700; }
.timeline-controls { display: flex; gap: 4px; }
.btn-move {
  width: 32px; height: 32px;
  border: none;
  background: var(--bg-alt);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-move:disabled { opacity: 0.3; }

/* 시간 지도 */
.roadmap-list { display: flex; flex-direction: column; }
.roadmap-node {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 10px;
  position: relative;
}
.roadmap-node:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 52px;
  width: 3px;
  height: 26px;
  background: var(--accent-soft);
}
.roadmap-dot {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  cursor: pointer;
}
.roadmap-node.locked .roadmap-dot { background: var(--bg-alt); filter: grayscale(0.6); opacity: 0.7; cursor: default; }
.roadmap-label { font-weight: 700; }
.roadmap-node.locked .roadmap-label { color: var(--gray); }
.roadmap-sub { font-size: 0.8rem; color: var(--ink-soft); }

/* 나의 기억 상태 */
.stat-summary-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-pill {
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.era-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.era-status-row .era-icon { font-size: 1.6rem; }
.era-status-row .era-name { flex: 1; font-weight: 700; }

/* 오늘의 복습 결과 */
.result-group { margin-bottom: 16px; }
.result-group h4 { margin: 0 0 8px; }
.result-item {
  background: var(--paper);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

/* 학생 번호 선택 화면 */
#studentGateScreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  background: var(--bg);
}
.gate-title { font-size: 1.4rem; color: var(--accent-dark); margin: 10px 0 4px; text-align: center; }
.gate-sub { color: var(--ink-soft); margin: 0 0 22px; text-align: center; }
.gate-icon { font-size: 2.6rem; }
.number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 420px;
  width: 100%;
}
.number-card {
  aspect-ratio: 1;
  border: 2px solid var(--accent-soft);
  background: var(--paper);
  border-radius: 14px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.number-card:active { background: var(--accent-soft); transform: scale(0.95); }

@media (max-width: 420px) {
  :root { font-size: 15.5px; }
  .connect-card { font-size: 0.85rem; }
}
