:root {
  --ink: #3C302A;
  --ink-soft: #6F5F56;
  --mint: #48B59B;
  --mint-dark: #2B8A74;
  --mint-soft: #DFF6EE;
  --coral: #FF7359;
  --coral-soft: #FFE7E1;
  --yellow: #FFD154;
  --glass-bg: rgba(255, 255, 255, 0.80);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.92);
  --shadow-soft: 0 8px 24px rgba(43, 138, 116, 0.14);
  --rail-w: 88px;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #E9F8FF;
  user-select: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.fullscreen-app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* 100% 全屏画布底层 */
.stage-canvas-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  cursor: pointer;
}

#stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 顶部极简悬浮角标 */
.hud-top {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.glass-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.glass-circle.small-circle {
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.glass-circle.star-circle {
  background: rgba(255, 245, 204, 0.90);
  border-color: #F6CF6B;
}

.glass-pill:active, .glass-circle:active, .action-circle:active, .word-card:active, .primary-btn:active, .quiz-opt:active {
  transform: scale(0.93);
}

.caret {
  font-size: 12px;
  color: var(--mint-dark);
}

.audio-chip {
  background: rgba(255, 244, 204, 0.92);
  color: #8A5B00;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
}

/* 右上角轻巧家长设置浮层 */
.settings-popover {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 54px);
  right: max(12px, env(safe-area-inset-right));
  width: 268px;
  z-index: 30;
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid #FFFFFF;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 14px 36px rgba(43, 138, 116, 0.20);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pop-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--mint-dark);
}

.pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.seg-group {
  display: inline-flex;
  background: var(--mint-soft);
  border-radius: 999px;
  padding: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--mint-dark);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--mint);
  color: #FFFFFF;
}

.mini-pill {
  border: 1.5px solid #CFECE1;
  background: #FFFFFF;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.ui-svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* 右侧悬浮情绪/词汇胶囊轨 */
.cards-rail {
  position: fixed;
  top: 44%;
  right: max(10px, env(safe-area-inset-right));
  transform: translateY(-50%);
  z-index: 15;
  max-height: calc(100dvh - 188px);
  overflow-y: auto;
  overflow-x: visible;
  padding: 6px 2px 6px 12px;
  scrollbar-width: none;
}

.cards-rail::-webkit-scrollbar {
  display: none;
}

.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.word-card {
  width: var(--rail-w);
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(43, 138, 116, 0.14);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.word-card.active {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--coral);
  transform: translateX(-8px) scale(1.06);
  box-shadow: 0 10px 24px rgba(255, 115, 89, 0.28);
}

.card-emoji {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.card-icon-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.quiz-opt-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
}

.shelf-icon-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shelf-icon-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: block;
}

.card-en {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-cn {
  display: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* 底部悬浮绘本字幕胶囊（竖屏横跨底部安全区不折行；横屏左置留出右侧 2×3 轨） */
.bottom-hud {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 16;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
}

.word-bubble {
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2.5px solid #FFFFFF;
  border-radius: 26px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 10px 28px rgba(43, 138, 116, 0.16);
}

.word-info {
  min-width: 0;
  flex: 1;
}

.word-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.active-word {
  font-size: 24px;
  font-weight: 900;
  color: var(--coral);
  line-height: 1.1;
}

.active-phrase {
  font-size: 13px;
  font-weight: 700;
  color: var(--mint-dark);
}

.active-cn {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.bubble-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.action-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #CFECE1;
  background: var(--mint-soft);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.action-circle.mic-circle {
  background: var(--coral-soft);
  border-color: #FFB4A2;
}

.action-circle.recording {
  background: var(--coral);
  border-color: var(--coral);
  animation: pulse-mic 0.9s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 115, 89, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(255, 115, 89, 0); }
}

.mic-bar {
  background: rgba(255, 249, 236, 0.95);
  backdrop-filter: blur(10px);
  border: 2px solid #F7D37A;
  border-radius: 18px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-soft);
}

.mic-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.mic-wave span {
  width: 4px;
  height: 8px;
  background: var(--coral);
  border-radius: 999px;
  animation: wave-bar 0.7s infinite ease-in-out;
}

.mic-wave span:nth-child(2) { animation-delay: 0.12s; }
.mic-wave span:nth-child(3) { animation-delay: 0.24s; }
.mic-wave span:nth-child(4) { animation-delay: 0.36s; }
.mic-wave span:nth-child(5) { animation-delay: 0.48s; }

.mic-wave.paused span {
  animation: none;
  height: 6px;
  background: var(--mint);
}

@keyframes wave-bar {
  0%, 100% { height: 6px; }
  50% { height: 18px; }
}

.mic-status {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
}

/* 全屏闯关模式 HUD */
.quiz-hud {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.quiz-stars {
  background: var(--glass-strong);
  border: 2px solid #F6CF6B;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 18px;
  letter-spacing: 2px;
  box-shadow: var(--shadow-soft);
}

.quiz-bottom-box {
  pointer-events: auto;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2.5px solid #FFFFFF;
  border-radius: 26px;
  padding: 14px;
  box-shadow: 0 12px 32px rgba(43, 138, 116, 0.20);
}

.quiz-prompt {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 10px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quiz-opt {
  border: 2.5px solid #CFECE1;
  border-radius: 20px;
  background: #FFFFFF;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
}

.quiz-opt.correct {
  border-color: var(--mint);
  background: var(--mint-soft);
}

.quiz-opt.wrong {
  border-color: #FF8C7A;
  background: #FFF0ED;
}

/* 弹窗（书架 / 奖状） */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 42, 38, 0.52);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-card {
  background: #FFFFFF;
  border-radius: 28px;
  padding: 18px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.shelf-modal-card {
  max-width: 540px;
  text-align: left;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  max-height: 60dvh;
  overflow-y: auto;
}

.shelf-card {
  background: #F6FDF9;
  border: 2.5px solid #CFECE1;
  border-radius: 20px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.shelf-card.current {
  border-color: var(--coral);
  background: #FFF9F7;
}

.shelf-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shelf-emoji-row {
  font-size: 20px;
}

.shelf-star-tag {
  background: #FFF4CC;
  color: #8A5B00;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 800;
}

.shelf-card h3 {
  margin: 0;
  font-size: 16px;
}

.shelf-card p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.award-canvas {
  width: 100%;
  max-width: 270px;
  height: auto;
  border-radius: 16px;
  border: 2px solid #CFECE1;
  margin-bottom: 12px;
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary-btn {
  border: 0;
  background: var(--coral);
  color: #FFFFFF;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

/* 免屏幕磨耳朵护眼浮层 */
.ear-overlay {
  position: fixed;
  inset: 0;
  background: #14221F;
  color: #EAF8F3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.ear-card {
  text-align: center;
  max-width: 340px;
}

.ear-moon {
  font-size: 56px;
  margin-bottom: 8px;
}

.ear-now {
  font-size: 22px;
  font-weight: 800;
  color: var(--yellow);
  margin: 12px 0;
}

.ear-tip {
  font-size: 13px;
  color: #9FC4B8;
  margin-bottom: 22px;
}

/* 横屏手机 / iPad / 桌面宽屏：右侧统一 2×3 悬浮圆格，6 词 100% 一屏全可见零滚动 */
@media (min-width: 620px) {
  :root {
    --rail-w: 224px;
  }
  .cards-rail {
    top: 52%;
    right: max(18px, env(safe-area-inset-right));
    max-height: calc(100dvh - 110px);
  }
  .cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 102px);
    gap: 10px;
  }
  .word-card {
    width: 102px;
    padding: 9px 6px 8px;
    border-radius: 22px;
  }
  .word-card.active {
    transform: translateY(-3px) scale(1.06);
  }
  .card-emoji {
    width: 54px;
    height: 54px;
  }
  .card-en {
    font-size: 14px;
  }
  .card-cn {
    display: block;
  }
  .bottom-hud {
    left: 24px;
    right: calc(var(--rail-w) + 34px);
    bottom: 20px;
  }
  .active-word {
    font-size: 30px;
  }
  .active-phrase {
    font-size: 15px;
  }
  .active-cn {
    font-size: 16px;
  }
}

/* 矮横屏手机：微缩 2×3 保持 6 词全可见 */
@media (max-height: 520px) and (min-width: 560px) {
  :root {
    --rail-w: 176px;
  }
  .cards-grid {
    grid-template-columns: repeat(2, 82px);
    gap: 8px;
  }
  .word-card {
    width: 82px;
    padding: 6px 4px;
  }
  .card-emoji {
    width: 38px;
    height: 38px;
  }
  .card-cn {
    display: none;
  }
}
