/* Mobile-first polished prototype UI for 学渣逆袭模拟器 */
:root {
  --bg0: #171021;
  --bg1: #28183b;
  --card: rgba(255, 250, 240, 0.92);
  --card2: rgba(255, 244, 232, 0.86);
  --ink: #2a1d2f;
  --muted: #7c687f;
  --purple: #6c3fc4;
  --pku: #ba2b3d;
  --gold: #f3bd58;
  --good: #2eaa72;
  --bad: #db5366;
  --line: rgba(75, 48, 92, 0.14);
  --shadow: 0 14px 34px rgba(27, 13, 40, 0.22);
  --radius: 20px;
  --tap: 44px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, rgba(255,240,220,.82), rgba(232,220,255,.88), rgba(36,19,48,.95)),
    url("assets/campus_study_bg.png") center top / cover fixed no-repeat;
  background-attachment: fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(130deg, rgba(255,255,255,.24), transparent 35%, rgba(186,43,61,.12));
}
#app {
  position: relative;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(94px + env(safe-area-inset-bottom));
}
.intro {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  z-index: 100;
  background: #12091d;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .38s ease;
}
.intro.hide { opacity: 0; pointer-events: none; }
.intro video, .intro-poster {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100%, calc(100vh * 9 / 16));
  height: min(100%, calc(100vw * 16 / 9));
  max-width: 520px;
  aspect-ratio: 9 / 16;
  transform: translate(-50%, -50%);
  object-fit: contain;
  background: #12091d;
}
.intro-poster { z-index: 1; transition: opacity .25s ease; }
.intro-poster.hide { opacity: 0; pointer-events: none; }
.intro video { z-index: 2; }
.intro-beats {
  position: absolute;
  left: 18px;
  right: 18px;
  top: calc(72px + env(safe-area-inset-top));
  z-index: 3;
  pointer-events: none;
}
.intro-beats span {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0;
  transform: translateY(10px);
  padding: 10px 13px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  background: linear-gradient(135deg, rgba(108,63,196,.78), rgba(186,43,61,.66));
  border: 1px solid rgba(255,255,255,.26);
  box-shadow: 0 12px 28px rgba(0,0,0,.24);
  backdrop-filter: blur(8px);
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  animation: introBeat 15s linear forwards;
}
.intro-beats span:nth-child(2) { animation-delay: 3.6s; }
.intro-beats span:nth-child(3) { animation-delay: 7.2s; }
.intro-beats span:nth-child(4) { animation-delay: 10.8s; }
@keyframes introBeat { 0%, 3% { opacity: 0; transform: translateY(10px); } 8%, 22% { opacity: 1; transform: translateY(0); } 30%, 100% { opacity: 0; transform: translateY(-8px); } }
.intro-caption {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 3;
  padding: 14px 16px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(180deg, rgba(42,18,58,.18), rgba(27,11,34,.72));
  border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(8px);
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.intro-caption b { display: block; font-size: 18px; line-height: 1.25; }
.intro-caption span { display: block; margin-top: 6px; font-size: 13px; line-height: 1.45; color: rgba(255,255,255,.86); }
.intro button {
  position: absolute;
  right: 18px;
  top: calc(18px + env(safe-area-inset-top));
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 999px;
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  background: rgba(30,14,44,.58);
  backdrop-filter: blur(8px);
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 14px;
  color: #fff;
  background: linear-gradient(135deg, rgba(63, 35, 110, .92), rgba(186, 43, 61, .7));
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: var(--shadow);
}
.hero-copy { min-width: 0; flex: 1 1 auto; }
.eyebrow { font-size: 12px; color: #ffe6ab; font-weight: 800; letter-spacing: .08em; }
.hero h1 { margin: 4px 0 2px; font-size: 28px; line-height: 1.05; text-shadow: 0 2px 0 rgba(0,0,0,.14); }
.hero p { margin: 0; color: rgba(255,255,255,.78); font-size: 13px; }
.hero-art {
  width: 88px;
  height: 120px;
  flex: none;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,.42);
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}
.hero-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.music-btn, .day-pill {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.24);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.music-btn {
  min-height: 34px;
  font-family: inherit;
  box-shadow: 0 8px 18px rgba(0,0,0,.12);
}
.gm-btn { min-height: 34px; padding: 7px 10px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; color: rgba(255,255,255,.82); background: rgba(25,15,40,.52); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.lang-btn { min-height: 34px; padding: 7px 11px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: #fff; background: rgba(25,15,40,.58); font-size: 11px; font-weight: 900; cursor: pointer; }
.language-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 20px; background: rgba(20,10,30,.72); backdrop-filter: blur(8px); }
.language-dialog { width: min(390px,92vw); padding: 26px; border: 1px solid rgba(178,113,221,.36); border-radius: 24px; background: linear-gradient(145deg,#fff,#f7edff); box-shadow: 0 25px 80px rgba(20,7,30,.4); color: #34213e; }
.language-dialog h2 { margin: 7px 0 18px; }
.language-options { display: grid; gap: 10px; }
.language-options button { min-height: 48px; padding: 10px 16px; border: 1px solid rgba(121,64,153,.18); border-radius: 14px; color: #563565; background: rgba(255,255,255,.8); font: inherit; font-weight: 900; cursor: pointer; }
.language-options button.active { color: #fff; border-color: transparent; background: linear-gradient(135deg,#8646ce,#d22f63); box-shadow: 0 8px 18px rgba(159,45,128,.22); }
.gm-modal { position: relative; }
.gm-danger { width: 100%; min-height: 48px; margin-top: 12px; border: 0; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #9f2940, #dc5369); font-weight: 900; box-shadow: 0 10px 22px rgba(186,43,61,.25); }
.day-pill { flex: none; }
.hero-actions, .hero-actions > *, .day-pill { min-width: 0; max-width: 100%; }
.day-pill { text-align: center; line-height: 1.25; overflow-wrap: anywhere; }
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 12px 12px 0;
}
.page-nav {
  position: sticky;
  top: 0;
  z-index: 16;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 10px 12px 0;
  padding: 6px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,.78), rgba(245,230,255,.72));
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: 0 10px 24px rgba(64, 35, 92, .14);
  backdrop-filter: blur(12px);
}
.page-tab {
  min-height: 40px;
  border: 0;
  border-radius: 15px;
  color: #6f4d89;
  font-family: inherit;
  font-weight: 900;
  background: transparent;
  box-shadow: none;
}
.page-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--pku));
  box-shadow: 0 8px 18px rgba(108,63,196,.28), inset 0 1px 0 rgba(255,255,255,.25);
}
.hud-chip {
  position: relative;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 16px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  font-family: inherit;
  box-shadow: 0 8px 20px rgba(64, 35, 92, .13);
}
.hud-chip em {
  position: absolute;
  right: 5px;
  top: 4px;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  color: #fff;
  background: var(--purple);
  font-size: 10px;
  font-style: normal;
  line-height: 15px;
  text-align: center;
}
.hud-name { color: var(--muted); font-size: 11px; font-weight: 700; }
.hud-chip strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.score-panel, .card {
  margin: 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.score-panel { padding: 14px; }
.score-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.score-head strong { color: var(--purple); font-size: 20px; }
.qingbei-track, .bar, .aff {
  height: 10px;
  border-radius: 999px;
  background: rgba(61, 40, 79, .13);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
}
.qingbei-track { margin-top: 10px; height: 12px; }
.qingbei-fill, .bar i, .aff i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pku), var(--purple), var(--gold));
  transition: width .38s ease;
}
.score-tip { margin-top: 8px; color: var(--muted); font-size: 12px; }
.content { padding-bottom: 8px; }
.card { padding: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-title > * { min-width: 0; overflow-wrap: anywhere; }
.section-title span { font-size: 16px; font-weight: 900; }
.section-title small { color: var(--muted); font-size: 11px; text-align: right; }
.quick-actions { margin: -2px 0 10px; }
.quick-actions button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--pku));
  box-shadow: 0 8px 18px rgba(108,63,196,.22);
}
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.daily-challenge { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 11px; padding: 11px 12px; border: 1px solid rgba(243,189,88,.32); border-radius: 15px; background: linear-gradient(135deg, rgba(243,189,88,.13), rgba(108,63,196,.08)); }
.daily-challenge div { min-width: 0; }
.daily-challenge span { display: block; color: #9a6c22; font-size: 10px; font-weight: 900; letter-spacing: .06em; }
.daily-challenge strong { display: block; margin-top: 2px; color: var(--ink); font-size: 14px; }
.daily-challenge p { margin: 2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.daily-challenge em { flex: 0 0 auto; max-width: 116px; padding: 6px 8px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #c58b27, var(--pku)); text-align: center; font-size: 10px; font-style: normal; font-weight: 900; }
.daily-challenge em { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.daily-challenge.completed { border-color: rgba(46,170,114,.32); background: rgba(46,170,114,.1); }
.daily-challenge.completed em { background: var(--good); }
.combo-guide { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.combo-guide b, .combo-guide span { padding: 5px 7px; border-radius: 999px; font-size: 10px; }
.combo-guide b { color: #fff; background: var(--purple); }
.combo-guide span { color: #694085; background: rgba(108,63,196,.08); }
.slot {
  min-height: 96px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fff1df);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  box-shadow: 0 6px 14px rgba(80, 45, 95, .1);
}
.slot.active { outline: 3px solid rgba(108,63,196,.23); border-color: rgba(108,63,196,.55); transform: translateY(-1px); }
.slot span { display: block; color: var(--purple); font-size: 12px; font-weight: 900; }
.slot strong { display: block; margin: 7px 0 4px; font-size: 14px; line-height: 1.18; }
.slot small { color: var(--muted); font-size: 11px; line-height: 1.2; }
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px;
  border-radius: 18px;
  background: rgba(108,63,196,.08);
  border: 1px solid rgba(108,63,196,.1);
}
.tab, .primary-btn, .choice {
  min-height: var(--tap);
  border: 0;
  border-radius: 15px;
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, opacity .15s ease;
}
.tab { background: rgba(255,255,255,.7); color: var(--purple); }
.tab.active { color: #fff; background: linear-gradient(135deg, var(--purple), var(--pku)); box-shadow: 0 8px 18px rgba(108,63,196,.25); }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.picker { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 2px; }
.pick-item {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fff8f0);
  color: var(--ink);
  padding: 10px 12px;
  font-family: inherit;
  text-align: left;
}
.pick-item strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.pick-item small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); margin-top: 2px; line-height: 1.28; }
.pick-item .gain { color: var(--good); font-weight: 900; white-space: nowrap; }
.pick-item em { grid-column: 1 / -1; color: #9a7b52; font-style: normal; font-size: 11px; overflow-wrap: anywhere; }
.work-pick { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.work-card-main { min-width: 0; }
.work-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.work-tags span { padding: 3px 6px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, var(--purple), var(--pku)); font-size: 10px; font-weight: 900; line-height: 1.2; }
.work-pick .gain { padding: 5px 7px; border-radius: 999px; color: #fff; background: var(--good); font-size: 11px; }
.work-pick .risk-赌 { background: var(--pku); }
.work-pick .risk-高, .work-pick .risk-中高 { background: #d97928; }
.course-pick {
  min-height: 104px;
  grid-template-columns: 62px 1fr auto;
  gap: 8px 10px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,242,231,.95));
}
.course-teacher-art {
  width: 62px;
  height: 82px;
  grid-row: span 2;
  object-fit: cover;
  object-position: center 14%;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,.88);
  box-shadow: 0 8px 18px rgba(108,63,196,.18);
}
.course-main { min-width: 0; }
.course-main p {
  margin: 4px 0 0;
  color: #6a516f;
  font-size: 11px;
  line-height: 1.28;
}
.course-gains {
  display: grid;
  gap: 5px;
  justify-items: end;
  align-self: center;
}
.course-gains span {
  white-space: nowrap;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--good), var(--purple));
}
.course-gains span + span { background: linear-gradient(135deg, var(--pku), var(--gold)); color: #351c00; }
.course-pick em { grid-column: 2 / -1; }
.subjects { display: flex; flex-direction: column; gap: 9px; }
.subject-row { display: grid; grid-template-columns: 42px 1fr 34px; gap: 9px; align-items: center; font-size: 13px; }
.subject-row span { font-weight: 800; }
.subject-row strong { color: var(--purple); text-align: right; font-variant-numeric: tabular-nums; }
.teachers { display: flex; flex-direction: column; gap: 10px; }
.teacher-card {
  width: 100%;
  display: grid;
  grid-template-columns: 72px 1fr 34px;
  gap: 10px;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.teacher-card:active { transform: scale(.985); }
.teacher-card::after { content: attr(data-view-label); grid-column: 2 / 4; justify-self: end; margin-top: -6px; color: var(--pku); font-size: 11px; font-weight: 900; }
.teacher-art {
  width: 72px;
  height: 92px;
  object-fit: cover;
  object-position: center 18%;
  border-radius: 18px;
  border: 2px solid rgba(255,255,255,.8);
  box-shadow: 0 8px 18px rgba(108,63,196,.22);
}
.teacher-info strong { display: block; font-size: 14px; }
.teacher-info small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.teacher-info p { margin: 0 0 6px; color: #6a516f; font-size: 11px; line-height: 1.28; }
.teacher-card b { color: var(--pku); text-align: right; }
.bond-list { display: flex; flex-direction: column; gap: 12px; }
.bond-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fff5ea);
  border: 1px solid var(--line);
}
.bond-art {
  width: 92px;
  height: 128px;
  object-fit: cover;
  object-position: center 16%;
  border-radius: 18px;
  grid-row: span 2;
}
.bond-item strong { display: block; color: var(--purple); font-size: 15px; }
.bond-item small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; }
.bond-actions { grid-column: 2; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.bond-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--pku));
}
.bond-actions button:disabled { background: #cbbbd0; color: #715f76; }
.shop-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 2px; }
.shop-item {
  display: grid;
  grid-template-columns: 58px 1fr 96px;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fff4ea);
  border: 1px solid var(--line);
}
.shop-icon {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 8px 16px rgba(108,63,196,.16);
}
.shop-item strong { display: block; color: var(--purple); font-size: 14px; }
.shop-item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.shop-item p { margin: 6px 0 0; color: #6a516f; font-size: 11px; line-height: 1.32; }
.shop-actions { display: grid; gap: 6px; align-content: center; }
.shop-actions b { color: var(--pku); font-size: 11px; text-align: center; }
.shop-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--pku));
}
.shop-actions button:disabled { background: #cbbbd0; color: #715f76; }
.story-list { display: flex; flex-direction: column; gap: 10px; }
.story-item {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  padding: 10px;
  border: 0;
  border-radius: 16px;
  background: rgba(108,63,196,.07);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.story-item:active { transform: scale(.985); }
.story-item img, .story-mark {
  width: 54px;
  height: 70px;
  object-fit: cover;
  object-position: center 16%;
  border-radius: 14px;
}
.story-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple), var(--pku));
  color: #fff;
  font-weight: 900;
}
.story-item strong { display: block; color: var(--purple); font-size: 14px; }
.story-item small { display: block; color: var(--muted); font-size: 11px; margin: 2px 0 4px; }
.story-item p { margin: 0; color: #5d4862; font-size: 12px; line-height: 1.4; }
.empty-story { color: var(--muted); font-size: 13px; padding: 10px; border-radius: 14px; background: rgba(108,63,196,.07); }
.log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.log-line {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(108,63,196,.07);
  color: #58435c;
  font-size: 12px;
  line-height: 1.35;
}
.log-line span { color: var(--purple); font-weight: 900; margin-right: 6px; }
.log-line.good { background: rgba(46,170,114,.1); }
.log-line.warn { background: rgba(243,189,88,.16); }
.log-line.bad { background: rgba(219,83,102,.12); }
.log-line.story { background: rgba(186,43,61,.1); }
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(32,17,43,.96) 58%, transparent);
}
.primary-btn {
  display: block;
  width: 100%;
  max-width: 488px;
  margin: 0 auto;
  min-height: 58px;
  color: #351c00;
  font-size: 17px;
  background: linear-gradient(180deg, #ffe39b, var(--gold));
  box-shadow: 0 10px 26px rgba(243,189,88,.38), inset 0 1px 0 rgba(255,255,255,.7);
}
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(27, 14, 39, .72);
  backdrop-filter: blur(8px);
}
.modal-layer[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 460px;
  border-radius: 26px;
  padding: 22px;
  background: linear-gradient(180deg, #fffaf3, #f5e7ff);
  box-shadow: 0 24px 70px rgba(0,0,0,.38);
  border: 1px solid rgba(255,255,255,.75);
  animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.modal-kicker { color: var(--pku); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.modal h2 { margin: 6px 0 8px; font-size: 23px; }
.modal p { color: #5f4a64; line-height: 1.55; }
.speaker { color: var(--purple) !important; font-weight: 900; margin-bottom: -4px; }
.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 2;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  background: rgba(42,29,47,.54);
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
}
.detail-modal {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: linear-gradient(180deg, #fff7ee, #f2e4ff 62%, #fffaf4);
}
.teacher-detail { display: grid; grid-template-columns: minmax(150px, 42%) 1fr; max-height: 88vh; }
.detail-art-wrap {
  position: relative;
  min-height: 520px;
  background: radial-gradient(circle at 50% 18%, rgba(255,231,164,.75), transparent 36%), linear-gradient(160deg, rgba(186,43,61,.28), rgba(108,63,196,.38));
  overflow: hidden;
}
.detail-art, .detail-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;
  filter: saturate(1.08) contrast(1.03);
}
.detail-bg-video { background: #180d22; }
.detail-glow {
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(0deg, rgba(32,17,43,.72), transparent);
}
.detail-body { padding: 24px 20px 20px; overflow-y: auto; }
.detail-quote {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 16px;
  color: #7a3550 !important;
  background: rgba(186,43,61,.09);
  font-weight: 800;
}
.detail-aff { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; margin: 10px 0 14px; }
.detail-aff strong { display: block; color: var(--pku); font-size: 28px; line-height: 1; }
.detail-aff span { color: var(--muted); font-size: 11px; font-weight: 900; }
.teacher-video {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 18px;
  margin: 0 0 12px;
  background: #180d22;
  box-shadow: 0 10px 22px rgba(36,19,48,.18);
}
.story-event-modal {
  position: relative;
  max-width: 430px;
  max-height: 92vh;
  overflow-y: auto;
}
.story-controls { position: sticky; top: -22px; z-index: 3; display: flex; justify-content: flex-end; gap: 6px; margin: -10px -10px 4px; padding: 8px; background: linear-gradient(180deg, rgba(255,250,243,.98), rgba(255,250,243,.78), transparent); }
.story-controls button, .story-tools button { min-height: 32px; padding: 6px 10px; color: #fff; border: 0; border-radius: 999px; background: linear-gradient(135deg, var(--purple), var(--pku)); font-size: 11px; font-weight: 900; }
.story-speaker-row { display: flex; align-items: center; gap: 9px; margin: 8px 0 4px; }
.story-speaker-row img, .story-speaker-mark { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: center 15%; box-shadow: 0 4px 12px rgba(48,28,65,.2); }
.story-speaker-mark { display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--purple), var(--pku)); font-size: 13px; font-weight: 900; }
.story-speaker-row .speaker { margin: 0; }
.story-event-text { min-height: 3.2em; white-space: pre-wrap; }
.story-event-text::after { content: '▍'; color: var(--pku); animation: cursorBlink .8s steps(1) infinite; }
.story-event-text.typed-done::after { display: none; }
.story-pending { opacity: .22; pointer-events: none; transform: translateY(4px); }
.choices { transition: opacity .2s ease, transform .2s ease; }
@keyframes cursorBlink { 50% { opacity: 0; } }
.vertical-video-stage {
  width: min(64vw, 250px);
  aspect-ratio: 9 / 16;
  margin: 12px auto 14px;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, rgba(255,231,164,.22), transparent 40%), #180d22;
  box-shadow: 0 16px 36px rgba(36,19,48,.3);
  border: 1px solid rgba(255,255,255,.58);
}
.story-vertical-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #180d22;
}
.story-event-text { margin-top: 10px; }
.story-cg-stage { width: 100%; aspect-ratio: 3 / 4; margin: 12px auto 14px; overflow: hidden; border-radius: 18px; background: #180d22; box-shadow: 0 16px 36px rgba(36,19,48,.3); }
.story-cg-stage img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; animation: cgDrift 12s ease-out both; }
@keyframes cgDrift { from { transform: scale(1.035) translate3d(-.5%, .4%, 0); } to { transform: scale(1.1) translate3d(.5%, -.4%, 0); } }
.story-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.story-tools span { color: var(--muted); font-size: 12px; font-weight: 900; }
.trait-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 12px; }
.trait-strip span { padding: 7px 5px; border-radius: 10px; color: #694085; background: rgba(108,63,196,.09); text-align: center; font-size: 11px; font-weight: 900; }
.cg-gallery { position: relative; width: min(94vw, 720px); max-width: 720px; max-height: 88vh; overflow-y: auto; }
.cg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.cg-tile { position: relative; min-height: 0; padding: 0; overflow: hidden; border-radius: 14px; aspect-ratio: 3 / 4; background: #281a39; }
.cg-tile img { width: 100%; height: 100%; object-fit: cover; }
.cg-tile span { position: absolute; inset: auto 0 0; padding: 18px 7px 7px; color: #fff; background: linear-gradient(transparent, rgba(20,10,30,.92)); font-size: 11px; font-weight: 900; }
.cg-tile.locked { opacity: .52; }
.cg-lock { display: grid; place-items: center; width: 100%; height: 100%; color: rgba(255,255,255,.55); font-size: 34px; background: radial-gradient(circle, rgba(108,63,196,.45), #281a39 70%); }
.replay-choice { margin-top: 12px; padding: 10px 12px; border-radius: 12px; color: #694085 !important; background: rgba(108,63,196,.1); font-size: 12px; font-weight: 900; }
.detail-grid { display: grid; gap: 9px; }
.detail-grid section {
  padding: 11px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(108,63,196,.12);
}
.detail-grid b { display: block; color: var(--purple); font-size: 13px; margin-bottom: 3px; }
.detail-grid p { margin: 0; font-size: 12px; line-height: 1.45; }
.gift-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.gift-tags span { padding: 4px 8px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, var(--purple), var(--pku)); font-size: 11px; font-weight: 900; }
.detail-note { margin-top: 12px; padding: 10px 12px; border-radius: 16px; color: #87633b; background: rgba(243,189,88,.18); font-size: 12px; line-height: 1.45; }
.story-replay { display: grid; grid-template-columns: 128px 1fr; max-height: 82vh; }
.story-replay.vertical-replay { grid-template-columns: minmax(150px, 42%) 1fr; max-width: 520px; }
.replay-video-stage { width: 100%; max-width: none; height: min(76vh, 520px); margin: 0; border-radius: 0; border: 0; box-shadow: none; }
.replay-art { width: 128px; height: 100%; min-height: 260px; object-fit: cover; object-position: center 14%; }
.replay-main-mark { display: flex; align-items: center; justify-content: center; min-height: 260px; color: #fff; font-size: 24px; font-weight: 900; background: linear-gradient(135deg, var(--purple), var(--pku)); }
.replay-body { padding: 24px 20px 20px; overflow-y: auto; }
.replay-text { margin-top: 14px; white-space: pre-wrap; font-size: 15px; line-height: 1.75 !important; }
.exam-prompt, .work-prompt { padding: 12px 14px; border-radius: 16px; color: #3f2948 !important; background: rgba(108,63,196,.08); font-size: 16px; font-weight: 900; }
.work-modal { box-shadow: 0 24px 70px rgba(243,189,88,.36); }
.work-meter { position: relative; height: 34px; margin: 12px 0 10px; border-radius: 999px; overflow: hidden; background: rgba(61,40,79,.12); box-shadow: inset 0 1px 3px rgba(0,0,0,.12); }
.work-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--good)); transition: width .22s ease; }
.work-meter span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 900; text-shadow: 0 1px 3px rgba(0,0,0,.28); }
.work-choice { background: linear-gradient(135deg, #8a5a2b, var(--gold)); color: #351c00; }
.exam-hint { margin: 8px 0 0; padding: 9px 11px; border-radius: 14px; color: #87633b !important; background: rgba(243,189,88,.18); font-size: 12px; }
.qte-modal { box-shadow: 0 24px 70px rgba(186,43,61,.42); }
.qte-timer { position: relative; height: 30px; margin: 10px 0 8px; border-radius: 999px; overflow: hidden; background: rgba(186,43,61,.12); }
.qte-timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), var(--pku)); animation: qteDrain linear forwards; transform-origin: left center; }
.qte-timer span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 900; text-shadow: 0 1px 3px rgba(0,0,0,.28); }
@keyframes qteDrain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.exam-choice { text-align: left; }
.choices { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.choice { width: 100%; padding: 12px 14px; color: #fff; background: linear-gradient(135deg, var(--purple), var(--pku)); text-align: center; }
.choice, .primary-btn, .page-tab, .tab, .slot, .shop-actions button, .bond-actions button { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.choice small { display: block; margin-top: 4px; color: rgba(255,255,255,.78); font-size: 11px; }
.gameover.win { box-shadow: 0 24px 70px rgba(46,170,114,.34); }
.gameover.lose { box-shadow: 0 24px 70px rgba(219,83,102,.34); }
.toast-layer {
  pointer-events: none;
  position: fixed;
  left: 0; right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.toast {
  opacity: 0;
  transform: translateY(10px);
  transition: .25s ease;
  padding: 8px 14px;
  border-radius: 14px;
  width: fit-content;
  max-width: min(88vw, 520px);
  line-height: 1.45;
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  background: rgba(42, 29, 47, .92);
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.good { background: rgba(46,170,114,.94); }
.toast.info { background: rgba(108,63,196,.94); }
.toast.warn { background: rgba(190,67,82,.96); }
.toast.mixed { background: linear-gradient(135deg, rgba(62,48,86,.97), rgba(105,63,155,.97)); border: 1px solid rgba(255,255,255,.16); }
.change-summary-layer {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 9, 28, .68);
  backdrop-filter: blur(7px);
}
.change-summary-layer[hidden] { display: none; }
.change-summary-card {
  width: min(100%, 390px);
  max-height: min(76vh, 620px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(155deg, rgba(53,38,79,.98), rgba(28,20,48,.98));
  box-shadow: 0 28px 80px rgba(0,0,0,.48);
}
.change-summary-card h2 { margin: 5px 0 16px; font-size: 24px; }
.change-summary-card section + section { margin-top: 14px; }
.change-summary-card h3 { margin: 0 0 7px; color: rgba(255,255,255,.62); font-size: 12px; letter-spacing: .14em; }
.change-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 12px; border-radius: 10px; }
.change-row + .change-row { margin-top: 5px; }
.change-row.gain { background: rgba(46,170,114,.13); }
.change-row.loss { background: rgba(219,83,102,.13); }
.change-row strong { font-size: 17px; }
.change-row.gain strong { color: #76e4ac; }
.change-row.loss strong { color: #ff8c9c; }
.change-confirm { position: static; width: 100%; margin-top: 20px; }
@keyframes gainPulse { 35% { transform: scale(1.08); box-shadow: 0 0 0 3px rgba(46,170,114,.25); } }
@keyframes lossPulse { 35% { transform: scale(.95); box-shadow: 0 0 0 3px rgba(219,83,102,.25); } }
.pulse-gain { animation: gainPulse .55s ease; }
.pulse-loss { animation: lossPulse .55s ease; }

/* English and Thai copy is often substantially wider than Chinese. These rules
   let cards grow vertically and prevent flex/grid children from forcing overflow. */
html[lang="en"] .hero,
html[lang="th"] .hero { align-items: stretch; }
html[lang="en"] .hero h1,
html[lang="th"] .hero h1 { font-size: clamp(21px, 5.4vw, 27px); line-height: 1.08; overflow-wrap: anywhere; }
html[lang="en"] .hero p,
html[lang="th"] .hero p,
html[lang="en"] .eyebrow,
html[lang="th"] .eyebrow { overflow-wrap: anywhere; line-height: 1.35; }
html[lang="en"] .hero-actions,
html[lang="th"] .hero-actions { flex: 0 1 150px; width: min(150px, 24vw); }
html[lang="en"] .hero-actions > *,
html[lang="th"] .hero-actions > * { width: 100%; padding-inline: 8px; }
html[lang="en"] .day-pill,
html[lang="th"] .day-pill { border-radius: 18px; font-size: 11px; }
html[lang="en"] .page-tab,
html[lang="th"] .page-tab,
html[lang="en"] .tab,
html[lang="th"] .tab { padding: 7px 5px; font-size: 11px; }
html[lang="en"] .daily-challenge,
html[lang="th"] .daily-challenge { align-items: stretch; }
html[lang="en"] .daily-challenge em,
html[lang="th"] .daily-challenge em { flex: 0 1 124px; display: grid; place-items: center; }
html[lang="en"] .slot,
html[lang="th"] .slot { height: auto; min-height: 108px; }
html[lang="en"] .slot strong,
html[lang="th"] .slot strong { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
html[lang="en"] .course-gains span,
html[lang="th"] .course-gains span { white-space: normal; max-width: 105px; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
html[lang="en"] .pick-item .gain,
html[lang="th"] .pick-item .gain { white-space: normal; max-width: 112px; text-align: center; overflow-wrap: anywhere; }
html[lang="en"] .modal h2,
html[lang="th"] .modal h2 { overflow-wrap: anywhere; line-height: 1.15; }
html[lang="en"] .primary-btn,
html[lang="th"] .primary-btn { height: auto; padding-block: 13px; }

/* The same expansion-safe layout automatically applies to every added locale. */
html.localized .hero { align-items: stretch; }
html.localized .hero h1 { font-size: clamp(21px, 5.4vw, 27px); line-height: 1.08; overflow-wrap: anywhere; }
html.localized .hero p, html.localized .eyebrow { overflow-wrap: anywhere; line-height: 1.35; }
html.localized .hero-actions { flex: 0 1 150px; width: min(150px, 24vw); }
html.localized .hero-actions > * { width: 100%; padding-inline: 8px; }
html.localized .day-pill { border-radius: 18px; font-size: 11px; }
html.localized .page-tab, html.localized .tab { padding: 7px 5px; font-size: 11px; }
html.localized .daily-challenge { align-items: stretch; }
html.localized .daily-challenge em { flex: 0 1 124px; display: grid; place-items: center; }
html.localized .slot { height: auto; min-height: 108px; }
html.localized .slot strong { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
html.localized .course-gains span { white-space: normal; max-width: 105px; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
html.localized .pick-item .gain { white-space: normal; max-width: 112px; text-align: center; overflow-wrap: anywhere; }
html.localized .modal h2 { overflow-wrap: anywhere; line-height: 1.15; }
html.localized .primary-btn { height: auto; padding-block: 13px; }
@media (max-width: 390px) {
  .hud { grid-template-columns: repeat(3, 1fr); }
  .slots { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .page-nav { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .page-tab { font-size: 12px; }
  .teacher-detail { grid-template-columns: 1fr; max-height: 90vh; }
  .detail-art-wrap { min-height: 360px; }
  .shop-item { grid-template-columns: 54px 1fr; }
  .shop-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr 1fr; align-items: center; }
  .story-replay, .story-replay.vertical-replay { grid-template-columns: 1fr; }
  .vertical-video-stage { width: min(72vw, 230px); }
  .replay-video-stage { width: 100%; height: 360px; border-radius: 24px 24px 0 0; }
  .replay-art, .replay-main-mark { width: 100%; height: 210px; min-height: 210px; }
  .cg-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  html.localized .hero { display: grid; grid-template-columns: minmax(0, 1fr) 74px; gap: 10px; }
  html.localized .hero-art { width: 74px; height: 104px; }
  html.localized .hero-actions { grid-column: 1 / -1; width: 100%; max-width: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  html.localized .day-pill { display: grid; place-items: center; }
  html.localized .daily-challenge { flex-direction: column; }
  html.localized .daily-challenge em { flex-basis: auto; max-width: none; min-height: 32px; }
  html.localized .section-title { align-items: flex-start; flex-direction: column; gap: 3px; }
  html.localized .section-title small { text-align: left; }
  html[lang="en"] .hero,
  html[lang="th"] .hero { display: grid; grid-template-columns: minmax(0, 1fr) 74px; gap: 10px; }
  html[lang="en"] .hero-art,
  html[lang="th"] .hero-art { width: 74px; height: 104px; }
  html[lang="en"] .hero-actions,
  html[lang="th"] .hero-actions { grid-column: 1 / -1; width: 100%; max-width: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  html[lang="en"] .day-pill,
  html[lang="th"] .day-pill { display: grid; place-items: center; }
  html[lang="en"] .daily-challenge,
  html[lang="th"] .daily-challenge { flex-direction: column; }
  html[lang="en"] .daily-challenge em,
  html[lang="th"] .daily-challenge em { flex-basis: auto; max-width: none; min-height: 32px; }
  html[lang="en"] .section-title,
  html[lang="th"] .section-title { align-items: flex-start; flex-direction: column; gap: 3px; }
  html[lang="en"] .section-title small,
  html[lang="th"] .section-title small { text-align: left; }
}
