/* ===== 용을 찾아서 — 한글 학습 ===== */

@import url('https://fonts.googleapis.com/css2?family=Jua&family=Gaegu:wght@400;700&family=Single+Day&display=swap');

:root {
  /* Pastel palette */
  --bg-cream: #FFF8F0;
  --bg-cream-2: #FDEFE0;
  --bg-twilight: #2D2350;
  --bg-twilight-2: #4A3978;
  --bg-day: #E8F4FB;
  --bg-day-2: #FFF1D6;

  --pink: #FFB6C1;
  --pink-deep: #F88CA0;
  --coral: #FFA07A;
  --mint: #A8E6CF;
  --mint-deep: #6DCAA3;
  --sky: #B4DCFB;
  --sky-deep: #7EBAEF;
  --lavender: #D4B8E8;
  --lavender-deep: #A988CE;
  --yellow: #FFE082;
  --yellow-deep: #F5C342;

  --ink: #3D2817;
  --ink-soft: #6B4F3F;
  --ink-faint: #A98F7E;

  --shadow-soft: 0 6px 0 rgba(61, 40, 23, 0.08), 0 2px 6px rgba(61, 40, 23, 0.06);
  --shadow-pop: 0 8px 0 rgba(61, 40, 23, 0.12), 0 4px 14px rgba(61, 40, 23, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
}
body {
  /* Taller than the visible area while the address bar is showing, so the page is
     scrollable — a small upward scroll then collapses the mobile browser's address bar. */
  min-height: 100vh;
  min-height: 100lvh;
  font-family: 'Jua', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-cream);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  /* Mobile: no blue tap-flash; block sideways scroll & pull-to-refresh, allow the vertical
     scroll that hides the address bar. */
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
}

#root {
  height: 100vh;
  height: 100dvh; /* fills the currently-visible area (grows as the address bar collapses) */
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* ===== Scene container ===== */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  /* Respect notch / home-bar safe areas on phones, keeping the 24px base padding */
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  /* If a screen's content is taller than a small phone, let it scroll instead of clipping */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== PROLOGUE ===== */
.scene-prologue {
  background: #1F1A3E;
  color: #FFF;
  justify-content: flex-end;
  padding: 0;
}
.prologue-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center 30%;
  transform: scale(1.08);
  transform-origin: 50% 22%;
  animation: bgDrift 26s ease-in-out infinite alternate;
}
.prologue-dragon {
  background-image: url('assets/rainbow-dragon.png');
  opacity: 1;
}
.prologue-shatter {
  background-image: url('assets/dragon-lose-orb.png');
  background-position: center 42%;
  opacity: 0;
}
.prologue-shatter.is-active {
  opacity: 1;
}
.prologue-sleep {
  background-image: url('assets/dragon-sleep.png');
  background-size: 150% auto;
  background-position: 34% 80%;
  opacity: 0;
  animation: none;
  transform: none;
}
.prologue-sleep.is-active {
  opacity: 1;
}
@keyframes bgDrift {
  0% { transform: scale(1.08); }
  100% { transform: scale(1.13) translateY(-1%); }
}
.prologue-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(31,26,62,0.10) 0%, rgba(31,26,62,0) 35%, rgba(31,26,62,0.25) 62%, rgba(31,26,62,0.78) 100%);
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #FFF;
  border-radius: 50%;
  opacity: 0;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.1); }
}

.dragon-silhouette {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  animation: dragonFloat 6s ease-in-out infinite;
  pointer-events: none;
  filter: drop-shadow(0 0 40px rgba(255, 200, 130, 0.45)) drop-shadow(0 0 12px rgba(212, 184, 232, 0.5));
  z-index: 1;
}
@keyframes dragonFloat {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  50% { transform: translateX(-50%) translateY(-14px) rotate(2deg); }
}

.story-card {
  position: relative;
  z-index: 2;
  max-width: 760px;
  width: 90%;
  margin: 0 auto 30px;
  padding: 16px 40px 18px;
  background: rgba(28, 22, 56, 0.6);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 220, 180, 0.35);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.4);
}

.story-text {
  font-family: 'Jua', sans-serif;
  font-size: 28px;
  line-height: 1.45;
  color: #FFF8E7;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  min-height: 62px;
  text-align: center;
  word-break: keep-all;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.story-text .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px);
  animation: wordIn 0.5s ease-out forwards;
  margin: 0 10px 4px;
  white-space: nowrap;
}
.story-text .word.accent {
  color: #FFD86B;
}
@keyframes wordIn {
  to { opacity: 1; transform: translateY(0); }
}

.next-btn {
  margin-top: 16px;
  background: linear-gradient(180deg, #FFD86B 0%, #F5B842 100%);
  color: #4A2F0E;
  border: none;
  padding: 12px 38px;
  border-radius: 999px;
  font-family: 'Jua', sans-serif;
  font-size: 23px;
  cursor: pointer;
  box-shadow: 0 6px 0 #B07A1F, 0 8px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s, box-shadow 0.1s;
  opacity: 0;
  animation: fadeIn 0.5s 0.3s ease-out forwards;
}
.next-btn:hover { transform: translateY(-2px); }
.next-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #B07A1F; }

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

/* ===== OPENING VIDEO ===== */
.scene-opening {
  background: #000;
  padding: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.opening-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* 'contain' so the whole frame (incl. the title) is visible in any orientation — never cropped. */
  object-fit: contain;
  background: #000;
}
.opening-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(31,26,62,0.25) 0%, rgba(10,8,24,0.55) 100%);
  cursor: pointer;
}
.opening-play {
  background: linear-gradient(180deg, #FFD86B 0%, #F5B842 100%);
  color: #4A2F0E;
  border: none;
  padding: 18px 52px;
  border-radius: 999px;
  font-family: 'Jua', sans-serif;
  font-size: 30px;
  cursor: pointer;
  box-shadow: 0 7px 0 #B07A1F, 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  white-space: nowrap;
  animation: openingPulse 1.8s ease-in-out infinite;
}
.opening-play:hover { transform: translateY(-2px); }
.opening-play:active { transform: translateY(3px); box-shadow: 0 2px 0 #B07A1F; }
@keyframes openingPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
/* End-of-video gate: title frame stays, "시작하기" button appears */
.opening-overlay--end {
  background: linear-gradient(to top, rgba(20, 16, 40, 0.42) 0%, rgba(20, 16, 40, 0) 34%);
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 7%;
  cursor: default;
}
.opening-start {
  font-size: 32px;
  padding: 18px 60px;
}
.opening-start.glow {
  position: relative;
  z-index: 3;
  animation: openingPulse 1.8s ease-in-out infinite, opGlow 1.8s ease-in-out infinite;
}
@keyframes opGlow {
  0%, 100% {
    box-shadow: 0 7px 0 #B07A1F, 0 10px 22px rgba(0, 0, 0, 0.35), 0 0 16px 4px rgba(255, 224, 130, 0.4);
  }
  50% {
    box-shadow: 0 7px 0 #B07A1F, 0 10px 22px rgba(0, 0, 0, 0.35), 0 0 36px 13px rgba(255, 224, 130, 0.7);
  }
}
.opening-sparkles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.op-sparkle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(255, 238, 170, 0.95) 38%, rgba(255, 205, 110, 0.55) 60%, rgba(255, 200, 120, 0) 78%);
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(255, 230, 150, 0.95));
  animation-name: opFloat;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
}
@keyframes opFloat {
  0% { opacity: 0; transform: translateY(26px) scale(0.4); }
  18% { opacity: 1; }
  55% { opacity: 1; transform: translateY(-16px) scale(1.35); }
  82% { opacity: 0.85; }
  100% { opacity: 0; transform: translateY(-58px) scale(0.5); }
}

/* ===== OPENING LOADING ===== */
.opening-loading {
  flex-direction: column;
  gap: 24px;
  z-index: 5;
  background: radial-gradient(ellipse at center, rgba(31, 26, 62, 0.72) 0%, rgba(10, 8, 24, 0.92) 100%);
}
.loading-orb {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff7a7a, #ffd86b, #7ee08a, #6bb8ef, #c08be8, #ff7a7a);
  -webkit-mask: radial-gradient(circle 23px at center, transparent 95%, #000 96%);
  mask: radial-gradient(circle 23px at center, transparent 95%, #000 96%);
  filter: drop-shadow(0 0 14px rgba(255, 216, 107, 0.6));
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: 'Jua', sans-serif;
  font-size: 27px;
  color: #FFF8E7;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.loading-dots span {
  display: inline-block;
  animation: dotBlink 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.22s; }
.loading-dots span:nth-child(3) { animation-delay: 0.44s; }
@keyframes dotBlink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* ===== OPENING MUTE BUTTON ===== */
.opening-mute {
  position: absolute;
  top: 18px;
  left: 22px;
  z-index: 4;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 248, 231, 0.45);
  background: rgba(20, 16, 40, 0.42);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF8E7;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.15s ease;
}
.opening-mute:hover { transform: scale(1.07); background: rgba(20, 16, 40, 0.6); }
.opening-mute:active { transform: scale(0.93); }

/* ===== MAIN-GAME MUSIC TOGGLE ===== */
.music-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 248, 231, 0.55);
  background: rgba(20, 16, 40, 0.42);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF8E7;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.15s ease;
}
.music-toggle:hover { transform: scale(1.07); background: rgba(20, 16, 40, 0.6); }
.music-toggle:active { transform: scale(0.93); }
/* On the map/farm, tuck under the top-right candy display to avoid overlap. */
.music-toggle--map { top: 116px; right: 18px; }
.opening-skip {
  position: absolute;
  right: 22px;
  bottom: 20px;
  z-index: 4;
  background: rgba(20, 16, 40, 0.5);
  color: #FFF8E7;
  border: 1.5px solid rgba(255, 248, 231, 0.35);
  backdrop-filter: blur(6px);
  padding: 9px 20px;
  border-radius: 999px;
  font-family: 'Jua', sans-serif;
  font-size: 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.opening-skip:hover { background: rgba(20, 16, 40, 0.72); transform: translateY(-1px); }
.opening-skip:active { transform: translateY(1px); }

/* ===== Opening: orientation-specific fits ===== */
/* Phone held sideways (short height): shrink controls so nothing overflows the screen */
@media (orientation: landscape) and (max-height: 500px) {
  .opening-play { font-size: 21px; padding: 11px 34px; }
  .opening-start { font-size: 23px; padding: 11px 38px; }
  .opening-overlay--end { padding-bottom: 3%; }
  .opening-skip { font-size: 14px; padding: 7px 15px; bottom: 12px; right: 14px; }
  .opening-mute { width: 38px; height: 38px; top: 12px; left: 14px; }
}
/* Narrow portrait phones: give the bottom button a bit more breathing room */
@media (orientation: portrait) and (max-width: 480px) {
  .opening-play { font-size: 25px; padding: 15px 40px; }
  .opening-start { font-size: 27px; padding: 15px 44px; }
  .opening-overlay--end { padding-bottom: 12%; }
}

/* ===== NAME INPUT ===== */
.scene-name {
  background: #F2E1C2;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  gap: 40px;
}
.name-wizard-img {
  position: absolute;
  right: 2%;
  top: 50%;
  transform: translateY(-50%);
  height: 88%;
  width: auto;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}
.name-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 250, 242, 0.97);
  border: 4px solid #E7D3A8;
  border-radius: 34px;
  padding: 32px 40px 38px;
  box-shadow: 0 14px 34px rgba(120, 90, 40, 0.24);
  max-width: 430px;
  margin-right: 30%;
}
.scene-name .scene-title { font-size: 38px; margin-bottom: 6px; white-space: nowrap; }
.scene-name .scene-subtitle { margin-bottom: 26px; }

.scene-title {
  font-family: 'Jua', sans-serif;
  font-size: 44px;
  color: var(--ink);
  margin-bottom: 10px;
  text-align: center;
  word-break: keep-all;
  max-width: 900px;
  line-height: 1.25;
}
.scene-subtitle {
  font-family: 'Gaegu', cursive;
  font-size: 23px;
  color: var(--ink-soft);
  margin-bottom: 22px;
  text-align: center;
}

.name-input {
  width: 360px;
  max-width: 80vw;
  padding: 20px 28px;
  font-family: 'Jua', sans-serif;
  font-size: 36px;
  text-align: center;
  border: 4px dashed var(--lavender-deep);
  border-radius: 24px;
  background: #FFF;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, transform 0.2s;
}
.name-input:focus {
  border-color: var(--pink-deep);
  border-style: solid;
  transform: scale(1.02);
}
/* Email is longer than a name — smaller font so it fits on one line */
.name-input--email {
  font-size: 24px;
  letter-spacing: 0.2px;
}

.primary-btn {
  margin-top: 32px;
  background: linear-gradient(180deg, var(--pink) 0%, var(--pink-deep) 100%);
  color: #FFF;
  border: none;
  padding: 18px 52px;
  border-radius: 999px;
  font-family: 'Jua', sans-serif;
  font-size: 30px;
  cursor: pointer;
  box-shadow: 0 6px 0 #C76781, 0 8px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.1s, box-shadow 0.1s;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); }
.primary-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #C76781; }
.primary-btn:disabled {
  background: linear-gradient(180deg, #DDD 0%, #BBB 100%);
  box-shadow: 0 6px 0 #999;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.7);
}

.back-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  background: #FFF;
  border: 3px solid var(--ink-faint);
  border-radius: 999px;
  padding: 12px 22px;
  font-family: 'Jua', sans-serif;
  font-size: 18px;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(61, 40, 23, 0.12);
  z-index: 10;
  white-space: nowrap;
}
.back-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(61, 40, 23, 0.12); }

/* ===== CHARACTER SELECT ===== */
.scene-charselect {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.60) 0%, rgba(255, 255, 255, 0.18) 22%, rgba(255, 255, 255, 0) 44%),
    url('assets/charselect-bg.png');
  background-size: cover, cover;
  background-position: center top, center;
  background-repeat: no-repeat, no-repeat;
}
.scene-charselect .scene-title,
.scene-charselect .scene-subtitle {
  text-shadow: 0 2px 9px rgba(255, 255, 255, 0.9), 0 1px 2px rgba(255, 255, 255, 0.9);
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  max-width: 1100px;
  width: 100%;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .char-grid { grid-template-columns: repeat(2, 1fr); max-width: 600px; }
}

/* ===== Avatar setup (pick a face) ===== */
.scene-avatar { justify-content: flex-start; padding-top: max(20px, env(safe-area-inset-top)); }
.scene-avatar .scene-title { margin-top: 6px; }
.avatar-pick-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  max-width: 560px; width: 100%; margin: 14px 0 6px;
}
.avatar-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #FFF; border: 4px solid transparent; border-radius: 22px; padding: 10px 6px 8px;
  cursor: pointer; box-shadow: var(--shadow-soft);
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.avatar-pick:active { transform: translateY(2px); }
.avatar-pick.on { border-color: var(--pink-deep); transform: translateY(-4px) scale(1.04); box-shadow: var(--shadow-pop); }
.avatar-pick-tag { font-family: 'Jua', sans-serif; font-size: 15px; color: #7A6A58; }
.avatar-friend-title { margin-top: 8px; }
.char-grid.avatar-friends { max-width: 540px; gap: 12px; margin-top: 6px; }
.avatar-friends .char-art { height: 96px; }
.avatar-friends .char-caption { padding: 8px 8px 12px; }
.avatar-friends .char-name { font-size: 18px; }
@media (max-width: 560px) {
  .avatar-pick-grid { gap: 8px; }
  .avatar-pick { border-radius: 18px; padding: 8px 4px 6px; }
}

/* ===== Avatar Maker (나를 만들어요) ===== */
.am-scene {
  background-image:
    linear-gradient(180deg, rgba(255, 244, 226, 0.5) 0%, rgba(255, 244, 226, 0.22) 30%, rgba(255, 244, 226, 0.12) 100%),
    url('assets/charselect-bg.png');
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  justify-content: flex-start; align-items: center; padding: 16px 0; color: #2B2340;
}
.am-title { text-shadow: 0 2px 8px rgba(255, 255, 255, 0.85); }
.am-wrap {
  width: 100%; max-width: 920px; box-sizing: border-box;
  margin: auto;  /* 공간 남으면 세로 가운데, 넘치면 위에서부터 스크롤 */
  display: flex; flex-direction: column; gap: 14px;
  padding: 2px max(16px, env(safe-area-inset-right)) 2px max(16px, env(safe-area-inset-left));
}
.am-header { display: flex; align-items: center; justify-content: space-between; }
.am-title { font-family: 'Jua', sans-serif; font-size: clamp(24px, 4.5vw, 34px); }
.am-iconbtn {
  width: 54px; height: 54px; border-radius: 50%; border: none; background: #FFF; cursor: pointer;
  box-shadow: 0 4px 0 #E8D9C0; display: flex; align-items: center; justify-content: center;
}
.am-iconbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #E8D9C0; }
.am-iconbtn svg { width: 26px; height: 26px; }
.am-main { display: flex; gap: 14px; align-items: stretch; }
.am-left { width: 40%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.am-preview {
  flex: 1; min-height: 340px; background: #FFF; border-radius: 28px; box-shadow: 0 6px 0 #E8D9C0;
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.am-preview-blob { position: absolute; left: 50%; bottom: -110px; width: 88%; height: 210px; border-radius: 50%; background: #FFE7C2; transform: translateX(-50%); }
.am-preview-av { width: 70%; max-width: 300px; position: relative; }
.am-random {
  position: absolute; right: 14px; bottom: 14px; width: 56px; height: 56px; border-radius: 18px; border: none; cursor: pointer;
  background: #FFC93C; box-shadow: 0 5px 0 #D9A21A; display: flex; align-items: center; justify-content: center;
}
.am-random svg { width: 32px; height: 32px; }
.am-random:active { transform: translateY(2px); box-shadow: 0 3px 0 #D9A21A; }
.am-name { height: 60px; background: #FFF; border-radius: 18px; box-shadow: 0 4px 0 #E8D9C0; display: flex; align-items: center; gap: 10px; padding: 0 16px; box-sizing: border-box; }
.am-name svg { width: 26px; height: 26px; flex: none; }
.am-name input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-family: 'Jua', sans-serif; font-size: 26px; color: #2B2340; }
.am-right { flex: 1; display: flex; gap: 12px; min-width: 0; align-items: stretch; }
.am-tabs { width: 92px; display: flex; flex-direction: column; gap: 10px; }
.am-tab {
  flex: 1; border: none; border-radius: 22px; background: #FFF; box-shadow: 0 5px 0 #E8D9C0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #2B2340; font-family: 'Jua', sans-serif; font-size: 19px; padding: 8px 0;
}
.am-tab.on { background: #FFC93C; box-shadow: 0 5px 0 #D9A21A; }
.am-tab-ico { width: 46px; height: 46px; }
.am-panel { flex: 1; background: #FFF; border-radius: 28px; box-shadow: 0 6px 0 #E8D9C0; padding: 18px; box-sizing: border-box; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.am-colors { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.am-swatch { width: 50px; height: 50px; border-radius: 50%; border: 4px solid #FFF; cursor: pointer; padding: 0; box-shadow: 0 0 0 0 #FF7A59; transition: box-shadow .12s; }
.am-swatch.on { box-shadow: 0 0 0 4px #FF7A59; }
.am-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 108px; gap: 12px; }
.am-item { border-radius: 22px; border: 4px solid transparent; padding: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; background: #FBF6EE; }
.am-item:active { transform: translateY(2px); }
.am-footer { display: flex; justify-content: flex-end; }
.am-finish { height: 64px; padding: 0 36px; border: none; border-radius: 32px; background: #FF7A59; box-shadow: 0 6px 0 #D9532F; color: #FFF; font-family: 'Jua', sans-serif; font-size: 30px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.am-finish svg { width: 28px; height: 28px; }
.am-finish:active { transform: translateY(3px); box-shadow: 0 3px 0 #D9532F; }
.am-modal { position: absolute; inset: 0; background: rgba(43, 35, 64, .55); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.am-card { width: 100%; max-width: 420px; background: #FFF4E2; border-radius: 36px; padding: 28px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 10px 0 #D9C7A8; }
.am-card-title { font-family: 'Jua', sans-serif; font-size: 26px; }
.am-card-av { width: 210px; height: 230px; background: #FFF; border-radius: 105px 105px 30px 30px; overflow: hidden; }
.am-card-name { font-family: 'Jua', sans-serif; font-size: 38px; }
.am-card-btns { display: flex; gap: 14px; }
.am-redo { height: 58px; padding: 0 26px; border: none; border-radius: 30px; background: #FFF; box-shadow: 0 5px 0 #E8D9C0; color: #2B2340; font-family: 'Jua', sans-serif; font-size: 23px; cursor: pointer; }
.am-ok { height: 58px; padding: 0 32px; border: none; border-radius: 30px; background: #FF7A59; box-shadow: 0 5px 0 #D9532F; color: #FFF; font-family: 'Jua', sans-serif; font-size: 23px; cursor: pointer; }

@media (max-width: 760px) {
  .am-main { flex-direction: column; }
  .am-left { width: 100%; max-width: none; }
  .am-preview { min-height: 290px; }
  .am-right { flex-direction: column; }
  .am-tabs { width: 100%; flex-direction: row; }
  .am-tab { flex: 1; padding: 8px 0; font-size: 17px; }
  .am-tab-ico { width: 38px; height: 38px; }
}

.char-card {
  background: #FFF;
  border: 4px solid transparent;
  border-radius: 28px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.char-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-pop); }
.char-card.selected {
  border-color: var(--pink-deep);
  background: linear-gradient(180deg, #FFF 0%, #FFF0F4 100%);
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 12px 0 rgba(248, 140, 160, 0.25), 0 8px 20px rgba(0, 0, 0, 0.12);
}

.char-art {
  width: 100%;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-art .animal-frame {
  width: 100% !important;
  height: 100% !important;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--bg-cream-2);
}
.char-caption {
  width: 100%;
  background: #FFF;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-top: 2px solid #F1E6D6;
}

/* Animal portrait frame */
.animal-frame {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 4px solid var(--ink);
  background: var(--bg-cream-2);
  box-shadow: inset 0 0 0 2px #FFF;
  flex-shrink: 0;
}
.animal-frame.round {
  border-radius: 50%;
  border-width: 3px;
}
.animal-frame.no-frame {
  border: none;
  box-shadow: none;
  background: transparent;
}
.animal-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
}
/* Character-select cards: fill the frame with the animal, head/ears kept up top. */
.char-art .animal-frame:not(.round) img {
  object-fit: cover;
  padding: 0;
  object-position: 50% 14% !important;
}
.char-name {
  font-family: 'Jua', sans-serif;
  font-size: 26px;
  color: var(--ink);
}
.char-desc {
  font-family: 'Gaegu', cursive;
  font-size: 18px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.3;
  min-height: 48px;
}

/* ===== WORLD MAP ===== */
.scene-map {
  background:
    radial-gradient(circle at 50% 20%, rgba(180, 220, 255, 0.35), transparent 55%),
    linear-gradient(180deg, #E8F4FB 0%, #FFF1D6 60%, #FDD9A0 100%);
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.map-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  z-index: 5;
  pointer-events: none;
}
.map-header > * { pointer-events: auto; }

.hero-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFF;
  padding: 8px 18px 8px 8px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 3px solid var(--ink);
}
.hero-chip .avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-cream-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.hero-chip .name {
  font-family: 'Jua', sans-serif;
  font-size: 22px;
  color: var(--ink);
}

.stars-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #FFF;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 3px solid var(--ink);
  font-family: 'Jua', sans-serif;
  font-size: 22px;
  color: var(--ink);
}
.stars-counter-candy { font-size: 20px; line-height: 1; }
.stars-counter { cursor: pointer; transition: transform .1s; }
.stars-counter:hover { transform: translateY(-1px); }
.stars-counter:active { transform: translateY(1px); }
.stars-counter-go {
  font-family: 'Jua', sans-serif; font-size: 14px; color: var(--ink);
  background: var(--yellow); border-radius: 999px; padding: 2px 9px; margin-left: 2px;
}

.orb-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(45, 35, 80, 0.85);
  padding: 8px 14px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-soft);
}
.orb-slot {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s;
}
.orb-slot.lit {
  animation: orbPulse 2.4s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.map-svg-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.map-svg {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  max-height: 100%;
  background-image: url('assets/map-background.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.map-node {
  cursor: pointer;
  transition: transform 0.2s;
  transform-origin: center;
  transform-box: fill-box;
}
.map-node:hover { transform: scale(1.08); }
.map-node.locked { cursor: not-allowed; }

.map-marker {
  position: absolute;
  animation: bobby 1.8s ease-in-out infinite;
}
@keyframes bobby {
  0%, 100% { transform: translate(-50%, -100%) translateY(0); }
  50% { transform: translate(-50%, -100%) translateY(-8px); }
}

/* ===== LESSON ===== */
.scene-lesson {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 224, 130, 0.4), transparent 50%),
    var(--bg-cream);
  padding: 0;
  display: flex;
  flex-direction: column;
}

.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  position: relative;
}

.progress-bar {
  flex: 1;
  margin: 0 24px;
  height: 18px;
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint) 0%, var(--mint-deep) 100%);
  transition: width 0.4s ease-out;
  border-radius: 999px;
}

.lesson-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 0 24px;
}

.companion-bubble {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.companion-bubble .companion {
  width: 110px; height: 110px;
  flex-shrink: 0;
}
.bubble {
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 16px 22px;
  font-family: 'Jua', sans-serif;
  font-size: 24px;
  color: var(--ink);
  position: relative;
  box-shadow: var(--shadow-soft);
  max-width: 380px;
}
.bubble::before {
  content: '';
  position: absolute;
  left: -14px;
  bottom: 18px;
  width: 0; height: 0;
  border-right: 16px solid var(--ink);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}
.bubble::after {
  content: '';
  position: absolute;
  left: -10px;
  bottom: 20px;
  width: 0; height: 0;
  border-right: 14px solid #FFF;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.combine-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.tile {
  width: 130px;
  height: 130px;
  background: #FFF;
  border: 4px solid var(--ink);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Jua', sans-serif;
  font-size: 80px;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}
.tile.slot {
  background: rgba(255, 255, 255, 0.5);
  border-style: dashed;
  color: var(--ink-faint);
  font-size: 60px;
}
.tile.slot.filled {
  border-style: solid;
  background: #FFF;
  color: var(--ink);
}
.tile.target {
  background: linear-gradient(180deg, #FFF 0%, #FFEBA0 100%);
  border-color: var(--yellow-deep);
  font-size: 80px;
}
.tile.target.correct {
  animation: correctPop 0.5s ease-out;
  background: linear-gradient(180deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: #FFF;
}
@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.2) rotate(-5deg); }
  70% { transform: scale(0.95) rotate(3deg); }
  100% { transform: scale(1); }
}
.tile.target.wrong {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.operator {
  font-family: 'Jua', sans-serif;
  font-size: 56px;
  color: var(--ink-soft);
}

.choice-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 600px;
}

.choice {
  min-width: 90px;
  height: 90px;
  padding: 0 18px;
  background: linear-gradient(180deg, #FFF 0%, #FFF8EC 100%);
  border: 4px solid var(--ink);
  border-radius: 20px;
  font-family: 'Jua', sans-serif;
  font-size: 52px;
  color: var(--ink);
  cursor: grab;
  box-shadow: 0 6px 0 var(--ink), 0 8px 14px rgba(61, 40, 23, 0.1);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.choice:hover { transform: translateY(-3px); }
.choice:active { cursor: grabbing; transform: translateY(2px); box-shadow: 0 3px 0 var(--ink); }
.choice.dragging {
  opacity: 0.4;
}
.choice.used {
  opacity: 0.25;
  pointer-events: none;
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 90px;
  height: 90px;
  background: linear-gradient(180deg, #FFF 0%, #FFF8EC 100%);
  border: 4px solid var(--ink);
  border-radius: 20px;
  font-family: 'Jua', sans-serif;
  font-size: 52px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%) rotate(-4deg) scale(1.1);
}

.slot.hover {
  border-color: var(--pink-deep);
  background: #FFF0F4;
  transform: scale(1.05);
}

/* ===== Reward overlay ===== */
.reward-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.reward-star {
  position: absolute;
  animation: starBurst 1.2s ease-out forwards;
}
@keyframes starBurst {
  0% { transform: translate(0,0) scale(0); opacity: 0; }
  20% { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 1; }
  100% { transform: translate(calc(var(--dx) * 2.4), calc(var(--dy) * 2.4 - 80px)) scale(0.4); opacity: 0; }
}

.toast {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  background: linear-gradient(180deg, #FFD86B 0%, #F5B842 100%);
  color: #4A2F0E;
  font-family: 'Jua', sans-serif;
  font-size: 56px;
  padding: 24px 56px;
  border-radius: 32px;
  border: 5px solid #FFF;
  box-shadow: 0 12px 0 #B07A1F, 0 16px 30px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
}
.toast.show {
  animation: toastIn 1.2s ease-out forwards;
}
@keyframes toastIn {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15) rotate(2deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  85% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
}

/* ===== Stage selection on map ===== */
.stage-pop {
  position: absolute;
  background: #FFF;
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 20px 24px;
  box-shadow: var(--shadow-pop);
  text-align: center;
  z-index: 30;
  min-width: 260px;
}
.stage-pop .title {
  font-family: 'Jua', sans-serif;
  font-size: 28px;
  color: var(--ink);
  margin-bottom: 6px;
}
.stage-pop .desc {
  font-family: 'Gaegu', cursive;
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

/* Lesson complete card */
.complete-card {
  position: absolute;
  inset: 0;
  background: rgba(45, 35, 80, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
}
.complete-inner {
  background: #FFF;
  border: 5px solid var(--ink);
  border-radius: 36px;
  padding: 40px 48px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 18px 0 rgba(61,40,23,0.2), 0 24px 50px rgba(0,0,0,0.3);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.complete-title {
  font-family: 'Jua', sans-serif;
  font-size: 48px;
  color: var(--ink);
  margin-bottom: 12px;
}
.complete-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 24px;
  font-size: 56px;
}
.complete-stars span {
  display: inline-block;
  animation: starJump 0.6s ease-out backwards;
}

.orb-reveal {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px auto 8px;
  width: 180px;
  height: 180px;
  animation: orbAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.orb-reveal > svg {
  position: relative;
  z-index: 2;
  animation: orbFloat 2.2s ease-in-out infinite;
}
.orb-reveal-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  animation: glowPulse 2s ease-in-out infinite;
}
@keyframes orbAppear {
  0% { transform: scale(0.2) rotate(-20deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* ===== Final revival scene ===== */
.revive-scene {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 220, 130, 0.45), transparent 55%),
    radial-gradient(ellipse at 50% 80%, rgba(212, 184, 232, 0.4), transparent 55%),
    linear-gradient(180deg, #1F1A3E 0%, #4A3978 60%, #7C5BA8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #FFF;
  overflow: hidden;
}
.revive-orbits {
  position: relative;
  width: 380px;
  height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  margin-top: 12px;
}
.revive-orb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  animation: orbit 18s linear infinite;
}
.revive-orb > div {
  position: absolute;
  transform: translate(-50%, -50%) translateX(150px) translateY(-20px);
  filter: drop-shadow(0 0 8px currentColor);
}
.revive-orb.flat {
  animation: none;
}
@keyframes orbit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.revive-dragon {
  position: relative;
  z-index: 5;
}
@media (prefers-reduced-motion: no-preference) {
  .revive-dragon { animation: dragonRise 2s ease-out, dragonFloatBig 4s ease-in-out 2s infinite; }
}
@keyframes dragonRise {
  0% { transform: translateY(120px) scale(0.4); opacity: 0; filter: blur(8px); }
  60% { transform: translateY(-12px) scale(1.05); opacity: 1; filter: blur(0); }
  100% { transform: translateY(0) scale(1); opacity: 1; filter: blur(0); }
}
@keyframes dragonFloatBig {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-16px) rotate(1deg); }
}
.revive-title {
  font-family: 'Jua', sans-serif;
  font-size: 34px;
  text-align: center;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  margin-bottom: 6px;
  word-break: keep-all;
  white-space: nowrap;
}
.revive-sub {
  font-family: 'Gaegu', cursive;
  font-size: 22px;
  opacity: 0.92;
  margin-top: 2px;
  text-align: center;
  line-height: 1.4;
}
.revive-final {
  justify-content: flex-end;
}
.revive-orb-row {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  padding: 10px 18px;
  background: rgba(28, 22, 56, 0.5);
  border: 2px solid rgba(255, 220, 180, 0.3);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.revive-orb-chip {
  animation: orbDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards, orbPulse 2.4s ease-in-out infinite;
  display: flex;
}
@keyframes orbDrop {
  0% { transform: translateY(-30px) scale(0.3); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes starJump {
  0% { transform: translateY(40px) scale(0); opacity: 0; }
  60% { transform: translateY(-12px) scale(1.2); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ============================================================
   STAGE 1 — 시작의 마을 (모음 배우기)
   ============================================================ */
.s1-scene {
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 224, 130, 0.45), transparent 55%),
    linear-gradient(180deg, #FFF7E8 0%, #FFF1DD 55%, #FCE7C6 100%);
  padding: 0;
}

.s1-glyph {
  display: flex; align-items: center; justify-content: center;
  border-radius: 28px;
  font-family: 'Jua', sans-serif;
  line-height: 1;
  font-weight: 400;
}

/* ---- shared play frame ---- */
.s1-play-wrap, .s1-village {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.s1-play-wrap { align-items: stretch; }
.s1-village {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.12) 24%, rgba(255, 255, 255, 0) 48%),
    url('assets/village-bg.png');
  background-size: cover, cover;
  background-position: center top, center;
  background-repeat: no-repeat, no-repeat;
}
.s1-top, .s1-play-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 16px 22px; flex-shrink: 0;
}
.s1-title-chip {
  font-family: 'Jua', sans-serif; font-size: 22px; color: var(--ink);
  background: #FFF; border: 3px solid var(--ink); border-radius: 999px;
  padding: 8px 22px; box-shadow: var(--shadow-soft); white-space: nowrap;
}
.s1-top-left { display: flex; align-items: center; gap: 12px; }
.s1-dex-count, .s1-bundle-tag {
  font-family: 'Jua', sans-serif; font-size: 20px; color: var(--ink);
  background: #FFF; border: 3px solid var(--ink); border-radius: 999px;
  padding: 8px 18px; box-shadow: var(--shadow-soft); white-space: nowrap;
}
.s1-bundle-tag { border-color: var(--bc, var(--ink)); }

.s1-play {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px; padding: 10px 24px 26px; text-align: center;
}
.s1-task-tag {
  font-family: 'Jua', sans-serif; font-size: 26px; color: var(--ink-soft);
  background: #FFF3D6; border: 3px solid var(--yellow-deep); border-radius: 999px;
  padding: 8px 26px; box-shadow: var(--shadow-soft); white-space: nowrap;
}
.s1-listen { font-family: 'Gaegu', cursive; font-size: 26px; color: var(--ink-soft); white-space: nowrap; }
.s1-hint-line {
  font-family: 'Gaegu', cursive; font-size: 24px; color: var(--ink-soft); white-space: nowrap;
  background: #FFF; border: 2.5px dashed var(--ink-faint); border-radius: 18px;
  padding: 8px 20px;
}

/* progress dots */
.s1-dots { display: flex; gap: 9px; align-items: center; }
.s1-dot { width: 11px; height: 11px; border-radius: 50%; background: #E3D6C0; transition: all .25s; }
.s1-dot.past { background: var(--mint-deep); }
.s1-dot.now { background: var(--pink-deep); transform: scale(1.5); }

/* buttons */
.s1-btn-row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.s1-btn {
  font-family: 'Jua', sans-serif; font-size: 24px; cursor: pointer;
  border: none; border-radius: 999px; padding: 14px 34px;
  transition: transform .1s, box-shadow .1s, opacity .2s;
}
.s1-btn.go {
  background: linear-gradient(180deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: #1F5C3E; box-shadow: 0 6px 0 #4FA77E;
}
.s1-btn.go:active { transform: translateY(3px); box-shadow: 0 3px 0 #4FA77E; }
.s1-btn.ghost {
  background: #FFF; color: var(--ink-soft); border: 3px solid var(--ink-faint);
  box-shadow: 0 5px 0 rgba(61,40,23,0.12);
}
.s1-btn.ghost:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(61,40,23,0.12); }
.s1-btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; transform: none; }

/* ---- ② mouth mimic ---- */
.s1-mimic { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; justify-content: center; }
.s1-mimic-face {
  background: #FFF; border: 4px solid var(--ink); border-radius: 36px;
  padding: 14px; box-shadow: var(--shadow-soft);
}
.s1-mimic-face.video { padding: 6px; }
.s1-mimic-vid {
  display: block; width: 620px; max-width: 88vw; aspect-ratio: 16 / 9;
  object-fit: cover; border-radius: 28px; background: #000;
}
.s1-mimic-glyph { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.s1-mimic-glyph .s1-glyph { border: 4px solid var(--ink); box-shadow: var(--shadow-soft); background: #FFF; }
.s1-say { font-family: 'Jua', sans-serif; font-size: 40px; color: var(--pink-deep); }

/* ---- ① sound pick ---- */
.s1-speaker {
  position: relative; width: 132px; height: 132px; border-radius: 50%;
  border: 5px solid var(--ink); cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #BCE7FF, #5AA8F0);
  box-shadow: 0 8px 0 #3D7FC0, 0 10px 18px rgba(0,0,0,0.14);
  display: flex; align-items: center; justify-content: center;
  animation: s1SpeakerPulse 1.8s ease-in-out infinite;
}
.s1-speaker:active { transform: translateY(4px); box-shadow: 0 4px 0 #3D7FC0; }
.s1-speaker-ico { font-size: 60px; line-height: 1; }
@keyframes s1SpeakerPulse {
  0%, 100% { box-shadow: 0 8px 0 #3D7FC0, 0 0 0 0 rgba(90,168,240,0.5); }
  50% { box-shadow: 0 8px 0 #3D7FC0, 0 0 0 18px rgba(90,168,240,0); }
}
.s1-choices { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.s1-choice {
  background: #FFF; border: 5px solid; border-radius: 28px; cursor: pointer;
  padding: 6px; box-shadow: 0 6px 0 rgba(61,40,23,0.12), 0 8px 16px rgba(0,0,0,0.08);
  transition: transform .12s, box-shadow .12s, background .2s;
}
.s1-choice:hover { transform: translateY(-4px); }
.s1-choice:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(61,40,23,0.12); }
.s1-choice.correct {
  background: linear-gradient(180deg, var(--mint) 0%, var(--mint-deep) 100%);
  animation: correctPop 0.5s ease-out;
}
/* Word-choice buttons (낱말 듣고 고르기): big readable Korean text instead of a glyph */
.s1-word-choice {
  border-color: var(--lavender-deep);
  min-width: 150px;
  padding: 22px 30px;
  font-family: 'Jua', sans-serif;
  font-size: 44px;
  color: var(--ink);
  line-height: 1.1;
}
.s1-word-choice.correct { color: #FFF; }
.s1-direction-hint {
  font-family: 'Jua', sans-serif; font-size: 24px; color: var(--ink);
  background: #FFF0F4; border: 3px solid var(--pink-deep); border-radius: 18px;
  padding: 10px 22px; animation: starJump .4s ease-out;
}
.s1-stroke-hint { font-size: 28px; }

/* ---- ③ match pairs ---- */
.s1-match-grid { display: grid; gap: 16px; }
.s1-match-grid.n4  { grid-template-columns: repeat(2, 1fr); }
.s1-match-grid.n8  { grid-template-columns: repeat(4, 1fr); }
.s1-match-card {
  width: 110px; height: 110px; border-radius: 24px; cursor: pointer;
  background: #FFF; border: 5px solid #E3D6C0;
  box-shadow: 0 6px 0 rgba(61,40,23,0.1); transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.s1-match-card:hover { transform: translateY(-3px); }
.s1-match-card.sel { transform: translateY(-3px) scale(1.05); }
.s1-match-card.bad { animation: s1Shake .4s; border-color: var(--coral) !important; }
.s1-match-card.done {
  background: linear-gradient(180deg, var(--mint) 0%, var(--mint-deep) 100%);
  box-shadow: none; cursor: default;
}
.s1-match-check { font-size: 56px; color: #FFF; }
@keyframes s1Shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); } 75% { transform: translateX(7px); }
}

/* ---- ④ transform ---- */
.s1-transform { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.s1-tf-stage {
  position: relative; width: 230px; height: 230px;
  display: flex; align-items: center; justify-content: center;
  background: #FFF; border: 4px solid var(--ink); border-radius: 36px;
  box-shadow: var(--shadow-soft);
}
.s1-tf-stage .s1-glyph { background: transparent; }
.s1-tf-stroke {
  position: absolute; right: 26px; top: 50%; font-size: 54px;
  animation: s1FlyIn .7s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes s1FlyIn {
  0% { transform: translate(120px,-50%) rotate(40deg); opacity: 0; }
  100% { transform: translate(0,-50%) rotate(0); opacity: 1; }
}
.s1-tf-pop { position: absolute; top: 14px; right: 18px; font-size: 44px; animation: starJump .5s ease-out; }
.s1-tf-label { font-family: 'Jua', sans-serif; font-size: 30px; color: var(--ink); white-space: nowrap; }
.s1-tf-label b { font-size: 36px; }

/* ---- village hub ---- */
.s1-bundles {
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
  padding: 4px 24px; flex-shrink: 0; margin-top: 38px;
}
.s1-bundle {
  width: 268px; cursor: pointer; text-align: center;
  background: #FFF; border: 5px solid var(--bc, var(--ink)); border-radius: 28px;
  padding: 20px 18px 16px; box-shadow: 0 8px 0 rgba(61,40,23,0.1), 0 10px 20px rgba(0,0,0,0.07);
  transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; gap: 8px;
}
.s1-bundle:hover:not(:disabled) { transform: translateY(-6px); }
.s1-bundle:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 4px 0 rgba(61,40,23,0.1); }
.s1-bundle.locked { filter: grayscale(0.6); opacity: 0.6; cursor: not-allowed; }
.s1-bundle.done { background: linear-gradient(180deg, #FFF 0%, #F2FBF4 100%); }
.s1-bundle-no {
  font-family: 'Jua', sans-serif; font-size: 18px; color: #FFF;
  background: var(--bc, var(--ink)); border-radius: 999px; padding: 4px 16px; align-self: center;
}
.s1-bundle-vowels {
  font-family: 'Jua', sans-serif; font-size: 46px; color: var(--ink); letter-spacing: 4px;
}
.s1-bundle-desc { font-family: 'Gaegu', cursive; font-size: 19px; color: var(--ink-soft); min-height: 46px; }
.s1-bundle-foot {
  font-family: 'Jua', sans-serif; font-size: 19px; color: var(--ink-soft);
  border-top: 2px dashed var(--ink-faint); padding-top: 10px;
}

.s1-dex {
  margin: 8px 24px 28px; padding: 18px 20px;
  background: rgba(255,255,255,0.7); border: 3px solid #E3D6C0; border-radius: 26px;
}
.s1-dex-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.s1-dex-title { font-family: 'Jua', sans-serif; font-size: 22px; color: var(--ink); white-space: nowrap; }
.s1-reset-btn {
  font-family: 'Jua', sans-serif; font-size: 17px; color: var(--ink-soft); cursor: pointer; white-space: nowrap;
  background: #FFF; border: 2.5px solid var(--ink-faint); border-radius: 999px;
  padding: 7px 16px; box-shadow: 0 4px 0 rgba(61,40,23,0.1); transition: transform .1s, box-shadow .1s;
}
.s1-reset-btn:hover { color: var(--pink-deep); border-color: var(--pink-deep); }
.s1-reset-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(61,40,23,0.1); }
.s1-dex-grid { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ===== 여의주 게이지 (사탕 주머니 대체) ===== */
.s1-orbgauge {
  margin: 8px 24px 28px; padding: 18px 20px;
  background: rgba(255,255,255,0.74); border: 3px solid #E3D6C0; border-radius: 26px;
}
.s1-orbgauge-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.s1-orbgauge-title { font-family: 'Jua', sans-serif; font-size: 22px; color: var(--ink); white-space: nowrap; }
.s1-orbgauge-body { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.s1-orbgauge-orb {
  position: relative; width: 108px; height: 108px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.s1-orbgauge-glow {
  position: absolute; inset: -8%; border-radius: 50%;
  transition: opacity .45s ease, transform .45s ease; pointer-events: none;
}
.s1-orbgauge-count {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  font-family: 'Jua', sans-serif; font-size: 15px; color: var(--ink);
  background: #FFF; border: 2.5px solid var(--ink); border-radius: 999px; padding: 0 9px;
}
.s1-orbgauge-cells {
  display: flex; flex-wrap: wrap; gap: 7px;
  flex: 1; min-width: 0; align-content: center;
}
.s1-orbcell {
  width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
  border-radius: 13px; background: #F4EEE2; border: 2.5px solid #E3D6C0;
  transition: background .25s, border-color .25s, box-shadow .25s, transform .25s;
}
.s1-orbcell.got {
  background: #FFF; border-color: var(--cc); transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(61,40,23,0.12);
}
.s1-orbcell-glyph { font-family: 'Jua', sans-serif; font-size: 24px; color: var(--cc); }
.s1-orbcell-lock { color: #CDBEA3; font-size: 22px; line-height: 1; }
.s1-orbgauge-cap {
  margin-top: 14px; font-family: 'Gaegu', cursive; font-size: 17px;
  color: var(--ink-soft); line-height: 1.45; text-wrap: pretty;
}

/* compact gauge in the play header */
.s1-orbmini {
  display: flex; align-items: center; gap: 7px;
  background: #FFF; border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 4px 11px 4px 5px; white-space: nowrap;
}
.s1-orbmini-bar { width: 60px; height: 9px; border-radius: 999px; background: #EDE2CE; overflow: hidden; }
.s1-orbmini-bar span { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.s1-orbmini-num { font-family: 'Jua', sans-serif; font-size: 14px; color: var(--ink); }

/* compact gauge placed at the top of the village */
.s1-orbgauge.compact {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: nowrap;
  width: fit-content; max-width: calc(100% - 48px);
  margin: 4px auto 6px; padding: 9px 18px;
}
.s1-orbgauge.compact .s1-orbgauge-lead { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.s1-orbgauge-orb.compact { position: relative; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.s1-orbgauge-leadtxt { display: flex; flex-direction: column; line-height: 1.15; }
.s1-orbgauge-leadtxt .s1-orbgauge-title { font-size: 17px; }
.s1-orbgauge-num { font-family: 'Jua', sans-serif; font-size: 15px; color: var(--ink-soft); }
.s1-orbgauge.compact .s1-orbgauge-cells { gap: 5px; justify-content: center; flex-wrap: nowrap; }
.s1-orbgauge.compact .s1-orbcell { width: 36px; height: 36px; border-radius: 10px; border-width: 2px; }
.s1-orbgauge.compact .s1-orbcell-glyph { font-size: 18px; }
.s1-orbgauge.compact .s1-reset-btn { flex-shrink: 0; }

.s1-animal-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #FFF; border: 3px solid #E3D6C0; border-radius: 20px; padding: 10px 6px;
}
.s1-animal-card.got { border-color: var(--mint-deep); box-shadow: 0 4px 0 rgba(109,202,163,0.3); }
.s1-animal-card.locked { background: #F4EEE2; }
.s1-animal-emoji { line-height: 1; }
.s1-animal-card.locked .s1-animal-emoji { filter: grayscale(1); opacity: 0.5; }
.s1-animal-name { font-family: 'Jua', sans-serif; font-size: 15px; color: var(--ink-soft); }

.s1-alldone-tag {
  align-self: center; margin: 0 24px 26px;
  font-family: 'Jua', sans-serif; font-size: 22px; color: #1F5C3E;
  background: var(--mint); border: 3px solid var(--mint-deep); border-radius: 999px;
  padding: 10px 26px; animation: starJump .5s ease-out;
}

/* ---- award celebration ---- */
.s1-award {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 40;
}
.s1-award-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: #FFF; border: 5px solid var(--yellow-deep); border-radius: 32px;
  padding: 26px 40px; box-shadow: 0 14px 30px rgba(0,0,0,0.2);
  animation: s1AwardIn .4s cubic-bezier(0.34,1.56,0.64,1);
}
.s1-award-emoji { font-size: 92px; line-height: 1; animation: starJump .6s ease-out; }
.s1-award-text { font-family: 'Jua', sans-serif; font-size: 26px; color: var(--ink); }
.s1-award-text b { color: var(--pink-deep); font-size: 30px; }
@keyframes s1AwardIn {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- 틀렸을 때 처음부터 다시 ---- */
.s1-restart-flash {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(61, 40, 23, 0.32); backdrop-filter: blur(2px);
  animation: s1RestartFade .25s ease-out;
}
.s1-restart-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: #FFF; border: 5px solid var(--pink-deep); border-radius: 30px;
  padding: 26px 40px; box-shadow: 0 16px 36px rgba(0,0,0,0.26);
  animation: s1AwardIn .4s cubic-bezier(0.34,1.56,0.64,1); text-align: center;
}
.s1-restart-emoji { font-size: 72px; line-height: 1; animation: starJump .6s ease-out; }
.s1-restart-text { font-family: 'Jua', sans-serif; font-size: 30px; color: var(--pink-deep); }
.s1-restart-sub { font-family: 'Gaegu', cursive; font-size: 20px; color: var(--ink-soft); line-height: 1.45; }
@keyframes s1RestartFade { from { opacity: 0; } to { opacity: 1; } }

.s1-complete-animals {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  font-size: 34px; margin: 6px 0 4px; max-width: 360px;
}
.s1-complete-animals span { animation: starJump .5s ease-out backwards; }

@media (max-width: 720px) {
  .s1-bundle { width: 100%; max-width: 320px; }
  .s1-mimic { gap: 18px; }
}

/* ===== Avatar Maker v2 additions (skin / face / bg tabs) ===== */
.am-tabs { width: 84px; }
.am-tab { padding: 8px 0; font-size: 15px; }
.am-tab-ico { width: 40px; height: 40px; }

/* skin tone big round chips */
.am-tones { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; padding: 8px 0; }
.am-tone {
  width: 62px; height: 62px; border-radius: 50%; border: 5px solid #FFF;
  cursor: pointer; padding: 0; box-shadow: 0 0 0 0 #FF7A59, 0 4px 0 rgba(0,0,0,0.12);
  transition: box-shadow .12s, transform .1s;
}
.am-tone.on { box-shadow: 0 0 0 5px #FF7A59, 0 4px 0 rgba(0,0,0,0.12); }
.am-tone:active { transform: translateY(2px); }

/* face sub-section grouping */
.am-section { display: flex; flex-direction: column; gap: 10px; }
.am-section + .am-section { margin-top: 4px; }
.am-section-label {
  font-family: 'Jua', sans-serif; font-size: 18px; color: #2B2340; opacity: 0.8;
  padding-left: 4px;
}
.am-panel-scroll { overflow-y: auto; }

/* blush ON/OFF toggle */
.am-toggle-row { display: flex; align-items: center; gap: 12px; padding: 4px 4px 2px; }
.am-toggle {
  height: 46px; padding: 0 22px; border: none; border-radius: 24px;
  font-family: 'Jua', sans-serif; font-size: 20px; cursor: pointer;
  background: #FBF6EE; color: #2B2340; box-shadow: 0 4px 0 #E8D9C0;
  display: flex; align-items: center; gap: 8px;
}
.am-toggle.on { background: #FFC93C; box-shadow: 0 4px 0 #D9A21A; }
.am-toggle:active { transform: translateY(2px); box-shadow: 0 2px 0 #D9A21A; }
.am-toggle-dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,120,130,0.6); }

@media (max-width: 720px) {
  .am-tabs { width: 100%; flex-direction: row; overflow-x: auto; }
  .am-tone { width: 52px; height: 52px; }
}
/* ===== Avatar Maker v2 — compact fixed height, drag/scroll item list ===== */
/* The editor is a compact, centered card. Only the item LIST scrolls (drag/swipe),
   so adding more hair/clothes/etc. never stretches the page. */
.am-main { height: clamp(380px, 60vh, 510px); min-height: 0; align-items: stretch; }
.am-left, .am-right { min-height: 0; }
.am-preview { min-height: 0; }            /* fills the left column via flex:1 */
.am-panel { min-height: 0; overflow: hidden; }
.am-colors, .am-tones { flex: 0 0 auto; }

/* Only the panel's DIRECT scroll area scrolls: the grid for most tabs,
   the whole panel-scroll for 얼굴 (face). */
.am-panel > .am-grid,
.am-panel > .am-panel-scroll {
  flex: 1 1 0; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.am-panel > .am-grid { align-content: start; }

/* 얼굴 탭: the inner section grids (눈/눈썹/입) keep their natural height so
   their thumbnails render fully — the outer panel-scroll handles the scrolling. */
.am-panel-scroll .am-grid { flex: none; min-height: 0; overflow: visible; }
.am-panel-scroll .am-section:last-child { padding-bottom: 2px; }

/* Phones: columns stack — pin the preview, let the list scroll instead of growing. */
@media (max-width: 760px) {
  .am-main { height: auto; }
  .am-left { flex: 0 0 auto; }
  .am-preview { flex: 0 0 auto; min-height: 210px; }
  .am-right { flex: 1 1 auto; min-height: 0; }
  .am-panel > .am-grid,
  .am-panel > .am-panel-scroll { max-height: 42vh; }
}

/* ===== Stage 1 — 읽기 확인(부모님 확인) ===== */
.s1-read { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.s1-read-card {
  position: relative; width: 206px; height: 206px; background: #FFF;
  border: 6px solid var(--pink-deep); border-radius: 36px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
}
.s1-read-check {
  position: absolute; right: -14px; bottom: -14px;
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(180deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: #FFF; font-family: 'Jua', sans-serif; font-size: 40px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 #4FA77E; animation: s1-pop .3s ease;
}
@keyframes s1-pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.s1-read-say { font-family: 'Gaegu', cursive; font-size: 26px; color: var(--ink-soft); }
.s1-read-hint { display: flex; align-items: center; gap: 12px; background: #FFF6E6; border: 2px dashed var(--yellow-deep); border-radius: 20px; padding: 8px 16px; }
.s1-read-hinttxt { font-family: 'Gaegu', cursive; font-size: 22px; color: var(--ink-soft); }

/* 부모 확인 게이트 — '어른이 눌러요' 느낌의 영역 */
.s1-parent-gate {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: rgba(108, 140, 245, 0.08);
  border: 2px solid rgba(108, 140, 245, 0.35);
  border-radius: 24px; padding: 14px 20px;
}
.s1-parent-label { font-family: 'Jua', sans-serif; font-size: 17px; color: #4A5BA6; letter-spacing: .2px; }

/* ===== 우리 농장 (Farm scene) ===== */
/* The farm renders a fixed-layout board; the scene must be edge-to-edge (no padding)
   so the inner absolute-inset:0 layout fills the whole screen. .scene already
   provides overflow-y:auto for taller-than-viewport cases. */
.scene-farm {
  padding: 0;
  display: block;
  background: #bfe3f6;
}

/* Farm animation keyframes (ported from the source <style> block, namespaced with
   a farm* prefix to avoid colliding with the app's existing popIn/trayIn/etc). */
@keyframes farmFxRise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20%  { opacity: 1; transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}
@keyframes farmSparkle {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(.4) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8) rotate(90deg); }
}
@keyframes farmWiggle {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}
@keyframes farmPopIn {
  0%   { transform: translate(-50%, 10px) scale(.9); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
@keyframes farmTrayIn {
  0%   { transform: translateY(20px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes farmGBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes farmCloud {
  0%   { transform: translateX(-30vw); }
  100% { transform: translateX(130vw); }
}
@keyframes farmStink {
  0%, 100% { transform: translate(-50%, 0) scaleX(1); opacity: .7; }
  50%      { transform: translate(-50%, -6px) scaleX(-1); opacity: 1; }
}
@keyframes farmSway {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}

/* ===== 지도 아바타 칩 — 누르면 아바타 꾸미기 ===== */
.hero-chip-btn { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .1s; }
.hero-chip-btn:active { transform: translateY(1px) scale(0.98); }
.hero-chip-av { position: relative; display: flex; align-items: center; justify-content: center; flex: none; }
.hero-chip-edit {
  position: absolute; right: -3px; bottom: -3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #FFC93C; border: 2.5px solid #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.28);
  pointer-events: none;
}

/* ===== 지도: 각 단계에 와 있는 친구들 (캐릭터 + 이름) ===== */
.map-friends { display: flex; flex-wrap: wrap; gap: 3px 7px; justify-content: center; align-items: flex-start; width: 164px; }
.map-friend { position: relative; display: flex; flex-direction: column; align-items: center; width: 46px; }
.map-friend-av {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: #FFE7C2;
  box-shadow: 0 0 0 2.5px #FFFFFF, 0 2px 4px rgba(0,0,0,0.3);
}
.map-friend-av .avatar-art, .map-friend-av > svg { width: 34px !important; height: 34px !important; display: block; }
.map-friend-crown { position: absolute; top: -9px; right: 3px; font-size: 15px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.map-friend-name {
  margin-top: 2px; max-width: 48px; font-family: 'Jua', sans-serif; font-size: 13px; color: #3D2817;
  background: rgba(255,255,255,0.92); border-radius: 7px; padding: 0 5px; line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.map-friend-more {
  align-self: center; font-family: 'Jua', sans-serif; font-size: 14px; color: #6B4A22;
  background: rgba(255,255,255,0.92); border-radius: 11px; padding: 2px 8px; margin-top: 7px;
}

/* 엔딩: 무지개용 영상 */
.revive-video {
  width: min(520px, 86vw); max-height: 56vh; border-radius: 24px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.45); background: #000;
  object-fit: contain; display: block;
}

/* 엔딩: 무지개용 영상 (전체화면) + 끝난 뒤 버튼 카드 */
.revive-full { padding: 0 !important; overflow: hidden !important; background: #000; }
.revive-video-full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.revive-skip {
  position: absolute; right: 16px; bottom: 16px; z-index: 3; border: none; cursor: pointer;
  border-radius: 999px; padding: 10px 20px; font-family: 'Jua', sans-serif; font-size: 18px; color: #2B2340;
  background: rgba(255,255,255,0.85); box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.revive-endcard {
  position: absolute; inset: 0; z-index: 2; box-sizing: border-box; padding: 24px 16px; text-align: center; color: #FFF;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(ellipse at 50% 42%, rgba(74,57,120,0.55), rgba(31,26,62,0.84));
  backdrop-filter: blur(5px); animation: reviveFadeIn .5s ease;
}
.revive-endbtns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
@keyframes reviveFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== 타이틀 메뉴 (시작하기 / 이어하기) ===== */
.title-card { align-items: center; text-align: center; gap: 8px; max-width: 420px; }
.title-logo { font-family: 'Jua', sans-serif; font-size: clamp(42px, 9vw, 64px); color: #FFD15E; letter-spacing: 1px; text-shadow: 0 4px 0 #B5600F, 0 10px 22px rgba(0,0,0,0.4); line-height: 1.1; }
.title-tag { font-family: 'Jua', sans-serif; font-size: 22px; color: #3D2817; margin-top: 2px; }
.title-btns { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; width: 100%; max-width: 300px; }
.title-btn { width: 100%; font-size: 26px; padding: 16px 0; }
.title-btn.continue { background: #FFFFFF; color: #4A3978; }
.title-hint { margin-top: 14px; font-family: 'Gaegu', cursive; font-size: 16px; color: #7A6A58; word-break: keep-all; }

/* ===================================================================
   RESPONSIVE MERGE — phones + short landscape + small-tablet portrait.
   Appended last to win the cascade. Every rule below is wrapped in a
   small-screen media query (the allowed exception is the global
   html/body overflow safeguard). Tablets 768-1366 and desktop are
   intentionally untouched.
   =================================================================== */

/* GLOBAL ANTI-OVERFLOW SAFEGUARD (allowed unscoped exception) */
html, body { max-width: 100%; overflow-x: hidden; }

/* ===== PHONES PORTRAIT (orientation: portrait) and (max-width: 480px) ===== */
@media (orientation: portrait) and (max-width: 480px) {
  .name-wizard-img { display: none; }
  .name-panel { margin-right: 0; width: min(420px, 92vw); max-width: 92vw; padding: 24px 20px 28px; }
  .scene-name .scene-title { white-space: normal; word-break: keep-all; font-size: clamp(24px, 7.2vw, 32px); }
  .scene-name .scene-subtitle { font-size: 18px; margin-bottom: 18px; }
  .name-input { width: 100%; max-width: 100%; font-size: clamp(26px, 8vw, 34px); padding: 16px 18px; }
  .name-input--email { font-size: clamp(18px, 5.2vw, 23px); }
  .scene-charselect .scene-title { font-size: clamp(22px, 6.4vw, 30px); }
  .scene-charselect .scene-subtitle { font-size: 18px; }
  .char-grid { gap: 14px; max-width: 94vw; }
  .char-art { height: 150px; }
  .char-caption { padding: 10px 8px 12px; }
  .char-name { font-size: 22px; }
  .char-desc { font-size: 16px; min-height: 40px; }
}

/* ===== PHONES PORTRAIT — generic (max-width: 480px) ===== */
@media (max-width: 480px) {
  .story-card { width: 92%; max-width: 92vw; padding: 14px 18px 16px; margin-bottom: 20px; }
  .story-text { font-size: clamp(19px, 5.6vw, 24px); min-height: 54px; line-height: 1.4; }
  .story-text .word { margin: 0 5px 3px; white-space: normal; }
  .next-btn { font-size: 20px; padding: 11px 30px; margin-top: 12px; }
  .title-card { max-width: 92vw; padding: 18px 20px 22px; }
  .title-tag { font-size: 19px; }
  .title-btns { max-width: 280px; margin-top: 18px; }
  .title-btn { font-size: 22px; padding: 14px 0; }
  .title-hint { font-size: 15px; }
  .primary-btn { margin-top: 22px; font-size: clamp(22px, 6.4vw, 28px); padding: 15px 38px; }
  .back-btn { top: 14px; left: 14px; padding: 10px 16px; font-size: 16px; }

  .map-header { padding: 10px 12px; gap: 8px; flex-wrap: wrap; justify-content: center; row-gap: 8px; }
  .orb-tray { order: 3; flex-basis: 100%; justify-content: center; padding: 6px 10px; gap: 2px; }
  .hero-chip { order: 1; gap: 8px; padding: 6px 14px 6px 6px; }
  .hero-chip .avatar { width: 40px; height: 40px; }
  .hero-chip .name { font-size: 18px; }
  .stars-counter { order: 2; font-size: 18px; padding: 8px 14px; }
  .stars-counter-candy { font-size: 18px; }
  .stars-counter-go { font-size: 12px; padding: 2px 7px; }
  .orb-slot { width: 30px; height: 30px; }
  .orb-slot > svg { width: 28px !important; height: 28px !important; }

  .lesson-top { padding: 12px 14px; }
  .progress-bar { margin: 0 12px; height: 14px; border-width: 2px; }
  .lesson-body { gap: 20px; padding: 12px 12px 16px; justify-content: flex-start; }
  .companion-bubble { gap: 10px; max-width: 100%; }
  .companion-bubble .companion { width: 76px; height: 76px; }
  .bubble { font-size: 17px; padding: 10px 14px; max-width: min(260px, 72vw); border-radius: 18px; }
  .combine-row { gap: 8px; }
  .tile { width: clamp(64px, 20vw, 92px); height: clamp(64px, 20vw, 92px); font-size: clamp(34px, 11vw, 54px); border-width: 3px; border-radius: 18px; }
  .tile.slot { font-size: clamp(28px, 9vw, 44px); }
  .tile.target { font-size: clamp(34px, 11vw, 54px); }
  .operator { font-size: 30px; }
  .choice-row { gap: 10px; max-width: 100%; }
  .choice { min-width: 56px; height: 56px; padding: 0 12px; font-size: 32px; border-width: 3px; border-radius: 16px; box-shadow: 0 4px 0 var(--ink), 0 6px 10px rgba(61,40,23,0.1); white-space: nowrap; }
  .drag-ghost { width: 56px; height: 56px; font-size: 32px; border-width: 3px; }
  .complete-inner { width: min(420px, 92vw); max-width: 92vw; padding: 26px 20px; border-radius: 26px; }
  .complete-title { font-size: 32px; }
  .complete-stars { font-size: 40px; gap: 6px; margin: 12px 0 18px; }
  .orb-reveal { width: 130px; height: 130px; }

  .s1-play { gap: 14px; padding: 8px 12px 20px; }
  .s1-task-tag { white-space: normal; font-size: 19px; padding: 7px 18px; max-width: 92vw; }
  .s1-listen { white-space: normal; font-size: 20px; max-width: 92vw; }
  .s1-hint-line { white-space: normal; font-size: 19px; padding: 7px 14px; max-width: 92vw; }
  .s1-direction-hint { white-space: normal; font-size: 19px; padding: 8px 16px; max-width: 92vw; }
  .s1-tf-label { white-space: normal; font-size: 24px; max-width: 92vw; }
  .s1-tf-label b { font-size: 28px; }
  .s1-match-grid { gap: 10px; max-width: 100%; }
  .s1-match-card { width: 100%; max-width: 72px; height: 72px; border-width: 4px; border-radius: 18px; }
  .s1-match-grid.n8 { grid-template-columns: repeat(4, 1fr); justify-items: center; }
  .s1-match-check { font-size: 40px; }
  .s1-play .s1-glyph { max-width: 40vw; max-height: 40vw; }
  .s1-match-card .s1-glyph { max-width: 56px; max-height: 56px; }
  .s1-choices { gap: 14px; }
  .s1-word-choice { min-width: 0; padding: 16px 20px; font-size: 34px; }
  .s1-choice { border-width: 4px; }
  .s1-speaker { width: 110px; height: 110px; }
  .s1-speaker-ico { font-size: 50px; }
  .s1-mimic { gap: 14px; }
  .s1-mimic-vid { width: 100%; max-width: 92vw; }
  .s1-say { font-size: 32px; }
  .s1-tf-stage { width: min(200px, 60vw); height: min(200px, 60vw); }
  .s1-btn { font-size: 20px; padding: 12px 24px; }
  .s1-btn-row { gap: 12px; }
  .s1-bundles { margin-top: 18px; gap: 14px; padding: 4px 12px; }
  .s1-bundle-vowels { font-size: 38px; }
  .s1-dex, .s1-orbgauge { margin: 8px 12px 20px; padding: 14px 14px; }
  .s1-orbcell { width: 42px; height: 42px; }
  .s1-orbgauge.compact { max-width: calc(100% - 20px); flex-wrap: wrap; padding: 8px 12px; }
  .s1-orbgauge.compact .s1-orbgauge-cells { flex-wrap: wrap; }
  .s1-award-card, .s1-restart-card { padding: 20px 24px; max-width: 90vw; }
  .s1-award-emoji { font-size: 72px; }

  .scene-farm [style*="height: 78px"],
  .scene-farm [style*="height:78px"] { height: auto !important; min-height: 56px !important; flex-wrap: wrap !important; gap: 6px !important; padding: 6px 10px !important; row-gap: 6px !important; }
  .scene-farm [style*="height: 124px"],
  .scene-farm [style*="height:124px"] { height: auto !important; min-height: 92px !important; flex-wrap: wrap !important; gap: 8px !important; padding: 8px 8px !important; }

  .am-wrap { gap: 10px; }
  .am-panel { padding: 12px; gap: 12px; border-radius: 22px; }
  .am-grid { grid-auto-rows: clamp(72px, 24vw, 96px); gap: 8px; }
  .am-item { border-radius: 16px; border-width: 3px; padding: 4px; }
  .am-colors { gap: 8px; }
  .am-swatch { width: 44px; height: 44px; border-width: 3px; }
  .am-tones { gap: 10px; padding: 4px 0; }
  .am-tone { width: 48px; height: 48px; border-width: 4px; }
  .am-section-label { font-size: 16px; }
  .am-toggle { height: 46px; padding: 0 18px; font-size: 18px; }
  .am-tab { font-size: 15px; padding: 7px 2px; min-height: 48px; }
  .am-tab-ico { width: 34px; height: 34px; }
  .am-finish { height: 56px; padding: 0 24px; font-size: 24px; border-radius: 28px; }
  .am-finish svg { width: 24px; height: 24px; }
  .am-name { height: 56px; padding: 0 14px; }
  .am-name input { font-size: 22px; }
  .am-preview-av { width: 74%; }
  .am-card { padding: 22px; border-radius: 30px; gap: 12px; }
  .am-card-title { font-size: 22px; text-align: center; }
  .am-card-name { font-size: 32px; }
  .am-card-av { width: 170px; height: 188px; border-radius: 85px 85px 26px 26px; }
  .am-card-btns { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .am-redo { height: 52px; padding: 0 20px; font-size: 20px; }
  .am-ok { height: 52px; padding: 0 24px; font-size: 20px; }

  .revive-title { white-space: normal; word-break: keep-all; font-size: clamp(22px, 7.5vw, 30px); line-height: 1.2; max-width: 92vw; }
  .revive-sub { font-size: clamp(15px, 4.6vw, 20px); max-width: 92vw; }
  .revive-endcard { padding: 20px 14px; gap: 10px; }
  .revive-orb-row { gap: 6px; padding: 8px 12px; flex-wrap: wrap; max-width: 94vw; margin-bottom: 12px; }
  .revive-endbtns { gap: 10px; margin-top: 12px; width: 100%; }
  .revive-endbtns .next-btn { font-size: 19px; padding: 12px 24px; min-height: 44px; }
  .revive-skip { right: 12px; bottom: 12px; padding: 11px 20px; font-size: 16px; min-height: 44px; }
}

/* ===== TINY PHONES (max-width: 380px) — map header ===== */
@media (max-width: 380px) {
  .map-header { padding: 8px 8px; }
  .hero-chip .name { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .orb-slot { width: 26px; height: 26px; }
  .orb-slot > svg { width: 24px !important; height: 24px !important; }
  .orb-tray { gap: 1px; padding: 5px 8px; }
}

/* ===== TINY PHONES (max-width: 360px) ===== */
@media (orientation: portrait) and (max-width: 360px) {
  .name-panel { padding: 20px 14px 24px; }
  .scene-name .scene-title { font-size: clamp(22px, 7.6vw, 28px); }
}
@media (max-width: 360px) {
  .combine-row { gap: 6px; }
  .tile { width: clamp(56px, 19vw, 80px); height: clamp(56px, 19vw, 80px); font-size: clamp(30px, 10vw, 46px); }
  .operator { font-size: 26px; }
  .choice { min-width: 50px; height: 52px; font-size: 28px; padding: 0 10px; }
  .bubble { font-size: 16px; max-width: 66vw; }
  .s1-match-card { max-width: 62px; height: 62px; }
  .s1-match-card .s1-glyph { max-width: 48px; max-height: 48px; }
  .s1-match-grid { gap: 7px; }
  .s1-word-choice { font-size: 30px; padding: 14px 16px; }
  .s1-bundle-vowels { font-size: 34px; }
  .am-grid { gap: 6px; grid-auto-rows: clamp(64px, 23vw, 84px); }
  .am-panel { padding: 10px; }
  .am-finish { padding: 0 18px; font-size: 22px; }
  .am-iconbtn { width: 48px; height: 48px; }
  .am-title { font-size: clamp(22px, 7vw, 28px); }
  .revive-title { font-size: clamp(20px, 7vw, 26px); }
  .revive-orb-row { gap: 4px; padding: 7px 10px; }
}

/* ===== SHORT / PHONE LANDSCAPE (orientation: landscape) and (max-height: 520px) ===== */
@media (orientation: landscape) and (max-height: 520px) {
  .scene-name { gap: 16px; }
  .name-wizard-img { display: block; height: 78%; right: 1%; opacity: 0.9; }
  .name-panel { margin-right: 26%; padding: 18px 26px 20px; max-width: 46vw; }
  .scene-name .scene-title { font-size: clamp(22px, 5vw, 32px); white-space: normal; }
  .scene-name .scene-subtitle { font-size: 17px; margin-bottom: 14px; }
  .name-input { font-size: 26px; padding: 12px 18px; width: 300px; }
  .name-input--email { font-size: 20px; }
  .primary-btn { margin-top: 16px; font-size: 24px; padding: 12px 40px; }
  .story-card { margin-bottom: 14px; padding: 10px 28px 12px; }
  .story-text { font-size: clamp(18px, 3.4vw, 24px); min-height: 46px; }
  .next-btn { margin-top: 10px; font-size: 20px; padding: 9px 28px; }
  .scene-charselect .scene-title { font-size: clamp(20px, 4vw, 30px); margin-top: 2px; }
  .scene-charselect .scene-subtitle { font-size: 16px; margin-bottom: 8px; }
  .char-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 94vw; margin-top: 4px; }
  .char-art { height: 118px; }
  .char-caption { padding: 8px 6px 10px; gap: 3px; }
  .char-name { font-size: 19px; }
  .char-desc { font-size: 14px; min-height: 34px; line-height: 1.25; }
  .title-logo { font-size: clamp(36px, 7vw, 52px); }
  .title-btns { margin-top: 14px; }
  .title-btn { font-size: 22px; padding: 12px 0; }

  .map-header { padding: 6px 12px; gap: 8px; flex-wrap: nowrap; }
  .hero-chip { padding: 5px 12px 5px 5px; gap: 7px; }
  .hero-chip .avatar { width: 36px; height: 36px; }
  .hero-chip .name { font-size: 16px; max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stars-counter { font-size: 16px; padding: 6px 12px; }
  .stars-counter-candy { font-size: 16px; }
  .orb-tray { padding: 5px 8px; gap: 2px; }
  .orb-slot { width: 26px; height: 26px; }
  .orb-slot > svg { width: 24px !important; height: 24px !important; }
  .scene-map .back-btn { font-size: 14px !important; padding: 8px 14px; right: 14px !important; bottom: 14px !important; }

  .lesson-top { padding: 8px 16px; }
  .progress-bar { height: 12px; margin: 0 16px; }
  .lesson-body { gap: 12px; padding: 8px 16px 12px; justify-content: flex-start; }
  .companion-bubble { gap: 10px; }
  .companion-bubble .companion { width: 64px; height: 64px; }
  .bubble { font-size: 16px; padding: 8px 12px; max-width: 50vw; }
  .combine-row { gap: 10px; }
  .tile { width: clamp(60px, 16vh, 110px); height: clamp(60px, 16vh, 110px); font-size: clamp(32px, 9vh, 64px); }
  .tile.slot { font-size: clamp(26px, 7vh, 50px); }
  .operator { font-size: 34px; }
  .choice-row { gap: 10px; }
  .choice { min-width: 56px; height: clamp(48px, 13vh, 76px); font-size: clamp(28px, 7vh, 46px); padding: 0 14px; }
  .drag-ghost { width: 64px; height: 64px; font-size: 40px; }
  .complete-inner { padding: 18px 26px; }
  .complete-title { font-size: 30px; }
  .orb-reveal { width: 110px; height: 110px; margin: 8px auto 4px; }
  .complete-stars { font-size: 34px; margin: 8px 0 14px; }

  .s1-play { gap: 10px; padding: 6px 20px 12px; }
  .s1-task-tag { font-size: 18px; padding: 6px 16px; white-space: normal; }
  .s1-listen { font-size: 17px; white-space: normal; }
  .s1-hint-line { font-size: 16px; white-space: normal; padding: 6px 14px; }
  .s1-play .s1-glyph { max-height: 34vh; max-width: 34vh; }
  .s1-tf-stage { width: 34vh; height: 34vh; max-width: 200px; max-height: 200px; }
  .s1-mimic { gap: 14px; }
  .s1-mimic-vid { max-height: 52vh; width: auto; max-width: 70vw; }
  .s1-speaker { width: 92px; height: 92px; }
  .s1-speaker-ico { font-size: 42px; }
  .s1-say { font-size: 30px; }
  .s1-match-card { width: 72px; height: 72px; }
  .s1-match-card .s1-glyph { max-width: 50px; max-height: 50px; }
  .s1-match-grid { gap: 10px; }
  .s1-btn { font-size: 19px; padding: 10px 22px; }
  .s1-bundles { margin-top: 12px; }
  .s1-award-emoji { font-size: 60px; }

  .scene-farm [style*="height: 124px"],
  .scene-farm [style*="height:124px"] { height: auto !important; min-height: 0 !important; padding: 6px 10px !important; gap: 10px !important; }
  .scene-farm [style*="height: 78px"],
  .scene-farm [style*="height:78px"] { height: auto !important; min-height: 0 !important; padding: 4px 12px !important; }

  .am-scene { padding: 8px 0; }
  .am-wrap { gap: 8px; }
  .am-main { height: clamp(220px, 74vh, 330px); }
  .am-preview { min-height: 0; border-radius: 22px; }
  .am-left { gap: 8px; }
  .am-name { height: 46px; }
  .am-name input { font-size: 20px; }
  .am-name svg { width: 22px; height: 22px; }
  .am-panel { padding: 12px; gap: 10px; }
  .am-grid { grid-auto-rows: clamp(66px, 16vh, 92px); gap: 8px; }
  .am-tabs { width: 76px; gap: 6px; }
  .am-tab { font-size: 14px; padding: 4px 0; min-height: 0; }
  .am-tab-ico { width: 30px; height: 30px; }
  .am-title { font-size: clamp(20px, 3.4vh, 26px); }
  .am-iconbtn { width: 46px; height: 46px; }
  .am-finish { height: 50px; padding: 0 24px; font-size: 22px; }
  .am-finish svg { width: 22px; height: 22px; }
  .am-random { width: 46px; height: 46px; border-radius: 14px; }
  .am-random svg { width: 26px; height: 26px; }
  .am-tones { padding: 2px 0; gap: 8px; }
  .am-tone { width: 46px; height: 46px; }
  .am-panel > .am-grid,
  .am-panel > .am-panel-scroll { min-height: 0; }

  .revive-endcard { padding: 10px 16px; gap: 6px; justify-content: center; }
  .revive-orb-row { gap: 6px; padding: 6px 12px; margin-bottom: 6px; }
  .revive-title { white-space: normal; word-break: keep-all; font-size: clamp(20px, 5vh, 28px); margin-bottom: 2px; max-width: 80vw; }
  .revive-sub { font-size: clamp(14px, 3.6vh, 18px); line-height: 1.3; }
  .revive-endbtns { margin-top: 8px; gap: 10px; }
  .revive-endbtns .next-btn { font-size: 17px; padding: 9px 22px; min-height: 42px; }
  .revive-skip { right: 12px; bottom: 10px; padding: 8px 18px; font-size: 15px; }
}

/* ===== SMALL-TABLET PORTRAIT (min-width:481px) and (max-width:834px) generic ===== */
@media (min-width: 481px) and (max-width: 834px) {
  .map-header { padding: 14px 18px; }
  .orb-slot { width: 32px; height: 32px; }
  .orb-slot > svg { width: 30px !important; height: 30px !important; }
  .hero-chip .name { font-size: 20px; }
  .stars-counter { font-size: 20px; }
  .s1-task-tag, .s1-listen, .s1-hint-line, .s1-direction-hint, .s1-tf-label { white-space: normal; max-width: 92vw; }
  .s1-match-grid { max-width: 100%; }
  .s1-orbgauge.compact { flex-wrap: wrap; }
  .s1-orbgauge.compact .s1-orbgauge-cells { flex-wrap: wrap; }
  .revive-title { white-space: normal; word-break: keep-all; max-width: 90vw; }
  .revive-sub { max-width: 88vw; }
  .revive-orb-row { flex-wrap: wrap; max-width: 92vw; }
}

/* ===== SMALL-TABLET / LARGE-PHONE PORTRAIT ONLY (481-834, portrait) ===== */
@media (orientation: portrait) and (min-width: 481px) and (max-width: 834px) {
  .name-panel { margin-right: 18%; max-width: 440px; }
  .scene-name .scene-title { white-space: normal; word-break: keep-all; }
  .name-wizard-img { right: 0; height: 70%; }
  .lesson-body { gap: 28px; }
  .combine-row { gap: 14px; }
  .tile { width: clamp(96px, 15vw, 130px); height: clamp(96px, 15vw, 130px); font-size: clamp(52px, 9vw, 80px); }
  .operator { font-size: 46px; }
  .bubble { max-width: min(380px, 60vw); }
  .am-main { flex-direction: column; height: auto; }
  .am-left { width: 100%; max-width: none; flex: 0 0 auto; }
  .am-preview { flex: 0 0 auto; min-height: 240px; }
  .am-right { flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .am-tabs { width: 100%; flex-direction: row; overflow-x: auto; }
  .am-tab { flex: 1; padding: 8px 0; font-size: 16px; min-height: 48px; }
  .am-tab-ico { width: 38px; height: 38px; }
  .am-panel > .am-grid,
  .am-panel > .am-panel-scroll { max-height: 46vh; }
}
