/* ========================
   全局样式 + CSS变量
======================= */
:root {
 --theme-color: #01B7ED;
 --card-bg: #1B1826;
 --text-main: #FFFFFF;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
 min-height: 100vh;
 background: #050a1f;
 font-family: 'Noto Sans TC', 'Microsoft JhengHei', -apple-system, sans-serif;
 color: #fff;
 overflow-x: hidden;
}

/* 页面切换 */
.page { display: none; }
.page.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* 首页 */
.home-bg {
 position: fixed; inset: 0;
 background: linear-gradient(135deg, #050a1f 0%, #0a1035 50%, #050a1f 100%);
 z-index: 0;
 overflow: hidden;
}
.home-bg::before {
 content: '';
 position: absolute; inset: 0;
 background: radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.8) 0%, transparent 100%),
 radial-gradient(2px 2px at 80% 20%, rgba(255,255,255,0.6) 0%, transparent 100%),
 radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.5) 0%, transparent 100%),
 radial-gradient(2px 2px at 60% 50%, rgba(255,255,255,0.7) 0%, transparent 100%),
 radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.4) 0%, transparent 100%);
 background-size: 300px 300px, 250px 250px, 200px 200px, 350px 350px, 180px 180px;
 animation: star-move 60s linear infinite;
}
@keyframes star-move {
 from { transform: translateY(0); }
 to { transform: translateY(-300px); }
}

.home-content { position: relative; z-index: 1; text-align: center; padding: 20px; }
.home-title {
 font-size: 2.5rem; font-weight: 900;
 background: linear-gradient(90deg, #ffd700, #ff9a3c, #ffd700);
 -webkit-background-clip: text; -webkit-text-fill-color: transparent;
 margin-bottom: 8px;
 text-shadow: 0 0 30px rgba(255,215,0,0.3);
}
.home-sub { font-size: 1rem; color: rgba(255,255,255,0.55); margin-bottom: 30px; letter-spacing: 2px; }
.home-input {
 background: rgba(255,255,255,0.08);
 border: 1px solid rgba(255,255,255,0.2);
 border-radius: 14px;
 padding: 13px 22px;
 font-size: 1rem;
 color: #fff;
 width: 240px;
 text-align: center;
 outline: none;
 transition: border-color 0.3s;
}
.home-input::placeholder { color: rgba(255,255,255,0.35); }
.home-input:focus { border-color: rgba(255,215,0,0.6); }

.draw-btn {
 margin-top: 22px;
 background: linear-gradient(135deg, #ffd700, #ffaa00);
 color: #111;
 border: none;
 border-radius: 50px;
 padding: 15px 48px;
 font-size: 1.15rem;
 font-weight: 900;
 cursor: pointer;
 letter-spacing: 3px;
 box-shadow: 0 4px 25px rgba(255,215,0,0.35);
 transition: transform 0.2s, box-shadow 0.2s;
}
.draw-btn:hover { transform: scale(1.05); box-shadow: 0 6px 35px rgba(255,215,0,0.5); }
.draw-btn:active { transform: scale(0.97); }

/* 背景音乐按钮 */
.bgm-toggle {
 position: fixed; top: 14px; right: 14px;
 background: rgba(255,255,255,0.08);
 border: 1px solid rgba(255,255,255,0.18);
 border-radius: 50%;
 width: 46px; height: 46px;
 cursor: pointer; color: #fff;
 font-size: 1.3rem;
 z-index: 200;
 backdrop-filter: blur(8px);
 transition: background 0.2s;
}
.bgm-toggle:hover { background: rgba(255,255,255,0.15); }

/* ========================
   结果页 - 玻璃拟态风格
======================= */
.result-view {
 background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
 min-height: 100vh; padding: 20px;
 color: #fff;
}

.user-info-banner { text-align: center; font-size: 0.9rem; color: #aaa; margin-bottom: 10px; }
.rarity-banner { 
 background: #f39c12; color: #000; text-align: center; 
 padding: 10px; border-radius: 50px; font-weight: 900; 
 margin-bottom: 20px; box-shadow: 0 4px 15px rgba(243,156,18,0.3);
}

.char-modal {
 background: linear-gradient(180deg, rgba(27,24,38,1) 0%, rgba(18,16,26,1) 100%);
 border: 1px solid rgba(255, 255, 255, 0.1);
 border-radius: 16px;
 padding: 24px;
 box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--theme-color) inset;
}

.modal-header {
 display: flex; align-items: center; gap: 20px;
 border-bottom: 1px solid rgba(255, 255, 255, 0.05);
 padding-bottom: 20px; margin-bottom: 24px;
}

.avatar {
 width: 100px; height: 100px;
 border-radius: 50%; object-fit: cover;
 border: 3px solid var(--theme-color);
 box-shadow: 0 0 15px var(--theme-color);
}

.char-name {
 font-size: 24px; font-weight: bold; margin: 0 0 4px 0;
 color: var(--theme-color);
 text-shadow: 0 0 5px rgba(255,255,255,0.2);
}

.tags-container { display: flex; gap: 8px; margin-top: 8px; }
.tag {
 background: rgba(255, 255, 255, 0.1);
 padding: 4px 10px; border-radius: 20px; font-size: 12px;
}

.song-box {
 display: flex; align-items: center; gap: 8px;
 background: rgba(255, 255, 255, 0.03);
 padding: 10px 14px; border-radius: 8px; margin-bottom: 24px;
}

.section-title { font-size: 16px; font-weight: bold; margin: 20px 0 10px 0; }
.section-title::before { content: "◆"; color: var(--theme-color); margin-right: 6px; }

.quote-box {
 background: linear-gradient(90deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 100%);
 border-left: 4px solid var(--theme-color);
 padding: 12px 16px; border-radius: 0 8px 8px 0;
 font-style: italic; margin: 16px 0;
}

.trivia-box {
 background: rgba(255, 255, 255, 0.05);
 border-radius: 12px; padding: 16px; margin-top: 10px;
}

/* 头像边框（应援色） */
#card-image {
  border: 3px solid var(--theme-color);
  border-radius: 8px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 圓形立繪 */
.avatar-wrapper {
 width: 100px; height: 100px; border-radius: 50%;
 overflow: hidden; flex-shrink: 0;
 background: #000; position: relative;
 /* 邊框加粗，準備接收稀有度顏色 */
 border: 3px solid #fff;
}
.avatar-wrapper img { width: 100%; height: 100%; object-fit: cover; }

.basic-info h1 { margin: 0; font-size: 1.5rem; letter-spacing: 1px; }
.jp-name { color: #888; font-size: 0.8rem; margin: 2px 0; }
.cv-info { color: #aaa; font-size: 0.85rem; margin: 5px 0; }

.tags-row { display: flex; gap: 8px; margin: 8px 0; }
.tag-label { background: #3498db; color: #fff; padding: 2px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; }
.tag-label.secondary { background: #555; }

.solo-song { font-size: 0.85rem; color: #ff4757; font-weight: bold; }

.audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: #ff4757;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.audio-btn svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 0px transparent);
  transition: filter 0.2s ease;
}
.audio-btn:hover {
  transform: scale(1.15);
}
.audio-btn.playing {
  animation: audioPulse 0.8s ease-in-out infinite;
}
/* Dark color icons need white glow to be visible on dark bg */
.audio-btn.dark-color svg {
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.9)) drop-shadow(0 0 6px rgba(255,255,255,0.5));
}

@keyframes audioPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 文本內容排版：防止單字掉行 */
.section-content { margin-bottom: 15px; }
.section-label { 
 font-size: 0.85rem; margin-bottom: 8px; font-weight: bold; 
 /* 顏色將由 JS 動態賦予 */
 letter-spacing: 1px;
}
.desc-text { 
 font-size: 0.9rem; line-height: 1.6; color: #ddd; 
 text-align: justify; /* 兩端對齊 */
 word-break: break-all; /* 防止單字意外折斷 */
}
.quote-line { 
 color: #aaa; font-style: italic; margin-top: 10px; font-size: 0.9rem; 
 /* 增加微透明背景與動態左邊框 */
 border-left: 3px solid #555; 
 padding: 6px 10px; 
 background: rgba(255,255,255,0.03);
 border-radius: 0 8px 8px 0;
}

/* 底部獨立區塊 */
.trivia-footer-box {
 background: rgba(0,0,0,0.4); padding: 15px; border-radius: 12px; margin-top: 20px;
 border: 1px solid rgba(255,255,255,0.05);
}
.trivia-text { font-size: 0.85rem; color: #bbb; line-height: 1.5; }

.btn-close { 
 display: block; width: fit-content; margin: 25px auto;
 background: none; border: 1px solid #444; color: #888;
 padding: 8px 30px; border-radius: 20px; cursor: pointer;
}

.btn-back-home {
 display: block; width: fit-content; margin: 25px auto;
 background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
 border: 1.5px solid rgba(255,255,255,0.4);
 color: #fff; padding: 12px 40px; border-radius: 30px; cursor: pointer;
 font-size: 14px; font-weight: 300; letter-spacing: 2px;
 backdrop-filter: blur(10px);
 box-shadow: 0 4px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
 transition: all 0.3s ease;
}
.btn-back-home:hover {
 background: linear-gradient(135deg, rgba(255,255,255,0.25), rgba(255,255,255,0.1));
 border-color: rgba(255,255,255,0.6);
 transform: translateY(-2px);
 box-shadow: 0 6px 25px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* 结果页布局容器 */
.result-container {
 width: 100%;
 max-width: 480px;
 margin: 0 auto;
 padding: 0 16px;
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 12px;
}

/* Toast */
#toast {
 position: fixed; bottom: 80px; left: 50%;
 transform: translateX(-50%) translateY(20px);
 background: rgba(0,0,0,0.85);
 color: #fff;
 padding: 12px 24px;
 border-radius: 12px;
 font-size: 0.95rem;
 opacity: 0;
 transition: opacity 0.3s, transform 0.3s;
 pointer-events: none;
 z-index: 9999;
 white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 虹咲學園 彩虹頭框動畫 */
@keyframes rainbow-border {
 0%   { border-color: #ff0000; box-shadow: 0 0 15px #ff000066; }
 14%  { border-color: #ff8000; box-shadow: 0 0 15px #ff800066; }
 28%  { border-color: #ffff00; box-shadow: 0 0 15px #ffff0066; }
 42%  { border-color: #00ff00; box-shadow: 0 0 15px #00ff0066; }
 57%  { border-color: #0080ff; box-shadow: 0 0 15px #0080ff66; }
 71%  { border-color: #8000ff; box-shadow: 0 0 15px #8000ff66; }
 85%  { border-color: #ff00ff; box-shadow: 0 0 15px #ff00ff66; }
 100% { border-color: #ff0000; box-shadow: 0 0 15px #ff000066; }
}
.avatar-wrapper.rainbow {
 border: 3px solid transparent;
 animation: rainbow-border 2.5s linear infinite;
}

/* 虹咲學園 彩虹卡片框（從上到下漸變） */
.main-card.rainbow {
 border: 3px solid transparent;
 border-image: linear-gradient(180deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b) 1;
}
/* 首页两排图片布局 */
.group-row {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 6px;
  justify-content: center;
}

.group-img {
  width: calc(50% - 3px);
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 6px;
}

/* 四个角落音乐按钮 */
.corner-audio {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
}

.corner-btn {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.corner-btn:active { transform: scale(0.95); }

.corner-mus {
  top: 12px; left: 12px;
  background: rgba(233, 30, 99, 0.75);
  box-shadow: 0 0 12px rgba(233, 30, 99, 0.6);
}

.corner-aqours {
  top: 12px; right: 12px;
  background: rgba(0, 159, 232, 0.75);
  box-shadow: 0 0 12px rgba(0, 159, 232, 0.6);
}

.corner-niji {
  bottom: 12px; left: 12px;
  background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  background-size: 300% 300%;
  animation: rainbowBg 3s ease infinite;
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.5);
}

.corner-liella {
  bottom: 12px; right: 12px;
  background: rgba(155, 89, 182, 0.75);
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.6);
}

@keyframes rainbowBg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 图鉴页面 */
#gallery-page {
  background: linear-gradient(135deg, #0a0518 0%, #1a0a28 50%, #0a0518 100%);
  min-height: 100vh;
  overflow-y: auto;
  padding: 12px 8px 40px;
  box-sizing: border-box;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #0a0518 0%, #1a0a28 50%, #0a0518 100%);
  z-index: 10;
}

.gallery-header h2 {
  color: #fff;
  margin: 0;
  font-size: 18px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px 0;
}

.gallery-item {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
}

.gallery-avatar {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.gallery-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-name {
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-group {
  font-size: 9px;
  margin-top: 2px;
  opacity: 0.8;
}

.gallery-group.rainbow-text {
  background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gallery-header .btn-close {
  background: transparent;
  border: none;
  color: rgba(150,100,180,0.6);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  padding: 0;
  margin-right: 4px;
  transition: color 0.2s ease, transform 0.2s ease;
  border-radius: 4px;
}
.gallery-header .btn-close:hover {
  color: #9D5BFF;
  transform: scale(1.1);
}
