:root {
  color-scheme: dark;
  --bg: #070a0c;
  --panel: #11161b;
  --panel-2: #171d22;
  --line: rgba(255, 255, 255, 0.17);
  --muted: #aab2b7;
  --text: #f7f8f8;
  --green: #28e29a;
  --green-2: #17c982;
  --gold: #f3c44f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a { font: inherit; }

button { color: inherit; }

.app {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background: #07090b;
}

.ambient {
  position: absolute;
  z-index: -2;
  inset: -8%;
  background: linear-gradient(rgba(4, 7, 9, .64), rgba(4, 7, 9, .86)), url("/assets/episode-1.png") center / cover;
  filter: blur(34px) saturate(.7);
  opacity: .7;
  transform: scale(1.08);
  transition: background-image .65s ease;
}

.app.episode-two .ambient { background-image: linear-gradient(rgba(4, 7, 9, .64), rgba(4, 7, 9, .86)), url("/assets/episode-2.png"); }

.topbar {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  height: calc(64px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 18px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(4, 7, 9, .78), transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: white;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.4px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #0e1418;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .4);
  transform: rotate(-2deg);
}

.brand-mark i {
  position: absolute;
  left: 7px;
  width: 19px;
  height: 7px;
  border-radius: 8px 2px 8px 2px;
  transform: skewX(-22deg);
}

.brand-mark i:first-child { top: 8px; background: #2de5a0; }
.brand-mark i:last-child { top: 17px; width: 14px; background: #ff4f88; }

.coin-gift,
.login,
.language {
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(18, 23, 28, .78);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.coin-gift {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 13px;
  border-color: rgba(243, 196, 79, .55);
  border-radius: 999px;
  color: #ffe395;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 25px rgba(243, 196, 79, .14);
}

.coin-icon {
  display: inline-grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid #ffe086;
  border-radius: 50%;
  background: linear-gradient(140deg, #b27a0e, #f6ca54);
  color: #4b3100;
  font-size: 10px;
  font-weight: 1000;
}

.coin-icon.small { width: 17px; height: 17px; font-size: 8px; }

.account-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.balance { display: flex; align-items: center; gap: 7px; color: #ffd85e; font-size: 14px; }
.language,
.login { height: 38px; border-radius: 7px; }
.language {
  position: relative;
  display: inline-flex;
  width: 72px;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
}
.language select {
  width: 100%;
  height: 100%;
  padding: 0 25px 0 10px;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}
.language select option { background: #11161b; color: #fff; }
.language svg {
  position: absolute;
  right: 6px;
  width: 15px;
  fill: rgba(255,255,255,.72);
  pointer-events: none;
}
.login { padding: 0 14px; font-size: 13px; font-weight: 800; }

.stage {
  position: absolute;
  z-index: 1;
  top: 0;
  right: clamp(72px, 10.5vw, 205px);
  bottom: 58px;
  left: clamp(72px, 10.5vw, 205px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.frame {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - 62px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0b1013;
  box-shadow: 0 22px 80px rgba(0, 0, 0, .45);
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.035);
  transform-origin: 52% 48%;
  user-select: none;
  -webkit-user-drag: none;
  cursor: pointer;
}

.scene-current { animation: drift 13s ease-in-out infinite alternate; }
.frame.video-ended .scene-current { animation-play-state: paused; }

.scene-next {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.08);
  transition: opacity .7s ease, transform 1.25s ease;
}

.frame.switching .scene-next { opacity: 1; transform: scale(1.035); }

@keyframes drift {
  from { transform: scale(1.035) translate3d(0, 0, 0); }
  to { transform: scale(1.09) translate3d(-.7%, -.3%, 0); }
}

.cinema-shade {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 5, 6, .12) 42%, rgba(3, 5, 6, .86) 100%),
    linear-gradient(90deg, rgba(3, 5, 6, .28), transparent 22%, transparent 75%, rgba(3, 5, 6, .08));
}

.scanline {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.012) 4px);
  mix-blend-mode: soft-light;
}

.story-copy {
  position: absolute;
  z-index: 5;
  left: clamp(18px, 2.2vw, 38px);
  bottom: clamp(22px, 4vw, 64px);
  max-width: min(560px, 60%);
  text-shadow: 0 3px 24px rgba(0,0,0,.75);
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
}

.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1 { margin: 0; font-size: clamp(23px, 2vw, 38px); line-height: 1.1; letter-spacing: -.04em; }

.episode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 9px;
  border: 1px solid rgba(243, 196, 79, .7);
  border-radius: 6px;
  background: rgba(74, 49, 5, .72);
  color: #ffe08a;
  font-size: 11px;
  font-weight: 900;
}

.synopsis { margin: 10px 0 6px; color: #edf1ef; font-size: clamp(12px, 1vw, 15px); line-height: 1.55; }
.tags { margin: 0; color: rgba(255,255,255,.72); font-size: 11px; font-weight: 700; }

.episode-kicker {
  position: absolute;
  z-index: 4;
  top: 82px;
  right: 26px;
  color: rgba(255,255,255,.64);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  writing-mode: vertical-rl;
}

.tap-play {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: grid;
  width: 64px;
  height: 64px;
  padding: 18px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%;
  background: rgba(5,9,11,.36);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.88);
  backdrop-filter: blur(12px);
  transition: opacity .2s ease, transform .2s ease;
  cursor: pointer;
}

.frame:hover .tap-play,
.frame.paused .tap-play { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tap-play svg { width: 25px; fill: white; }
.frame.paused .tap-play svg path { d: path("M8 5v14l11-7z"); }

.playback-bar {
  position: relative;
  z-index: 9;
  width: 100%;
  height: 18px;
  margin-top: -11px;
}

.playback-bar::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 7px;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
}

.playback-bar input {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.playback-bar input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.playback-bar input::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.progress-fill {
  position: absolute;
  z-index: 1;
  top: 7px;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 999px;
  background: #22dc96;
  box-shadow: 0 0 15px rgba(40,226,154,.22);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .24s linear;
  pointer-events: none;
  will-change: transform;
}

.playback-bar input::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  appearance: none;
  border: 2px solid #092b20;
  border-radius: 50%;
  background: #35efa9;
  box-shadow: 0 0 0 3px rgba(53,239,169,.2);
  opacity: 0;
  transition: opacity .15s ease;
}

.playback-bar input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid #092b20;
  border-radius: 50%;
  background: #35efa9;
  opacity: 0;
}

.playback-bar:hover input::-webkit-slider-thumb,
.playback-bar input:focus-visible::-webkit-slider-thumb { opacity: 1; }
.playback-bar:hover input::-moz-range-thumb,
.playback-bar input:focus-visible::-moz-range-thumb { opacity: 1; }

.playback-bar output {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 17px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(5,8,10,.68);
  color: rgba(255,255,255,.8);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  pointer-events: none;
}

.action-dock {
  position: absolute;
  z-index: 30;
  right: 0;
  bottom: calc(8px + var(--safe-bottom));
  left: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.action-dock button { pointer-events: auto; cursor: pointer; }

.secondary,
.unlock {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 850;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.secondary:hover,
.unlock:hover { transform: translateY(-2px); }

.secondary {
  min-width: 132px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(19,24,29,.95);
  color: #f8f8f8;
}

.secondary svg { width: 20px; fill: none; stroke: var(--gold); stroke-width: 1.7; }
.favorite { border-color: rgba(243,196,79,.62); color: #f7d46f; }
.favorite[aria-pressed="true"] svg { fill: var(--gold); }
.follow .plus { font-size: 19px; line-height: 1; }
.follow[aria-pressed="true"] { border-color: var(--green); color: var(--green); }

.unlock {
  position: relative;
  min-width: 236px;
  padding: 6px 20px 6px 48px;
  border: 0;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #062b20;
  box-shadow: 0 12px 36px rgba(31,214,142,.3);
}

.unlock svg { position: absolute; top: 14px; left: 20px; width: 21px; fill: currentColor; }
.unlock-label { display: block; font-size: 15px; }
.unlock-sub { display: block; margin-top: 1px; font-size: 9px; opacity: .7; }
.unlock.done { padding-left: 20px; background: #263129; color: #bdc8c0; box-shadow: none; }
.unlock.done svg { display: none; }

.side-controls {
  position: absolute;
  z-index: 20;
  right: 16px;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transform: translateY(-35%);
}

.side-controls button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 10px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 7px;
  background: rgba(12,16,19,.8);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.side-controls svg { width: 22px; fill: white; }
.sound-on { display: none; }
.sound-enabled .sound-off { display: none; }
.sound-enabled .sound-on { display: block; }

footer {
  position: absolute;
  z-index: 10;
  bottom: calc(12px + var(--safe-bottom));
  left: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.42);
  font-size: 10px;
}

footer button { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
.mock-label { border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: 3px 7px; }

.toast {
  position: absolute;
  z-index: 50;
  top: calc(72px + var(--safe-top));
  left: 50%;
  max-width: calc(100% - 36px);
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  background: rgba(10,14,17,.9);
  color: white;
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  transform: translate(-50%, -12px);
  backdrop-filter: blur(14px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .app { min-height: 520px; }
  .topbar { height: calc(58px + var(--safe-top)); padding-right: 11px; padding-left: 11px; }
  .brand { font-size: 14px; gap: 6px; }
  .brand-mark { width: 29px; height: 29px; }
  .coin-gift { min-height: 34px; padding: 5px 9px; }
  .coin-gift span:last-child { display: none; }
  .account-actions { gap: 6px; }
  .balance { font-size: 12px; gap: 5px; }
  .language { width: 65px; height: 34px; }
  .language select { padding-right: 21px; padding-left: 8px; font-size: 10px; }
  .login { height: 34px; padding: 0 9px; font-size: 11px; }

  .stage { inset: 0 0 0; display: block; }
  .frame { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; }
  .scene { object-fit: cover; transform-origin: 48% center; }
  .cinema-shade {
    background: linear-gradient(180deg, rgba(3,5,6,.22) 0, transparent 34%, rgba(3,5,6,.2) 56%, rgba(3,5,6,.96) 90%);
  }
  .playback-bar { position: absolute; right: 0; bottom: calc(88px + var(--safe-bottom)); left: 0; margin: 0; }
  .playback-bar output { right: 8px; bottom: 17px; }
  .story-copy { right: 18px; bottom: calc(112px + var(--safe-bottom)); left: 18px; max-width: none; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: clamp(24px, 7vw, 31px); }
  .synopsis { max-width: 90%; font-size: 12px; }
  .episode-kicker { top: 74px; right: 12px; }
  .tap-play { display: none; }

  .side-controls { top: auto; right: 10px; bottom: calc(174px + var(--safe-bottom)); transform: none; }
  .side-controls button { width: 38px; height: 38px; padding: 8px; }

  .action-dock {
    bottom: calc(30px + var(--safe-bottom));
    padding: 0 10px;
    gap: 6px;
  }
  .secondary { min-width: 0; width: 54px; padding: 0; font-size: 0; }
  .secondary svg { width: 21px; }
  .follow .plus { font-size: 24px; }
  .unlock { flex: 1; max-width: 290px; min-width: 0; }
  footer { bottom: calc(7px + var(--safe-bottom)); left: 12px; font-size: 8px; }
  footer > :not(.mock-label) { display: none; }
  .mock-label { padding: 2px 6px; }
}

@media (max-height: 650px) and (min-width: 801px) {
  .stage { right: 130px; bottom: 48px; left: 130px; }
  .story-copy { bottom: 34px; }
  .synopsis { display: none; }
  .action-dock { bottom: 4px; transform: scale(.9); transform-origin: bottom center; }
}

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