/* ===========================================================
   數學冒險島 — screens.css
   各畫面：標題、地圖、遊戲、結算、練習、貼紙、家長
   =========================================================== */

.screens { position: relative; overflow: hidden; }
.screen {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  opacity: 0; visibility: hidden;
  transform: translateY(18px) scale(.99);
  transition: opacity .32s ease, transform .32s cubic-bezier(.2, 1.2, .5, 1), visibility .32s;
  padding: 18px;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; }

/* ===========================================================
   1. 標題畫面
   =========================================================== */
#screen-title { display: grid; place-items: center; padding: 10px 18px 6px; }
.title-hero {
  position: relative;
  width: min(var(--maxw), 100%);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 24px;
  align-items: center;
}
.title-island {
  position: relative; height: min(72vh, 560px);
  border-radius: 46% 46% 30% 30% / 40% 40% 22% 22%;
  background: radial-gradient(120% 90% at 50% 15%, #ffffff 0%, #ffeeb8 42%, #ffd97a 70%, #f5bb4e 100%);
  box-shadow: 0 26px 0 rgba(0, 0, 0, .08), 0 36px 60px rgba(20, 60, 110, .3), inset 0 -22px 0 rgba(0, 0, 0, .06);
  display: grid; place-items: center;
  overflow: hidden;
}
.title-island::after {
  content: ''; position: absolute; left: 6%; right: 6%; bottom: -6%; height: 26%;
  background: linear-gradient(180deg, #6fd3ff, #2e9fdc);
  border-radius: 50%;
  opacity: .55;
}
.title-hero-char { width: 34%; max-width: 190px; position: relative; z-index: 3; animation: floatY 2.4s ease-in-out infinite; }
.title-tree { position: absolute; z-index: 2; }
.title-tree.tree-l { left: 4%; bottom: 6%; width: 34%; }
.title-tree.tree-r { right: 2%; bottom: 10%; width: 26%; transform: scaleX(-1); }
.title-cloud {
  position: absolute; height: 40px; width: 130px; border-radius: 40px;
  background: rgba(255, 255, 255, .9);
  filter: blur(.4px);
  box-shadow: 40px 10px 0 -6px rgba(255, 255, 255, .9), -34px 12px 0 -8px rgba(255, 255, 255, .9);
}
.title-cloud.cloud-a { top: 8%; left: 4%; animation: floatY2 7s ease-in-out infinite; }
.title-cloud.cloud-b { top: 20%; right: 6%; transform: scale(.8); animation: floatY2 9s ease-in-out infinite reverse; }

.title-panel { display: flex; flex-direction: column; gap: 16px; }
.game-logo { display: flex; flex-direction: column; line-height: .98; }
.logo-line1, .logo-line2 {
  font-size: clamp(46px, 6.4vw, 86px);
  font-weight: 800; letter-spacing: .05em;
}
.logo-line1 { color: #fff; text-shadow: 0 6px 0 #3aa0d8, 0 12px 22px rgba(0, 60, 110, .35); }
.logo-line2 { color: #ffe27a; text-shadow: 0 6px 0 #d98b12, 0 12px 22px rgba(120, 70, 0, .35); }
.game-sub { font-size: 18px; font-weight: 800; color: #17608c; letter-spacing: .06em; }
.title-welcome {
  font-size: 19px; color: #2b4a6b; background: rgba(255, 255, 255, .74);
  padding: 10px 18px; border-radius: 999px; align-self: flex-start; font-weight: 700;
}
.title-btns { display: flex; flex-direction: column; gap: 12px; max-width: 400px; }
.title-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.tstat {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .82); border-radius: 999px;
  padding: 7px 15px; font-size: 15px; font-weight: 700; color: #2b4a6b;
}
.tstat img { width: 22px; height: 22px; object-fit: contain; }
.title-credit {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: rgba(20, 60, 90, .6);
}

@media (max-width: 900px) {
  .title-hero { grid-template-columns: 1fr; }
  .title-island { height: 200px; order: 2; }
  .title-panel { order: 1; }
}

/* ===========================================================
   2. 世界地圖
   =========================================================== */
#screen-map {
  display: flex; flex-direction: column;
  padding: 8px 12px 10px;
}
.map-wrap { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; padding: 0; }
.map-board {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 360px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(140, 220, 255, .35), rgba(90, 180, 230, .2));
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, .55), var(--sh-1);
  overflow: visible;
}
.map-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.island {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
  transition: transform .16s ease;
}
.island:hover { transform: translate(-50%, -50%) scale(1.06); }
.island-art {
  position: relative;
  width: clamp(56px, min(6.6vw, 10.6vh), 132px); height: clamp(56px, min(6.6vw, 10.6vh), 132px); border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff, var(--island-color, #ffd070) 62%, rgba(0, 0, 0, .12) 130%);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .16), 0 10px 18px rgba(20, 60, 110, .28), inset 0 -6px 0 rgba(0, 0, 0, .08);
  display: grid; place-items: center;
  border: 4px solid rgba(255, 255, 255, .95);
}
.island-icon { width: 56%; height: 56%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .2)); }
.island-glow {
  position: absolute; inset: -10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 70%);
  opacity: 0; animation: pulse 1.6s ease-in-out infinite;
}
.island.is-current .island-glow { opacity: 1; }
.island.is-current .island-art { border-color: #ffe27a; box-shadow: 0 0 0 5px rgba(255, 216, 90, .55), 0 6px 0 rgba(0, 0, 0, .16), 0 10px 18px rgba(20, 60, 110, .3); }
.island.is-locked .island-art { filter: grayscale(.75) brightness(.92); }
.island.is-locked .island-icon { width: 36%; opacity: .7; }
.island.is-done .island-art::after {
  content: ''; position: absolute; right: -4px; bottom: -2px; width: clamp(20px, min(1.7vw, 2.8vh), 34px); height: clamp(20px, min(1.7vw, 2.8vh), 34px);
  background: url('../assets/ui/check_round_color.png') center/contain no-repeat;
}
.island-num {
  position: absolute; left: -8px; top: -8px;
  width: clamp(24px, min(1.9vw, 3vh), 38px); height: clamp(24px, min(1.9vw, 3vh), 38px); border-radius: 50%;
  background: #fff; color: var(--ink);
  display: grid; place-items: center; font-size: clamp(13px, min(1.05vw, 1.7vh), 21px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .16);
}
.island-name {
  font-size: clamp(12px, min(1.15vw, 1.8vh), 21px); font-weight: 800; color: #1d4f74;
  background: rgba(255, 255, 255, .94); padding: 3px 12px; border-radius: 999px;
  white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .14);
}
.island-stars { display: flex; gap: 1px; }
.map-star { width: clamp(13px, min(1.4vw, 2.3vh), 28px); height: clamp(13px, min(1.4vw, 2.3vh), 28px); object-fit: contain; }
.island-lock { display: none; }
.map-hero {
  position: absolute; width: clamp(46px, min(5.6vw, 9vh), 108px);
  left: -38%; top: 24%;
  animation: floatY 1.8s ease-in-out infinite; z-index: 4;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .22));
}
.map-tip {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin: 12px auto 0; padding: 10px 20px;
  background: rgba(255, 255, 255, .9); border-radius: 999px;
  font-size: 16px; color: #2b4a6b; font-weight: 700;
  box-shadow: var(--sh-1);
}
.map-tip-img { width: 34px; height: 34px; object-fit: contain; animation: wiggle 2.6s ease-in-out infinite; }

@media (max-width: 760px) {
  #screen-map { padding: 6px 8px 8px; }
  .map-board { min-height: 460px; }
  .island-name { font-size: 11px; padding: 1px 7px; }
  .map-star { width: 13px; height: 13px; }
  .map-hero { left: -46%; }
  .map-tip { font-size: 14px; padding: 8px 14px; }
  .map-tip-img { width: 28px; height: 28px; }
}

/* ===========================================================
   3. 遊戲畫面
   =========================================================== */
.screen-game { display: flex; flex-direction: column; padding: 12px 16px 14px; }
.stage-wrap {
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  overflow: hidden;
}
.stage {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px;
}
.stage.is-in > * { animation: popIn .4s cubic-bezier(.2, 1.3, .5, 1) both; }

/* 答對 / 答錯 大徽章 */
.answer-badge {
  position: fixed; left: 50%; top: 42%;
  width: 150px; height: 150px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .94);
  z-index: 70; pointer-events: none;
  animation: badgePop .95s cubic-bezier(.2, 1.5, .5, 1) forwards;
}
.answer-badge img { width: 84px; height: 84px; object-fit: contain; }
.answer-badge.is-ok { box-shadow: 0 0 0 10px rgba(75, 200, 106, .35), 0 18px 40px rgba(20, 90, 50, .3); }
.answer-badge.is-bad { box-shadow: 0 0 0 10px rgba(255, 156, 90, .35), 0 18px 40px rgba(140, 80, 20, .3); }
@keyframes badgePop {
  0% { transform: translate(-50%, -50%) scale(.3) rotate(-18deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.12) rotate(5deg); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(.9); opacity: 0; }
}

/* 底部回饋條 */
.feedback {
  position: fixed; left: 50%; bottom: 14px; transform: translate(-50%, 140%);
  width: min(760px, 94vw);
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--sh-2);
  transition: transform .34s cubic-bezier(.2, 1.35, .5, 1);
  z-index: 65; pointer-events: none;
  border: 4px solid rgba(255, 255, 255, .9);
}
.feedback.is-on { transform: translate(-50%, 0); }
.feedback.is-ok { background: linear-gradient(180deg, #e8fff0, #c8f7d8); }
.feedback.is-bad { background: linear-gradient(180deg, #fff6e8, #ffe1c2); }
.fb-ico { width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); }
.fb-ico img { width: 34px; height: 34px; object-fit: contain; }
.fb-body { flex: 1; min-width: 0; }
.fb-text { font-size: 23px; font-weight: 800; color: var(--ink); }
.fb-answer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.fb-answer-label { font-size: 15px; color: #a05a12; font-weight: 700; }
.fb-answer-val {
  font-family: var(--font-num); font-size: 28px; font-weight: 800; color: #d2691e;
  background: #fff; border-radius: 12px; padding: 1px 16px; box-shadow: var(--sh-1);
}
.fb-explain { font-size: 15px; color: #8a5a20; }
.fb-streak { font-size: 15px; color: #1d8a4b; font-weight: 800; margin-top: 2px; }

/* 階段提示橫幅 */
.stage-banner {
  position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(.7);
  padding: 22px 60px; border-radius: var(--r-xl); text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(235, 248, 255, .98));
  box-shadow: var(--sh-2), 0 0 0 8px rgba(255, 255, 255, .5);
  animation: bannerIn .6s cubic-bezier(.2, 1.5, .5, 1) both;
  z-index: 80;
}
.stage-banner.is-out { opacity: 0; transform: translate(-50%, -70%) scale(.9); transition: all .5s ease; }
.stage-banner-num { font-size: 20px; color: var(--ink-soft); font-weight: 800; }
.stage-banner-name { font-size: 40px; font-weight: 800; color: #2f8fc4; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.7); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.pause-tip { font-size: 16px; color: var(--ink-soft); text-align: center; margin-top: 6px; line-height: 1.7; }

/* ===========================================================
   4. 結算畫面
   =========================================================== */
#screen-result { display: grid; place-items: center; }
.rs-card {
  width: min(620px, 94vw);
  background: var(--paper);
  border-radius: var(--r-xl);
  padding: 24px 30px 26px;
  box-shadow: var(--sh-2), 0 0 0 8px rgba(255, 255, 255, .5);
  text-align: center;
  animation: popIn .5s cubic-bezier(.2, 1.4, .5, 1) both;
}
.rs-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rs-hero { width: 92px; height: 92px; object-fit: contain; animation: floatY 2s ease-in-out infinite; }
.rs-title { font-size: 32px; font-weight: 800; color: var(--ink); }
.rs-sub { font-size: 17px; color: var(--ink-soft); font-weight: 700; }
.rs-stars { display: flex; justify-content: center; gap: 10px; margin: 16px 0 18px; }
.rs-star { width: 74px; height: 74px; object-fit: contain; opacity: .45; }
.rs-star.is-on { opacity: 1; }
.rs-star.is-pop { animation: starPop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes starPop {
  0% { transform: scale(.4) rotate(-30deg); }
  55% { transform: scale(1.28) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.rs-rows { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.rs-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 18px; border-radius: 14px; font-size: 18px;
  color: var(--ink-soft);
}
.rs-row:nth-child(odd) { background: rgba(120, 190, 250, .12); }
.rs-row-val { color: var(--ink); font-size: 21px; }
.rs-btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ===========================================================
   5. 自由練習
   =========================================================== */
.practice-grid {
  display: grid; gap: 16px; width: min(var(--maxw), 96vw); margin: 0 auto 30px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.practice-card {
  background: rgba(255, 255, 255, .95);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh-1);
  border: 3px solid rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .14s ease, box-shadow .14s ease;
}
.practice-card:hover { transform: translateY(-4px); box-shadow: var(--sh-2); }
.practice-ico {
  width: 62px; height: 62px; border-radius: 18px; background: #eaf6ff;
  display: grid; place-items: center;
}
.practice-ico img { width: 38px; height: 38px; object-fit: contain; }
.practice-name { font-size: 23px; font-weight: 800; }
.practice-desc { font-size: 15px; color: var(--ink-soft); min-height: 38px; line-height: 1.5; }
.practice-stat { font-size: 13px; color: var(--ink-soft); }
.pstat-bar { height: 10px; border-radius: 6px; background: #e6eef7; overflow: hidden; margin-bottom: 4px; }
.pstat-fill { height: 100%; background: linear-gradient(90deg, #7fe0a8, #35c069); border-radius: 6px; transition: width .4s ease; }
.practice-diff { display: flex; gap: 8px; margin-top: 4px; }

/* ===========================================================
   6. 貼紙簿
   =========================================================== */
.sticker-grid {
  display: grid; gap: 14px; width: min(var(--maxw), 96vw); margin: 0 auto 40px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.sticker {
  background: rgba(255, 255, 255, .95);
  border-radius: var(--r);
  padding: 12px; text-align: center;
  box-shadow: var(--sh-1); border: 3px solid rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative;
}
.sticker-img {
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff, #dff0ff 70%);
  display: grid; place-items: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .07);
}
.sticker-img img { width: 66px; height: 66px; object-fit: contain; }
.sticker:not(.is-owned) .sticker-img img { filter: brightness(0) opacity(.22); }
.sticker-name { font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.sticker.is-owned .sticker-name { color: var(--ink); }
.sticker-own { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; }
.sticker-own img { width: 100%; height: 100%; object-fit: contain; }
.all-done {
  width: min(600px, 92vw); margin: 0 auto 40px; text-align: center;
  background: #fff8dd; border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--sh-1);
}
.all-done-txt { font-size: 22px; font-weight: 800; color: #b1670a; }

/* ===========================================================
   7. 家長區
   =========================================================== */
.parent-grid, .parent-tools {
  display: grid; gap: 16px; width: min(var(--maxw), 96vw); margin: 0 auto 18px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
.parent-tools { padding-bottom: 40px; }
