/* ============================================================
   成语接龙 — 样式（暖色可爱，Chrome 61 基线层）
   约束：无 flex gap / aspect-ratio / clamp / 逻辑属性 / :has
         / @container / dvh / backdrop-filter
   间距统一用子项 margin，Flex 子项设 min-width:0
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #fff6ec;
  color: #4a3728;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--app-height, 100vh));
}

/* ---------- 顶栏 ---------- */
.app-header {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  position: relative;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  background: -webkit-linear-gradient(135deg, #ff8c42, #ffb35c);
  background: linear-gradient(135deg, #ff8c42, #ffb35c);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(255, 140, 66, 0.25);
}

.header-brand {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 10px 16px;
  min-height: 52px;
  position: relative;
}

.header-icon {
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 8px;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.header-title { font-size: 18px; font-weight: 700; }

.header-ver {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.85;
}

.header-back {
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 56px;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 24px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.header-back:active { opacity: 0.6; }

/* ---------- 主体 ---------- */
.app-main {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  min-width: 0;
}

.view { padding: 16px 16px 28px; max-width: 720px; margin: 0 auto; }

/* 首页：内容垂直分布 */
.view.home {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  min-height: 100%;
}

/* ---------- 通用卡片 / 按钮 ---------- */
.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 3px 12px rgba(255, 140, 66, 0.08);
  margin-bottom: 12px;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0 10px;
  text-align: center;
  color: #4a3728;
}

.btn {
  min-height: 48px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  background: #fff3e4;
  color: #ff7a45;
  cursor: pointer;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.btn:active { opacity: 0.75; }

.btn-primary {
  background: -webkit-linear-gradient(135deg, #ff8c42, #ff7a45);
  background: linear-gradient(135deg, #ff8c42, #ff7a45);
  color: #ffffff;
}

.btn-ghost { background: #f5eee6; color: #9b8a78; }

.btn-danger { background: #fff1f0; color: #f5222d; }

.btn-big { min-height: 56px; font-size: 18px; border-radius: 14px; }

/* 首页主按钮：满宽更醒目 */
.home-hero .btn-big { width: 100%; }

.btn-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 12px;
}

.btn-row > * + * { margin-left: 10px; }

/* ---------- 首页 ---------- */
.home-hero { text-align: center; padding: 24px 16px 20px; }

.hero-title { font-size: 24px; font-weight: 800; color: #4a3728; }

.hero-sub { font-size: 13px; color: #9b8a78; margin-top: 6px; margin-bottom: 18px; }

.home-status {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  padding: 14px 8px;
}

.status-item {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 0;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.status-item b { display: block; font-size: 19px; color: #ff7a45; min-height: 26px; }

.status-item span { font-size: 12px; color: #9b8a78; }

.home-settings { padding: 14px 16px 16px; }

.setting-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 8px 0;
  min-height: 52px;
}

.setting-left { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; padding-right: 12px; }

.setting-label { font-size: 15px; font-weight: 700; }

.setting-desc { font-size: 12px; color: #9b8a78; margin-top: 2px; line-height: 1.5; }

/* 开关 */
.switch {
  width: 52px;
  height: 30px;
  border: none;
  border-radius: 15px;
  background: #e8dcd0;
  position: relative;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  cursor: pointer;
  padding: 0;
  -webkit-transition: background 0.2s;
  transition: background 0.2s;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  -webkit-transition: left 0.2s;
  transition: left 0.2s;
}

.switch.on { background: #ff8c42; }

.switch.on .switch-knob { left: 25px; }

/* 限时档位 */
.seg-wrap { padding: 6px 0 4px; }

.seg-title { font-size: 13px; color: #9b8a78; margin-bottom: 6px; }

.seg-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}

.seg-btn {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 0;
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: #f5eee6;
  color: #9b8a78;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.seg-btn + .seg-btn { margin-left: 8px; }

.seg-btn.on { background: #ff8c42; color: #ffffff; }

/* ---------- 接龙页 ---------- */
.chain-top {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chain-steps { font-size: 14px; font-weight: 700; color: #ff7a45; min-width: 0; }

.chain-total { font-size: 13px; color: #9b8a78; }

.chain-exit {
  min-width: 48px;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: #f5eee6;
  color: #9b8a78;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.chain-exit:active { opacity: 0.7; }

.cur-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 22px 16px 18px;
  text-align: center;
  box-shadow: 0 3px 12px rgba(255, 140, 66, 0.08);
  margin-bottom: 10px;
}

.cur-label { font-size: 12px; color: #9b8a78; }

.cur-word {
  font-size: 42px;
  font-weight: 800;
  color: #4a3728;
  margin-top: 6px;
  line-height: 1.35;
  letter-spacing: 6px;
}

.cur-ch { letter-spacing: 6px; }

.cur-tail {
  color: #ff7a45;
  border-bottom: 4px solid #ff7a45;
  border-radius: 2px;
  padding-bottom: 2px;
}

.cur-guide {
  margin-top: 12px;
  font-size: 15px;
  color: #ff7a45;
  font-weight: 700;
}

.step-cd {
  text-align: center;
  margin-bottom: 6px;
  font-size: 14px;
  color: #e8590c;
  font-weight: 700;
  min-height: 22px;
}

.step-cd.warn { color: #ff4d4f; }

.feedback {
  min-height: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.6;
}

.feedback.ok { color: #00b578; }
.feedback.bad { color: #ff4d4f; }
.feedback.hint { color: #ff9f1a; }

.cand-card {
  position: relative;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(255, 140, 66, 0.10);
  border: 2px solid transparent;
  cursor: pointer;
}

.cand-card:active { opacity: 0.8; }

.cand-word { font-size: 22px; font-weight: 800; color: #4a3728; letter-spacing: 3px; }

.cand-py { font-size: 12px; color: #9b8a78; margin-top: 4px; }

.cand-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 10px;
  color: #ffffff;
  background: #9aa5b1;
  border-radius: 8px;
  padding: 2px 8px;
}

.cand-card.correct {
  border-color: #00b578;
  background: #f0fbf5;
  -webkit-animation: flashOk 0.6s ease;
  animation: flashOk 0.6s ease;
}

@-webkit-keyframes flashOk {
  0% { background: #b7ebc5; }
  100% { background: #f0fbf5; }
}
@keyframes flashOk {
  0% { background: #b7ebc5; }
  100% { background: #f0fbf5; }
}

.cand-card.dim { opacity: 0.45; cursor: default; }

.cand-card.wrong {
  border-color: #ff4d4f;
  background: #fff5f5;
  opacity: 0.55;
  cursor: default;
}

.cand-card.hint-mark { border-color: #ff9f1a; background: #fffaf0; }
.cand-card.timeout-mark { border-color: #ff4d4f; }

.chain-hint-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-top: 4px;
}

.hint-btn {
  min-width: 88px;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: #fff3e4;
  color: #ff7a45;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  padding: 0 12px;
}

.hint-btn:disabled { background: #f0e9e1; color: #b8a99a; cursor: default; }

.chain-err { font-size: 13px; color: #ff4d4f; font-weight: 700; }

/* ---------- 释义卡 ---------- */
.meaning-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 3px 12px rgba(255, 140, 66, 0.10);
  margin-bottom: 10px;
}

.meaning-word { font-size: 26px; font-weight: 800; color: #ff7a45; letter-spacing: 2px; }

.meaning-emoji { font-size: 20px; }

.meaning-py { font-size: 13px; color: #9b8a78; margin-top: 4px; }

.meaning-desc { font-size: 15px; line-height: 1.75; color: #4a3728; margin-top: 10px; }

.meaning-src { font-size: 12px; color: #9b8a78; margin-top: 8px; }

.meaning-ex {
  font-size: 13px;
  color: #6b5844;
  margin-top: 8px;
  line-height: 1.6;
  background: #fff7ee;
  border-radius: 8px;
  padding: 8px 10px;
}

/* ---------- 结算页 ---------- */
.result-card { text-align: center; padding: 22px 16px 18px; }

.result-stars { font-size: 34px; color: #ff9f1a; min-height: 46px; letter-spacing: 4px; }

.result-len { font-size: 40px; font-weight: 800; color: #ff7a45; margin-top: 4px; }

.result-msg { font-size: 15px; color: #e8590c; font-weight: 700; margin-top: 10px; }

.newbest {
  display: inline-block;
  background: #ffe1cc;
  color: #ff7a45;
  border-radius: 10px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 10px;
}

.result-stats {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 14px;
}

.result-stat {
  margin: 0 12px;
  font-size: 13px;
  color: #9b8a78;
  text-align: center;
  min-width: 0;
}

.result-stat b { display: block; font-size: 20px; color: #4a3728; }

.streak-info { text-align: center; margin-top: 12px; font-size: 14px; color: #9b8a78; }
.streak-info b { color: #ff7a45; }

.result-enc { text-align: center; font-size: 14px; color: #9b8a78; line-height: 1.7; }

/* ---------- 打卡日历 ---------- */
.calendar {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 3px 12px rgba(255, 140, 66, 0.08);
  margin-bottom: 12px;
}

.calendar-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 8px;
}

.calendar-grid > * { width: 14.28%; padding: 4px; }

.cal-day {
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  border-radius: 6px;
  color: #9b8a78;
  background: #faf3ea;
}

.cal-day.done { background: #ff8c42; color: #ffffff; font-weight: 700; }
.cal-day.today { outline: 2px solid #ff4d4f; }

.streak-info { text-align: center; margin-top: 10px; font-size: 14px; color: #9b8a78; }
.streak-info b { color: #ff7a45; }

/* ---------- 家长面板：recent10 ---------- */
.recent-card { padding: 14px 16px; }

.recent-list { margin-top: 4px; }

.recent-item {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid #f5eee6;
}

.recent-item:last-child { border-bottom: none; }

.recent-len { font-size: 16px; font-weight: 700; color: #4a3728; min-width: 0; }

.recent-meta { font-size: 12px; color: #9b8a78; margin-top: 2px; }

.recent-stars { font-size: 16px; color: #ff9f1a; -webkit-box-flex: 0; -webkit-flex: 0 0 auto; flex: 0 0 auto; }

.recent-empty { font-size: 13px; color: #9b8a78; text-align: center; padding: 14px 0; }

/* ---------- 分享弹层 ---------- */
.share-overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 55, 40, 0.6);
  z-index: 50;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.share-box {
  max-width: 520px;
  margin: 40px auto 60px;
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
}

.share-card-img {
  width: 100%;
  border-radius: 12px;
  display: block;
}

.share-hint { text-align: center; font-size: 13px; color: #9b8a78; margin-top: 10px; }

.share-text {
  width: 100%;
  min-height: 64px;
  margin-top: 12px;
  border: 1px solid #f0e6d6;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: #4a3728;
  background: #fffaf2;
  resize: none;
  font-family: inherit;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.share-feedback { text-align: center; font-size: 13px; min-height: 20px; margin-top: 8px; }
.share-feedback.ok { color: #00b578; }
.share-feedback.bad { color: #ff4d4f; }

.share-btns {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 12px;
}

.share-btns > * + * { margin-left: 10px; }

/* ---------- 底栏 ---------- */
.app-footer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 1px solid #f5eee6;
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.footer-nav {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 8px 12px 10px;
}

.footer-nav > * + * { margin-left: 10px; }

.footer-btn {
  min-width: 64px;
  padding: 9px 0;
  font-size: 13px;
  color: #ff7a45;
  text-align: center;
  border-radius: 8px;
  background: #fff3e4;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 40%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  background: rgba(74, 55, 40, 0.85);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 60;
  max-width: 80%;
  text-align: center;
  line-height: 1.6;
}

/* 安全区增强 */
@supports ((padding-bottom: var(--safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom))) {
  .app-header { padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); }
  .app-footer { padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
  .share-overlay { padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
}
