/* ===== 全局 ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Comic Sans MS", "Chalkboard SE", "PingFang SC", "Microsoft YaHei", "STYuanti", sans-serif;
  color: #5D4A3A;
  background: #FFF6D6;
}

body { min-height: 100vh; }

button { font-family: inherit; }

.hidden { display: none !important; }

/* ===== 视图切换 ===== */
.view { display: none; flex-direction: column; min-height: 100vh; }
.view.active { display: flex; }

/* ===== 通用按钮 ===== */
.btn {
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  background: #FFFFFF;
  color: #5D4A3A;
  font-weight: 800;
  font-size: 20px;
  padding: 12px 28px;
  cursor: pointer;
  box-shadow: 0 5px 0 #C9B89E;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  user-select: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #C9B89E; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #C9B89E; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 #C9B89E; }

.btn-big { font-size: 26px; padding: 15px 42px; letter-spacing: 2px; }
.btn-small { font-size: 16px; padding: 7px 16px; }
.btn-start { background: #FFD43B; }
.btn-green { background: #69DB7C; }
.btn-yellow { background: #FFE066; }
.btn-danger { background: #FF8787; }
.btn-option {
  font-size: 34px;
  min-width: 120px;
  min-height: 84px;
  padding: 10px 20px;
  border-radius: 28px;
  background: #FFFFFF;
}
.btn-option:hover { background: #FFF3C4; }
.btn-option.correct {
  background: #69DB7C;
  border-color: #2F9E44;
  color: #2F9E44;
  animation: pop 0.5s ease;
}
.btn-option.wrong {
  background: #FFC9C9;
  border-color: #E03131;
  color: #E03131;
  animation: shake 0.45s ease;
}

/* ===== 顶部栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #FFE9A8, #FFDF7E);
  border-bottom: 4px solid #E8C35A;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
}
.topbar-right { min-width: 60px; text-align: right; font-size: 18px; font-weight: 800; }
.topbar-right .golden-badge { color: #B8860B; }

/* ===== 主菜单 ===== */
#view-menu {
  position: relative;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 16px 60px;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.85) 0 40px, transparent 42px),
    radial-gradient(circle at 85% 30%, rgba(255,255,255,0.8) 0 30px, transparent 32px),
    linear-gradient(180deg, #BFE8FF 0%, #DDF4FF 26%, #FFF6D6 60%, #E9FBD9 100%);
}

.game-title {
  font-size: 46px;
  margin: 6px 0 2px;
  color: #F08C00;
  text-shadow: 3px 3px 0 #FFFFFF, -2px -2px 0 #FFFFFF, 2px -2px 0 #FFFFFF, -2px 2px 0 #FFFFFF;
  animation: float 3s ease-in-out infinite;
}
.game-sub {
  font-size: 20px;
  font-weight: 800;
  color: #7A6A58;
  margin: 4px 0 10px;
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 6px 18px;
  display: inline-block;
}

.mascot { margin: 6px 0; animation: float 2.6s ease-in-out infinite; }
.mascot svg { width: 170px; height: auto; filter: drop-shadow(0 6px 6px rgba(93,74,58,0.25)); }

.menu-buttons { display: flex; flex-direction: column; gap: 16px; margin: 8px 0 18px; }
.menu-buttons .btn { min-width: 240px; }

.menu-stats {
  font-size: 18px;
  font-weight: 800;
  color: #7A6A58;
  background: rgba(255,255,255,0.85);
  border-radius: 999px;
  padding: 8px 20px;
  border: 3px dashed #E8C35A;
}

/* 装饰：太阳、云、草地 */
.sun {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #FFD43B;
  box-shadow: 0 0 0 10px rgba(255, 212, 59, 0.35), 0 0 30px rgba(255, 212, 59, 0.6);
  animation: float 4s ease-in-out infinite;
}
.cloud {
  position: absolute;
  background: #FFFFFF;
  border-radius: 999px;
  opacity: 0.9;
  animation: drift 18s linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #FFFFFF;
  border-radius: 50%;
}
.cloud::before { width: 60px; height: 60px; top: -26px; left: 20px; }
.cloud::after { width: 44px; height: 44px; top: -16px; left: 62px; }
.cloud-1 { width: 130px; height: 40px; top: 90px; left: -140px; animation-duration: 26s; }
.cloud-2 { width: 100px; height: 32px; top: 150px; left: -120px; animation-duration: 34s; animation-delay: -10s; }
.cloud-3 { width: 120px; height: 36px; top: 210px; left: -130px; animation-duration: 30s; animation-delay: -20s; }

.grass {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 46px;
  background: repeating-linear-gradient(90deg,
    #7ED957 0 34px, #69C94A 34px 68px);
  border-top: 5px solid #4C9A33;
  border-radius: 40px 40px 0 0;
}

/* ===== 小岛之旅地图 ===== */
#view-map { background: linear-gradient(180deg, #A8DCFF 0%, #BFE8FF 100%); }

.map-scroll {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 10px 24px;
}

#map-root { width: 100%; max-width: 820px; margin: 0 auto; }

.journey-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 880 / 420;
  min-height: 250px;
  overflow: hidden;
  border: 5px solid #5D4A3A;
  border-radius: 30px;
  box-shadow: 0 8px 0 rgba(93, 74, 58, 0.3);
  background: linear-gradient(180deg, #AEE3FF, #E6F7FF);
}

.journey-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.island-layer { transition: opacity 0.25s ease; }

.wave {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 3;
}
.wave-1 { animation: wave-move 7s ease-in-out infinite alternate; }
.wave-2 { animation: wave-move 9s ease-in-out infinite alternate-reverse; }

.swim-route {
  stroke: #FFFFFF;
  stroke-width: 4;
  stroke-dasharray: 10 12;
  stroke-linecap: round;
  opacity: 0.85;
  animation: route-flow 2.4s linear infinite;
}

.island-clickable { cursor: pointer; }
.island-clickable:hover .island-badge { animation: wiggle 0.5s ease; }
.island-current .island-badge { animation: float 2.6s ease-in-out infinite; }
.island-badge { transform-box: fill-box; transform-origin: center; }

.island-star {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.island-star.star-pop { opacity: 1; animation: pop 0.6s ease; }
.island-star.shown { opacity: 1; animation: twinkle 1.6s ease-in-out infinite; }

.turtle-sit {
  position: absolute;
  left: 30%;
  top: 62%;
  width: 82px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  animation: float 2.4s ease-in-out infinite;
}
.turtle-sit svg, .turtle-swim svg { width: 100%; height: auto; }
.turtle-sit.hide, .turtle-swim.hide { display: none; }

.turtle-swim {
  position: absolute;
  left: 30%;
  top: 62%;
  width: 64px;
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 4px 5px rgba(93, 74, 58, 0.25));
}

.journey-progress {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 58%;
  max-width: 400px;
  z-index: 8;
  text-align: center;
}
.journey-progress-label {
  display: inline-block;
  font-size: 16px;
  font-weight: 900;
  color: #2F6FAC;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  padding: 4px 16px;
  margin-bottom: 6px;
}
.journey-progress-track {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 3px solid #5D4A3A;
  border-radius: 999px;
}
.journey-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFD43B, #FF9F1C);
  transition: width 0.6s ease;
}
.journey-progress-marker {
  position: absolute;
  top: 50%;
  font-size: 18px;
  transform: translate(-50%, -50%);
  transition: left 0.6s ease;
  z-index: 2;
}

.journey-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 16px;
  font-weight: 800;
  color: #5D4A3A;
  z-index: 8;
  white-space: nowrap;
}

.bubble {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 5;
  animation: bubble-rise 0.9s ease-out forwards;
}

.splash {
  position: absolute;
  font-size: 30px;
  pointer-events: none;
  z-index: 6;
  animation: splash-anim 0.55s ease-out forwards;
}

/* ===== 答题页 ===== */
#view-game {
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.8) 0 40px, transparent 42px),
    linear-gradient(180deg, #BFE8FF 0%, #E8F7D8 55%, #FFF6D6 100%);
}

.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 20px 16px 50px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.turtle-chat {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.turtle-chat-avatar svg { width: 76px; height: auto; animation: float 2.4s ease-in-out infinite; }
.speech-bubble {
  position: relative;
  background: #FFFFFF;
  border: 3px solid #5D4A3A;
  border-radius: 22px;
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 800;
  max-width: 320px;
  box-shadow: 0 4px 0 #C9B89E;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -14px;
  bottom: 16px;
  border: 8px solid transparent;
  border-right-color: #5D4A3A;
}
.speech-bubble::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 18px;
  border: 6px solid transparent;
  border-right-color: #FFFFFF;
}

.question-card {
  background: #FFFFFF;
  border: 4px solid #5D4A3A;
  border-radius: 34px;
  box-shadow: 0 8px 0 #C9B89E;
  padding: 26px 34px;
  min-width: 280px;
  text-align: center;
  transition: transform 0.2s ease;
}
.question-card.wrong-card { animation: shake 0.45s ease; border-color: #E03131; }
.question-card.correct-card { animation: pop 0.5s ease; border-color: #2F9E44; }
.question-text { font-size: 56px; font-weight: 900; letter-spacing: 4px; color: #F08C00; }

.options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  max-width: 420px;
}

.num-pad {
  background: #FFFFFF;
  border: 4px solid #5D4A3A;
  border-radius: 30px;
  box-shadow: 0 8px 0 #C9B89E;
  padding: 18px;
  width: 100%;
  max-width: 340px;
}
.pad-display {
  background: #FFF3C4;
  border: 3px solid #5D4A3A;
  border-radius: 18px;
  font-size: 44px;
  font-weight: 900;
  text-align: right;
  padding: 8px 18px;
  margin-bottom: 14px;
  color: #F08C00;
  min-height: 70px;
}
.pad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pad-grid button {
  font-size: 26px;
  font-weight: 900;
  padding: 12px 0;
  border: 3px solid #5D4A3A;
  border-radius: 18px;
  background: #FFF;
  box-shadow: 0 4px 0 #C9B89E;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.pad-grid button:active { transform: translateY(3px); box-shadow: 0 1px 0 #C9B89E; }
.pad-grid .pad-fn { background: #FFE066; }

/* ===== 收集册 ===== */
#view-collection { background: linear-gradient(180deg, #BFE8FF 0%, #E8F7D8 45%, #FFF6D6 100%); }
.collection-body {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 20px 16px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}
.turtle-card {
  background: #FFFFFF;
  border: 4px solid #5D4A3A;
  border-radius: 24px;
  box-shadow: 0 6px 0 #C9B89E;
  padding: 14px 10px;
  text-align: center;
  transition: transform 0.15s ease;
}
.turtle-card:hover { transform: translateY(-3px); }
.turtle-card.golden-card {
  border-color: #E8A800;
  background: linear-gradient(180deg, #FFF8DC, #FFEDB0);
  box-shadow: 0 6px 0 #D4A017, 0 0 18px rgba(255, 200, 0, 0.45);
}
.turtle-card svg { width: 100px; height: auto; }
.turtle-card .turtle-name { font-size: 18px; font-weight: 900; margin-top: 4px; }
.turtle-card .turtle-count {
  display: inline-block;
  margin-top: 6px;
  background: #FFE066;
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  padding: 3px 16px;
  font-weight: 900;
}
.collection-footer {
  padding: 14px 16px 34px;
  text-align: center;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255,246,214,0.9), #FFF6D6);
}

/* ===== 设置页 ===== */
#view-settings { background: linear-gradient(180deg, #BFE8FF 0%, #E8F7D8 45%, #FFF6D6 100%); }
.settings-body {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.setting-card {
  background: #FFFFFF;
  border: 4px solid #5D4A3A;
  border-radius: 26px;
  box-shadow: 0 6px 0 #C9B89E;
  padding: 16px 18px;
}
.setting-title { font-size: 20px; font-weight: 900; margin-bottom: 10px; }
.setting-title small { font-weight: 700; color: #9A8A70; font-size: 13px; }
.seg-row { display: flex; flex-wrap: wrap; gap: 10px; }
.seg-btn {
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  background: #FFF3C4;
  font-size: 18px;
  font-weight: 900;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.seg-btn.active { background: #FFD43B; box-shadow: 0 3px 0 #C9B89E; }

.color-row { display: flex; flex-wrap: wrap; gap: 12px; }
.color-sw {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid #5D4A3A;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.color-sw:hover { transform: scale(1.08); }
.color-sw.off { opacity: 0.28; }
.color-sw.off::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: #E03131;
}

.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle {
  width: 74px;
  height: 40px;
  border: 3px solid #5D4A3A;
  border-radius: 999px;
  background: #D9D0BD;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid #5D4A3A;
  transition: left 0.2s ease;
}
.toggle.on { background: #69DB7C; }
.toggle.on::after { left: 37px; }

.save-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.save-actions .btn { font-size: 17px; padding: 10px 18px; }

/* ===== 弹层 ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(93, 74, 58, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in 0.25s ease;
}
.overlay-card {
  background: #FFF6D6;
  border: 5px solid #5D4A3A;
  border-radius: 34px;
  box-shadow: 0 12px 0 rgba(93, 74, 58, 0.35);
  padding: 30px 26px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  animation: pop 0.4s ease;
}
.overlay-card h2 { margin: 6px 0 8px; font-size: 32px; color: #F08C00; }
.overlay-card p { font-size: 19px; font-weight: 800; margin: 8px 0 16px; }
.overlay-card .overlay-turtle svg { width: 160px; height: auto; animation: float 2s ease-in-out infinite; }
.overlay-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

.confetti-piece {
  position: absolute;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  top: -30px;
  animation: confetti-fall 2.6s linear infinite;
}

/* ===== 提示条 ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: #5D4A3A;
  color: #FFF6D6;
  font-size: 17px;
  font-weight: 800;
  padding: 12px 26px;
  border-radius: 999px;
  z-index: 200;
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
  animation: fade-in 0.3s ease;
}

/* ===== 动画 ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes bounce-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes pop {
  0% { transform: scale(0.6); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
@keyframes drift {
  0% { left: -160px; }
  100% { left: 110%; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}
@keyframes wave-move {
  from { transform: translateX(-24px); }
  to { transform: translateX(8px); }
}
@keyframes route-flow {
  to { stroke-dashoffset: -44; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}
@keyframes bubble-rise {
  0% { opacity: 0.9; transform: scale(0.5); }
  100% { opacity: 0; transform: translateY(-26px) scale(1.2); }
}
@keyframes splash-anim {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(1.7); opacity: 0; }
}

/* ===== 移动端适配 ===== */
@media (max-width: 420px) {
  .game-title { font-size: 36px; }
  .question-text { font-size: 46px; }
  .btn-option { font-size: 30px; min-width: 100px; min-height: 72px; }
  .menu-buttons .btn { min-width: 210px; }
}
