/* ============================================================
   받아쓰기 앱 스타일
   테마: "국어 공책" — 크림색 종이 + 초록 줄노트 + 크레용 색 포인트
   시그니처: 정답을 쓰는 원고지 칸(answer-grid) + 결과화면의 빨간 도장
   ============================================================ */

:root {
  --paper: #fffbf0;
  --paper-line: #cfe9d8;
  --ink: #2d3047;
  --ink-soft: #5b5f7a;
  --red: #ef5b5b;
  --yellow: #f4a825;
  --green: #3e9f6e;
  --blue: #3e92cc;
  --purple: #8e6fce;
  --stamp-red: #d13b3b;

  --radius-lg: 28px;
  --radius-md: 16px;
  --shadow-soft: 0 6px 0 rgba(45, 48, 71, 0.08), 0 10px 24px rgba(45, 48, 71, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Gowun Dodum", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 43px,
    var(--paper-line) 43px,
    var(--paper-line) 45px
  );
  background-attachment: local;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
}

.app-shell {
  width: 100%;
  max-width: 640px;
}

/* -------------------- 상단 노트 탭 -------------------- */

.notebook-tab {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.notebook-tab .tab-chip {
  background: var(--green);
  color: #fff;
  font-family: "Jua", sans-serif;
  font-size: 15px;
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}

.notebook-tab h1 {
  font-family: "Jua", sans-serif;
  font-size: 30px;
  margin: 0;
  letter-spacing: 1px;
}

.notebook-tab .subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* -------------------- 카드 공통 -------------------- */

.card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  width: 40px;
  height: 10px;
  background: var(--yellow);
  border-radius: 0 0 6px 6px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: page-in 0.35s ease;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(10px) rotate(-0.5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
}

/* -------------------- 시작 화면 -------------------- */

label {
  display: block;
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  font-weight: 600;
}

.name-input {
  width: 100%;
  font-family: "Gowun Dodum", sans-serif;
  font-size: 20px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--paper-line);
  background: var(--paper);
  outline: none;
  margin-bottom: 22px;
  transition: border-color 0.15s;
}

.name-input:focus {
  border-color: var(--blue);
}

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

.round-card {
  border: 2px solid var(--paper-line);
  background: var(--paper);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  font-family: "Jua", sans-serif;
  font-size: 15px;
  color: var(--ink);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.round-card .round-num {
  display: block;
  font-size: 22px;
  color: var(--blue);
  margin-bottom: 4px;
}

.round-card:hover {
  transform: translateY(-2px);
}

.round-card.selected {
  border-color: var(--blue);
  background: #eaf4fb;
}

.round-card.selected .round-num {
  color: var(--red);
}

.btn {
  font-family: "Jua", sans-serif;
  font-size: 18px;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  color: #fff;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.btn:active {
  transform: translateY(2px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue);
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--ink-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  text-decoration: underline;
}

/* -------------------- 퀴즈 화면 -------------------- */

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.quiz-progress {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper-line);
  transition: background 0.2s, transform 0.2s;
}

.dot.done-correct {
  background: var(--green);
}

.dot.done-wrong {
  background: var(--red);
}

.dot.current {
  transform: scale(1.3);
  background: var(--yellow);
}

.quiz-count {
  font-family: "Jua", sans-serif;
  color: var(--ink-soft);
  font-size: 14px;
}

.speaker-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0 26px;
}

.speaker-btn {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(62, 146, 204, 0.25), 0 16px 30px rgba(62, 146, 204, 0.35);
  position: relative;
}

.speaker-btn svg {
  width: 56px;
  height: 56px;
  fill: #fff;
}

.speaker-btn.playing {
  animation: pulse-ring 0.9s ease-out infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 10px 0 rgba(62, 146, 204, 0.25), 0 0 0 0 rgba(62, 146, 204, 0.45);
  }
  70% {
    box-shadow: 0 10px 0 rgba(62, 146, 204, 0.25), 0 0 0 22px rgba(62, 146, 204, 0);
  }
  100% {
    box-shadow: 0 10px 0 rgba(62, 146, 204, 0.25), 0 0 0 0 rgba(62, 146, 204, 0);
  }
}

.speaker-hint {
  margin-top: 12px;
  font-size: 14px;
  color: var(--ink-soft);
}

.replay-btn {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--blue);
  font-family: "Gowun Dodum", sans-serif;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

/* 원고지 칸 스타일 정답 입력 (시그니처 요소) */

.answer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--paper);
  border: 2px dashed var(--paper-line);
  cursor: text;
  min-height: 76px;
  align-content: flex-start;
  position: relative;
}

.answer-grid:focus-within {
  border-color: var(--blue);
}

.cell {
  width: 44px;
  height: 56px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Gowun Dodum", sans-serif;
  font-size: 24px;
  color: var(--ink);
}

.cell.empty {
  border-color: var(--paper-line);
  background: transparent;
}

.cell.caret {
  border-color: var(--blue);
}

.answer-input-hidden {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}

.feedback-msg {
  margin-top: 14px;
  font-size: 14px;
  min-height: 20px;
  color: var(--ink-soft);
}

/* -------------------- 결과 화면 -------------------- */

.result-header {
  text-align: center;
  margin-bottom: 6px;
}

.stamp-wrap {
  display: flex;
  justify-content: center;
  margin: 6px 0 18px;
}

.stamp {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 6px solid var(--stamp-red);
  color: var(--stamp-red);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Jua", sans-serif;
  font-size: 20px;
  line-height: 1.3;
  transform: scale(0) rotate(-18deg);
  animation: stamp-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) 0.15s forwards;
  box-shadow: inset 0 0 0 3px rgba(209, 59, 59, 0.25);
}

.stamp.stamp-blue {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: inset 0 0 0 3px rgba(62, 146, 204, 0.25);
}

@keyframes stamp-in {
  to {
    transform: scale(1) rotate(-10deg);
  }
}

.score-line {
  text-align: center;
  font-family: "Jua", sans-serif;
  font-size: 22px;
  margin-bottom: 20px;
}

.score-line span {
  color: var(--blue);
  font-size: 28px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--paper);
}

.review-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.review-mark.correct {
  background: var(--green);
}

.review-mark.wrong {
  background: var(--red);
}

.review-text {
  font-size: 15px;
}

.review-text .your-answer {
  color: var(--ink-soft);
  font-size: 13px;
}

.save-status {
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 18px;
  min-height: 18px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-actions .btn {
  flex: 1;
}

footer.hint-footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 18px;
}

@media (max-width: 420px) {
  .cell {
    width: 36px;
    height: 48px;
    font-size: 20px;
  }
  .speaker-btn {
    width: 108px;
    height: 108px;
  }
  .speaker-btn svg {
    width: 46px;
    height: 46px;
  }
}
