/* ==========================================================================
   링링 보카 (RingRing Vocab) — UI 재설계 3/4: 스테이지 맵 화면 (style_stagemap.css)
   Soft Claymorphism & Pastel Craft Design System
   Flow 원본 에셋(assets/flow/*) 및 런타임 최적화 조각(assets/ui/*) 기반
   ========================================================================== */

:root {
  /* Flow Asset Reference Registry (assets/flow -> assets/ui) */
  --flow-dori-ref: url('../assets/flow/01_dori_ref_sheet_alpha.png');
  --flow-dori-sheet: url('../assets/flow/02_dori_expressions_7_alpha.png');
  --flow-title-keyart: url('../assets/flow/03_title_keyart.png');
  --flow-map-ch1: url('../assets/flow/04_map_ch1_forest_cafe.png');
  --flow-map-ch2: url('../assets/flow/05_map_ch2_airport.png');
  --flow-map-ch3: url('../assets/flow/06_map_ch3_office_sunset.png');
  --flow-rings-sheet: url('../assets/flow/07_clay_rings_material_alpha.png');
  --flow-tiles-sheet: url('../assets/flow/08_letter_tile_blank_sheet_alpha.png');
  --flow-board-lavender: url('../assets/flow/09_board_bg_lavender_blue.png');
  --flow-board-peach: url('../assets/flow/10_board_bg_peach.png');
  --flow-board-mint: url('../assets/flow/11_board_bg_mint.png');
  --flow-clear-bg: url('../assets/flow/12_clear_celebration_bg.png');
  --flow-frames-sheet: url('../assets/flow/13_meaning_card_frames_alpha.png');
  --flow-flames-sheet: url('../assets/flow/14_streak_flames_5_alpha.png');
  --flow-daily-banner: url('../assets/flow/15_daily_challenge_banner.png');
  --flow-share-blue-pink: url('../assets/flow/16_share_card_bg_blue_pink.png');
  --flow-share-mint-yellow: url('../assets/flow/17_share_card_bg_mint_yellow.png');
  --flow-share-peach-lavender: url('../assets/flow/18_share_card_bg_peach_lavender.png');
  --flow-icons-sheet: url('../assets/flow/19_icons_hint_settings_book_shop_invite_alpha.png');
  --flow-dori-skins: url('../assets/flow/20_dori_skins_6_alpha.png');
  --flow-feature-graphic: url('../assets/flow/21_play_feature_graphic_1024x500.png');
  --flow-app-icon-a: url('../assets/flow/22_app_icon_a.png');
  --flow-app-icon-b: url('../assets/flow/23_app_icon_b.png');
  --flow-hero-books-a: url('../assets/flow/24_hero_books_a.png');
  --flow-hero-books-b: url('../assets/flow/25_hero_books_b.png');

  /* Color Palette — Warm Clay & Pastel Sanctuary */
  --bg-canvas: #faf5ee;
  --bg-card: #fffdf8;
  --bg-card-elevated: #ffffff;
  --ink-primary: #24383e;
  --ink-secondary: #4e676d;
  --ink-muted: #6c848a;

  /* Clay Tactile Surfaces & Shadows */
  --clay-teal: #2a6f6b;
  --clay-teal-dark: #1d524f;
  --clay-mint: #dff3ea;
  --clay-mint-border: #68a88d;
  --clay-cream: #fbf3e4;
  --clay-border: #d8cfc2;
  --shadow-soft: 0 8px 24px rgba(56, 72, 78, 0.08), 0 2px 6px rgba(56, 72, 78, 0.05);
  --shadow-clay-card:
    0 6px 0 #e5ddd0,
    0 10px 20px rgba(68, 60, 48, 0.08),
    inset 0 2px 0 #ffffff;
  --shadow-clay-btn:
    0 4px 0 #cbbfb0,
    0 6px 12px rgba(45, 58, 62, 0.09),
    inset 0 2px 0 #ffffff;
  --shadow-clay-primary:
    0 5px 0 var(--clay-teal-dark),
    0 8px 16px rgba(36, 91, 89, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);

  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  color: var(--ink-primary);
  background:
    radial-gradient(circle at 12% 6%, #e7f4ed 0%, transparent 40%),
    radial-gradient(circle at 88% 15%, #efe9fb 0%, transparent 44%),
    var(--bg-canvas);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink-primary);
}

main#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px 44px;
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

p {
  margin: 0;
  line-height: 1.55;
}

small, .eyebrow {
  font-size: 13px;
  color: var(--ink-secondary);
}

.eyebrow {
  letter-spacing: 0.06em;
  font-weight: 700;
}

section {
  scroll-margin-top: 12px;
}

button, input, select, summary, textarea {
  font: inherit;
  touch-action: manipulation;
}

button, summary {
  cursor: pointer;
}

button {
  min-height: 48px;
  border: 2px solid #e2d9cb;
  background: linear-gradient(180deg, #ffffff 0%, #f8f2e8 100%);
  border-radius: 16px;
  padding: 10px 16px;
  color: var(--ink-primary);
  font-weight: 700;
  box-shadow: var(--shadow-clay-btn);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
}

button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #f3ebde 100%);
}

button:active:not(:disabled) {
  transform: translateY(3px) scale(0.985);
  box-shadow:
    0 1px 0 #cbbfb0,
    0 2px 4px rgba(45, 58, 62, 0.08),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

button:focus-visible,
summary:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #356ec9;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.52;
  cursor: default;
  box-shadow: none;
}

.primary {
  width: 100%;
  min-height: 52px;
  margin: 8px 0;
  background: linear-gradient(180deg, #327c77 0%, #245b59 100%);
  color: #ffffff;
  border: 2px solid #1e4d4b;
  border-radius: 18px;
  font-size: 15.5px;
  font-weight: 800;
  box-shadow: var(--shadow-clay-primary);
}

.icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 8px;
  filter: drop-shadow(0 2px 3px rgba(36, 56, 62, 0.14));
}

/* ==========================================================================
   상단 타이틀 키아트 헤더 (.title-art)
   ========================================================================== */
header.title-art {
  position: relative;
  min-height: 224px;
  padding: 18px 16px;
  margin-bottom: 14px;
  border-radius: 26px;
  background-color: #e9e3f1;
  background-image:
    url('../assets/ui/03_title_keyart.webp'),
    var(--flow-title-keyart);
  background-position: center 44%;
  background-size: cover;
  border: 3px solid #ffffff;
  box-shadow:
    0 8px 0 #dfd6c8,
    0 14px 28px rgba(82, 74, 62, 0.14);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.title-art .eyebrow,
.title-art h1,
.title-art p {
  position: relative;
  width: fit-content;
  max-width: 100%;
  background: rgba(255, 252, 244, 0.92);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 4px 10px;
  line-height: 1.38;
  box-shadow: 0 3px 10px rgba(36, 56, 62, 0.08);
}

.title-art h1 {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 850;
}

.title-art h1 small {
  font-size: 12px;
  font-weight: 700;
  background: #e7f3ef;
  color: var(--clay-teal);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.title-art p:last-child {
  font-size: 13px;
  font-weight: 650;
  margin-top: auto;
  padding-top: 5px;
  padding-bottom: 5px;
}

/* ==========================================================================
   소리 설정 아코디언 (#audio-panel)
   ========================================================================== */
#audio-panel {
  margin: 0 0 16px;
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid #e6dfd3;
  border-radius: 18px;
  padding: 4px 14px;
  box-shadow: 0 4px 12px rgba(68, 60, 48, 0.05);
}

#audio-panel summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
  list-style: none;
}

#audio-panel summary::-webkit-details-marker {
  display: none;
}

#audio-panel summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 14px;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}

#audio-panel[open] summary::after {
  transform: rotate(180deg);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  font-size: 14px;
  font-weight: 600;
  border-top: 1px dashed #e6ded2;
}

.setting input[type="range"] {
  min-height: 44px;
  width: 58%;
  accent-color: var(--clay-teal);
}

.setting input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--clay-teal);
}

#audio-status {
  font-size: 12px;
  color: var(--ink-muted);
  padding: 6px 0 10px;
  text-align: right;
}

/* ==========================================================================
   스테이지 화면 컨테이너 & 일일 챌린지 영역 (#stage-screen, #daily-start, #streak-status)
   ========================================================================== */
#stage-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#stage-heading {
  font-size: 21px;
  font-weight: 850;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#stage-heading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #398983 0%, #245b59 100%);
}

/* 일일 챌린지 배너 (15_daily_challenge_banner.png -> 15_daily_challenge_banner.webp) */
.daily-banner,
#daily-start {
  position: relative;
  width: 100%;
  min-height: 136px;
  padding: 18px 20px;
  text-align: left;
  border-radius: 24px;
  border: 3px solid #ffffff;
  background-color: #cfe6e7;
  background-image:
    url('../assets/ui/15_daily_challenge_banner.webp'),
    var(--flow-daily-banner);
  background-position: right 52%;
  background-size: cover;
  font-size: 20px;
  font-weight: 850;
  color: #1f373d;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.95);
  box-shadow:
    0 7px 0 #b8d3d4,
    0 12px 24px rgba(45, 78, 82, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
}

.daily-banner:hover:not(:disabled),
#daily-start:hover:not(:disabled) {
  background-color: #c5e0e2;
  background-image:
    url('../assets/ui/15_daily_challenge_banner.webp'),
    var(--flow-daily-banner);
}

.daily-banner span,
#daily-start span {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 750;
  max-width: 190px;
  color: #244248;
  background: rgba(255, 249, 236, 0.94);
  border: 1.5px solid #ffffff;
  padding: 6px 11px;
  border-radius: 12px;
  margin-top: 10px;
  box-shadow: 0 3px 8px rgba(36, 56, 62, 0.1);
}

#daily-description {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 0 6px;
}

/* 스트릭 상태 배지 (14_streak_flames_5_alpha.png -> flame-1..5.webp) */
#streak-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fffdf9 0%, #f9efe0 100%);
  border: 2px solid #ebd9be;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 750;
  color: #3a4f54;
  box-shadow:
    0 4px 0 #e3d1b6,
    0 6px 14px rgba(84, 64, 36, 0.06);
}

#streak-flame {
  width: 34px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 5px rgba(214, 108, 44, 0.25));
}

#streak-text {
  flex: 1;
}

/* ==========================================================================
   챕터 선택 컨트롤 바 (.chapter-picker, #chapter-prev, #chapter-select, #chapter-next)
   ========================================================================== */
.chapter-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 2px solid #e3dacb;
  border-radius: 20px;
  box-shadow: var(--shadow-clay-card);
}

.chapter-picker button {
  min-width: 52px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
}

.chapter-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink-primary);
}

.chapter-picker select {
  min-height: 48px;
  min-width: 112px;
  max-width: 140px;
  border: 2px solid #cfdedd;
  background: #f6fbfa;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-primary);
  box-shadow: inset 0 2px 4px rgba(36, 56, 62, 0.05);
  cursor: pointer;
}

/* ==========================================================================
   스테이지 맵 캔버스 & 클레이 징검다리 노드 (#stage-list, .chapter-map, .map-nodes)
   Flow 맵 3종 순환:
   - data-theme="0": 04_map_ch1_forest_cafe (숲속 카페)
   - data-theme="1": 05_map_ch2_airport (여행의 시작)
   - data-theme="2": 06_map_ch3_office_sunset (노을빛 오피스)
   ========================================================================== */
.stage-grid,
#stage-list {
  display: block;
}

.chapter-map {
  position: relative;
  padding: 18px 16px 34px;
  border-radius: 28px;
  background-color: #d4ecdb;
  background-image:
    url('../assets/ui/04_map_ch1_forest_cafe.webp'),
    var(--flow-map-ch1);
  background-size: cover;
  background-position: center;
  min-height: 580px;
  border: 4px solid #ffffff;
  box-shadow:
    0 10px 0 #d8cfc1,
    0 18px 34px rgba(45, 62, 68, 0.16),
    inset 0 0 0 2px rgba(255, 255, 255, 0.65);
  overflow: hidden;
  isolation: isolate;
}

.chapter-map[data-theme="0"] {
  background-color: #d4ecdb;
  background-image:
    url('../assets/ui/04_map_ch1_forest_cafe.webp'),
    var(--flow-map-ch1);
  --map-node-border: #ffffff;
  --map-node-shadow: rgba(68, 114, 94, 0.45);
  --map-badge-bg: rgba(255, 252, 243, 0.94);
}

.chapter-map[data-theme="1"] {
  background-color: #d7eaf6;
  background-image:
    url('../assets/ui/05_map_ch2_airport.webp'),
    var(--flow-map-ch2);
  --map-node-border: #ffffff;
  --map-node-shadow: rgba(66, 104, 136, 0.45);
  --map-badge-bg: rgba(248, 253, 255, 0.94);
}

.chapter-map[data-theme="2"] {
  background-color: #f6e1d3;
  background-image:
    url('../assets/ui/06_map_ch3_office_sunset.webp'),
    var(--flow-map-ch3);
  --map-node-border: #ffffff;
  --map-node-shadow: rgba(136, 86, 74, 0.45);
  --map-badge-bg: rgba(255, 250, 245, 0.94);
}

/* 맵 상단 챕터 타이틀 배너 */
.chapter-map h3 {
  position: relative;
  z-index: 2;
  background: var(--map-badge-bg, rgba(255, 252, 243, 0.94));
  backdrop-filter: blur(6px);
  border: 2px solid #ffffff;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 0 0 18px;
  font-size: 16.5px;
  font-weight: 850;
  text-align: center;
  color: var(--ink-primary);
  box-shadow:
    0 4px 0 rgba(56, 72, 78, 0.14),
    0 8px 18px rgba(36, 56, 62, 0.12);
}

/* 2열 지그재그 클레이 노드 그리드 (챕터당 10판) */
.map-nodes {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 36px;
}

.map-nodes button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 70px;
  padding: 10px 8px;
  background: linear-gradient(180deg, rgba(255, 255, 252, 0.96) 0%, rgba(250, 244, 232, 0.94) 100%);
  border: 2.5px solid var(--map-node-border, #ffffff);
  border-radius: 22px;
  box-shadow:
    0 6px 0 var(--map-node-shadow, rgba(98, 139, 123, 0.45)),
    0 10px 18px rgba(36, 56, 62, 0.16),
    inset 0 2px 0 #ffffff;
  font-size: 16.5px;
  font-weight: 850;
  line-height: 1.25;
  color: var(--ink-primary);
}

.map-nodes button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #f7efe0 100%);
}

/* 짝수 번호 노드 지그재그 오프셋 (징검다리 리듬 유지) */
.map-nodes button:nth-child(2n) {
  transform: translateY(18px);
}

.map-nodes button:nth-child(2n):active:not(:disabled) {
  transform: translateY(21px) scale(0.97);
}

.map-nodes small {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-secondary);
  background: rgba(235, 243, 240, 0.85);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ==========================================================================
   하단 아코디언 패널: 진행 저장 (#save-panel) & 도리 아틀리에 (#art-panel)
   ========================================================================== */
details#save-panel,
details#art-panel {
  margin: 6px 0 0;
  padding: 6px 14px 14px;
  background: var(--bg-card);
  border: 2px solid #e3dacb;
  border-radius: 20px;
  box-shadow: var(--shadow-clay-card);
}

details#save-panel summary,
details#art-panel summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  line-height: 44px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-primary);
  list-style: none;
}

details#save-panel summary::-webkit-details-marker,
details#art-panel summary::-webkit-details-marker {
  display: none;
}

details#save-panel summary::after,
details#art-panel summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 14px;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}

details#save-panel[open] summary::after,
details#art-panel[open] summary::after {
  transform: rotate(180deg);
}

#storage-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin: 6px 0 10px;
}

label[for="save-code"] {
  display: block;
  font-size: 13px;
  font-weight: 750;
  color: var(--ink-primary);
  margin-bottom: 4px;
}

textarea#save-code {
  display: block;
  width: 100%;
  margin: 6px 0 10px;
  border: 2px solid #d4cbc0;
  border-radius: 14px;
  padding: 10px 12px;
  background: #fcfaf5;
  color: var(--ink-primary);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.actions button {
  flex: 1;
  font-size: 14px;
}

#save-message {
  font-size: 13px;
  font-weight: 700;
  color: var(--clay-teal);
  margin-top: 8px;
  min-height: 20px;
}

/* 도리 아틀리에 갤러리 (Flow 01, 02, 20, 21, 23, 24, 25) */
#art-panel > p {
  font-size: 13.5px;
  color: var(--ink-secondary);
  margin: 4px 0 10px;
}

.art-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.art-gallery img {
  width: 100%;
  height: 186px;
  object-fit: contain;
  border-radius: 16px;
  background: linear-gradient(180deg, #f7f1e8 0%, #ede3d5 100%);
  border: 2px solid #ffffff;
  padding: 6px;
  box-shadow: 0 4px 10px rgba(56, 72, 78, 0.08);
}

.feature-art {
  width: 100%;
  margin-top: 12px;
  border-radius: 16px;
  border: 2px solid #ffffff;
  box-shadow: 0 6px 14px rgba(56, 72, 78, 0.1);
}

/* ==========================================================================
   오류 복구 패널 & 플레이 화면 호환 스타일 (#load-error, #play-screen, footer)
   ========================================================================== */
#load-error {
  padding: 20px;
  background: #fff9e9;
  border: 2px solid #ebd9b4;
  border-radius: 20px;
  box-shadow: var(--shadow-clay-card);
}

#load-error h2 {
  margin-bottom: 8px;
}

#load-error p {
  margin-bottom: 12px;
}

footer {
  margin-top: 32px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* ==========================================================================
   반응형 미디어 쿼리 (360px 소형 모바일 및 모션 감소 대응)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 360px) {
  main#app {
    padding: 12px 10px 36px;
  }

  header.title-art {
    padding: 14px 12px;
    min-height: 206px;
  }

  .title-art h1 {
    font-size: 25px;
  }

  .title-art p:last-child {
    font-size: 12px;
  }

  .chapter-picker {
    padding: 6px 8px;
    gap: 6px;
  }

  .chapter-map {
    padding: 14px 12px 28px;
  }

  .map-nodes {
    gap: 16px 24px;
  }

  .map-nodes button {
    font-size: 15px;
    min-height: 64px;
  }
}
