/* ============================================================
   虫妹学习园地 · 全局样式
   瓢虫/昆虫主题 · Mobile-first 响应式 · 纯 CSS 无依赖
   ============================================================ */

:root {
  /* 主题色 */
  --c-ladybug: #FF5A5F;   /* 瓢虫红 */
  --c-leaf:    #36C98D;   /* 叶绿 */
  --c-sky:     #4DA8FF;   /* 天空蓝 */
  --c-sun:     #FFC94D;   /* 暖黄 */
  --c-purple:  #9B7BFF;   /* 梦幻紫 */

  --c-chinese: #FF5A5F;
  --c-math:    #4DA8FF;
  --c-english: #36C98D;

  /* 中性 */
  --c-bg:      #FFF7F2;
  --c-card:    #FFFFFF;
  --c-ink:     #3A3340;
  --c-ink-soft:#7A7080;
  --c-line:    #F0E6DE;

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 8px 24px rgba(255, 90, 95, 0.12);
  --shadow-lg: 0 14px 40px rgba(155, 123, 255, 0.18);

  --maxw: 720px;
  --safe: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--c-ink);
  line-height: 1.65;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255,201,77,.25), transparent 60%),
    radial-gradient(1000px 500px at 110% 0%, rgba(77,168,255,.20), transparent 55%),
    linear-gradient(180deg, #FFFDF9 0%, #FFF1F4 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }

/* 居中容器 */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--safe) 48px;
}

/* ====================== 顶部栏 ====================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--safe);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-line);
}
.topbar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 17px;
  color: var(--c-ladybug);
  text-decoration: none;
}
.topbar .logo img {
  width: 34px; height: 34px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  object-fit: cover;
}
.topbar .spacer { flex: 1; }
.topbar .badge {
  font-size: 12px;
  color: var(--c-ink-soft);
  background: var(--c-line);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ====================== 首页 Hero ====================== */
.hero {
  text-align: center;
  padding: 28px 8px 8px;
  position: relative;
}
.hero .mascot-big {
  width: 150px; height: 150px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #fff;
  padding: 8px;
  box-shadow: var(--shadow-lg);
  animation: floaty 4s ease-in-out infinite;
}
.hero h1 {
  margin: 6px 0 4px;
  font-size: 30px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--c-ladybug), var(--c-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .slogan {
  color: var(--c-ink-soft);
  font-size: 15px;
  margin: 0 auto;
  max-width: 420px;
}
.hero .welcome {
  margin: 16px auto 6px;
  max-width: 460px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-size: 15px;
  text-align: left;
  position: relative;
}
.hero .welcome::before {
  content: "🐞";
  position: absolute;
  right: 12px; top: -14px;
  font-size: 26px;
}

/* 飘浮装饰 */
.float-deco {
  position: fixed;
  font-size: 22px;
  opacity: .5;
  animation: floaty 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
.float-deco.d1 { left: 6%;  top: 30%; animation-delay: 0s; }
.float-deco.d2 { right: 8%; top: 45%; animation-delay: 1.2s; }
.float-deco.d3 { left: 12%; top: 70%; animation-delay: 2.4s; }
.float-deco.d4 { right: 10%; top: 78%; animation-delay: 3.1s; }

/* ====================== 学科大卡片 ====================== */
.subject-grid {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}
.subject-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card, #fff);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--c-ink);
  box-shadow: var(--shadow);
  border-left: 8px solid var(--accent, var(--c-ladybug));
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
  overflow: hidden;
}
.subject-card:hover, .subject-card:active {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg);
}
.subject-card .emoji {
  font-size: 44px;
  line-height: 1;
  flex: 0 0 auto;
}
.subject-card .meta h3 { margin: 0; font-size: 21px; }
.subject-card .meta p { margin: 2px 0 0; color: var(--c-ink-soft); font-size: 13px; }
.subject-card .go {
  margin-left: auto;
  font-size: 22px;
  color: var(--accent, var(--c-ladybug));
}
.subject-card.c-chinese { --accent: var(--c-chinese); }
.subject-card.c-math    { --accent: var(--c-math); }
.subject-card.c-english { --accent: var(--c-english); }

/* ====================== 按钮 ====================== */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 18px;
  min-height: 44px;
  border-radius: 999px;
  background: var(--c-ladybug);
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.btn-leaf   { background: var(--c-leaf); }
.btn.btn-sky    { background: var(--c-sky); }
.btn.btn-purple { background: var(--c-purple); }
.btn.btn-ghost  {
  background: #fff; color: var(--c-ink);
  border: 2px solid var(--c-line); box-shadow: none;
}
.btn.btn-block { display: block; width: 100%; }
.btn.btn-sm { padding: 9px 14px; font-size: 13px; min-height: 40px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }

/* ====================== 返回按钮 ====================== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--c-ink-soft);
  font-weight: 700;
  padding: 8px 0;
  font-size: 14px;
}

/* ====================== 学科页头部 ====================== */
.subject-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
}
.subject-head .emoji { font-size: 40px; }
.subject-head .title h2 { margin: 0; font-size: 24px; }
.subject-head .title .tip {
  font-size: 13px; color: var(--c-ink-soft);
  background: #fff; border-radius: 999px; padding: 4px 12px;
  display: inline-block; margin-top: 4px; box-shadow: var(--shadow);
}
.mascot-hello {
  margin: 14px 0 6px;
  background: linear-gradient(135deg, #fff, #FFF4F6);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.mascot-hello img { width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; object-fit: cover; }

/* ====================== 模块选项卡 ====================== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 2px;
}
.tab {
  flex: 0 0 auto;
  border: 2px solid var(--c-line);
  background: #fff;
  color: var(--c-ink-soft);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  transition: all .15s ease;
}
.tab.active {
  background: var(--accent, var(--c-ladybug));
  border-color: var(--accent, var(--c-ladybug));
  color: #fff;
  box-shadow: var(--shadow);
}

/* ====================== 模式分段控件 ====================== */
.segment {
  display: flex;
  background: #fff;
  border-radius: 999px;
  padding: 5px;
  box-shadow: var(--shadow);
  margin: 6px 0 14px;
}
.segment button {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--c-ink-soft);
  padding: 10px 6px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.segment button.active {
  background: var(--accent, var(--c-ladybug));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.mode-desc {
  font-size: 13px;
  color: var(--c-ink-soft);
  background: #fff7;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 14px;
}

/* ====================== 进度条 ====================== */
.progress-wrap {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 16px;
}
.progress-bar {
  flex: 1;
  height: 12px;
  background: var(--c-line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--c-leaf), var(--c-sky));
  border-radius: 999px;
  transition: width .35s ease;
}
.progress-label { font-size: 13px; color: var(--c-ink-soft); font-weight: 700; white-space: nowrap; }
.timer { font-weight: 800; color: var(--c-ladybug); font-variant-numeric: tabular-nums; }

/* ====================== 题目卡片 ====================== */
.q-card {
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  animation: pop .3s ease both;
}
.q-card .q-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--c-ink-soft); margin-bottom: 8px;
}
.q-card .q-no {
  background: var(--accent, var(--c-ladybug));
  color: #fff; font-weight: 800;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.q-card .q-prompt { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.q-card .q-hint {
  font-size: 13px; color: var(--c-sky);
  background: #EAF5FF; border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 12px;
}

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--c-line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
  transition: all .15s ease;
  text-align: left;
}
.option:hover { border-color: var(--accent, var(--c-ladybug)); }
.option .key {
  flex: 0 0 auto; width: 26px; height: 26px;
  border-radius: 50%; background: var(--c-line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: var(--c-ink-soft);
}
.option.selected { border-color: var(--accent, var(--c-ladybug)); background: #FFF4F6; }
.option.correct { border-color: var(--c-leaf); background: #E9FBF2; }
.option.correct .key { background: var(--c-leaf); color: #fff; }
.option.wrong { border-color: var(--c-ladybug); background: #FFEFF0; }
.option.wrong .key { background: var(--c-ladybug); color: #fff; }

.fill-input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  min-height: 48px;
  border: 2px solid var(--c-line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease;
}
.fill-input:focus { border-color: var(--accent, var(--c-ladybug)); }

.feedback {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  display: none;
}
.feedback.show { display: block; animation: pop .25s ease both; }
.feedback.ok  { background: #E9FBF2; border: 1px solid var(--c-leaf); }
.feedback.no  { background: #FFEFF0; border: 1px solid var(--c-ladybug); }
.feedback .mark { font-weight: 800; }
.feedback .explain { margin-top: 6px; color: var(--c-ink); }

.q-actions { margin-top: 14px; display: flex; gap: 10px; }

/* ====================== 小结 / 结算 ====================== */
.summary {
  background: linear-gradient(135deg, #fff, #F3F0FF);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  margin: 18px 0;
  animation: pop .35s ease both;
}
.summary .score {
  font-size: 46px; font-weight: 900;
  background: linear-gradient(90deg, var(--c-ladybug), var(--c-purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.summary .score small { font-size: 18px; -webkit-text-fill-color: var(--c-ink-soft); }
.summary .line { color: var(--c-ink-soft); margin: 4px 0; }

/* ====================== 模态框 ====================== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(58, 51, 64, 0.45);
  display: none;
  align-items: center; justify-content: center;
  padding: 16px; z-index: 60;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; animation: fade .2s ease; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  max-width: 480px; width: 100%;
  max-height: 86vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop .25s ease both;
}
.modal h3 { margin: 0 0 10px; }
.modal .analysis {
  background: #F7F4FF; border-radius: var(--radius-sm);
  padding: 14px; font-size: 14px; white-space: pre-wrap; line-height: 1.7;
}
.modal .mail-note { margin-top: 12px; font-weight: 700; font-size: 14px; }
.modal .mail-note.ok { color: var(--c-leaf); }
.modal .mail-note.wait { color: var(--c-sun); }
.modal .mail-note.err { color: var(--c-ladybug); }
.modal .close-row { margin-top: 16px; text-align: right; }

/* ====================== 游戏区 ====================== */
.game-box {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 16px 0;
}
.game-box .game-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.game-box .game-sub { font-size: 13px; color: var(--c-ink-soft); margin-bottom: 12px; }
.game-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.game-bar .pill {
  background: var(--c-line); border-radius: 999px;
  padding: 6px 12px; font-weight: 700; font-size: 13px;
}
.game-board { margin-top: 8px; }
.game-msg { margin-top: 12px; font-weight: 700; font-size: 15px; min-height: 22px; }
.game-over {
  text-align: center; padding: 10px 0 4px;
}
.game-over .g-score { font-size: 34px; font-weight: 900; color: var(--c-ladybug); }

/* 诗词连连看 / 配对网格 */
.match-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.match-item {
  border: 2px solid var(--c-line);
  background: #fff; border-radius: var(--radius-sm);
  padding: 12px 10px; text-align: center;
  font-size: 15px; cursor: pointer; min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.match-item.sel { border-color: var(--accent, var(--c-ladybug)); background: #FFF4F6; }
.match-item.done { opacity: .45; pointer-events: none; border-color: var(--c-leaf); background: #E9FBF2; }
.match-item.right { border-color: var(--c-leaf); background: #E9FBF2; }
.match-item.wrong { border-color: var(--c-ladybug); background: #FFEFF0; }

/* 分数消消乐 */
.match-grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.tile {
  border: 2px solid var(--c-line);
  background: #fff; border-radius: var(--radius-sm);
  padding: 14px 6px; text-align: center; font-weight: 800;
  font-size: 16px; cursor: pointer; min-height: 56px;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s ease;
}
.tile.sel { border-color: var(--c-purple); background: #F3F0FF; transform: scale(1.05); }
.tile.done { visibility: hidden; }

/* 坐标寻宝 */
.coord-board {
  display: grid; gap: 4px;
  background: var(--c-sky); padding: 6px; border-radius: var(--radius-sm);
  margin: 0 auto; max-width: 320px;
}
.coord-cell {
  aspect-ratio: 1 / 1;
  background: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; transition: all .12s ease;
}
.coord-cell.treasure { background: var(--c-sun); }
.coord-cell.hit { background: #FFEFF0; }
.coord-cell.miss { background: #EAF5FF; }

/* 拖拽配对 */
.drag-area { display: grid; gap: 10px; }
.drag-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drag-chip {
  border: 2px dashed var(--c-purple);
  background: #F3F0FF; border-radius: var(--radius-sm);
  padding: 10px 14px; font-weight: 700; cursor: grab; min-height: 44px;
  user-select: none;
}
.drop-slot {
  border: 2px solid var(--c-line);
  background: #fff; border-radius: var(--radius-sm);
  padding: 10px 14px; min-height: 44px; min-width: 110px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.drop-slot.over { border-color: var(--c-leaf); background: #E9FBF2; }
.drop-slot.filled { border-style: solid; border-color: var(--c-leaf); background: #E9FBF2; }

/* ====================== 页脚 ====================== */
.site-foot {
  text-align: center;
  font-size: 12px;
  color: var(--c-ink-soft);
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px dashed var(--c-line);
}

/* ====================== 动画 ====================== */
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes pop {
  0% { transform: scale(.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ====================== 响应式 ====================== */
@media (max-width: 480px) {
  .hero h1 { font-size: 26px; }
  .hero .mascot-big { width: 120px; height: 120px; }
  .subject-card { padding: 14px; }
  .subject-card .emoji { font-size: 38px; }
  .match-grid { grid-template-columns: 1fr; }
  .match-grid.cols3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 560px) {
  .subject-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

/* ====================== 顶部导航链接 ====================== */
.nav-link {
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-purple);
  background: #F3F0FF;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ====================== 学科卡片：更新日志 ====================== */
.subject-card.c-blog { --accent: var(--c-purple); }

/* ====================== 更新日志页面 ====================== */
.blog-hero { padding-top: 18px; }
.blog-hero .mascot-big { width: 110px; height: 110px; }
.blog-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
.blog-item {
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-left: 8px solid var(--c-purple);
  position: relative;
  animation: pop .3s ease both;
}
.blog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ver-badge {
  background: linear-gradient(90deg, var(--c-ladybug), var(--c-purple));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 12px;
  border-radius: 999px;
}
.blog-date { font-size: 13px; color: var(--c-ink-soft); }
.blog-title { margin: 6px 0 10px; font-size: 19px; }
.blog-changes { margin: 0; padding-left: 20px; }
.blog-changes li { margin: 4px 0; font-size: 14px; color: var(--c-ink); }
