/* ============================================================
   单词森林：关卡地图 + 关卡内玩法
   ============================================================ */

/* ---------- 关卡地图 ---------- */

.map-page {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(900px 520px at 50% -12%, #ffffffb8, transparent 65%),
    linear-gradient(165deg, #eef4e0, #e4eedb 55%, #f3f1e2);
}

.map-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px clamp(14px, 3.4vw, 46px) 6px;
}
.map-head__titles { display: grid; gap: 2px; }
.map-head__kicker { font-size: 11.5px; font-weight: 800; letter-spacing: .16em; color: #7b8b7f; }
.map-head__title { font-size: clamp(20px, 2.2vw, 30px); font-weight: 900; color: #1d3f31; }
.points-badge {
  margin-left: auto;
  display: grid;
  justify-items: end;
  padding: 8px 16px;
  background: #fdfbf2;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.points-badge strong { font-size: 20px; color: #b4791f; line-height: 1; }
.points-badge span { font-size: 11px; color: #87988f; font-weight: 700; }

.map-stage {
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  gap: 12px;
  padding: 0 clamp(10px, 2vw, 26px);
  min-height: 0;
}
.map-caption { text-align: center; color: #6b7d72; font-size: 13.5px; }

.carousel-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.carousel-arrow {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fdfbf2;
  color: #4a5f52;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
}
.carousel-arrow:hover { background: #fff; box-shadow: var(--shadow); }
.carousel-arrow:disabled { opacity: .4; cursor: default; }

.level-carousel {
  display: flex;
  gap: clamp(10px, 1.4vw, 20px);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 6px 4px 14px;
  min-height: 0;
  scrollbar-width: thin;
}
.level-carousel::-webkit-scrollbar { height: 8px; }
.level-carousel::-webkit-scrollbar-thumb { background: #c6d3b8; border-radius: 99px; }

.level-card {
  flex: 0 0 clamp(300px, 31vw, 430px);
  scroll-snap-align: center;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid transparent;
  background: #fff;
  box-shadow: 0 8px 20px #1d3b2c1a;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.level-card:hover { transform: translateY(-4px); box-shadow: 0 16px 30px #1d3b2c26; }
.level-card[aria-pressed="true"] { border-color: #f2c14e; box-shadow: 0 16px 32px #b4791f33; }

.level-card__art { position: relative; aspect-ratio: 16 / 10; overflow: hidden; }
.level-card__art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.level-card__badge {
  position: absolute;
  left: 10px; top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ffffffe6;
  font-size: 11.5px;
  font-weight: 900;
  color: #3f6b4f;
  letter-spacing: .04em;
}
.level-card__lock {
  position: absolute;
  right: 10px; top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #2b2b2be0;
  color: #ffe89a;
  font-size: 11.5px;
  font-weight: 800;
}
.level-card__meta { padding: 10px 14px 14px; display: grid; gap: 6px; }
.level-card__meta h3 { font-size: 16px; color: #22412f; }
.level-card__meta p { margin: 0; font-size: 12px; color: #7c8b81; }
.level-card__bar { height: 6px; border-radius: 99px; background: #edf0e2; overflow: hidden; }
.level-card__bar i { display: block; height: 100%; background: linear-gradient(90deg, #8ec267, #4f8f4b); }

.map-dock {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 clamp(10px, 2vw, 26px) max(12px, env(safe-area-inset-bottom));
  padding: 14px clamp(14px, 2.2vw, 24px);
  border-radius: 20px;
  background: #fdfbf2dd;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.map-dock__text { flex: 1; min-width: 0; }
.map-dock__text span { font-size: 12px; font-weight: 800; color: #6b8a5f; letter-spacing: .06em; }
.map-dock__text h2 { font-size: clamp(17px, 1.7vw, 22px); color: #1d3f31; margin: 2px 0 2px; }
.map-dock__text p { margin: 0; font-size: 12.5px; color: #7c8b81; }
.map-dock .btn { flex: 0 0 auto; }

/* ---------- 关卡内 ---------- */

.play-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #a7cf81;
  touch-action: manipulation;
}

.play-world { position: absolute; inset: 0; }
.play-world > svg.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }

.growth-layer { position: absolute; inset: 0; }
.scene-prop {
  animation: propGrow .55s cubic-bezier(.22, 1.4, .5, 1) both;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 6px 6px #1d3b2c2e);
}
@keyframes propGrow {
  0% { opacity: 0; transform: scale(.2) translateY(10px); }
  70% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}

.play-topbar {
  position: absolute;
  z-index: 6;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.play-topbar .quiet-btn {
  min-height: 42px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 0;
  background: #ffffffe8;
  color: #26382c;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px #1d3b2c26;
  backdrop-filter: blur(6px);
}
.play-topbar .quiet-btn:hover { background: #fff; }
.play-heading { display: grid; gap: 1px; color: #fff; text-shadow: 0 2px 6px #16372e99; }
.play-heading span { font-size: 11px; font-weight: 800; letter-spacing: .14em; opacity: .9; }
.play-heading h1 { font-size: clamp(17px, 1.8vw, 24px); font-weight: 900; }
.progress-pill {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 7px 16px;
  border-radius: 999px;
  background: #ffffffe8;
  box-shadow: 0 4px 12px #1d3b2c26;
  font-weight: 900;
  color: #2f5c40;
}
.progress-pill strong { font-size: 19px; }
.progress-pill span { font-size: 12px; color: #7c8b81; }

.orb-field { position: absolute; inset: 0; z-index: 4; }
.orb {
  position: absolute;
  width: clamp(54px, 6.2vw, 86px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 38% 32%, #fffbe6 0%, #ffe89a 38%, #f5c24a 68%, #e0a52c 100%);
  box-shadow: 0 0 0 6px #ffe89a55, 0 10px 22px #7a5a1233, 0 0 34px #ffe08a88;
  animation: float 4.6s ease-in-out infinite;
  transition: transform .16s ease, box-shadow .16s ease;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #7a5a12;
}
.orb::after {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 34%, #ffffffcc, transparent 70%);
}
.orb:hover { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 9px #ffe89a66, 0 14px 26px #7a5a1244, 0 0 46px #ffe08aaa; }
.orb[data-state="found"] { opacity: .28; pointer-events: none; }
.orb[data-state="popped"] {
  animation: orbPop .45s ease forwards;
  pointer-events: none;
}
@keyframes float {
  0%, 100% { transform: translate(-50%, calc(-50% - 8px)); }
  50% { transform: translate(-50%, calc(-50% + 8px)); }
}
@keyframes orbPop {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
}

.paused-anim .orb, .paused-anim .scene-prop { animation-play-state: paused !important; }

.word-prompt {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 15%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 22px;
  border-radius: 999px;
  background: #16372ecc;
  color: #fff8e2;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 6px 16px #14342733;
  max-width: min(92vw, 720px);
  text-align: center;
  backdrop-filter: blur(4px);
}

.word-card[hidden] { display: none; }
.word-card {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-radius: 20px;
  background: #fffdf6f2;
  box-shadow: 0 18px 40px #1434273d, 0 0 0 3px #ffe89a66;
  animation: popIn .25s ease;
}
.word-card__en { font-size: clamp(26px, 3.4vw, 42px); font-weight: 900; color: #1d6543; letter-spacing: .02em; }
.word-card__zh { font-size: 15px; color: #7c8b81; font-weight: 700; }
.word-card__say {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 0;
  background: #eef3e0;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.word-card__say:hover { background: #e2ecd0; }

.writing-dock {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  padding: 14px clamp(12px, 2vw, 20px) 16px;
  border-radius: 22px;
  background: #fffdf6f2;
  border: 1px solid #f0e7cb;
  box-shadow: 0 18px 40px #14342738;
  backdrop-filter: blur(10px);
}
.writing-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.writing-tools label { font-size: 13px; font-weight: 800; color: #4a5f52; }
.writing-tools button {
  margin-left: auto;
  border: 0;
  background: #eef3e0;
  color: #4a5f52;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  min-height: 34px;
}
.writing-row { display: flex; gap: 10px; }
.writing-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 800;
  letter-spacing: .06em;
  padding: 12px 18px;
  border-radius: 14px;
  border: 2px solid #e6dfc8;
  background: #fffef9;
  color: #1d3f31;
}
.writing-row input:focus { border-color: #8ec267; outline: none; box-shadow: 0 0 0 4px #a7cf8140; }
.writing-row input:disabled { background: #f4f1e4; color: #9aa79d; }
.writing-row .btn { min-width: 108px; }
.shake { animation: shake .38s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px) }
  20%, 80% { transform: translateX(4px) }
  30%, 50%, 70% { transform: translateX(-7px) }
  40%, 60% { transform: translateX(7px) }
}

.input-feedback {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 108px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #1d6543;
  text-shadow: 0 2px 8px #ffffffcc;
  pointer-events: none;
  min-height: 22px;
}
.input-feedback[data-kind="bad"] { color: #b1462f; }

.completion-banner {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  padding: 28px 26px;
  border-radius: 26px;
  background: #fffdf7;
  box-shadow: 0 30px 70px #14342755, 0 0 0 4px #ffe89a88;
  text-align: center;
  animation: popIn .3s ease;
}
.completion-banner[hidden] { display: none; }
.completion-banner span { font-size: 12.5px; font-weight: 900; letter-spacing: .16em; color: #b4791f; }
.completion-banner h2 { font-size: clamp(22px, 2.6vw, 30px); color: #1d6543; margin: 6px 0 4px; }
.completion-banner p { color: #7c8b81; font-size: 13.5px; margin: 0 0 18px; }
.completion-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.audio-settings { position: relative; }
.audio-settings summary {
  list-style: none;
  min-height: 42px;
  padding: 8px 15px;
  border-radius: 999px;
  background: #ffffffe8;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px #1d3b2c26;
  display: grid;
  place-items: center;
  color: #26382c;
}
.audio-settings summary::-webkit-details-marker { display: none; }
.audio-settings-panel {
  position: absolute;
  right: 0;
  top: 50px;
  width: 232px;
  padding: 14px;
  border-radius: 16px;
  background: #fffdf6;
  box-shadow: 0 16px 34px #14342733;
  display: grid;
  gap: 12px;
  z-index: 8;
}
.audio-settings-panel label { display: grid; gap: 4px; font-size: 12px; font-weight: 800; color: #4a5f52; }
.audio-settings-panel input[type="range"] { width: 100%; accent-color: #4f8f4b; }

@media (max-width: 720px) {
  .play-heading { display: none; }
  .word-card { top: 20%; padding: 12px 16px; }
  .word-prompt { top: 11%; font-size: 12.5px; padding: 8px 14px; }
  .writing-row .btn { min-width: 84px; }
  .map-dock { flex-wrap: wrap; }
  .map-dock .btn { width: 100%; }
  .carousel-arrow { display: none; }
}
