/* ============================================================
   Henry 學習樂園 — 彩虹糖果色設計系統 (Rainbow Candy Theme)
   PC 側邊欄導航 + 手機底部 Tab · 按鈕 ≥ 44px
   ============================================================ */
:root {
  --pink:   #FF9EC4;
  --pink-d: #FF7FB0;
  --blue:   #7EC8E3;
  --blue-d: #5BB4D6;
  --yellow: #FFD93D;
  --yellow-d:#F5C518;
  --green:  #B5EAD7;
  --green-d:#8FD9C0;
  --purple: #C9A7EB;
  --purple-d:#B389E0;
  --ink:    #5b4a6a;
  --ink-soft:#8a7a99;
  --paper:  #fffdfa;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(0,0,0,.08), 0 10px 22px rgba(150,120,180,.18);
  --font: 'Fredoka','ZCOOL KuaiLe','Comic Sans MS','PingFang TC','Microsoft YaHei','Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',system-ui,sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, #FFE3F1 0, transparent 38%),
    radial-gradient(circle at 88% 12%, #DDF3FB 0, transparent 40%),
    radial-gradient(circle at 80% 88%, #E7FBE9 0, transparent 42%),
    radial-gradient(circle at 18% 85%, #F1E7FF 0, transparent 40%),
    linear-gradient(135deg, #FFF6FB, #F3FAFF);
  background-attachment: fixed;
  overflow: hidden;
  user-select: none;
}

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------------- 側邊欄 (PC) / 抽屜 (手機) ---------------- */
#sidebar {
  width: 240px; flex: 0 0 240px;
  background: linear-gradient(180deg, #fff, #fff7fc);
  border-right: 4px solid #ffe1ef;
  display: flex; flex-direction: column;
  padding: 18px 14px; gap: 14px;
  box-shadow: 4px 0 18px rgba(200,150,190,.10);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-logo {
  font-size: 38px; width: 56px; height: 56px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  border-radius: 18px; box-shadow: var(--shadow);
  animation: bob 3s ease-in-out infinite;
}
.brand-name { font-weight: 700; font-size: 22px; line-height: 1.05; color: var(--pink-d); }
.brand-name span { font-size: 14px; color: var(--blue-d); }

.star-box {
  background: linear-gradient(135deg, var(--yellow), #fff0a8);
  border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 18px;
  text-align: center; color: #a9790a; box-shadow: var(--shadow);
}
.nav { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; cursor: pointer; text-align: left;
  background: #fff; border-radius: 18px; padding: 12px 14px;
  min-height: 60px;
  box-shadow: 0 3px 0 rgba(0,0,0,.06);
  transition: transform .12s, box-shadow .12s; color: var(--ink);
  font-family: var(--font);
}
.nav-item:active { transform: translateY(2px); box-shadow: none; }
.nav-icon { font-size: 30px; }
.nav-label { font-weight: 600; font-size: 17px; line-height: 1.05; }
.nav-label small { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.nav-item.active {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; box-shadow: 0 5px 0 var(--purple-d);
}
.nav-item.active .nav-label small { color: #fff8; }
.reset-btn {
  border: none; cursor: pointer; background: #fff0f6; color: var(--pink-d);
  border-radius: 14px; padding: 10px; font-family: var(--font); font-weight: 600;
  min-height: 44px;
}

/* ---------------- 主區 ---------------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px); border-bottom: 3px solid #ffe1ef;
}
.menu-btn {
  display: none !important; /* 手機底部 Tab 已涵蓋導航，隱藏漢堡 */
  border: none; background: var(--blue); color: #fff;
  width: 46px; height: 46px; border-radius: 14px; font-size: 22px; cursor: pointer;
}
.top-title { font-weight: 700; font-size: 20px; color: var(--purple-d); flex: 1; }
.top-title .en { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.top-star { background: var(--yellow); color: #a9790a; font-weight: 700; padding: 6px 12px; border-radius: 14px; }

#content { flex: 1; overflow-y: auto; padding: 18px 18px 28px; -webkit-overflow-scrolling: touch; }

/* ---------------- 模組標題 ---------------- */
.module-head { margin-bottom: 12px; }
.module-head h2 { margin: 0; font-size: 26px; color: var(--purple-d); }
.module-head h2 .en { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.module-head .sub { margin: 6px 0 0; color: var(--ink-soft); font-size: 15px; }

/* ---------------- 子分頁 ---------------- */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.subtab {
  border: none; cursor: pointer; background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 16px; font-weight: 600; font-size: 15px;
  font-family: var(--font); min-height: 44px; box-shadow: 0 3px 0 rgba(0,0,0,.06);
}
.subtab.active { background: linear-gradient(135deg, var(--blue), var(--green)); color: #144; box-shadow: 0 4px 0 var(--green-d); }

/* ---------------- 通用按鈕 ---------------- */
.big-btn {
  border: none; cursor: pointer; font-family: var(--font); font-weight: 700;
  min-height: 64px; padding: 14px 20px; border-radius: 20px; font-size: 20px;
  background: #fff; color: var(--ink); box-shadow: 0 5px 0 rgba(0,0,0,.10);
  transition: transform .1s, box-shadow .1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: none; }
.big-btn.primary { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; box-shadow: 0 5px 0 var(--purple-d); }
.big-btn.spotify { background: linear-gradient(135deg, #1db954, #0f9d4e); color: #fff; box-shadow: 0 5px 0 #0b7a3b; font-size: 18px; }

/* ---------------- 字母卡 ---------------- */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.letter-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius);
  padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--pink));
}
.letter-card:active { transform: translateY(3px); }
.lc-emoji { font-size: 34px; }
.lc-u { font-size: 34px; font-weight: 700; color: var(--c, var(--pink)); line-height: 1; }
.lc-l { font-size: 18px; color: var(--ink-soft); }
.lc-word { font-size: 14px; font-weight: 600; }
.lc-word small { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.pop { animation: pop .35s ease; }

/* ---------------- 遊戲通用 ---------------- */
.game-wrap { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); max-width: 640px; }
.game-stat { font-size: 16px; font-weight: 600; color: var(--ink-soft); margin-bottom: 12px; }
.game-stat b { color: var(--pink-d); font-size: 20px; }
.game-prompt { text-align: center; margin: 10px 0 18px; }
.gp-label { font-size: 16px; color: var(--ink-soft); }
.gp-letter { font-size: 84px; font-weight: 700; color: var(--blue-d); line-height: 1; margin: 6px 0; }
.gp-en { font-size: 13px; color: var(--ink-soft); }
.opt-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.opt-btn {
  border: none; cursor: pointer; background: #fff; border-radius: 20px;
  min-height: 72px; font-size: 30px; font-family: var(--font); color: var(--ink);
  box-shadow: 0 5px 0 rgba(0,0,0,.10); display: grid; place-items: center;
}
.opt-btn:active { transform: translateY(4px); box-shadow: none; }
.opt-t { font-size: 30px; font-weight: 700; }
.feedback { margin-top: 14px; text-align: center; font-size: 18px; font-weight: 700; min-height: 28px; }
.feedback .ok { color: #2faa6a; }
.feedback .no { color: #e0738a; }
.reward { color: var(--yellow-d); margin-top: 4px; animation: pop .4s ease; }

/* ---------------- 古詩 ---------------- */
.poem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.poem-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; text-align: left;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-left: 8px solid var(--c, var(--purple));
}
.poem-card:active { transform: translateY(3px); }
.pc-no { font-size: 13px; color: var(--c, var(--purple)); font-weight: 700; }
.pc-title { font-size: 24px; font-weight: 700; }
.pc-en { font-size: 12px; color: var(--ink-soft); }
.pc-author { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.back-btn { border: none; cursor: pointer; background: #fff; color: var(--purple-d); border-radius: 14px; padding: 10px 16px; font-family: var(--font); font-weight: 700; min-height: 44px; margin-bottom: 12px; box-shadow: 0 3px 0 rgba(0,0,0,.06); }
.poem-detail { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); max-width: 640px; border-top: 8px solid var(--c, var(--purple)); }
.poem-detail h3 { margin: 0; font-size: 28px; color: var(--purple-d); }
.poem-detail h3 small { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.poem-author { color: var(--ink-soft); margin: 4px 0 14px; }
.poem-lines { display: flex; flex-direction: column; gap: 10px; }
.poem-line { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 10px; border-radius: 14px; background: #faf6ff; cursor: pointer; }
.poem-line.flash { background: #ffe9a8; animation: pop .4s ease; }
.ch { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.4em; }
.ch .py { font-size: 13px; color: var(--blue-d); font-weight: 600; line-height: 1; }
.ch .zi { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.poem-actions { margin-top: 16px; text-align: center; }

/* ---------------- 數字 ---------------- */
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.num-card {
  border: none; cursor: pointer; background: #fff; border-radius: 18px; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 4px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-bottom: 6px solid var(--c, var(--yellow));
}
.num-card:active { transform: translateY(3px); }
.nc-num { font-size: 36px; font-weight: 700; color: var(--c, var(--yellow-d)); line-height: 1; }
.nc-cn { font-size: 16px; color: var(--ink-soft); }
.math-q { text-align: center; font-size: 54px; font-weight: 700; color: var(--yellow-d); margin: 8px 0 18px; }
.count-items { text-align: center; font-size: 34px; line-height: 1.8; letter-spacing: 4px; margin: 12px 0; }
.count-items.big { font-size: 40px; }

/* ---------------- 邏輯 ---------------- */
.logic-q { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.logic-q .en { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.logic-seq { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
.seq-item { font-size: 46px; background: #eafaf3; border-radius: 16px; padding: 6px 10px; box-shadow: 0 3px 0 var(--green-d); }
.seq-q { font-size: 46px; color: var(--pink-d); font-weight: 700; }
.logic-target { text-align: center; font-size: 80px; margin: 8px 0 18px; }

/* ---------------- 徽章牆 ---------------- */
.badge-wall-wrap { margin-top: 26px; }
.badge-wall-wrap h3 { font-size: 20px; color: var(--pink-d); margin: 0 0 12px; }
.badge-wall-wrap h3 .en { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.badge-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.badge { background: #fff; border-radius: 18px; padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.badge.got { background: linear-gradient(135deg, #fff7d6, #ffe9f4); border: 2px solid var(--yellow); }
.badge.locked { filter: grayscale(.9); opacity: .6; }
.badge-icon { font-size: 40px; }
.badge-name { font-weight: 700; font-size: 15px; margin-top: 4px; }
.badge-en { font-size: 11px; color: var(--ink-soft); }

/* ---------------- 冒險 ---------------- */
.adv-level { font-size: 18px; font-weight: 700; color: var(--pink-d); text-align: center; margin-bottom: 8px; }
.progress { height: 14px; background: #ffe1ef; border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); transition: width .4s; }
.celebrate { text-align: center; }
.big-emoji { font-size: 56px; }
.celebrate h3 { font-size: 28px; color: var(--pink-d); }

/* ---------------- 兒歌 ---------------- */
.section-title {
  font-size: 18px; font-weight: 800; color: var(--purple-d); margin: 10px 6px 8px;
}
.lyrics-section-title { margin-top: 24px; padding-top: 14px; border-top: 3px dashed rgba(0,0,0,.08); }

/* 冰雪奇緣 Frozen 歌曲卡 */
.frozen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.frozen-card {
  border: none; cursor: pointer; background: linear-gradient(160deg, #fff, #f0f8ff); border-radius: var(--radius); padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--blue));
  transition: transform .1s, box-shadow .1s;
}
.frozen-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.fc-icon { font-size: 40px; }
.fc-song { font-size: 14px; font-weight: 700; text-align: center; line-height: 1.25; }
.fc-zh { font-size: 12px; color: var(--ink-soft); text-align: center; }
.fc-part { font-size: 11px; color: #3a6ea5; background: #e0edff; padding: 2px 8px; border-radius: 10px; margin-top: 2px; }
.frozen-detail { border-top-color: #9EC4FF !important; }

/* Spotify 歌曲卡 */
.spotify-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.spotify-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius); padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--pink));
  transition: transform .1s, box-shadow .1s;
}
.spotify-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.sp-icon { font-size: 36px; }
.sp-title { font-size: 14px; font-weight: 700; text-align: center; line-height: 1.25; }
.sp-artist { font-size: 11px; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.sp-dur { font-size: 11px; color: var(--purple-d); background: #f3e8ff; padding: 2px 8px; border-radius: 10px; margin-top: 2px; }

/* Spotify 歌曲詳情（App 內嵌 YouTube 播真人唱） */
.song-detail {
  background: linear-gradient(160deg, #fff, #fff0f8); border-radius: var(--radius); padding: 18px 14px;
  box-shadow: var(--shadow); max-width: 560px; text-align: center; border-top: 8px solid var(--c, var(--pink));
}
.sd-icon { font-size: 60px; }
.sd-title { font-size: 24px; font-weight: 800; color: var(--purple-d); margin-top: 6px; }
.sd-artist { font-size: 15px; color: var(--ink-soft); margin-top: 4px; }
.yt-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 14px 0 8px; border-radius: 16px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.15); background: #000; }
.yt-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sd-hint { font-size: 13px; color: var(--ink-soft); margin: 6px 0 14px; }
.spotify-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.spotify-actions .big-btn { min-height: 56px; font-size: 18px; }

/* ---------------- 動物樂園 ---------------- */
.animal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.animal-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius); padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--green));
  transition: transform .1s, box-shadow .1s;
}
.animal-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.ac-icon { font-size: 42px; }
.ac-name { font-size: 15px; font-weight: 700; }
.ac-zh { font-size: 13px; color: #d97baa; }
.ac-cn { font-size: 12px; color: var(--blue-d); }
.ac-sound { font-size: 12px; color: var(--green-d); background: #eaffea; padding: 2px 8px; border-radius: 10px; }

/* 動物猜謎 */
.quiz-box {
  background: linear-gradient(160deg, #fff, #f2fff2); border-radius: var(--radius); padding: 20px 16px;
  box-shadow: var(--shadow); max-width: 560px; text-align: center; border-top: 8px solid var(--c, var(--green));
}
.quiz-head { font-size: 22px; font-weight: 800; color: var(--green-d); margin-bottom: 14px; }
.quiz-head .en { font-size: 14px; color: var(--ink-soft); display: block; margin-top: 4px; }
.quiz-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
.opt-btn {
  border: none; cursor: pointer; background: #fff; border-radius: 16px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--green); min-height: 90px;
  transition: transform .1s;
}
.opt-btn:active { transform: translateY(3px); }
.oq-icon { font-size: 40px; }
.oq-name { font-size: 16px; font-weight: 700; }
.quiz-fb { font-size: 20px; font-weight: 800; min-height: 34px; margin-bottom: 12px; }
.quiz-fb.good { color: var(--green-d); }
.quiz-fb.bad { color: var(--pink-d); }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }

/* ---------------- 水果 / 蔬菜 ---------------- */
.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.food-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius); padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--pink));
  transition: transform .1s, box-shadow .1s;
}
.food-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.fc-icon { font-size: 44px; }
.fc-name { font-size: 15px; font-weight: 700; text-align: center; }
.fc-zh { font-size: 13px; color: var(--ink-soft); }
.food-card.bounce { animation: foodBounce .4s ease; }
@keyframes foodBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.song-card {
  border: none; cursor: pointer; background: #fff; border-radius: var(--radius); padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,.08); font-family: var(--font); color: var(--ink);
  border-top: 6px solid var(--c, var(--pink));
}
.song-card:active { transform: translateY(3px); }
.sc-icon { font-size: 40px; }
.sc-title { font-size: 15px; font-weight: 700; text-align: center; }
.sc-zh { font-size: 13px; color: var(--ink-soft); }
.song-stage { background: linear-gradient(160deg, #fff, #fff0f8); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); max-width: 640px; border-top: 8px solid var(--c, var(--pink)); position: relative; overflow: hidden; }
.floater-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.floater { position: absolute; bottom: -40px; animation: floatUp linear infinite; opacity: .85; }
.song-head { display: flex; align-items: center; gap: 12px; position: relative; z-index: 2; }
.sh-icon { font-size: 44px; }
.sh-title { font-weight: 700; font-size: 20px; color: var(--pink-d); }
.sh-zh { font-size: 14px; color: var(--ink-soft); }
.lyrics { position: relative; z-index: 2; margin: 14px 0; min-height: 160px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.lyric-line { text-align: center; font-size: 20px; color: var(--ink-soft); padding: 8px 10px; border-radius: 14px; transition: all .3s; }
.lyric-line.active { background: var(--yellow); color: #7a5800; font-weight: 700; transform: scale(1.06); box-shadow: 0 4px 0 var(--yellow-d); }
.song-actions { display: flex; gap: 10px; position: relative; z-index: 2; justify-content: center; }

/* ---------------- Toast ---------------- */
.henry-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(90,60,110,.94); color: #fff; padding: 12px 20px; border-radius: 18px;
  font-weight: 700; font-size: 16px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 86vw; text-align: center;
}
.henry-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 動畫 ---------------- */
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-6px);} }
@keyframes pop { 0%{ transform: scale(.8);} 60%{ transform: scale(1.12);} 100%{ transform: scale(1);} }
@keyframes floatUp { 0%{ transform: translateY(0) rotate(0);} 100%{ transform: translateY(-110vh) rotate(360deg);} }

/* ============================================================
   手機版：底部 Tab + 抽屜側欄
   ============================================================ */
@media (max-width: 767px) {
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-105%); transition: transform .25s ease;
    width: 78vw; max-width: 300px;
  }
  #sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  /* 漢堡選單已永久隱藏 */
  #bottomNav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
    border-top: 3px solid #ffe1ef; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; gap: 4px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  #bottomNav::-webkit-scrollbar { display: none; }
  #bottomNav .nav-item { flex: 0 0 auto; min-width: 62px; flex-direction: column; gap: 2px; min-height: 56px; padding: 6px 4px; border-radius: 14px; box-shadow: none; background: transparent; }
  #bottomNav .nav-icon { font-size: 26px; }
  #bottomNav .nav-label { font-size: 11px; }
  #bottomNav .nav-label small { display: none; }
  #bottomNav .nav-item.active { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; }
  #content { padding-bottom: 90px; }
  .top-title { font-size: 17px; }
}
/* ============================================================
   打賞 / 客服 / 廣告 / 交叉引流
   ============================================================ */
.layout-center {
  flex: 1;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

/* 頂部操作按鈕 */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.top-btn {
  border: none; cursor: pointer; font-family: var(--font); font-weight: 700;
  border-radius: 14px; padding: 8px 12px; font-size: 14px;
  min-height: 38px; white-space: nowrap;
  background: #fff; color: var(--ink);
  box-shadow: 0 3px 0 rgba(0,0,0,.08);
  transition: transform .1s, box-shadow .1s;
}
.top-btn:active { transform: translateY(3px); box-shadow: none; }
.top-btn.tip-btn { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; box-shadow: 0 3px 0 var(--purple-d); }
.top-btn.cs-btn { background: linear-gradient(135deg, var(--blue), var(--green)); color: #144; box-shadow: 0 3px 0 var(--green-d); }

/* 側邊欄底部：交叉引流 + 重新開始 */
.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.promo-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #fff8f0, #fff);
  border: 2px dashed var(--yellow-d); border-radius: 18px;
  padding: 12px 10px; text-align: center; text-decoration: none;
  color: var(--ink); cursor: pointer; transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 0 rgba(245,197,24,.15);
}
.promo-card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(245,197,24,.2); }
.promo-card.vertical { gap: 8px; padding: 16px 10px; }
.promo-emoji { font-size: 34px; line-height: 1; }
.promo-card.vertical .promo-emoji { font-size: 44px; }
.promo-title { font-weight: 700; font-size: 15px; color: var(--purple-d); }
.promo-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.35; }

/* 廣告位（桌面兩側） */
.ad-rail {
  width: 170px; flex: 0 0 170px;
  background: rgba(255,255,255,.55);
  border-left: 3px solid #ffe1ef;
  border-right: 3px solid #ffe1ef;
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 10px; gap: 12px;
  overflow-y: auto;
}
.ad-rail.left { border-left: none; border-right: 3px solid #ffe1ef; }
.ad-rail.right { border-left: 3px solid #ffe1ef; border-right: none; }
.ad-tag {
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  background: rgba(255,255,255,.8); padding: 4px 10px; border-radius: 999px;
  margin-top: auto;
}
.ad-placeholder {
  width: 100%;
  min-height: 180px;
  border: 2px dashed var(--blue-d);
  border-radius: 18px;
  background: linear-gradient(160deg, #fff, #f0faff);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 12px; gap: 6px;
  color: var(--ink);
  cursor: pointer;
}
.ad-placeholder-title { font-weight: 700; font-size: 15px; color: var(--blue-d); }
.ad-placeholder-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.35; }
.ad-placeholder-hint {
  font-size: 11px; color: #fff; background: var(--blue-d);
  padding: 4px 10px; border-radius: 999px; margin-top: 4px;
}

/* 彈窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(60,45,75,.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  padding: 16px;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: var(--radius);
  width: min(520px, 100%);
  max-height: 86vh; overflow: hidden;
  box-shadow: 0 18px 50px rgba(80,50,100,.25);
  display: flex; flex-direction: column;
  animation: pop .25s ease;
}
.modal h3 {
  margin: 0; padding: 16px 18px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.modal h3 .close {
  border: none; background: rgba(255,255,255,.25); color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.modal h3 .close:active { background: rgba(255,255,255,.4); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-hint { margin: 0 0 14px; color: var(--ink-soft); font-size: 15px; text-align: center; }
.modal-note { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--ink-soft); }

/* 二維碼 */
.qr-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box.single { margin: 0 auto; max-width: 260px; }
.qr-frame {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 16px; overflow: hidden;
  background: #f8f8f8; border: 2px solid #eee;
  display: flex; align-items: center; justify-content: center;
}
.qr-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.qr-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 12px; gap: 8px;
  background: repeating-linear-gradient(45deg, #f8f8f8, #f8f8f8 10px, #fff 10px, #fff 20px);
  color: var(--ink-soft);
}
.qr-placeholder span { font-weight: 700; font-size: 14px; color: var(--pink-d); }
.qr-placeholder small { font-size: 11px; }
.qr-placeholder.hk span { color: var(--blue-d); }
.qr-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.qr-note { font-size: 11px; color: var(--ink-soft); margin-top: -4px; }
.cs-id {
  background: #f6fff9; border: 2px dashed var(--green-d); border-radius: 16px;
  padding: 16px; text-align: center; font-size: 15px; color: var(--ink);
}
.cs-id b { font-size: 18px; color: var(--green-d); letter-spacing: .5px; }
.cs-id small { font-size: 11px; color: var(--ink-soft); }

/* 客服郵件 */
.cs-email {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 12px;
  background: linear-gradient(135deg, var(--blue), var(--green-d));
  color: #144; font-weight: 700; font-size: 15px;
  border-radius: 16px; text-decoration: none;
  box-shadow: 0 4px 0 var(--green-d);
  transition: transform .1s;
}
.cs-email:active { transform: translateY(4px); box-shadow: none; }

/* ============================================================
   手機版：底部 Tab + 抽屜側欄
   ============================================================ */
@media (max-width: 767px) {
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-105%); transition: transform .25s ease;
    width: 78vw; max-width: 300px;
  }
  #sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  /* 漢堡選單已永久隱藏 */
  #bottomNav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
    border-top: 3px solid #ffe1ef; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; gap: 4px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  #bottomNav::-webkit-scrollbar { display: none; }
  #bottomNav .nav-item { flex: 0 0 auto; min-width: 62px; flex-direction: column; gap: 2px; min-height: 56px; padding: 6px 4px; border-radius: 14px; box-shadow: none; background: transparent; }
  #bottomNav .nav-icon { font-size: 26px; }
  #bottomNav .nav-label { font-size: 11px; }
  #bottomNav .nav-label small { display: none; }
  #bottomNav .nav-item.active { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; }
  #content { padding-bottom: 90px; }
  .top-title { font-size: 17px; }
  .top-btn { padding: 6px 10px; font-size: 12px; min-height: 32px; border-radius: 12px; }
  .ad-rail { display: none; }
  .promo-card { margin-top: 4px; }
  .modal { max-height: 92vh; }
  .qr-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (min-width: 768px) {
  #bottomNav { display: none; }
}

/* ===== 賬戶同步 ===== */
.top-btn.acct-btn {
  background: linear-gradient(135deg, #fff, #fff7e6);
  color: var(--gold, #c79a3a);
  border: 1px solid var(--gold, #c79a3a);
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
  position: relative;
}
.acct-sync-dot {
  display: inline-block;
  margin-left: 4px;
  width: 8px;
  height: 8px;
  vertical-align: middle;
}
.acct-sync-dot > span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
}
.acct-modal { max-width: 380px; width: 92vw; text-align: left; }
.acct-tabs { display: flex; gap: 8px; margin: 8px 0 14px; }
.acct-tab {
  flex: 1; padding: 6px 0; text-align: center;
  background: #fff; border: 1px solid #ddd; border-radius: 6px;
  cursor: pointer; font-family: inherit; font-size: 13px;
}
.acct-tab.active { background: var(--gold, #c79a3a); color: #fff; border-color: var(--gold, #c79a3a); }
.acct-modal .ctl {
  display: flex; align-items: center; gap: 8px; margin: 6px 0;
}
.acct-modal .ctl span { min-width: 90px; font-size: 13px; color: #666; }
.acct-modal .ctl input {
  flex: 1; border: 1px solid #ddd; border-radius: 6px;
  padding: 6px 10px; font-size: 14px; font-family: inherit; outline: none;
}
.acct-modal .ctl input:focus { border-color: var(--gold, #c79a3a); }
.acct-submit {
  width: 100%; background: var(--gold, #c79a3a); color: #fff; border: none;
  border-radius: 6px; padding: 9px; margin-top: 10px;
  font-size: 14px; cursor: pointer; font-family: inherit; font-weight: 600;
}
.acct-sub-hint { font-size: 11px; color: #999; margin-top: 6px; text-align: center; }
.acct-msg { min-height: 18px; font-size: 12px; color: #e74c3c; margin-top: 8px; text-align: center; }
.acct-info {
  background: #fff7e6; border-radius: 8px; padding: 12px; margin: 8px 0;
}
.acct-line {
  font-size: 13px; line-height: 1.9;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.acct-line b { min-width: 60px; color: #888; font-weight: 600; }
.acct-invite {
  font-family: Menlo, Consolas, monospace; font-size: 18px; font-weight: 700;
  color: var(--gold, #c79a3a); letter-spacing: 2px;
  background: #fff; padding: 2px 8px; border-radius: 4px;
}
.acct-role { font-size: 11px; color: #888; background: #eee; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acct-mini {
  flex: 1; min-width: 80px;
  background: #fff; border: 1px solid #ddd; border-radius: 6px;
  padding: 6px 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.acct-mini:hover { background: #fff7e6; }
.acct-hint { font-size: 13px; color: #666; margin: 8px 0; line-height: 1.6; }
