/* ============ 星语心愿 · Stellar Hearts ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --pink:  #ff7eb6;
  --blue:  #7aa8ff;
  --gold:  #ffd76e;
  --bg:    #0b0e1d;
  --panel: rgba(10, 14, 32, .86);
  --line:  rgba(255, 255, 255, .1);
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: #f0f2ff;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- 屏幕切换 ---------- */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; animation: screenIn .5s ease both; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 通用背景 ---------- */
.bg-holder { position: absolute; inset: 0; }
.bg-holder::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
}
.bg-holder img, .bg-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: var(--bg);
}

/* ================= 标题界面 ================= */
#screen-title { display: none; }
#screen-title.active { display: flex; align-items: center; justify-content: center; }

.title-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(5,8,20,.72) 100%); }

.title-inner { position: relative; z-index: 2; text-align: center; animation: floatY 6s ease-in-out infinite; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.logo {
  font-size: clamp(46px, 9vw, 100px);
  letter-spacing: .18em;
  font-weight: 900;
  background: linear-gradient(180deg, #fff 15%, #ffd6e8 40%, #ff7eb6 65%, #7aa8ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(255, 126, 182, .45));
}
.logo-en {
  display: block; font-size: clamp(12px, 1.6vw, 18px);
  letter-spacing: .9em; text-indent: .9em; margin-top: 10px;
  color: rgba(255,255,255,.75); font-weight: 300;
}
.subtitle { margin: 18px 0 40px; color: rgba(255,255,255,.8); letter-spacing: .3em; font-size: 15px; }

.menu { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.menu-btn {
  width: 280px; padding: 13px 0;
  font-size: 17px; letter-spacing: .3em; text-indent: .3em; color: #fff;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(6px);
  transition: all .25s ease;
}
.menu-btn:hover { background: rgba(255,126,182,.22); border-color: var(--pink); box-shadow: 0 0 22px rgba(255,126,182,.35); transform: translateY(-2px); }
.menu-btn:disabled { opacity: .35; cursor: not-allowed; }
.menu-btn.small { width: 180px; font-size: 14px; padding: 9px 0; }
.menu-btn.highlight { border-color: var(--gold); color: var(--gold); }
.menu-btn.highlight:hover { background: rgba(255,215,110,.18); box-shadow: 0 0 22px rgba(255,215,110,.35); }

.ver { margin-top: 46px; font-size: 12px; color: rgba(255,255,255,.4); letter-spacing: .1em; }

/* ================= 选关界面 ================= */
.select-inner {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 34px 20px 20px; overflow-y: auto;
}
.sec-title { font-size: clamp(22px, 3.4vw, 34px); letter-spacing: .3em; text-shadow: 0 2px 18px rgba(0,0,0,.8); }
.sec-sub { margin: 10px 0 26px; color: rgba(255,255,255,.66); font-size: 13px; letter-spacing: .08em; }

.char-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 218px)); gap: 18px;
  justify-content: center; width: 100%; max-width: 1240px; padding-bottom: 20px;
}
.char-card {
  position: relative; border-radius: 16px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; transition: all .28s ease;
  animation: cardIn .5s ease both;
}
.char-card:nth-child(1) { animation-delay: .05s; } .char-card:nth-child(2) { animation-delay: .12s; }
.char-card:nth-child(3) { animation-delay: .19s; } .char-card:nth-child(4) { animation-delay: .26s; }
.char-card:nth-child(5) { animation-delay: .33s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.char-card:hover { transform: translateY(-7px); border-color: var(--card, var(--pink)); box-shadow: 0 12px 34px rgba(0,0,0,.5), 0 0 24px color-mix(in srgb, var(--card) 40%, transparent); }
.char-card.locked { filter: grayscale(.9); opacity: .55; cursor: not-allowed; }
.char-card.locked:hover { transform: none; box-shadow: none; border-color: var(--line); }

.card-avatar { height: 210px; overflow: hidden; border-bottom: 1px solid var(--line); }
.card-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 38%; }

.card-body { padding: 12px 14px 14px; }
.card-lv { font-size: 11px; letter-spacing: .2em; color: var(--card, var(--pink)); }
.card-name { font-size: 19px; font-weight: 700; margin: 3px 0 6px; }
.card-tag { font-size: 12px; color: rgba(255,255,255,.62); line-height: 1.5; min-height: 36px; }
.card-status { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.card-clear { color: var(--gold); }
.card-clear.normal { color: #b9c3e8; }
.card-resume { color: #8fe3b0; }

.back-btn {
  position: absolute; left: 22px; top: 22px; z-index: 5;
  padding: 8px 18px; font-size: 14px; color: rgba(255,255,255,.8);
  background: rgba(10,14,32,.6); border: 1px solid var(--line); border-radius: 999px;
  transition: all .2s;
}
.back-btn:hover { color: #fff; border-color: var(--pink); }

/* ================= 游戏界面 ================= */
#screen-game { cursor: pointer; }

.sprite-wrap {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  height: 82%; display: flex; align-items: flex-end; z-index: 2;
  pointer-events: none;
}
#sprite {
  height: 100%; max-width: 92vw; object-fit: contain;
  filter: drop-shadow(0 10px 28px rgba(0,0,0,.5));
  transition: opacity .45s ease, transform .45s ease;
  animation: spriteIn .6s ease both;
}
@keyframes spriteIn { from { opacity: 0; transform: translateY(36px) scale(.98); } to { opacity: 1; transform: none; } }
#sprite.fx-happy   { animation: fxBounce .7s ease; }
#sprite.fx-shy     { animation: fxWobble .8s ease; }
#sprite.fx-surp    { animation: fxJump .55s ease; }
#sprite.fx-out     { opacity: 0; transform: translateY(30px); }
@keyframes fxBounce { 0% { transform: none; } 30% { transform: translateY(-14px) rotate(-2deg); } 60% { transform: translateY(0) rotate(1deg); } 100% { transform: none; } }
@keyframes fxWobble { 0%,100% { transform: none; } 25% { transform: rotate(-2.5deg); } 50% { transform: rotate(2deg); } 75% { transform: rotate(-1.2deg); } }
@keyframes fxJump   { 0% { transform: none; } 35% { transform: translateY(-24px) scale(1.03); } 100% { transform: none; } }

/* Q 版人物：对话框上方居中 */
.chibi {
  position: absolute; left: 50%; transform: translate(-50%, 0);
  bottom: calc(3.5% + 178px);
  height: clamp(120px, 23vh, 215px);
  z-index: 7; pointer-events: none;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.5));
  animation: chibiIn .55s ease both;
}
.chibi[style*="display: none"] { animation: none; }
@keyframes chibiIn { from { opacity: 0; transform: translate(-50%, 36px) scale(.92); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.chibi.talk { animation: chibiTalk .55s ease; }
@keyframes chibiTalk {
  0% { transform: translate(-50%, 0); }
  30% { transform: translate(-50%, -14px) scale(1.04); }
  60% { transform: translate(-50%, 0); }
  80% { transform: translate(-50%, -5px); }
  100% { transform: translate(-50%, 0); }
}

/* 好感爱心 + HUD */
.hud { position: absolute; top: 14px; right: 16px; left: 16px; z-index: 10; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#hearts { display: flex; gap: 4px; font-size: 20px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
#hearts span { color: rgba(255,255,255,.28); -webkit-text-stroke: 1px rgba(255,255,255,.45); transition: all .3s; }
#hearts span.on { color: var(--pink); animation: heartPop .45s ease; text-shadow: 0 0 12px rgba(255,126,182,.9); }
@keyframes heartPop { 0% { transform: scale(.4); } 55% { transform: scale(1.5); } 100% { transform: scale(1); } }

.hud-btns { display: flex; gap: 8px; pointer-events: auto; }
.hud-btn {
  min-width: 40px; height: 34px; padding: 0 10px; font-size: 13px; color: rgba(255,255,255,.85);
  background: rgba(10,14,32,.55); border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(4px); transition: all .2s;
}
.hud-btn:hover { border-color: var(--blue); color: #fff; }
.hud-btn.on { background: rgba(122,168,255,.25); border-color: var(--blue); color: #fff; }

/* 对话框 */
.dialog {
  position: absolute; left: 50%; bottom: 3.5%; transform: translateX(-50%);
  width: min(94%, 1000px); min-height: 172px; z-index: 5;
  background: linear-gradient(180deg, rgba(14,18,42,.78), rgba(8,11,26,.92));
  border: 1px solid rgba(255,255,255,.16); border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 44px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08);
  padding: 26px 30px 30px;
}
.nameplate {
  position: absolute; top: -19px; left: 26px;
  padding: 5px 22px; border-radius: 999px;
  font-size: 15px; font-weight: 700; letter-spacing: .12em; color: #fff;
  background: linear-gradient(135deg, #7aa8ff, #ff7eb6);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  text-shadow: 0 1px 3px rgba(0,0,0,.35);
  transition: background .3s;
}
.nameplate.hidden { opacity: 0; }
.text {
  font-size: clamp(16px, 2.1vw, 21px); line-height: 1.9; letter-spacing: .03em;
  min-height: 88px; color: #f5f6ff; white-space: pre-wrap;
}
.text.narration { color: #c9d3f2; font-style: italic; }
.next-hint {
  position: absolute; right: 22px; bottom: 12px; font-size: 13px; color: var(--blue);
  animation: hintBlink 1.1s ease-in-out infinite; opacity: 0;
}
.next-hint.show { opacity: 1; }
@keyframes hintBlink { 0%,100% { transform: translateY(0); opacity: .9; } 50% { transform: translateY(4px); opacity: .3; } }

/* 选项 */
.choices {
  position: absolute; left: 50%; bottom: 33%; transform: translateX(-50%);
  width: min(88%, 620px); z-index: 8;
  display: flex; flex-direction: column; gap: 12px;
}
.choices.hidden { display: none; }
.choice-btn {
  padding: 14px 20px; font-size: clamp(15px, 1.8vw, 17px); color: #fff; text-align: left;
  background: rgba(10,14,32,.82); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(8px); transition: all .22s ease;
  animation: choiceIn .4s ease both;
}
.choice-btn:nth-child(1) { animation-delay: .05s; } .choice-btn:nth-child(2) { animation-delay: .15s; } .choice-btn:nth-child(3) { animation-delay: .25s; }
@keyframes choiceIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.choice-btn:hover {
  border-color: var(--pink); background: rgba(255,126,182,.16);
  box-shadow: 0 0 22px rgba(255,126,182,.3); transform: translateX(6px);
}

/* 选项限时条 */
.choice-timer {
  position: relative; width: 100%; height: 24px; flex: none;
  background: rgba(10,14,32,.7); border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; display: flex; align-items: center;
}
.choice-timer .bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  background: linear-gradient(90deg, #7aa8ff, #ff7eb6);
  transition: width .12s linear;
}
.choice-timer .num {
  position: relative; z-index: 1; width: 100%; text-align: center;
  font-size: 14px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); letter-spacing: .1em;
}
.choice-timer.danger .bar { background: linear-gradient(90deg, #ff5252, #ff7e6b); }
.choice-timer.danger .num { color: #ffd6d6; animation: hintBlink .5s infinite; }

.card-bad { color: #ff8080; }

/* 人物档案卡 */
.profile-card {
  width: min(92%, 560px); max-height: 86vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(16,20,44,.96), rgba(8,11,26,.97));
  border: 1px solid rgba(255,255,255,.18); border-radius: 20px;
  padding: 26px 30px; box-shadow: 0 18px 60px rgba(0,0,0,.6);
  animation: cardIn .5s ease both;
}
.pf-load {
  display: inline-block; font-family: Consolas, monospace; font-size: 11px;
  color: #7df3ff; background: rgba(77,227,255,.08);
  border: 1px solid rgba(77,227,255,.35); border-radius: 6px;
  padding: 4px 10px; letter-spacing: .06em; margin-bottom: 14px;
}
.pf-name { font-size: 30px; letter-spacing: .1em; margin: 4px 0 6px; }
.pf-stars { color: var(--gold); font-size: 14px; letter-spacing: .2em; margin-bottom: 18px; }
.pf-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-bottom: 18px; }
.pf-row {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; line-height: 1.6;
}
.pf-row b { display: block; color: var(--card, var(--blue)); font-size: 11.5px; letter-spacing: .15em; margin-bottom: 3px; }
.pf-warn { font-size: 13px; color: #ffb1b1; line-height: 1.7; margin-bottom: 16px; }
.pf-hint { text-align: center; color: rgba(255,255,255,.55); font-size: 13px; letter-spacing: .3em; animation: hintBlink 1.6s infinite; }
@media (max-width: 640px) { .pf-rows { grid-template-columns: 1fr; } .profile-card { padding: 20px; } }

/* 成就殿堂 */
.ach-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; width: 100%; max-width: 1000px; padding-bottom: 20px;
}
.ach-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; animation: cardIn .4s ease both;
}
.ach-item.locked { opacity: .45; filter: grayscale(.7); }
.ach-item.special { border-color: var(--gold); box-shadow: 0 0 18px rgba(255,215,110,.25); }
.ach-emoji { font-size: 30px; flex: none; }
.ach-body { min-width: 0; }
.ach-chapter { font-size: 11px; color: rgba(255,255,255,.5); letter-spacing: .12em; }
.ach-name { font-size: 14.5px; font-weight: 700; margin: 2px 0; color: var(--gold); }
.ach-item.locked .ach-name { color: rgba(255,255,255,.55); }
.ach-date { font-size: 11.5px; color: rgba(255,255,255,.45); }

/* 记录弹窗 */
.overlay { position: absolute; inset: 0; z-index: 30; background: rgba(4,6,16,.72); display: flex; align-items: center; justify-content: center; }
.overlay.hidden { display: none; }
.log-box {
  width: min(88%, 640px); max-height: 76vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; display: flex; flex-direction: column; gap: 14px;
}
.log-box h3 { letter-spacing: .3em; text-align: center; }
#log-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.log-line b { color: var(--blue); margin-right: 8px; }
.log-line { font-size: 14px; line-height: 1.7; color: rgba(255,255,255,.85); }
.log-line.narration { color: rgba(255,255,255,.55); font-style: italic; }
.log-box .menu-btn { align-self: center; }

/* ================= 结局界面 ================= */
.ending-inner { position: relative; z-index: 2; height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ending-card {
  text-align: center; max-width: 520px; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 30px 30px; animation: cardIn .6s ease both;
  display: flex; flex-direction: column; align-items: center;
}
#ending-sprite { height: 200px; filter: drop-shadow(0 8px 22px rgba(0,0,0,.5)); margin-bottom: 8px; }
.ending-emoji { font-size: 40px; margin-bottom: 6px; }
#ending-title { font-size: 26px; letter-spacing: .14em; margin-bottom: 12px; color: var(--gold); }
#ending-text { color: rgba(255,255,255,.82); line-height: 1.9; font-size: 15px; }
.ending-aff { margin-top: 10px; font-size: 13px; color: var(--pink); }
.ending-btns { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }

/* ================= 说明界面 ================= */
.about-inner { position: relative; z-index: 2; height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.about-card {
  max-width: 560px; width: 100%; background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 30px 34px;
}
.about-card h2 { letter-spacing: .3em; margin-bottom: 18px; text-align: center; }
.about-card ul { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.about-card li { color: rgba(255,255,255,.82); line-height: 1.7; font-size: 15px; }
.about-card li::before { content: "✦ "; color: var(--pink); }
.credit { margin: -8px 0 20px; font-size: 12px; line-height: 1.8; text-align: center; color: rgba(255,255,255,.45); }
.credit a { color: var(--blue); }

/* toast 提示 */
.toast {
  position: fixed; top: 26px; left: 50%; transform: translate(-50%, -90px);
  z-index: 99; padding: 11px 26px; border-radius: 999px;
  background: rgba(10,14,32,.92); border: 1px solid var(--line); color: #fff;
  font-size: 14px; transition: transform .4s cubic-bezier(.2,.9,.3,1.3);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }

/* ================= 手机适配 ================= */
@media (max-width: 640px) {
  .sprite-wrap { height: 66%; }
  .dialog { min-height: 150px; padding: 22px 20px 26px; }
  .text { min-height: 72px; }
  #hearts { font-size: 16px; }
  .hud-btn { min-width: 34px; height: 30px; font-size: 12px; }
  .choices { bottom: 42%; }
  .char-grid { grid-template-columns: repeat(2, 1fr); }
  .card-avatar { height: 160px; }
}
