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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #FFF8EF;
  color: #4A3F35;
  overscroll-behavior: none;
}

button { font-family: inherit; border: none; background: none; cursor: pointer; }

/* ============ 书架 index.html ============ */

.shelf-header {
  background: linear-gradient(135deg, #FFD93D, #FFB84D);
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.shelf-title { font-size: 24px; font-weight: 800; color: #5A4310; }

.shelf-title .logo { font-size: 26px; }

.storage-box {
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 13px;
  color: #6B5520;
  display: flex;
  align-items: center;
  gap: 8px;
}

.storage-box .btn-mini {
  background: #FF8F5E;
  color: #fff;
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  padding: 18px;
  max-width: 1000px;
  margin: 0 auto;
}

.story-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(90, 60, 20, 0.12);
  transition: transform .15s;
}

.story-card:active { transform: scale(0.97); }

.card-cover { width: 100%; height: 180px; object-fit: cover; display: block; background: #EAF4FF; }
@supports (aspect-ratio: 4 / 3) {
  .card-cover { aspect-ratio: 4 / 3; height: auto; }
}

.card-body { padding: 12px 14px 14px; }

.card-title { font-size: 17px; font-weight: 800; }

.card-title-en { font-size: 13px; color: #9A8A72; margin-top: 2px; }

.card-words { margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.card-badges { display: flex; gap: 8px; margin-bottom: 10px; font-size: 12px; font-weight: 700; }

.badge { padding: 3px 10px; border-radius: 999px; }

.badge.online { background: #E8F5E9; color: #2E7D32; }

.badge.cached { background: #FFF3E0; color: #E65100; }

.card-btns { display: flex; gap: 8px; }

.btn-play {
  flex: 1;
  background: linear-gradient(135deg, #FFB84D, #FF8F5E);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  border-radius: 14px;
  padding: 10px 0;
}

.btn-dl {
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 14px;
  font-weight: 700;
  border-radius: 14px;
  padding: 10px 14px;
}

.btn-del { background: #FDECEA; color: #C62828; font-size: 14px; font-weight: 700; border-radius: 14px; padding: 10px 12px; }

.shelf-empty, .shelf-error {
  text-align: center;
  padding: 60px 20px;
  color: #9A8A72;
  font-size: 16px;
}

.shelf-error button {
  margin-top: 14px;
  background: #FF8F5E;
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  padding: 10px 22px;
  font-size: 15px;
}

@supports not (gap: 1px) {
  .option-row .option-card, .word-cards .word-card { margin: 7px; }
  .card-btns .btn-play, .card-btns .btn-dl, .card-btns .btn-del { margin: 0 4px; }
  .card-words .word-chip, #ovWords .word-chip { margin: 3px; }
  .card-badges .badge { margin: 0 4px; }
  .end-btns .btn-primary, .end-btns .btn-secondary { margin: 0 6px; }
  #stage.end-screen > * { margin: 7px 0; }
}

/* ============ 故事播放器 story.html ============ */

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #FFF8EF;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#interactionPanel {
  position: relative;
  z-index: 10;
  flex: 0 1 auto;
  width: 100%;
  max-height: calc(100% - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 248, 239, 0.96);
}

#stage img, #stage svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#stage .layout-img {
  position: absolute;
  inset: auto;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.layout-emoji {
  position: absolute;
  line-height: 1;
  pointer-events: none;
  text-align: center;
}

#stage .option-art img, #stage .word-art img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.emoji-art {
  font-size: 38vw;
  line-height: 1;
  animation: pop-in .4s ease;
}
@supports (width: min(1px, 2px)) {
  .emoji-art { font-size: min(38vw, 280px); }
}

.option-row {
  position: static;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 14px;
  padding: 0 14px 14px;
}

.option-card {
  background: #fff;
  border-radius: 18px;
  width: 108px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 10px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  transition: transform .15s, opacity .3s;
}

.option-card:active { transform: scale(0.94); }

.option-card.dim { opacity: 0.45; }

.option-card.active { transform: scale(1.06); box-shadow: 0 0 0 4px #FFD93D; }

.option-card.correct { box-shadow: 0 0 0 5px #4CAF50; animation: bounce .5s; }

.option-card.wrong { box-shadow: 0 0 0 5px #E53935; animation: shake .5s; }

.option-art { font-size: 44px; }

.option-art img { width: 54px; height: 54px; object-fit: contain; }

.option-label { font-size: 14px; font-weight: 700; color: #4A3F35; }

.option-speak { font-size: 16px; color: #FF8F5E; }

#bubble {
  position: static;
  margin: 12px 12px 12px;
  bottom: 14px;
  min-height: 76px;
  background: rgba(255,255,255,0.96);
  border-radius: 20px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  z-index: 5;
}

#bubble.show { display: flex; animation: pop-in .3s; }

#text {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  color: #4A3F35;
  line-height: 1.4;
}

#speakBtn {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFB84D, #FF8F5E);
  color: #fff;
  font-size: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  animation: bounce 1s infinite;
}

#speakBtn.show { display: flex; }

#nextBtn {
  position: absolute;
  right: 22px;
  bottom: 104px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6FBF57, #4E9A3B);
  color: #fff;
  font-size: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  z-index: 6;
  animation: none;
}

#nextBtn.show { display: flex; }

/* 找一找 */

.find-layer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 20; }

.find-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 800;
  color: #4A3F35;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.find-hint {
  margin: 0 12px 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #FFF3D6;
  color: #7A5C28;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.find-skip {
  display: block;
  width: calc(100% - 24px);
  min-height: 46px;
  margin: 0 12px 12px;
  padding: 8px 16px;
  border-radius: 14px;
  background: #FFFFFF;
  color: #FF8F5E;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  font-size: 16px;
  font-weight: 800;
}

.find-skip.complete {
  background: linear-gradient(135deg, #6FBF57, #4E9A3B);
  color: #FFFFFF;
}

.hitbox { position: absolute; border-radius: 12px; }

.hitbox.found { background: rgba(255, 217, 61, 0.55); border: 3px dashed #E65100; animation: pop-in .3s; }

.find-badge {
  position: absolute;
  background: #FF8F5E;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  border-radius: 10px;
  padding: 4px 12px;
  transform: translateX(-50%);
  animation: pop-in .3s;
  pointer-events: none;
}

/* 结尾页 */

#stage.end-screen {
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(160deg, #FFF3C4, #FFE0B2);
}

.end-art { position: static !important; width: auto !important; height: auto !important; max-width: 70%; max-height: 30%; object-fit: contain; }

.end-art-box {
  position: relative;
  width: 88vw;
  max-width: 420px;
  height: 30vh;
  flex: none;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.end-art-box .layout-img, .end-art-box .layout-emoji { max-height: 100%; }

.emoji-art.end-art { font-size: min(30vw, 160px); }

.stars { font-size: 34px; letter-spacing: 6px; }

.word-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
}

.word-card {
  background: #fff;
  border-radius: 16px;
  width: 96px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  transition: transform .15s;
}

.word-card:active { transform: scale(0.93); }

.word-art { font-size: 36px; }

.word-art img { width: 42px; height: 42px; object-fit: contain; }

.word-label { font-size: 14px; font-weight: 700; }

.end-btns { display: flex; gap: 12px; }

.btn-primary, .btn-secondary {
  font-size: 17px;
  font-weight: 800;
  border-radius: 16px;
  padding: 12px 24px;
}

.btn-primary { background: linear-gradient(135deg, #FFB84D, #FF8F5E); color: #fff; }

.btn-secondary { background: #fff; color: #FF8F5E; box-shadow: 0 3px 10px rgba(0,0,0,0.12); }

/* 开始浮层 */

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  background: linear-gradient(160deg, #FFF8EF, #FFE8CC);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s;
}

#overlay.show { opacity: 1; pointer-events: auto; }

#overlay.hide { opacity: 0; pointer-events: none; }

#ovCover {
  width: 62vw;
  max-width: 320px;
  height: 47vw;
  max-height: 240px;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(90, 60, 20, 0.25);
}
@supports (aspect-ratio: 4 / 3) {
  #ovCover { width: min(62vw, 320px); height: auto; aspect-ratio: 4 / 3; }
}

#ovTitle { font-size: 30px; font-weight: 900; color: #5A4310; }

#ovTitleEn { font-size: 16px; color: #9A8A72; font-weight: 700; }

#ovWords { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.word-chip {
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 700;
  color: #4A3F35;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

#ovGo {
  background: linear-gradient(135deg, #FFB84D, #FF8F5E);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  border-radius: 999px;
  padding: 14px 52px;
  box-shadow: 0 8px 20px rgba(255, 143, 94, 0.45);
  animation: none;
}

#ovAgain {
  display: none;
  background: #fff;
  color: #9A8A72;
  font-size: 16px;
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 26px;
}

/* 动画 */

@keyframes pop-in { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

@media (max-width: 480px) {
  .option-card { width: 92px; min-height: 116px; }
  .option-art { font-size: 38px; }
  #text { font-size: 17px; }
  .story-grid { grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
  .btn-play { font-size: 14px; }
}
