/* ============================================================
   星光偶像学园 · VN 界面样式
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #1a2148 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 110%, #261a4a 0%, transparent 55%),
    #07070f;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  overflow: hidden;
}
#app { height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---------- 舞台 ---------- */
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 0 90px rgba(80, 90, 255, .18), 0 0 18px rgba(0,0,0,.8);
  user-select: none;
  cursor: pointer;
}
#bgLayer, #cgLayer, #spriteLayer, #fxLayer { position: absolute; inset: 0; pointer-events: none; }
#bgLayer { z-index: 0; }
#bgImg { width: 100%; height: 100%; object-fit: cover; opacity: 1; transition: opacity .55s ease; }
#bgVeil { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6,6,16,.55) 0%, transparent 22%, transparent 62%, rgba(4,5,14,.82) 88%),
    radial-gradient(120% 90% at 50% 30%, transparent 55%, rgba(2,2,10,.4) 100%); }
#cgLayer { z-index: 2; opacity: 0; transition: opacity .5s ease; }
#cgLayer.hidden { display: none; }
#cgImg { width: 100%; height: 100%; object-fit: cover; }
#spriteLayer { z-index: 3; }
#fxLayer { z-index: 6; overflow: hidden; }

/* ---------- 立绘 ---------- */
.sprite { position: absolute; bottom: -1%; height: 86%; z-index: 3; filter: drop-shadow(0 12px 26px rgba(0,0,0,.45)); transform-origin: bottom center; }
.sprite img { height: 100%; width: auto; opacity: 0; transition: opacity .55s ease; animation: idle 5.2s ease-in-out infinite; }
.sprite.in img { opacity: 1; }
.sprite.left  { left: 1%; }
.sprite.right { right: 1%; transform: scaleX(-1); }
.sprite.right img { animation-name: idleFlip; }
.sprite.center { left: 50%; transform: translateX(-50%); height: 92%; }
.sprite.center.end-sprite { bottom: -2%; height: 96%; }
@keyframes idle { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes idleFlip { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-7px); } }

/* ---------- 好感计量器 ---------- */
#meter {
  position: absolute; top: 1.2%; left: 1.2%; z-index: 8; display: flex; flex-wrap: wrap; gap: 4px;
  max-width: 66%;
}
.meter-item {
  display: flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px;
  background: rgba(6,8,22,.6); border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px; backdrop-filter: blur(3px);
  transition: transform .2s;
}
.meter-item.pulse { animation: meterPulse .5s ease; }
@keyframes meterPulse { 0%{transform:scale(1)} 35%{transform:scale(1.16)} 100%{transform:scale(1)} }
.m-name { font-size: clamp(9px, 1.2vw, 13px); font-weight: 700; letter-spacing: 1px; color: var(--mc); text-shadow: 0 0 8px var(--mc); }
.m-hearts { display: inline-flex; letter-spacing: -1px; }
.mh { font-size: clamp(9px, 1.1vw, 12px); color: rgba(255,255,255,.18); }
.mh.on { color: var(--mc); text-shadow: 0 0 7px var(--mc); }

.float-heart {
  position: absolute; bottom: -4%; font-size: clamp(14px, 2.2vw, 26px);
  animation: rise 1.2s ease-out forwards; opacity: .95; text-shadow: 0 0 10px currentColor; z-index: 9;
}
@keyframes rise {
  0% { transform: translateY(0) scale(.7); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translateY(-48vh) scale(1.3) rotate(8deg); opacity: 0; }
}

/* ---------- 顶部工具条 ---------- */
#topBar { position: absolute; top: 1%; right: 1%; z-index: 8; display: flex; gap: 5px; align-items: center; }
#chapterTag { font-size: clamp(8px, 1vw, 12px); color: rgba(255,255,255,.55); background: rgba(0,0,0,.3); padding: 3px 10px; border-radius: 999px; letter-spacing: 2px; }
.tb {
  border: 1px solid rgba(255,255,255,.22); background: rgba(8,10,26,.55); color: #dfe6ff;
  font-size: clamp(10px, 1vw, 12px); padding: 3px 11px; border-radius: 999px; cursor: pointer;
  font-family: inherit; letter-spacing: 1px;
}
.tb:hover, .tb.active { background: rgba(120,130,255,.35); color: #fff; }

/* ---------- 对话 ---------- */
#dialogBox {
  position: absolute; z-index: 7; left: 3%; right: 3%; bottom: 2.4%;
  min-height: 25%;
  background: linear-gradient(180deg, rgba(10,13,32,.16), rgba(7,9,24,.86) 30%, rgba(5,7,20,.94));
  border: 1px solid rgba(255,255,255,.16); border-radius: 16px;
  padding: 12px 26px 22px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
}
#namePlate {
  display: inline-block; position: relative; top: -27px; margin-bottom: -18px;
  font-size: clamp(12px, 1.6vw, 17px); font-weight: 800; letter-spacing: 2px;
  background: rgba(8,10,26,.96); border: 1px solid; border-bottom: none;
  border-radius: 10px 10px 0 0; padding: 5px 16px 7px;
  text-shadow: 0 0 10px currentColor;
}
#namePlate.hidden { display: none; }
#dialogText {
  --ncolor: #e8ecff;
  color: var(--ncolor); font-size: clamp(14px, 1.75vw, 19px); line-height: 1.85;
  min-height: 5.4em; text-shadow: 0 1px 3px rgba(0,0,0,.8);
  letter-spacing: .6px;
}
#nextMark {
  position: absolute; right: 18px; bottom: 10px; color: rgba(255,255,255,.8);
  animation: blink 1s infinite; font-size: clamp(10px, 1.3vw, 14px);
}
#nextMark.hidden { display: none; }
@keyframes blink { 0%,100%{opacity:.25; transform:translateY(0)} 50%{opacity:1; transform:translateY(3px)} }

/* ---------- 选项 ---------- */
#choiceBox {
  position: absolute; z-index: 9; right: 4%; bottom: 30%; width: 62%; max-width: 760px;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
#choiceBox.hidden { display: none; }
.choice {
  pointer-events: auto; display: flex; align-items: center; gap: 13px; text-align: left;
  background: linear-gradient(100deg, rgba(12,15,38,.88), rgba(20,24,56,.72));
  border: 1px solid rgba(255,255,255,.22); border-radius: 13px;
  padding: 10px 18px; color: #f2f4ff; cursor: pointer; font-family: inherit;
  font-size: clamp(13px, 1.45vw, 17px); line-height: 1.55; letter-spacing: .5px;
  box-shadow: 0 5px 16px rgba(0,0,0,.35); backdrop-filter: blur(4px);
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease, background .2s;
  animation: choiceIn .35s ease backwards;
}
.choice:nth-child(2) { animation-delay: .06s; } .choice:nth-child(3) { animation-delay: .12s; }
.choice:nth-child(4) { animation-delay: .18s; } .choice:nth-child(5) { animation-delay: .24s; }
@keyframes choiceIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: translateX(0); } }
.choice:hover {
  border-color: var(--cc); background: linear-gradient(100deg, rgba(24,20,56,.92), rgba(34,26,80,.85));
  transform: translateX(6px); box-shadow: 0 0 20px color-mix(in srgb, var(--cc) 45%, transparent);
}
.ch-badge {
  flex: 0 0 auto; width: 27px; height: 27px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 900; color: #101022;
  background: var(--cc); box-shadow: 0 0 12px color-mix(in srgb, var(--cc) 70%, transparent);
  font-size: 14px;
}

/* ---------- toast ---------- */
#toast {
  position: absolute; z-index: 10; top: 8%; left: 50%; transform: translate(-50%, -8px);
  background: rgba(10,12,30,.9); border: 1px solid rgba(255,255,255,.3); color: #ffe9a8;
  padding: 6px 20px; border-radius: 999px; font-size: clamp(11px, 1.3vw, 14px);
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.hidden { display: none; }

/* ---------- 标题 ---------- */
#titleScreen { position: absolute; inset: 0; z-index: 20; }
#titleScreen.hidden { display: none; }
.title-bg { position: absolute; inset: 0; background: url('../assets/bg/title.jpg') center/cover no-repeat;
  filter: brightness(.55) saturate(1.05); }
.title-bg::after { content: ''; position: absolute; inset: 0;
  background: radial-gradient(90% 70% at 50% 42%, rgba(10,14,60,.25), rgba(4,4,16,.92)); }
.starfield { position: absolute; inset: 0; opacity: .9; pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, #fff 60%, transparent), radial-gradient(1.2px 1.2px at 68% 14%, #ffe 60%, transparent),
    radial-gradient(1.6px 1.6px at 82% 62%, #fff 60%, transparent), radial-gradient(1px 1px at 38% 74%, #ffe 60%, transparent),
    radial-gradient(1.3px 1.3px at 54% 38%, #fff 60%, transparent), radial-gradient(1px 1px at 8% 58%, #ffe 60%, transparent),
    radial-gradient(1.2px 1.2px at 92% 32%, #fff 60%, transparent), radial-gradient(1px 1px at 30% 6%, #ffe 60%, transparent);
  animation: twinkle 4s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .45; } to { opacity: 1; } }
.title-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; z-index: 2; }
.logo-kicker { font-size: clamp(8px, 1.05vw, 13px); letter-spacing: 5px; color: #ffd98e; opacity: .9; margin-bottom: 8px; font-weight: 600; }
.logo-main {
  font-size: clamp(34px, 6.4vw, 84px); font-weight: 900; letter-spacing: 12px; line-height: 1.12;
  background: linear-gradient(180deg, #fff7e0 8%, #ffd98e 46%, #ff9ecf 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255,190,120,.35)) drop-shadow(0 0 30px rgba(180,150,255,.25));
}
.logo-sub { margin-top: 6px; font-size: clamp(12px, 1.6vw, 19px); color: #dbe4ff; letter-spacing: 8px; }
.title-menu { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; width: min(300px, 58%); }
.tbtn {
  font-family: inherit; cursor: pointer; border-radius: 999px; padding: 11px 0;
  border: 1px solid rgba(255,255,255,.35); background: rgba(16,20,48,.55); color: #eef2ff;
  font-size: clamp(13px, 1.5vw, 17px); letter-spacing: 4px; transition: all .18s ease; backdrop-filter: blur(4px);
}
.tbtn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(120,130,255,.35); }
.tbtn.primary {
  background: linear-gradient(100deg, #f6c96f, #ff9ecf); border: none; color: #24103a; font-weight: 800;
  box-shadow: 0 6px 22px rgba(255,150,200,.4);
}
.tbtn.primary:hover { filter: brightness(1.08); }
/* ---------- 语言切换 (title) ---------- */
.title-lang {
  margin-top: 20px; display: inline-flex; gap: 4px; padding: 4px;
  background: rgba(16,20,48,.62); border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px; backdrop-filter: blur(4px);
}
.langbtn {
  font-family: inherit; cursor: pointer; border: none; background: transparent;
  color: rgba(235,240,255,.72); font-size: clamp(11px, 1.25vw, 14px); letter-spacing: 2px;
  padding: 6px 20px; border-radius: 999px; transition: all .18s ease;
}
.langbtn:hover { color: #fff; }
.langbtn.active {
  background: linear-gradient(100deg, #f6c96f, #ff9ecf); color: #24103a; font-weight: 800;
  box-shadow: 0 4px 14px rgba(255,150,200,.4);
}
.title-foot { margin-top: 20px; font-size: clamp(10px, 1.25vw, 14px); color: rgba(235,240,255,.75); line-height: 2; letter-spacing: 2px; }
.credit { position: absolute; bottom: 2.2%; width: 100%; text-align: center; z-index: 3; font-size: clamp(8px, .95vw, 11px); color: rgba(255,255,255,.35); letter-spacing: 2px; }

/* ---------- 结局 ---------- */
#endScreen { position: absolute; inset: 0; z-index: 18; background: rgba(3,4,12,.55); }
#endScreen.hidden { display: none; }
#endBackdrop { position: absolute; inset: 0; background: center/cover no-repeat; filter: brightness(.5) blur(2px) saturate(1.1); transform: scale(1.03); }
#endScreen .sprite { height: 98%; bottom: -3%; z-index: 2; opacity: 1; }
/* 结局布局：有角色时——左立绘 + 右文案 */
#endScreen.withHero .end-hero { left: 2%; bottom: -3%; height: 102%; z-index: 3; }
#endScreen.withHero .end-hero img { filter: drop-shadow(0 0 26px rgba(0,0,0,.4)); }
#endScreen.withHero #endInner { left: 56%; top: 50%; transform: translate(-50%, -50%); width: min(660px, 46%); }
#endScreen.withHero #endLines { max-width: 620px; }
#endScreen.withHero #endLines p { font-size: clamp(12px, 1.35vw, 16px); line-height: 1.9; }
#endInner {
  position: absolute; z-index: 4; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(880px, 94%); max-height: 94%; overflow-y: auto;
  background: linear-gradient(180deg, rgba(9,11,28,.62), rgba(7,9,24,.9));
  border: 1px solid rgba(255,255,255,.22); border-radius: 22px;
  padding: 30px 44px 24px; text-align: center; backdrop-filter: blur(8px);
  box-shadow: 0 20px 70px rgba(0,0,0,.65);
}
#endStamp { display: inline-block; border: 1px solid #fff; color: #fff; border-radius: 8px; padding: 3px 16px; font-size: clamp(10px,1.2vw,14px); letter-spacing: 6px; opacity: .95; }
#endTitle { margin-top: 10px; font-size: clamp(22px, 3vw, 38px); font-weight: 900; letter-spacing: 5px; color: #fff; text-shadow: 0 0 24px rgba(255,220,150,.45); }
#endChar { margin-top: 2px; font-size: clamp(11px, 1.3vw, 15px); color: rgba(255,255,255,.6); letter-spacing: 3px; }
#endLines { margin: 16px auto 0; max-width: 680px; text-align: left; }
#endLines p { color: #e9ecff; font-size: clamp(13px, 1.5vw, 17px); line-height: 2.05; letter-spacing: .6px; margin-bottom: 6px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
#endHearts { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.end-heart-chip {
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.05);
  border-radius: 999px; padding: 3px 12px; font-size: clamp(10px,1.2vw,14px); color: var(--mc);
}
.end-heart-chip b { color: var(--mc); letter-spacing: 0; }
.end-heart-chip i { font-style: normal; color: rgba(255,255,255,.18); }
#endButtons { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#endButtons .tbtn { padding: 9px 22px; letter-spacing: 2px; }

/* ---------- 图鉴 / 帮助 ---------- */
#galleryScreen, #helpScreen { position: absolute; inset: 0; z-index: 30; background: rgba(4,5,14,.9); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; }
#galleryScreen.hidden, #helpScreen.hidden { display: none; }
.gal-inner, .help-inner { width: min(860px, 92%); max-height: 92%; overflow-y: auto; text-align: center; padding: 26px 20px; }
.gal-inner h2, .help-inner h2 { color: #ffe6b0; letter-spacing: 8px; font-size: clamp(18px,2.4vw,30px); margin-bottom: 18px; text-shadow: 0 0 18px rgba(255,200,120,.4); }
#galleryGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gal-card {
  background: linear-gradient(170deg, rgba(30,34,80,.7), rgba(10,12,30,.9));
  border: 1px solid rgba(255,255,255,.15); border-radius: 18px; padding: 16px 10px 12px;
  transition: transform .2s;
}
.gal-card:hover { transform: translateY(-4px); }
.gal-card.group { grid-column: span 1; opacity: .85; }
.gal-avatar {
  width: 72px; height: 96px; margin: 0 auto 8px; border-radius: 12px; overflow: hidden;
  border: 1px solid #888; display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #ffe6b0;
}
.gal-avatar img { height: 100%; width: auto; object-fit: contain; }
.gal-name { font-weight: 800; font-size: 16px; letter-spacing: 2px; }
.gal-end { font-size: 12px; color: rgba(255,255,255,.55); margin: 3px 0 6px; }
.gal-stars { color: #ffd98e; letter-spacing: 4px; font-size: 15px; }
.help-inner ul { list-style: none; color: #dce2ff; font-size: clamp(13px,1.5vw,17px); line-height: 2.2; text-align: left; display: inline-block; }
.help-inner li { padding-left: 18px; position: relative; }
.help-inner li::before { content: '✦'; position: absolute; left: 0; color: #ffd98e; }
#galleryScreen .tbtn, #helpScreen .tbtn { margin-top: 18px; padding: 10px 34px; }

/* ---------- 菜单 overlay ---------- */
.menu-overlay { position: absolute; inset: 0; z-index: 40; background: rgba(3,4,12,.66); display: flex; align-items: center; justify-content: center; }
.menu-panel { width: min(320px, 80%); background: rgba(10,12,30,.96); border: 1px solid rgba(255,255,255,.2); border-radius: 18px; padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.menu-panel h3 { color: #ffe6b0; letter-spacing: 6px; margin-bottom: 4px; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
