/* ===================================================================
   Happy Math Land - 快乐数学城堡视觉样式系统
   专为小学三年级量身打造：高对比度、大圆角、动效钟表、互动收银台
   =================================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Comic Sans MS", cursive, sans-serif;
  --bg-math: linear-gradient(135deg, #E0F7FA 0%, #FFF9C4 50%, #FFE0B2 100%);
  --math-blue: #0288D1;
  --math-orange: #FB8500;
  --math-green: #2EC4B6;
  --math-purple: #7B2CBF;
  --text-main: #2D3436;
  --card-bg: #FFFFFF;
  --card-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  --card-hover-shadow: 0 18px 36px rgba(0, 0, 0, 0.12);
  --border-radius-lg: 24px;
  --border-radius-md: 18px;
  --border-radius-sm: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-family);
  background: var(--bg-math);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* 顶部导航与状态栏 */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid #81D4FA;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.logo-container:hover {
  transform: scale(1.03);
}

.mascot-avatar {
  font-size: 2.2rem;
  background: #B3E5FC;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(2, 136, 209, 0.25);
  cursor: pointer;
  transition: all 0.2s;
  animation: bounceGentle 3s infinite ease-in-out;
}

.mascot-avatar:hover {
  transform: scale(1.15) rotate(10deg);
}

@keyframes bounceGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.logo-title h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #01579B;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-title .badge-tag {
  font-size: 0.72rem;
  font-weight: 700;
  background: #0288D1;
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
}

.logo-title p {
  font-size: 0.82rem;
  color: #546E7A;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile-pill {
  background: #E1F5FE;
  border: 2px solid #81D4FA;
  padding: 6px 14px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0277BD;
  cursor: pointer;
  transition: all 0.2s;
}

.user-profile-pill:hover {
  background: #B3E5FC;
  transform: scale(1.05);
}

.star-bank {
  background: #FFF3CD;
  border: 2px solid #FFD166;
  border-radius: 30px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #D48806;
  box-shadow: 0 4px 8px rgba(255, 209, 102, 0.3);
  cursor: pointer;
}

.icon-btn {
  background: #F1F2F6;
  border: 2px solid #CED6E0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  transform: scale(1.1);
  background: white;
}

.voice-guide-btn {
  background: linear-gradient(135deg, #B3E5FC 0%, #81D4FA 100%);
  border: 2px solid #4FC3F7;
  color: #01579B;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(79, 195, 247, 0.3);
  transition: all 0.2s;
}

.voice-guide-btn:hover {
  transform: scale(1.06);
}

/* 主容器 */
.main-content {
  position: relative;
  z-index: 10;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ================= 视图 1：单元大地图 ================= */
.map-view {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

.hero-banner {
  background: linear-gradient(135deg, #81D4FA 0%, #B2EBF2 50%, #FFE082 100%);
  border-radius: var(--border-radius-lg);
  padding: 32px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  box-shadow: 0 16px 32px rgba(2, 136, 209, 0.15);
}

.hero-text h2 {
  font-size: 2.1rem;
  font-weight: 900;
  color: #01579B;
  margin-bottom: 8px;
}

.hero-text p {
  font-size: 1.1rem;
  color: #37474F;
  max-width: 580px;
  line-height: 1.6;
}

.hero-badges {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mini-pill {
  background: rgba(255, 255, 255, 0.85);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0277BD;
}

.hero-mascot-img {
  font-size: 5rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.hero-mascot-img:hover {
  transform: scale(1.2) rotate(8deg);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.unit-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  position: relative;
  border: 3px solid transparent;
  display: flex;
  flex-direction: column;
}

.unit-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--card-hover-shadow);
}

.unit-card.unlocked {
  border-color: #81D4FA;
}

.unit-card.locked {
  opacity: 0.72;
  filter: grayscale(0.2);
  cursor: not-allowed;
}

.unit-card.locked:hover {
  transform: none;
}

.unit-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.unit-number-tag {
  font-size: 0.9rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 30px;
  color: white;
}

.unit-icon-large {
  font-size: 2.8rem;
}

.unit-card h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #2D3436;
  margin-bottom: 8px;
}

.unit-card .unit-desc {
  font-size: 0.92rem;
  color: #636E72;
  line-height: 1.5;
  margin-bottom: 20px;
  flex-grow: 1;
}

.unit-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 2px dashed #ECEFF1;
  padding-top: 14px;
}

.btn-enter-unit {
  background: linear-gradient(135deg, #0288D1 0%, #26C6DA 100%);
  color: white;
  border: none;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(2, 136, 209, 0.3);
  transition: transform 0.15s;
}

.btn-enter-unit:hover {
  transform: scale(1.08);
}

/* ================= 视图 2：单元大本营 ================= */
.unit-hub-view {
  display: none;
  animation: fadeIn 0.35s ease-out;
}

.hub-nav-header {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.hub-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back-map {
  background: #F1F2F6;
  border: 2px solid #DFE4EA;
  padding: 8px 16px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-back-map:hover {
  background: #B3E5FC;
  border-color: #81D4FA;
}

.hub-tabs {
  display: flex;
  gap: 10px;
  background: #F1F2F6;
  padding: 6px;
  border-radius: 40px;
  overflow-x: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 800;
  color: #546E7A;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  background: white;
  color: #0288D1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: scale(1.04);
}

.module-panel {
  display: none;
  animation: slideUp 0.3s ease-out;
}

.module-panel.active {
  display: block;
}

/* ---------------- 知识概念卡 ---------------- */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.concept-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  border: 3px solid #E0F2FE;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.concept-card:hover {
  transform: translateY(-6px);
  border-color: #81D4FA;
}

.concept-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.concept-icon {
  font-size: 2.2rem;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: #E1F5FE;
  display: flex;
  align-items: center;
  justify-content: center;
}

.concept-title h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #01579B;
}

.concept-title .pinyin {
  font-size: 0.82rem;
  color: #E67E22;
}

.concept-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #37474F;
}

.concept-formula {
  background: #FFF9E6;
  border-left: 4px solid #FFD166;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 800;
  color: #D35400;
  font-size: 1rem;
}

.concept-life {
  background: #F1F8E9;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #33691E;
}

/* ---------------- 交互时钟实验室 (Clock Lab) ---------------- */
.clock-lab-container {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 32px;
  box-shadow: var(--card-shadow);
  border: 4px solid #81D4FA;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.clock-main-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

.clock-face-wrap {
  width: 260px;
  height: 260px;
  position: relative;
  background: #FFFFFF;
  border-radius: 50%;
  border: 12px solid #0288D1;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.1), 0 10px 25px rgba(2, 136, 209, 0.2);
}

.clock-center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #D32F2F;
  border: 3px solid white;
  border-radius: 50%;
  z-index: 10;
}

.clock-hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform-origin: 50% 100%;
  border-radius: 6px;
  transition: transform 0.05s linear;
}

.hour-hand {
  width: 7px;
  height: 65px;
  margin-left: -3.5px;
  background: #263238;
  z-index: 3;
}

.minute-hand {
  width: 5px;
  height: 90px;
  margin-left: -2.5px;
  background: #0288D1;
  z-index: 4;
}

.second-hand {
  width: 2px;
  height: 105px;
  margin-left: -1px;
  background: #E53935;
  z-index: 5;
}

.clock-number {
  position: absolute;
  width: 30px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  font-size: 1.25rem;
  font-weight: 900;
  color: #37474F;
}

.digital-time-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.digital-lcd {
  background: #212121;
  color: #64DD17;
  font-family: monospace;
  font-size: 2.8rem;
  font-weight: 900;
  padding: 12px 24px;
  border-radius: 16px;
  letter-spacing: 2px;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.6), 0 4px 10px rgba(0,0,0,0.1);
}

.clock-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-clock-ctrl {
  background: #E1F5FE;
  border: 2px solid #81D4FA;
  color: #0277BD;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-clock-ctrl:hover {
  background: #81D4FA;
  color: white;
  transform: scale(1.06);
}

/* ---------------- 心跳 30 秒盲估大挑战 ---------------- */
.time-sense-card {
  background: linear-gradient(135deg, #FFF9C4 0%, #FFE082 100%);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  text-align: center;
  border: 4px solid #FFD54F;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.big-stop-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 8px solid white;
  background: linear-gradient(135deg, #FF6B6B 0%, #EE5253 100%);
  color: white;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(238, 82, 83, 0.4);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.big-stop-btn:hover {
  transform: scale(1.08);
}

.big-stop-btn:active {
  transform: scale(0.94);
}

/* ---------------- 超市收银台与影院选座 ---------------- */
.supermarket-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.goods-item-card {
  background: white;
  border: 3px solid #CFD8DC;
  border-radius: var(--border-radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.goods-item-card:hover {
  border-color: #FB8500;
  transform: translateY(-4px) scale(1.03);
}

.goods-item-card.selected {
  border-color: #E65100;
  background: #FFF3E0;
}

.checkout-box {
  background: #ECEFF1;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 3px solid #B0BEC5;
  flex-wrap: wrap;
  gap: 16px;
}

/* 练习与闯关选择题 */
.quiz-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  border: 3px solid #ECEFF1;
  margin-bottom: 20px;
}

.quiz-question {
  font-size: 1.2rem;
  font-weight: 800;
  color: #2D3436;
  margin-bottom: 16px;
}

.quiz-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-option-btn {
  background: #F8F9FA;
  border: 2px solid #CFD8DC;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 1rem;
  color: #37474F;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-option-btn:hover {
  background: #E1F5FE;
  border-color: #81D4FA;
  transform: scale(1.05);
}

.quiz-option-btn.correct {
  background: #E8F5E9;
  border-color: #66BB6A;
  color: #2E7D32;
}

.quiz-option-btn.wrong {
  background: #FFEBEE;
  border-color: #EF5350;
  color: #C62828;
}

/* 动效 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 响应式 */
@media (max-width: 768px) {
  .top-navbar {
    padding: 10px 14px;
  }
  .hero-banner {
    flex-direction: column;
    text-align: center;
    padding: 24px 18px;
  }
  .clock-main-stage {
    gap: 20px;
  }
}

/* ================= 模态弹窗系统 (Modal & Certificate) ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: none; /* 默认必须隐藏，仅在点击时弹出 */
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  position: relative;
  text-align: center;
  border: 4px solid #81D4FA;
  animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-close-modal {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #F1F2F6;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: #E2E8F0;
  transform: rotate(90deg);
}

.certificate-box {
  background: #F8FDFF;
  border: 6px double #81D4FA;
  border-radius: 16px;
  padding: 24px;
  margin: 16px 0;
  box-shadow: inset 0 0 20px rgba(129, 212, 250, 0.15);
}

.cert-header {
  font-size: 1.5rem;
  font-weight: 900;
  color: #0288D1;
  margin-bottom: 8px;
}

.cert-name {
  font-size: 1.6rem;
  font-weight: 900;
  color: #0288D1;
  border-bottom: 2px solid #4FC3F7;
  display: inline-block;
  padding: 0 16px 4px;
  margin: 10px 0;
  cursor: pointer;
}

.cert-body {
  font-size: 1rem;
  color: #37474F;
  line-height: 1.6;
  margin-bottom: 16px;
}

.cert-seal {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-top: 12px;
}

.seal-item {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0277BD;
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
