:root {
  --bg: #03050f;
  --navy: #002358;
  --panel: rgba(10, 16, 40, 0.72);
  --line: rgba(160, 182, 240, 0.18);
  --text: #e9eefb;
  --dim: #95a3c8;
  --accent: #6f9bff;
  --ui: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:lang(ja) { --ui: Inter, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif; }
:lang(ko) { --ui: Inter, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif; }
:lang(th) { --ui: Inter, Thonburi, "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; touch-action: manipulation; }
body.idle { cursor: none; }

#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); transition: right 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (min-width: 761px) {
  body.drawer #stage, body.drawer #top, body.drawer #bottom, body.drawer #legal { right: min(440px, 92vw); }
  #top, #bottom { transition: opacity 0.4s ease, transform 0.4s ease, right 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
}
#view { display: block; background: #03050f; }

/* ---------- chrome (auto-hides while playing; a tap on the picture hides it until the next tap) ---------- */
.chrome { position: fixed; left: 0; right: 0; z-index: 10; transition: opacity 0.4s ease, transform 0.4s ease; }
body.idle .chrome, body.hidechrome .chrome, body.hidechrome #ended { opacity: 0; pointer-events: none; }
body.idle #top, body.hidechrome #top { transform: translateY(-8px); }
body.idle #bottom, body.hidechrome #bottom { transform: translateY(8px); }

#top {
  top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + var(--safe-t)) clamp(16px, 3vw, 32px) 28px;
  background: linear-gradient(to bottom, rgba(3, 5, 15, 0.82), rgba(3, 5, 15, 0));
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand .mark { width: 26px; height: 26px; }
.brand .word { height: 14px; width: auto; }
.brand .mark g, .brand .word path { fill: #fff; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); color: var(--text); cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 13px; font-weight: 600;
}
.pill:hover { background: rgba(255, 255, 255, 0.14); }
.pill svg { width: 16px; height: 16px; flex: none; }
.pill .chev { width: 14px; height: 14px; opacity: 0.7; }
.pill.big { height: 44px; padding: 0 18px; font-size: 14px; }

.lang { position: relative; }
#langList {
  position: absolute; right: 0; top: 44px; min-width: 168px; margin: 0; padding: 6px; list-style: none;
  background: rgba(12, 18, 44, 0.94); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#langList li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; }
#langList li:hover, #langList li:focus { background: rgba(255, 255, 255, 0.08); outline: none; }
#langList li.on { color: #fff; }
#langList li.on::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
#langList li span { color: var(--dim); font-size: 12px; font-family: var(--mono); }

/* ---------- intro / ended ---------- */
#intro {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 46%, rgba(0, 35, 88, 0.55), rgba(3, 5, 15, 0.86) 70%);
  transition: opacity 0.6s ease;
}
#intro.hide { opacity: 0; pointer-events: none; }
#intro .kicker { font: 600 12px/1 var(--mono); letter-spacing: 0.42em; color: var(--dim); margin-bottom: 4px; }
#intro h1 { margin: 0; font-weight: 700; font-size: clamp(24px, 4.2vw, 52px); line-height: 1.2; letter-spacing: 0.01em; max-width: 18em; text-wrap: balance; word-break: auto-phrase; }
#intro #subtitle { margin: 0; color: var(--dim); font-size: clamp(14px, 1.5vw, 18px); font-weight: 500; }
#bigplay {
  margin-top: 18px; width: 92px; height: 92px; border-radius: 50%; border: 0; background: #fff; color: var(--navy);
  display: grid; place-items: center; cursor: pointer; position: relative; transition: transform 0.2s ease;
}
#bigplay::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); animation: ring 2.4s ease-out infinite; }
@keyframes ring { from { transform: scale(0.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
#bigplay:hover { transform: scale(1.05); }
#bigplay svg { width: 32px; height: 32px; margin-left: 5px; }
#intro .hint { margin: 10px 0 0; color: var(--dim); font-size: 13px; }

#ended { position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-b)); z-index: 12; display: flex; justify-content: center; transition: opacity 0.4s ease; }
#ended[hidden] { display: none; }

/* ---------- control bar ---------- */
#bottom { bottom: 0; z-index: 22; padding: 40px clamp(10px, 2.4vw, 28px) calc(30px + var(--safe-b)); background: linear-gradient(to top, rgba(3, 5, 15, 0.85), rgba(3, 5, 15, 0)); }
#bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  max-width: 1280px; margin: 0 auto;
}
.ico { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; }
.ico:hover { background: rgba(255, 255, 255, 0.08); }
.ico svg { width: 20px; height: 20px; }
#play { background: #fff; color: var(--navy); border-radius: 50%; }
#play:hover { background: #e6ebff; }
.txt { flex: none; height: 34px; padding: 0 11px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.txt:hover { background: rgba(255, 255, 255, 0.08); }
.txt.on { background: rgba(90, 130, 255, 0.2); border-color: rgba(120, 155, 255, 0.35); }
#time { flex: none; font: 500 12px var(--mono); color: var(--dim); min-width: 92px; text-align: center; }
#track { position: relative; flex: 1; height: 32px; cursor: pointer; min-width: 60px; touch-action: none; }
#track .rail { position: absolute; left: 0; right: 0; top: 14px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
#track .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #4f7dff, #9cc0ff); }
#track .seg { position: absolute; top: 10px; width: 1px; height: 12px; background: rgba(255, 255, 255, 0.35); }
#track .head { position: absolute; top: 9px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(111, 155, 255, 0.25); }
#track .tip { position: absolute; bottom: 34px; transform: translateX(-50%); font: 500 11px var(--ui); background: rgba(0, 0, 0, 0.78); padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; display: none; }
#track:hover .tip { display: block; }
#legal { position: fixed; left: 0; right: 0; bottom: calc(6px + var(--safe-b)); z-index: 23; padding: 0 16px; text-align: center; font-size: 11px; line-height: 1.4; color: rgba(149, 163, 200, 0.75); }
#legal a { color: inherit; text-decoration: none; }
#legal a:hover { text-decoration: underline; }

/* ---------- script drawer (英文底稿) ---------- */
#script {
  position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); display: flex; flex-direction: column;
  background: #080c20; border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(0, 0, 0, 0.45);
  transform: translateX(104%); transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#script.open { transform: none; }
.shead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: calc(20px + var(--safe-t)) 20px 14px; border-bottom: 1px solid var(--line); }
.shead h2 { margin: 0; font-size: 17px; font-weight: 700; }
.shead p { margin: 6px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--dim); }
#lines { list-style: none; margin: 0; padding: 8px 10px calc(28px + var(--safe-b)); overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#lines .ch { padding: 18px 10px 6px; font: 700 11px var(--mono); letter-spacing: 0.24em; color: var(--accent); }
#lines .ln { display: grid; grid-template-columns: 48px 1fr; gap: 2px 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
#lines .ln:hover { background: rgba(255, 255, 255, 0.05); }
#lines .ln.on { background: rgba(90, 130, 255, 0.16); }
#lines .tc { grid-row: span 2; font: 500 11px var(--mono); color: var(--dim); padding-top: 3px; }
#lines .en { font-size: 15px; line-height: 1.45; color: #fff; font-family: Inter, var(--ui); }
#lines .tr { font-size: 13px; line-height: 1.5; color: var(--dim); }

@media (max-width: 760px) {
  #script { top: auto; left: 0; right: 0; width: auto; height: 64vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transform: translateY(104%); }
  #bar { gap: 6px; padding: 6px; }
  .txt { padding: 0 8px; font-size: 12px; }
  #time { min-width: 0; }
}
@media (max-width: 520px) {
  #time { display: none; }
  .ico { width: 34px; height: 34px; }
  #top { padding-bottom: 18px; }
}

/* ---------- portrait phones: readable captions under the film ---------- */
#cap { display: none; position: fixed; left: 16px; right: 16px; z-index: 6; text-align: center; transition: opacity 0.18s ease; pointer-events: none; }
body.portrait #cap { display: block; }
#cap .n { font-size: 19px; line-height: 1.45; font-weight: 600; color: #fff; text-wrap: balance; word-break: auto-phrase; }
#cap .e { margin-top: 6px; font-size: 14px; line-height: 1.45; color: var(--dim); font-family: Inter, var(--ui); text-wrap: balance; }
