:root {
  --red: #ff4a1c;
  --orange: #ff9a2e;
  --green: #6fd64b;
  --ink: #141210;
  --cream: #fff7ec;
  --display: "Archivo Black", "Noto Sans SC", system-ui, sans-serif;
  --body: "Noto Sans SC", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b0a09; font-family: var(--body); color: #fff; overflow: hidden; }
button { font: inherit; cursor: pointer; }

.phone {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ink);
}
@media (min-width: 600px) {
  .phone { height: min(100%, 900px); top: 50%; transform: translateY(-50%); border-radius: 28px; box-shadow: 0 0 0 10px #222, 0 30px 80px rgba(0,0,0,.6); }
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 24px;
  background: linear-gradient(rgba(0,0,0,.55), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.back { font-size: 30px; line-height: 1; text-decoration: none; color: #fff; padding: 0 4px; }
.iq { flex: 1; }
.iq-row { display: flex; align-items: baseline; gap: 8px; }
.iq-label { font-size: 12px; opacity: .8; }
.iq-num { font-family: var(--display); font-size: 22px; transition: color .3s; }
.iq-num.low { color: var(--red); }
.iq-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; margin: 4px 0; }
.iq-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--orange), var(--green)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.iq-tier { font-size: 11px; opacity: .85; }
.iq.hit .iq-num { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tabs { display: flex; gap: 12px; font-weight: 700; font-size: 15px; padding-top: 4px; }
.tab { opacity: .6; }
.tab.on { opacity: 1; border-bottom: 2px solid #fff; padding-bottom: 2px; }

/* ---------- feed ---------- */
.feed {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.ep {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: linear-gradient(160deg, var(--c1), var(--c2));
}
.ep::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, transparent 30%, rgba(0,0,0,.45) 100%);
  pointer-events: none;
}

.ep-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.2); z-index: 4; }
.ep-progress i { display: block; height: 100%; width: 0; background: #fff; }

/* stage: mascot + speech */
.stage { position: absolute; inset: 90px 70px 190px 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 2; }
.mascot {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #fff;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  animation: float 2.6s ease-in-out infinite;
  flex-shrink: 0;
}
.mascot img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 72%; transform: scale(1.85); transform-origin: 50% 78%; }
.ep.paused .mascot, .ep.paused .danmaku span { animation-play-state: paused; }
@keyframes float { 50% { transform: translateY(-10px) rotate(4deg); } }
.ep.shock .mascot { animation: zoom .5s ease-out forwards; }
@keyframes zoom { to { transform: scale(1.25) rotate(-8deg); } }

.lines { width: 100%; margin-top: 22px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.line {
  align-self: flex-start;
  max-width: 92%;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  border-radius: 4px 16px 16px 16px;
  padding: 9px 13px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s, transform .3s;
}
.line.show { opacity: 1; transform: none; }
.line.narr { align-self: center; background: rgba(0,0,0,.55); color: #fff; border-radius: 10px; font-style: italic; text-align: center; }
.line b { display: block; font-size: 11px; color: var(--red); margin-bottom: 1px; }

.hook {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 28px;
  text-align: center;
  background: rgba(0,0,0,.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s;
}
.ep.hooked .hook { opacity: 1; pointer-events: auto; }
.hook-flash { font-family: var(--display); color: var(--red); font-size: 13px; letter-spacing: .2em; margin-bottom: 14px; }
.hook-text { font-size: 22px; font-weight: 900; line-height: 1.5; margin: 0 0 26px; animation: none; }
.ep.hooked .hook-text { animation: punch .5s ease-out; }
@keyframes punch { 0% { transform: scale(1.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.hook-next { font-size: 14px; opacity: .8; }
.hook-next b { font-family: var(--display); color: var(--orange); font-size: 20px; }
.hook-btn { margin-top: 18px; background: var(--red); color: #fff; border: 0; border-radius: 999px; padding: 12px 26px; font-weight: 900; font-size: 16px; }

/* danmaku */
.danmaku { position: absolute; inset: 120px 0 auto 0; height: 120px; z-index: 3; pointer-events: none; overflow: hidden; }
.danmaku span {
  position: absolute;
  left: 100%;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  animation: fly linear forwards;
}
.danmaku span.mine { color: var(--orange); border: 1px solid var(--orange); border-radius: 999px; padding: 0 8px; }
@keyframes fly { to { transform: translateX(calc(-100vw - 100%)); } }
@media (min-width: 600px) { @keyframes fly { to { transform: translateX(-900px); } } }

/* right rail */
.rail { position: absolute; right: 10px; bottom: 150px; z-index: 6; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.rail button { background: none; border: 0; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.rail .ico { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); transition: transform .15s; }
.rail button:active .ico { transform: scale(.85); }
.rail .liked .ico { animation: pop .35s; }
@keyframes pop { 50% { transform: scale(1.4); } }
.rail .avatar { width: 46px; height: 46px; border-radius: 50%; border: 2px solid #fff; overflow: hidden; }
.rail .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* bottom info */
.info { position: absolute; left: 14px; right: 80px; bottom: 26px; z-index: 6; }
.info .series { display: inline-flex; gap: 6px; align-items: center; background: rgba(0,0,0,.35); border-radius: 6px; padding: 4px 8px; font-size: 12px; margin-bottom: 8px; }
.info .series b { color: var(--orange); }
.info h2 { font-size: 19px; font-weight: 900; margin: 0 0 6px; line-height: 1.35; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.info .tags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; opacity: .9; }
.info .tags span::before { content: "#"; }
.info .full { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.18); border-radius: 8px; padding: 6px 10px; font-size: 12px; }

.paused-icon { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; font-size: 72px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.ep.paused .paused-icon { opacity: .85; }

/* ---------- overlays ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: 152px;
  z-index: 40;
  transform: translate(-50%, -10px);
  background: rgba(0,0,0,.82);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.ad, .sheet, .cert { position: absolute; inset: 0; z-index: 30; }
[hidden] { display: none !important; }

.ad { background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 24px; }
.ad-card { position: relative; background: #fff; color: var(--ink); border-radius: 22px; padding: 30px 22px 22px; text-align: center; width: 100%; }
.ad-tag { position: absolute; top: 12px; left: 12px; background: #eee; font-size: 12px; border-radius: 6px; padding: 3px 8px; }
.ad-card img { width: 110px; height: 110px; border-radius: 50%; margin: 0 auto 14px; animation: float 1.2s ease-in-out infinite; }
.ad-card h3 { font-size: 22px; font-weight: 900; margin: 0 0 8px; }
.ad-card p { margin: 0 0 20px; color: #4a4540; line-height: 1.6; }
.ad-skip { width: 100%; padding: 14px; border-radius: 999px; border: 0; background: var(--red); color: #fff; font-weight: 900; font-size: 16px; }
.ad-skip:disabled { background: #ccc; }

.sheet { background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; background: #fff; color: var(--ink); border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .25s ease-out; }
.sheet-card.tall { height: 70%; display: flex; flex-direction: column; }
@keyframes up { from { transform: translateY(100%); } }
.sheet-card h3 { margin: 0 0 6px; font-size: 18px; font-weight: 900; text-align: center; }
.sheet-sub { text-align: center; font-size: 13px; color: #6a645e; margin: 0 0 18px; line-height: 1.6; }
.tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tip-grid button { padding: 16px 8px; border-radius: 14px; border: 2px solid var(--ink); background: var(--cream); font-weight: 700; font-size: 15px; }
.tip-grid button:active { background: var(--orange); }
.sheet-close { width: 100%; background: none; border: 0; padding: 10px; color: #6a645e; font-size: 15px; }
.cmt-list { list-style: none; margin: 10px 0; padding: 0; overflow-y: auto; flex: 1; }
.cmt-list li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0ebe5; font-size: 14px; line-height: 1.5; }
.cmt-list .u { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: var(--cream); }
.cmt-list small { display: block; color: #8a847e; font-size: 12px; }
.cmt-list .me small { color: var(--red); }
.cmt-form { display: flex; gap: 8px; }
.cmt-form input { flex: 1; border: 2px solid #eee; border-radius: 999px; padding: 10px 14px; font: inherit; font-size: 15px; outline: none; min-width: 0; }
.cmt-form input:focus { border-color: var(--red); }
.cmt-form button { border: 0; background: var(--red); color: #fff; font-weight: 900; border-radius: 999px; padding: 0 18px; }

.cert { background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 18px; overflow-y: auto; }
.cert-card { width: 100%; text-align: center; animation: punch .5s ease-out; }
.cert-card canvas { width: 100%; height: auto; border-radius: 16px; box-shadow: 0 20px 60px rgba(255,74,28,.35); }
.cert-actions { display: flex; gap: 10px; margin-top: 14px; }
.cert-actions > * { flex: 1; padding: 14px; border-radius: 999px; font-weight: 900; font-size: 16px; text-decoration: none; text-align: center; }
.btn-dark { background: var(--red); color: #fff; border: 0; }
.btn-light { background: #fff; color: var(--ink); }
.cert-again { margin-top: 12px; background: none; border: 0; color: #fff; opacity: .7; text-decoration: underline; font-size: 14px; }

.hint { position: absolute; inset: 0; z-index: 25; display: grid; place-content: center; text-align: center; background: rgba(0,0,0,.55); pointer-events: none; transition: opacity .4s; }
.hint.gone { opacity: 0; }
.hint-hand { font-size: 52px; animation: swipe 1.4s ease-in-out infinite; }
.hint p { font-weight: 900; font-size: 18px; line-height: 1.5; }
.hint small { font-weight: 400; opacity: .8; font-size: 13px; }
@keyframes swipe { 0% { transform: translateY(30px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- real video ---------- */
.ep.real { background: #000; }
.ep.real::after { background: linear-gradient(transparent 55%, rgba(0,0,0,.65)); }
.vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.ep.real .danmaku { inset: 110px 0 auto 0; }
.ep.real.loading .paused-icon { opacity: .9; }
.ep.real.loading .paused-icon::before { content: ""; position: absolute; width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.ep.real.loading .paused-icon { font-size: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.mute { position: absolute; top: 110px; left: 14px; z-index: 7; border: 0; border-radius: 999px; background: rgba(0,0,0,.5); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 12px; }
.ep.real:not(.muted) .mute { font-size: 18px; padding: 4px 9px; }
.info .desc { margin: 0 0 6px; font-size: 13px; line-height: 1.5; opacity: .9; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.info button.full { border: 0; color: #fff; font: inherit; font-size: 12px; cursor: pointer; }
.eps-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-height: 50vh; overflow-y: auto; margin: 14px 0; }
.eps-grid button { aspect-ratio: 1; border-radius: 10px; border: 0; background: #f3eee8; font-weight: 700; font-size: 15px; color: var(--ink); }
.eps-grid button.seen { color: #a09a94; }
.eps-grid button.on { background: var(--red); color: #fff; }
