/* ==========================================================================
   노인 친화 디자인 토큰 (복지센터 앱 톤 · 88px 터치 타겟 · 20px+ 본문)
   ========================================================================== */

:root {
  --color-bg: #F7F3EA;
  --color-surface: #FFFFFF;
  --color-surface-soft: #FFFCF6;
  --color-text: #10201F;
  --color-text-soft: #526663;
  --color-muted: #7A6F62;
  --color-primary: #0F766E;
  --color-primary-dark: #0A4F49;
  --color-primary-soft: #DDF1EE;
  --color-accent: #B7791F;
  --color-accent-dark: #7C4F13;
  --color-accent-darker: #5F3B0D;
  --color-accent-soft: #FFF1CE;
  --color-success: #166534;
  --color-success-soft: #E5F4EA;
  --color-warn: #A16207;
  --color-warn-soft: #FFF3D7;
  --color-danger: #9F1D1D;
  --color-danger-soft: #FDE2E2;
  --color-highlight: #FFF0B8;
  --color-highlight-border: #B7791F;
  --color-border: #DCD4C4;
  --color-border-strong: #C7BBA8;
  --color-shadow: rgba(43, 38, 30, 0.12);
  --color-tree: #14735F;

  --font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont,
    'Apple SD Gothic Neo', sans-serif;
  --font-size-body: 20px;
  --font-size-sm: 17px;
  --font-size-lg: 23px;
  --font-size-xl: 31px;
  --font-size-xxl: 38px;
  --font-size-verse: 30px;
  --line-height-body: 1.6;

  --touch-target: 88px;
  --radius-card: 8px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --radius: var(--radius-card);
  --radius-lg: var(--radius-control);
  --padding-btn: 22px;
  --gap: 18px;
  --app-width: 430px;

  --anim-fast: 180ms;
  --anim-med: 360ms;
  --anim-slow: 700ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 4px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: var(--radius-control);
}

/* ==========================================================================
   레이아웃 공통
   ========================================================================== */

.app-header,
.app-main,
.app-footer {
  width: 100%;
  max-width: min(var(--app-width), 100vw);
  min-width: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 74px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header .title {
  min-width: 0;
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.app-header .streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius-pill);
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}

.streak-label {
  color: var(--color-text-soft);
  font-size: 14px;
  font-weight: 700;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}

.app-footer {
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-soft);
  text-align: center;
}

.footer-main,
.footer-note {
  margin: 0;
}

.footer-main {
  font-size: 16px;
  font-weight: 600;
}

.footer-note {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  min-height: 58px;
  padding: 14px 18px;
  color: var(--color-text);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  font-size: 18px;
  font-weight: 800;
  transition: transform var(--anim-fast) ease, background var(--anim-fast) ease;
}

.back-button::before {
  content: "‹";
  margin-right: 8px;
  font-size: 28px;
  line-height: 1;
}

.back-button:active {
  transform: translateY(1px);
  background: var(--color-primary-soft);
}

/* ==========================================================================
   메인 화면
   ========================================================================== */

.hero {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap);
  min-width: 0;
}

.training-intro {
  padding: 8px 2px 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--color-primary-dark);
  font-size: 15px;
  font-weight: 900;
}

.training-intro h2 {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-xxl);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.training-intro p {
  max-width: 420px;
  margin: 10px 0 0;
  color: var(--color-text-soft);
  font-size: var(--font-size-body);
  font-weight: 600;
}

.profile-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius-card);
  min-width: 0;
}

.welcome-message {
  margin: 0;
  color: var(--color-primary-dark);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-form label {
  color: var(--color-text-soft);
  font-size: 16px;
  font-weight: 900;
}

.name-input-row {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.name-input-row input {
  flex: 1;
  min-width: 0;
  min-height: 62px;
  padding: 12px 14px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid rgba(15, 118, 110, 0.3);
  border-radius: var(--radius-control);
  font-family: inherit;
  font-size: 20px;
  font-weight: 800;
}

.name-save,
.name-edit {
  min-height: 62px;
  color: #FFFFFF;
  background: var(--color-primary);
  border-radius: var(--radius-control);
  font-size: 19px;
  font-weight: 900;
}

.name-save {
  flex: 0 0 92px;
}

.name-edit {
  align-self: flex-start;
  padding: 12px 18px;
}

.name-save:active,
.name-edit:active {
  background: var(--color-primary-dark);
}

.tree-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 22px 20px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 24px var(--color-shadow);
  text-align: center;
}

#treeImage {
  display: grid;
  place-items: center;
  width: 176px;
  height: 176px;
  margin-bottom: 2px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 50%;
}

.tree-container svg {
  width: 138px;
  height: 138px;
  filter: saturate(0.86) contrast(0.98);
}

.tree-stage-label {
  margin: 0;
  color: var(--color-tree);
  font-size: var(--font-size-lg);
  font-weight: 900;
}

.tree-points,
.tree-next {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 18px;
  font-weight: 700;
}

.tree-next {
  color: var(--color-muted);
  font-size: 16px;
}

.today-message {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.section-heading-row > div {
  min-width: 0;
}

.section-heading-row h2,
.journey-main h2 {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.section-kicker,
.progress-kicker {
  margin: 0 0 4px;
  color: var(--color-primary-dark);
  font-size: 14px;
  font-weight: 900;
}

.daily-reading-card,
.journey-card,
.pilot-card,
.result-progress-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 18px rgba(43, 38, 30, 0.08);
  min-width: 0;
}

.daily-reading-card {
  border-color: rgba(15, 118, 110, 0.24);
}

.difficulty-pill,
.sync-pill {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

.daily-passage,
.daily-summary,
.pilot-card p,
.license-note,
.progress-caption,
.result-progress-card p {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.daily-passage {
  color: var(--color-accent-dark);
  font-weight: 900;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tag-row span,
.price-preview span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  color: var(--color-muted);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 800;
}

.daily-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.daily-actions .secondary-cta,
.daily-actions .primary-cta {
  min-height: 74px;
  font-size: 22px;
}

.daily-actions .primary-cta {
  box-shadow: 0 4px 0 var(--color-primary-dark);
}

.daily-done.is-complete {
  color: var(--color-success);
  background: var(--color-success-soft);
  border-color: rgba(22, 101, 52, 0.25);
}

.journey-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.journey-main > div:first-child {
  min-width: 0;
}

.journey-main p {
  margin: 6px 0 0;
  color: var(--color-text-soft);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.level-number {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  color: #FFFFFF;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12);
  font-size: 34px;
  font-weight: 950;
}

.one-read-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--color-text-soft);
  font-size: 15px;
  font-weight: 900;
}

.mini-progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  background: #E7DFD1;
  border-radius: var(--radius-pill);
}

.mini-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #8A9A5B);
  border-radius: inherit;
  transition: width var(--anim-med) ease;
}

.license-note {
  padding: 10px 12px;
  background: var(--color-accent-soft);
  border: 1px solid rgba(183, 121, 31, 0.2);
  border-radius: var(--radius-card);
  color: var(--color-accent-dark);
  font-size: 14px;
}

.role-toggle button {
  min-height: 56px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius-control);
  font-size: 16px;
  font-weight: 900;
}

.role-toggle {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.role-toggle button[aria-pressed="true"] {
  color: #FFFFFF;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.price-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-cta,
.secondary-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius-control);
  text-align: center;
  transition: transform var(--anim-fast) ease, box-shadow var(--anim-fast) ease,
    background var(--anim-fast) ease;
}

.primary-cta {
  min-height: 94px;
  padding: var(--padding-btn) 30px;
  color: #FFFFFF;
  background: var(--color-primary);
  box-shadow: 0 5px 0 var(--color-primary-dark);
  font-size: var(--font-size-xl);
  font-weight: 900;
}

.primary-cta:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--color-primary-dark);
}

.secondary-cta {
  min-height: var(--touch-target);
  padding: 20px 24px;
  color: var(--color-primary-dark);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.secondary-cta:active {
  background: var(--color-primary-soft);
}

.danger-cta {
  color: var(--color-danger);
  background: var(--color-surface);
  border-color: #E6B7B7;
}

.danger-cta:active {
  background: var(--color-danger-soft);
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  min-width: 0;
  padding: 18px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  text-align: center;
}

.stat-card .value {
  color: var(--color-primary-dark);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.stat-card .label {
  margin-top: 8px;
  color: var(--color-text-soft);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

/* ==========================================================================
   게임 화면
   ========================================================================== */

.game-header {
  min-height: 70px;
}

.game-header .title {
  flex: 1;
  text-align: center;
  font-size: 20px;
}

.game-main {
  min-height: calc(100svh - 70px);
  padding-top: 14px;
  gap: 14px;
}

.game-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.verse-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 186px;
  padding: 30px 22px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  text-align: center;
  box-shadow: 0 8px 18px rgba(43, 38, 30, 0.08);
  transition: opacity var(--anim-med) ease;
}

.verse-display.fading {
  opacity: 0;
}

.verse-display.collapsed {
  display: none;
}

.verse-ref {
  margin: 0 0 12px;
  color: var(--color-primary-dark);
  font-size: 17px;
  font-weight: 900;
}

.verse-text {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-verse);
  font-weight: 850;
  line-height: 1.48;
}

.verse-text .target {
  display: inline-block;
  padding: 2px 10px 4px;
  background: var(--color-highlight);
  border-bottom: 4px solid var(--color-highlight-border);
  border-radius: 8px;
}

.ref-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  z-index: 3;
  max-width: calc(100% - 28px);
  padding: 8px 14px;
  transform: translateX(-50%);
  color: var(--color-text-soft);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-med) ease;
  white-space: nowrap;
}

.ref-hint.visible {
  opacity: 1;
}

.word-arena {
  position: relative;
  flex: 1;
  min-height: 330px;
  overflow: hidden;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.word-arena::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.18);
  border-radius: var(--radius-card);
  pointer-events: none;
}

.floating-word {
  position: absolute;
  min-width: 104px;
  min-height: 76px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  box-shadow: 0 3px 0 var(--color-border-strong);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
  will-change: transform;
  transition: transform 0.05s linear;
  -webkit-tap-highlight-color: transparent;
}

.floating-word.target-glow {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 5px var(--color-accent-soft), 0 3px 0 var(--color-accent-dark);
  animation: glowPulse 1.7s ease-in-out infinite;
}

.floating-word.correct {
  color: var(--color-success);
  background: var(--color-success-soft);
  border-color: var(--color-success);
  animation: popSuccess var(--anim-med) ease forwards;
}

.floating-word.wrong-pick {
  background: var(--color-warn-soft);
  border-color: var(--color-warn);
  animation: shakeWrong 380ms ease;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 0 5px var(--color-accent-soft), 0 3px 0 var(--color-accent-dark);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(183, 121, 31, 0.18), 0 3px 0 var(--color-accent-dark);
  }
}

@keyframes popSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(0.02); opacity: 0; }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.feedback-pulse {
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}

.feedback-pulse.correct {
  background: rgba(22, 101, 52, 0.10);
  animation: pulseFlash 480ms ease;
}

.feedback-pulse.wrong {
  background: rgba(161, 98, 7, 0.12);
  animation: pulseFlash 480ms ease;
}

@keyframes pulseFlash {
  0% { opacity: 0; }
  45% { opacity: 1; }
  100% { opacity: 0; }
}

.progress-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  background: #E7DFD1;
  border-radius: var(--radius-pill);
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--anim-fast) linear;
}

.round-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-text-soft);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.round-counter span {
  line-height: 1.2;
}

.round-counter strong {
  color: var(--color-primary-dark);
  font-size: var(--font-size-lg);
}

.round-hint {
  color: var(--color-muted);
  font-size: 16px;
  font-weight: 800;
  text-align: right;
}

.game-instruction {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

/* ==========================================================================
   결과 화면
   ========================================================================== */

.result-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  text-align: center;
  box-shadow: 0 10px 24px var(--color-shadow);
}

.result-hero .big-score {
  margin: 0;
  color: var(--color-primary);
  font-size: 78px;
  font-weight: 950;
  line-height: 1;
  animation: scoreBounce 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-hero .score-label {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-xl);
  font-weight: 900;
  line-height: 1.25;
}

.result-hero .subtitle {
  margin: 0;
  color: var(--color-text-soft);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.mode-label {
  margin: 0;
  color: var(--color-muted);
  font-size: 18px;
  font-weight: 800;
}

@keyframes scoreBounce {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.result-stat {
  padding: 20px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  text-align: center;
}

.result-stat .stat-value {
  color: var(--color-primary-dark);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.result-stat .stat-label {
  margin-top: 8px;
  color: var(--color-text-soft);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.result-note-wrap {
  margin-top: 2px;
}

.comparison-note {
  min-height: 32px;
  color: var(--color-text-soft);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.comparison-note-positive {
  color: var(--color-tree);
}

.result-progress-card h2 {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 900;
  line-height: 1.25;
}

.result-actions {
  margin-top: 2px;
}

.confetti-container {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: confettiFall 2.4s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-20vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}

/* ==========================================================================
   설정 다이얼로그
   ========================================================================== */

.settings-dialog {
  width: calc(100% - 32px);
  max-width: 430px;
  padding: 22px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  box-shadow: 0 24px 60px rgba(20, 24, 20, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(16, 32, 31, 0.38);
}

.settings-dialog h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.2;
}

.settings-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.settings-sync {
  margin: 0 0 18px;
  padding: 16px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.settings-sync h3 {
  margin: 0 0 8px;
  color: var(--color-primary);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
}

.settings-sync p {
  margin: 0 0 14px;
  color: var(--color-muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.45;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  font-size: 20px;
  font-weight: 800;
}

.setting-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  accent-color: var(--color-primary);
}

.setting-ageband {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.setting-ageband legend {
  padding: 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--color-text-soft);
}

.dialog-action {
  min-height: 68px;
  margin-bottom: 12px;
  font-size: 20px;
}

.dialog-close {
  min-height: 82px;
  margin-top: 6px;
}

.loading-message,
.load-error {
  padding: 70px 24px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.5;
}

.loading-message {
  color: var(--color-text-soft);
}

.load-error {
  color: var(--color-accent-darker);
}

/* ==========================================================================
   Utility
   ========================================================================== */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.centered-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.compact-actions {
  margin-top: 0;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

/* ==========================================================================
   모드 선택 카드 (index.html)
   ========================================================================== */

.mode-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 112px;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  text-align: left;
  transition: transform var(--anim-fast) ease, box-shadow var(--anim-fast) ease, border-color var(--anim-fast) ease;
  box-shadow: 0 8px 18px rgba(43, 38, 30, 0.08);
}

.mode-card:active {
  transform: translateY(2px);
  box-shadow: 0 4px 10px rgba(43, 38, 30, 0.08);
}

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

.mode-card .mode-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 86px;
  height: 86px;
  padding: 8px;
  background: #F4FAF8;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius-control);
}

.mode-card .mode-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mode-card .mode-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.mode-card .mode-title {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.mode-card .mode-desc {
  font-size: 16px;
  color: var(--color-text-soft);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mode-card .mode-last {
  font-size: 14px;
  color: var(--color-accent-dark);
  font-weight: 800;
  margin-top: 4px;
}

/* ==========================================================================
   말씀 조각 맞추기 (game-puzzle.html)
   ========================================================================== */

.puzzle-stage,
.story-stage,
.quiz-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  min-height: 520px;
  box-shadow: 0 8px 18px rgba(43, 38, 30, 0.08);
}

.story-stage {
  min-height: 440px;
}

.quiz-stage {
  min-height: 360px;
}

.puzzle-header,
.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.puzzle-ref,
.story-ref {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-soft);
}

.story-title {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--color-text);
}

.tts-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.26);
  border-radius: var(--radius-control);
  cursor: pointer;
}

.tts-mini:active {
  transform: translateY(2px);
}

/* ==========================================================================
   오늘 말씀 퀴즈 (game-quiz.html)
   ========================================================================== */

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-ref {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-soft);
}

.quiz-question {
  margin: 0;
  font-size: 30px;
  line-height: 1.45;
  color: var(--color-text);
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-timer {
  height: 8px;
  background: var(--color-surface-soft);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.quiz-tts-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-tts-options .tts-mini {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 16px;
}

.quiz-choice {
  min-height: 66px;
  padding: 14px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-card);
  transition: background var(--anim-fast), border-color var(--anim-fast), transform var(--anim-fast);
}

.quiz-choice:active {
  transform: translateY(2px);
}

.quiz-choice.correct {
  background: var(--color-success-soft);
  border-color: var(--color-success);
  color: var(--color-success);
}

.quiz-choice.wrong {
  background: var(--color-warn-soft);
  border-color: var(--color-warn);
}

.quiz-feedback {
  min-height: 32px;
  font-size: 20px;
  font-weight: 800;
  color: var(--color-text-soft);
}

.quiz-feedback.correct {
  color: var(--color-success);
}

.quiz-feedback.wrong {
  color: var(--color-warn-dark);
}

/* 슬롯 행 */
.puzzle-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  min-height: 240px;
}

.puzzle-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-card);
  text-align: left;
  font-family: inherit;
  font-size: var(--font-size-body);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--anim-fast), border-color var(--anim-fast), transform var(--anim-fast);
}

.puzzle-slot .slot-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.puzzle-slot .slot-text {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
}

.puzzle-slot.filled {
  background: var(--color-accent-soft);
  border-style: solid;
  border-color: var(--color-accent);
}

.puzzle-slot.slot-correct {
  background: var(--color-success-soft);
  border-color: var(--color-success);
  color: var(--color-success);
}

.puzzle-slot.slot-wrong {
  background: var(--color-warn-soft);
  border-color: var(--color-warn);
  animation: shakeWrong 420ms ease;
}

/* 조각 풀 */
.puzzle-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  min-height: 120px;
}

.puzzle-piece {
  min-height: 64px;
  padding: 14px 22px;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  box-shadow: 0 3px 0 var(--color-border-strong);
  cursor: pointer;
  transition: transform var(--anim-fast), box-shadow var(--anim-fast);
}

.puzzle-piece:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--color-border);
}

.puzzle-piece.placed {
  opacity: 0.25;
  pointer-events: none;
  cursor: default;
}

.puzzle-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
}

.puzzle-actions .primary-cta,
.puzzle-actions .secondary-cta {
  flex: 1;
  min-height: 72px;
  max-width: none;
}

.puzzle-actions .primary-cta:disabled {
  background: var(--color-border);
  color: var(--color-text-soft);
  box-shadow: none;
  cursor: not-allowed;
}

/* ==========================================================================
   이야기 순서 맞추기 (game-story.html)
   ========================================================================== */

.story-narration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 24px;
  text-align: center;
}

.story-narration p {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}

.story-narration .story-start {
  max-width: 420px;
}

.story-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.story-slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-height: 180px;
  padding: 8px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-card);
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background var(--anim-fast), border-color var(--anim-fast);
}

.story-slot .slot-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  align-self: flex-start;
  margin: 4px;
}

.story-slot .slot-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.story-slot.filled {
  background: var(--color-accent-soft);
  border-style: solid;
  border-color: var(--color-accent);
}

.story-slot.slot-correct {
  background: var(--color-success-soft);
  border-color: var(--color-success);
}

.story-slot.slot-wrong {
  background: var(--color-warn-soft);
  border-color: var(--color-warn);
  animation: shakeWrong 420ms ease;
}

.story-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.story-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-card);
  box-shadow: 0 3px 0 var(--color-border-strong);
  font-family: inherit;
  cursor: pointer;
  min-height: 180px;
  text-align: center;
  transition: transform var(--anim-fast), box-shadow var(--anim-fast);
}

.story-card:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--color-border);
}

.story-card.placed {
  opacity: 0.3;
  pointer-events: none;
}

.story-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--color-bg);
}

.story-card-text-box {
  display: grid;
  place-items: center;
  padding: 12px;
  background: #F5EFE3;
  border: 1px solid var(--color-border);
}

.story-card-text-box span {
  color: var(--color-text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}

.story-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.story-card-caption {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  padding: 0 4px;
}

/* ==========================================================================
   Motion preference & small screen
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .floating-word {
    transition: none;
  }
}

@media (max-width: 420px) {
  :root {
    --font-size-body: 19px;
    --font-size-lg: 22px;
    --font-size-xl: 28px;
    --font-size-xxl: 34px;
    --font-size-verse: 26px;
    --gap: 16px;
  }

  .app-header {
    min-height: 70px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-header .streak {
    padding-left: 12px;
    padding-right: 12px;
    font-size: 16px;
  }

  .streak-label {
    display: none;
  }

  #treeImage {
    width: 160px;
    height: 160px;
  }

  .tree-container svg {
    width: 126px;
    height: 126px;
  }

  .floating-word {
    min-width: 92px;
    min-height: 68px;
    padding: 13px 18px;
    font-size: 23px;
  }

  .result-hero .big-score {
    font-size: 68px;
  }

  .mode-card { padding: 16px; min-height: 104px; gap: 14px; }
  .mode-card .mode-icon { width: 68px; height: 68px; padding: 6px; }

  .daily-reading-card,
  .journey-card,
  .pilot-card,
  .result-progress-card {
    padding: 16px;
  }

  .section-heading-row {
    align-items: flex-start;
  }

  .daily-actions .secondary-cta,
  .daily-actions .primary-cta {
    min-height: 70px;
    font-size: 20px;
  }

  .level-number {
    width: 64px;
    height: 64px;
    font-size: 30px;
  }

  .puzzle-piece { font-size: 18px; padding: 12px 16px; min-height: 56px; }
  .puzzle-slot .slot-text { font-size: 18px; }
  .puzzle-actions { flex-direction: column; }

  .story-pool { grid-template-columns: repeat(2, 1fr); }
  .story-slots { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .story-slot { min-height: 150px; }
  .story-card { min-height: 150px; }
  .story-card-caption { font-size: 13px; }
}

@media (max-width: 600px) {
  body {
    align-items: flex-start;
  }
}

@media (max-width: 360px) {
  :root {
    --font-size-verse: 24px;
  }

  .training-intro h2 {
    font-size: 31px;
  }

  .primary-cta {
    font-size: 26px;
  }

  .round-counter {
    gap: 8px;
    font-size: 15px;
  }

  .back-button {
    min-width: 94px;
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (max-height: 720px) {
  .verse-display {
    min-height: 160px;
    padding: 24px 18px;
  }

  .word-arena {
    min-height: 270px;
  }

  .primary-cta {
    min-height: 88px;
  }
}
