/* ============================================================
 * style.css — 全局主题、排版、组件、响应式布局
 * 面向 6 岁儿童：大字体、大按钮、明亮配色、圆角、触控友好
 * ============================================================ */

:root {
  --c-bg1: #fff7e6;
  --c-bg2: #ffe3f1;
  --c-bg3: #e3f4ff;
  --c-primary: #ff6b9d;
  --c-primary-d: #e94f86;
  --c-secondary: #4fc3f7;
  --c-accent: #ffd23f;
  --c-green: #6be585;
  --c-purple: #b88bff;
  --c-text: #3a2e3f;
  --c-soft: #fff;
  --radius: 26px;
  --radius-sm: 18px;
  --shadow: 0 10px 0 rgba(0,0,0,0.08), 0 14px 28px rgba(0,0,0,0.12);
  --shadow-press: 0 4px 0 rgba(0,0,0,0.10), 0 6px 14px rgba(0,0,0,0.10);
  --btn-min: 88px;
  --font: "Comic Sans MS", "Baloo 2", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: var(--font);
  color: var(--c-text);
  background: linear-gradient(135deg, var(--c-bg1), var(--c-bg2) 45%, var(--c-bg3));
  background-attachment: fixed;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  gap: 10px;
}
.app-title {
  font-size: clamp(28px, 6vw, 48px);
  margin: 0; font-weight: 800;
  color: var(--c-primary-d);
  text-shadow: 2px 3px 0 #fff, 4px 6px 0 rgba(0,0,0,0.08);
  letter-spacing: 1px;
  flex: 1; text-align: center;
}
.icon-btn {
  font-size: 34px; width: 64px; height: 64px;
  border: none; border-radius: 50%;
  background: var(--c-soft); box-shadow: var(--shadow-press);
  cursor: pointer; transition: transform .12s;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.92); }

.stars-badge {
  position: fixed; top: 14px; right: 90px;
  background: var(--c-accent); color: #7a5b00;
  font-weight: 800; font-size: 26px;
  padding: 8px 18px; border-radius: 999px;
  box-shadow: var(--shadow-press); z-index: 40;
  display: flex; align-items: center; gap: 6px;
  transition: transform .2s;
}
.stars-badge.bump { animation: badge-bump .5s ease; }
@media (max-width: 600px){ .stars-badge { right: 86px; top: 12px; font-size: 22px; padding: 6px 12px; } }

/* ---------- 屏幕容器 ---------- */
.screen { padding: 8px 18px 40px; max-width: 1100px; margin: 0 auto; }
.module-title {
  font-size: clamp(30px, 7vw, 52px); text-align: center;
  margin: 6px 0 18px; color: var(--c-primary-d);
  text-shadow: 2px 2px 0 #fff;
}
.subtitle { text-align: center; font-size: clamp(18px,4vw,26px); color: #7a5b86; margin: -8px 0 18px; }

/* ---------- 通用按钮 ---------- */
.btn {
  font-family: var(--font); font-weight: 800;
  border: none; border-radius: var(--radius-sm);
  padding: 18px 28px; font-size: clamp(22px, 4.5vw, 32px);
  cursor: pointer; color: #fff;
  background: var(--c-primary);
  box-shadow: var(--shadow); transition: transform .12s, filter .12s;
  min-height: var(--btn-min); min-width: var(--btn-min);
}
.btn:active { transform: translateY(4px); box-shadow: var(--shadow-press); }
.btn-primary { background: var(--c-primary); }
.btn-secondary { background: var(--c-secondary); }
.btn-green { background: var(--c-green); color: #14532d; }
.btn-purple { background: var(--c-purple); }
.btn-warn { background: #ff8a5b; }
.btn-accent { background: var(--c-accent); color: #7a5b00; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- 首页模块卡片 ---------- */
.home-grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(2, 1fr);
  max-width: 760px; margin: 10px auto 0;
}
.home-card {
  background: var(--c-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 18px 22px;
  text-align: center; cursor: pointer; border: 4px solid transparent;
  transition: transform .14s, border-color .14s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 200px; justify-content: center;
}
.home-card:active { transform: translateY(6px) scale(.98); }
.home-card .emoji { font-size: clamp(64px, 16vw, 110px); line-height: 1; }
.home-card .label { font-size: clamp(24px, 5vw, 34px); font-weight: 800; color: var(--c-primary-d); }
.home-card .stars { font-size: 22px; color: #e0a800; }
.home-card.c1 { background: #fff0f6; }
.home-card.c2 { background: #eaf6ff; }
.home-card.c3 { background: #fff7e0; }
.home-card.c4 { background: #eefcef; }

.home-tip { text-align:center; font-size: clamp(18px,4vw,24px); color:#8a6fa0; margin: 22px auto 0; max-width: 640px; }

/* 奖杯角入口 */
.trophy-bar { display:flex; justify-content:center; gap:14px; flex-wrap:wrap; margin-top: 26px; }
.trophy-chip {
  background: var(--c-soft); border-radius: 999px; padding: 10px 20px;
  font-size: 22px; box-shadow: var(--shadow-press); font-weight: 700;
}
.trophy-chip.locked { opacity: .45; filter: grayscale(1); }

/* ---------- 通用内容网格（字母/卡片）---------- */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
/* 居中换行布局：整组水平居中，长词自动换行不重叠 */
.img-grid { display:flex; flex-wrap:wrap; gap:16px; justify-content:center; }
.img-grid .big-card { flex: 0 1 auto; min-width: 140px; max-width: 200px; }
.word-grid { display:flex; flex-wrap:wrap; gap:14px; justify-content:center; }
.big-card {
  background: var(--c-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; text-align: center;
  cursor: pointer; transition: transform .12s; border: 4px solid #ffe0ee;
  display:flex; flex-direction:column; align-items:center; gap:8px;
  min-height: 150px; justify-content:center;
}
.big-card:active { transform: scale(.96); }
.big-card.matched { border-color: var(--c-green); background: #eafcef; }
.big-card .big-letter { font-size: clamp(54px, 12vw, 86px); font-weight: 900; color: var(--c-primary); }
.big-card .small { font-size: 22px; color:#7a5b86; }

/* 字母详情视图 */
.detail-wrap { text-align:center; }
.detail-letter {
  font-size: clamp(90px, 26vw, 200px); font-weight: 900; color: var(--c-primary);
  text-shadow: 3px 4px 0 #fff; margin: 6px 0;
}
.word-row { display:flex; flex-wrap:wrap; gap:18px; justify-content:center; margin-top: 10px; }
.word-chip {
  background: var(--c-soft); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 18px 22px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:6px;
  min-width: 150px; border: 4px solid #e3f4ff; transition: transform .12s;
}
.word-chip:active { transform: scale(.95); }
.word-chip .e { font-size: clamp(56px, 14vw, 90px); }
.word-chip .w { font-size: clamp(24px, 5vw, 34px); font-weight: 800; color: var(--c-secondary); }

/* ---------- 配对 / 游戏 通用 ---------- */
.play-area { display:grid; gap: 24px; }
.match-item {
  background: var(--c-soft); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display:flex; align-items:center; justify-content:center; gap:12px;
  min-height: var(--btn-min); cursor:pointer; border: 4px solid #fff; transition: transform .12s, border-color .15s;
  font-size: clamp(22px,5vw,32px); font-weight:800; text-align:center;
  flex: 0 1 auto; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
}
.match-item:active { transform: scale(.97); }
.match-item .emoji { font-size: clamp(48px,12vw,80px); }
.match-item.selected { border-color: var(--c-accent); transform: scale(1.03); }
.match-item.matched { border-color: var(--c-green); background:#eafcef; pointer-events:none; opacity:.85; }
.match-item.wrong { border-color: #ff8a5b; }

/* 拖拽游戏 */
.drag-game { display:grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.drag-col { display:flex; flex-direction:column; gap:14px; }
.drag-token {
  background: var(--c-soft); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 14px; display:flex; align-items:center; justify-content:center; gap:10px;
  min-height: 84px; cursor: grab; border: 4px solid #fff; touch-action: none;
  font-size: clamp(22px,4.5vw,32px); font-weight:800; user-select:none;
  min-width: 0; overflow-wrap: anywhere; word-break: break-word; text-align:center;
}
.drag-token .emoji { font-size: clamp(44px,11vw,72px); }
.drag-token.dragging { opacity:.55; cursor: grabbing; z-index: 999; position: relative; }
.drop-slot {
  background: #ffffffcc; border: 4px dashed #ffc2dd; border-radius: var(--radius-sm);
  min-height: 84px; display:flex; align-items:center; justify-content:center;
  font-size: clamp(22px,4.5vw,32px); font-weight:800; color:#b07ca0;
  transition: border-color .15s, background .15s;
  min-width: 0; overflow-wrap: anywhere; word-break: break-word; text-align:center;
}
.drop-slot.over { border-color: var(--c-green); background:#eafcef; }
.drop-slot.filled { border-style: solid; border-color: var(--c-green); color: var(--c-text); cursor: default; }
.drop-slot .emoji { font-size: clamp(44px,11vw,72px); margin-right: 8px; }
.drag-ghost { position: fixed; pointer-events:none; z-index: 1000; transform: translate(-50%,-50%); }

/* 跟读 */
.speak-stage { text-align:center; }
.speak-emoji { font-size: clamp(120px, 34vw, 240px); line-height:1; margin: 8px 0; animation: floaty 3s ease-in-out infinite; }
.speak-word { font-size: clamp(36px, 9vw, 72px); font-weight:900; color: var(--c-secondary); margin: 4px 0 18px; text-align:center; overflow-wrap: anywhere; word-break: break-word; }
.speak-actions { display:flex; gap:18px; justify-content:center; flex-wrap:wrap; }
.big-round {
  width: clamp(110px, 30vw, 160px); height: clamp(110px, 30vw, 160px);
  border-radius: 50%; border:none; cursor:pointer; box-shadow: var(--shadow);
  font-size: clamp(40px,10vw,64px); display:grid; place-items:center; transition: transform .12s;
  background: var(--c-primary); color:#fff;
}
.big-round:active { transform: scale(.93); }
.big-round.rec { background: #ff5e5e; }
.big-round.rec.on { animation: pulse-red 1s infinite; }
.rec-status { font-size: clamp(20px,4.5vw,28px); color:#ff5e5e; min-height: 36px; text-align:center; margin-top: 10px; }

/* 进度条 */
.progress-row { display:flex; align-items:center; gap:12px; justify-content:center; margin: 14px 0; flex-wrap:wrap; }
.progress-bar { width: min(420px, 80vw); height: 26px; background:#ffffffaa; border-radius:999px; overflow:hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.1); }
.progress-fill { height:100%; width:0%; background: linear-gradient(90deg, var(--c-green), var(--c-accent)); border-radius:999px; transition: width .5s ease; }
.progress-label { font-size: 24px; font-weight:800; color: var(--c-primary-d); }

/* 完成弹窗 */
.done-card {
  background: var(--c-soft); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 24px; text-align:center; max-width: 520px; margin: 20px auto;
}
.done-card .big { font-size: clamp(48px, 12vw, 80px); font-weight:900; color: var(--c-primary); }
.done-card .stars-earned { font-size: 40px; margin: 10px 0; }

/* 设置面板 */
.settings-panel {
  position: fixed; inset: 0; background: rgba(40,20,50,.45);
  display:flex; align-items:center; justify-content:center; z-index: 60; padding: 20px;
}
.settings-panel.hidden { display:none; }
.settings-card {
  background: var(--c-soft); border-radius: var(--radius); padding: 26px;
  width: min(460px, 92vw); box-shadow: var(--shadow);
}
.settings-card h2 { margin: 0 0 16px; font-size: 34px; color: var(--c-primary-d); text-align:center; }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:12px; font-size: 26px; margin: 16px 0; font-weight:700; }
.setting-row input[type=range] { width: 55%; }
.voice-name { font-size: 20px; color:#7a5b86; max-width: 50%; text-align:right; }
.settings-actions { display:flex; gap:14px; justify-content:center; margin-top: 20px; }

/* 特效覆盖层（彩屑/气泡挂载处） */
#fx-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden;
}

/* Chrome 直接打开的友好提示横幅 */
.filehint {
  position: relative; background: #fff4d6; border: 3px solid #ffcf5c;
  border-radius: 16px; padding: 12px 42px 12px 16px; margin: 8px 0 16px;
  font-size: 20px; font-weight: 700; color: #7a5a00; line-height: 1.45;
}
.filehint-close {
  position: absolute; top: 8px; right: 10px; border: none; background: transparent;
  font-size: 22px; line-height: 1; cursor: pointer; color: #7a5a00;
}

/* 隐藏工具 */
.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .home-card { min-height: 150px; padding: 18px 10px; }
  .screen { padding: 4px 12px 36px; }
  .drag-game { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
}
@media (min-width: 900px) {
  .home-grid { grid-template-columns: repeat(4, 1fr); max-width: 1000px; }
}
