/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; }
button { border: none; outline: none; background: transparent; cursor: pointer; font-family: inherit; }

/* ========== App容器 - 牛皮纸纹理 ========== */
#app {
  width: 100vw;
  height: 100vh;
  background-color: #f2e3c3;
  background-image: 
    repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(139,105,60,0.025) 2px, rgba(139,105,60,0.025) 3px),
    repeating-linear-gradient(-45deg, transparent, transparent 2px, rgba(139,105,60,0.025) 2px, rgba(139,105,60,0.025) 3px),
    radial-gradient(circle at 15% 20%, rgba(180,140,90,0.1) 0%, transparent 25%),
    radial-gradient(circle at 85% 15%, rgba(160,120,70,0.08) 0%, transparent 20%),
    radial-gradient(circle at 25% 85%, rgba(170,130,80,0.09) 0%, transparent 22%),
    radial-gradient(circle at 75% 75%, rgba(150,110,60,0.07) 0%, transparent 18%);
  position: relative;
  overflow: hidden;
}

/* ========== 视图切换 ========== */
.view { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.view.active { display: flex; flex-direction: column; }

/* ========== 首页 ========== */
#view-home.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3vh 5vw;
}

/* 左侧活页环装饰 */
.spiral-binding {
  position: absolute;
  left: 3vw;
  top: 0;
  bottom: 0;
  width: 6vw;
  max-width: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 3vh 0;
  z-index: 5;
}
.spiral-ring {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid #5a3820;
  border-radius: 50%;
  background: transparent;
}

/* 右上角金币徽章 */
.coin-badge {
  position: absolute;
  top: 3vh;
  right: 5vw;
  display: flex;
  align-items: center;
  gap: 1vw;
  background: #fff9e6;
  border: 2.5px solid #5a3820;
  border-radius: 30px;
  padding: 1vh 3vw;
  box-shadow: 2px 3px 0 rgba(90,56,32,0.2);
  z-index: 10;
}
.coin-num {
  font-size: 2.2vh;
  font-weight: 900;
  color: #5a3820;
}

/* 大标题 */
.game-title {
  font-size: 6vh;
  font-weight: 900;
  color: #5a3820;
  margin-top: 8vh;
  letter-spacing: 0.5vw;
  text-shadow: 2px 2px 0 rgba(90,56,32,0.1);
  transform: rotate(-1deg);
}

/* 主视觉角色区域 */
.hero-area {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}
.cloud {
  position: absolute;
  filter: drop-shadow(2px 3px 0 rgba(90,56,32,0.1));
}
.cloud-1 { top: 10%; left: 15%; }
.cloud-2 { top: 20%; right: 12%; }
.hero-egg {
  filter: drop-shadow(3px 5px 0 rgba(90,56,32,0.1));
}

/* 开始按钮 */
.start-btn {
  width: 80%;
  max-width: 320px;
  padding: 2.5vh 0;
  background: linear-gradient(180deg, #ffe98a, #ffd93d);
  border: 3.5px solid #5a3820;
  border-radius: 45px 50px 48px 52px / 50px 45px 52px 48px;
  font-size: 3.2vh;
  font-weight: 900;
  color: #5a3820;
  box-shadow: 
    0 6px 0 #c4a35a, 
    0 8px 20px rgba(0,0,0,0.15),
    inset 0 2px 0 rgba(255,255,255,0.5);
  transition: all 0.1s;
  letter-spacing: 0.5vw;
  margin-bottom: 3vh;
}
.start-btn:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #c4a35a, 
    0 4px 10px rgba(0,0,0,0.1),
    inset 0 2px 0 rgba(255,255,255,0.5);
}

/* 底部导航按钮 */
.bottom-nav {
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding: 0 2vw;
  gap: 2vw;
}
.nav-icon-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8vh;
  padding: 1.5vh 1vw;
  border-radius: 16px;
  border: 2.5px solid #5a3820;
  transition: all 0.1s;
}
.nav-icon-box.shop { background: #ffeaa7; }
.nav-icon-box.album { background: #dfe9f3; }
.nav-icon-box.settings { background: #e8e8e8; }
.nav-icon-box.more { background: #fff3cd; }
.nav-icon-box span {
  font-size: 1.8vh;
  font-weight: 700;
  color: #5a3820;
}
.nav-icon-box:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(90,56,32,0.2);
}

/* ========== 通用元素 ========== */
.back-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #5a3820;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 5vw;
  top: 3vh;
  z-index: 10;
  box-shadow: 2px 2px 0 rgba(90,56,32,0.15);
}
.page-title {
  text-align: center;
  font-size: 4vh;
  font-weight: 900;
  color: #5a3820;
  margin-top: 3vh;
  margin-bottom: 1.5vh;
  letter-spacing: 0.3vw;
}
.dashed-line {
  height: 2px;
  margin: 0 10vw 2vh;
  background: repeating-linear-gradient(90deg, #5a3820 0, #5a3820 8px, transparent 8px, transparent 14px);
  opacity: 0.4;
}

/* ========== 关卡选择页 ========== */
.levels-container {
  flex: 1;
  overflow-y: auto;
  padding: 1vh 5vw 14vh;
}
.levels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2vh 4vw;
}
.level-card {
  background: #fff;
  border: 3px solid #5a3820;
  border-radius: 16px;
  padding: 1.5vh 2vw;
  position: relative;
  text-align: center;
  transition: all 0.1s;
  box-shadow: 3px 4px 0 rgba(90,56,32,0.15);
}
.level-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(90,56,32,0.2);
}
.level-card.locked {
  background: #e8e0d0;
  opacity: 0.8;
}
.level-num {
  font-size: 3vh;
  font-weight: 900;
  color: #5a3820;
  line-height: 1;
  margin-bottom: 0.8vh;
}
.level-scene {
  height: 10vh;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.8vh;
  border: 2px solid rgba(90,56,32,0.3);
}
.level-stars {
  font-size: 1.8vh;
  letter-spacing: 0.3vw;
}
.level-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3.5vh;
}

/* 章节切换标签 */
.chapter-tabs {
  position: absolute;
  bottom: 4vh;
  left: 5vw;
  right: 5vw;
  display: flex;
  gap: 3vw;
  z-index: 10;
}
.chapter-tab {
  flex: 1;
  padding: 1.8vh 2vw;
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 24px;
  font-size: 1.8vh;
  font-weight: 700;
  color: #5a3820;
  text-align: center;
  box-shadow: 2px 3px 0 rgba(90,56,32,0.15);
}
.chapter-tab.active {
  background: #FFD93D;
}

/* ========== 游戏内页 ========== */
.game-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5vh 3vw;
}
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1vh 0 1.5vh;
}
.game-back-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #5a3820;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-level-label {
  font-size: 2.8vh;
  font-weight: 900;
  color: #5a3820;
}
.game-top-btns {
  display: flex;
  gap: 2vw;
}
.game-small-btn {
  padding: 1vh 3vw;
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 20px;
  font-size: 1.6vh;
  font-weight: 700;
  color: #5a3820;
}
.game-canvas-wrap {
  flex: 1;
  border: 3px solid #5a3820;
  border-radius: 20px;
  overflow: hidden;
  background: #e8f4fd;
  position: relative;
}
.game-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1.5vh 2vw 1vh;
}
.ctrl-left-group {
  display: flex;
  gap: 3vw;
}
.ctrl-btn {
  width: 16vw;
  max-width: 64px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}
.ctrl-btn.circle.dark {
  background: #5a3820;
  border: 3px solid #3d2515;
  box-shadow: 0 4px 0 #3d2515;
}
.ctrl-btn.circle.yellow {
  width: 20vw;
  max-width: 80px;
  background: #FFD93D;
  border: 3px solid #b8860b;
  box-shadow: 0 4px 0 #b8860b;
}
.ctrl-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #3d2515;
}
.ctrl-btn.circle.yellow:active {
  box-shadow: 0 1px 0 #b8860b;
}
.game-hint-text {
  text-align: center;
  font-size: 1.4vh;
  color: #8B7355;
  padding: 0.5vh;
}

/* 游戏弹窗 */
.game-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-inner {
  background: #f5ecd7;
  border: 3px solid #5a3820;
  border-radius: 24px;
  padding: 3vh 4vw 2.5vh;
  width: 80%;
  max-width: 320px;
  text-align: center;
}
.modal-title {
  font-size: 3vh;
  font-weight: 900;
  color: #5a3820;
  margin-bottom: 2vh;
}
.win-stars {
  font-size: 4vh;
  margin-bottom: 1.5vh;
}
.win-coins {
  font-size: 1.8vh;
  font-weight: 700;
  color: #8B7355;
  margin-bottom: 2.5vh;
}
.modal-btn {
  display: block;
  width: 100%;
  padding: 1.5vh;
  margin-bottom: 1.2vh;
  border-radius: 24px;
  font-size: 2vh;
  font-weight: 900;
  border: 2.5px solid #5a3820;
  transition: all 0.1s;
}
.modal-btn.yellow { background: #FFD93D; color: #5a3820; }
.modal-btn.green { background: #90EE90; color: #2d5016; }
.modal-btn.gray { background: #e0e0e0; color: #666; }
.modal-btn:active { transform: translateY(2px); }

/* ========== 商店页 ========== */
.shop-coin-badge {
  position: absolute;
  right: 5vw;
  top: 3vh;
  display: flex;
  align-items: center;
  gap: 1vw;
}
.shop-coin-badge span {
  font-size: 2.4vh;
  font-weight: 900;
  color: #5a3820;
}
.shop-layout {
  flex: 1;
  display: flex;
  gap: 3vw;
  padding: 2vh 5vw;
}
.shop-stage {
  width: 42%;
  background: #fff;
  border: 3px solid #5a3820;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage-curtain {
  height: 6vh;
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  border-bottom: 2.5px solid #5a3820;
}
.stage-floor {
  flex: 1;
  background: #d4a574;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1vh;
}
.shop-items {
  flex: 1;
}
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2vh 2vw;
}
.shop-item {
  aspect-ratio: 1;
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8vh;
  padding: 1vh;
}
.shop-item.equipped {
  background: #e8f5e9;
  box-shadow: inset 0 0 0 2.5px #4CAF50;
}
.item-icon {
  font-size: 4vh;
}
.item-name {
  font-size: 1.6vh;
  font-weight: 700;
  color: #5a3820;
}
.item-price {
  font-size: 1.6vh;
  font-weight: 900;
  color: #b8860b;
}
.shop-cats {
  display: flex;
  justify-content: space-around;
  padding: 2vh 5vw 3vh;
  gap: 3vw;
}
.cat-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5vh;
  padding: 1.5vh 1vw;
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 16px;
  font-size: 1.6vh;
  font-weight: 700;
  color: #5a3820;
}
.cat-tab.active {
  background: #FFD93D;
}
.cat-tab span {
  font-size: 2.8vh;
}

/* ========== Toast提示 ========== */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(90,56,32,0.9);
  color: #fff;
  padding: 1.5vh 4vw;
  border-radius: 24px;
  font-size: 1.8vh;
  font-weight: 700;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
}

/* ========== 安全区适配 ========== */
@supports (padding-top: env(safe-area-inset-top)) {
  .back-circle { top: calc(3vh + env(safe-area-inset-top)); }
  .coin-badge { top: calc(3vh + env(safe-area-inset-top)); }
  .shop-coin-badge { top: calc(3vh + env(safe-area-inset-top)); }
  .bottom-nav { padding-bottom: calc(1vh + env(safe-area-inset-bottom)); }
  .shop-cats { padding-bottom: calc(3vh + env(safe-area-inset-bottom)); }
  .chapter-tabs { bottom: calc(3vh + env(safe-area-inset-bottom)); }
}

/* ========== 图鉴页 ========== */
.album-container {
  flex: 1;
  overflow-y: auto;
  padding: 1vh 5vw 5vh;
}
.album-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2vh 3vw;
}
.album-item {
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 16px;
  padding: 2vh 1vw;
  text-align: center;
  box-shadow: 2px 3px 0 rgba(90,56,32,0.15);
}
.album-item.locked {
  background: #e0e0e0;
  opacity: 0.6;
}
.album-emoji {
  font-size: 5vh;
  margin-bottom: 1vh;
}
.album-name {
  font-size: 1.6vh;
  font-weight: 700;
  color: #5a3820;
}
.album-count {
  font-size: 1.3vh;
  color: #8B7355;
  margin-top: 0.5vh;
}

/* ========== 设置页 ========== */
.settings-list {
  padding: 2vh 5vw;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 2.5px solid #5a3820;
  border-radius: 16px;
  padding: 2vh 4vw;
  margin-bottom: 2vh;
  box-shadow: 2px 3px 0 rgba(90,56,32,0.15);
}
.setting-left {
  display: flex;
  align-items: center;
  gap: 3vw;
}
.setting-icon {
  font-size: 3vh;
}
.setting-name {
  font-size: 2vh;
  font-weight: 700;
  color: #5a3820;
}
.setting-value {
  font-size: 1.6vh;
  color: #8B7355;
}
.setting-arrow {
  font-size: 3vh;
  color: #8B7355;
}

/* 开关样式 */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 28px;
  transition: .3s;
  border: 2px solid #5a3820;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .slider {
  background-color: #90EE90;
}
input:checked + .slider:before {
  transform: translateX(24px);
}

/* ========== 更多模式页 ========== */
.more-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1vh 5vw 5vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5vh 4vw;
}
.more-card {
  background: #fff;
  border: 3px solid #5a3820;
  border-radius: 20px;
  padding: 3vh 2vw;
  text-align: center;
  box-shadow: 3px 4px 0 rgba(90,56,32,0.15);
  transition: all 0.1s;
}
.more-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(90,56,32,0.15);
}
.more-icon {
  font-size: 6vh;
  margin-bottom: 1.5vh;
}
.more-name {
  font-size: 2.2vh;
  font-weight: 900;
  color: #5a3820;
  margin-bottom: 0.8vh;
}
.more-desc {
  font-size: 1.5vh;
  color: #8B7355;
}
