/* the full-screen class player (player.js): /play/<flow> and the /lp/ryan story */
:root {
  color-scheme: dark;
  --gold: #e2bd6b;
  --gold-deep: #b98d35;
  --glass: rgba(20, 17, 14, .46);
  --line: rgba(255, 255, 255, .18);
  --ok: #4cc38a;
  --font: var(--cjk, "Noto Sans HK"), system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #14110e; color: #fff; font-family: var(--font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

/* the 9:16 screen: full viewport on phones, a centred phone-sized column on wide screens */
.backdrop { position: fixed; inset: -40px; background: center / cover var(--backdrop, none); filter: blur(30px) brightness(.45); }
.screen {
  position: relative; height: 100dvh; width: 100%; margin: 0 auto; overflow: hidden; background: #14110e;
}
@media (min-aspect-ratio: 10 / 16) { .screen { width: calc(100dvh * 9 / 16); box-shadow: 0 0 80px rgba(0, 0, 0, .6); } }
.scenes { position: absolute; inset: 0; }
.scene {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%;
  transition: opacity .7s ease;
}
.scene.off { opacity: 0; }
.scene.step { object-position: 50% 45%; }
.scene.mirror { transform: scaleX(-1); }
.shade {
  position: absolute; inset: 0; pointer-events: none; transition: background .6s ease;
  background: linear-gradient(180deg, rgba(0, 0, 0, .45) 0%, transparent 18%, transparent 52%, rgba(10, 8, 6, .82) 100%);
}
/* /lp/ryan story: darker while the "what's tired" choices are up */
.screen.asking .shade { background: linear-gradient(180deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, .1) 30%, rgba(10, 8, 6, .9) 100%); }
.screen.flowing .shade { background: linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, transparent 22%, transparent 60%, rgba(10, 8, 6, .78) 100%); }

.top {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: "Bricolage Grotesque", var(--font); font-weight: 700; font-size: 1.02rem; color: #fff; text-decoration: none; }
.brand img { width: 30px; height: 30px; padding: 3px; border-radius: 9px; background: rgba(255, 255, 255, .92); }
.brand small { opacity: .7; font-weight: 500; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(10px); display: grid; place-items: center; padding: 0;
}
.round svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round.off { opacity: .55; }
/* /lp/ryan story only: sound toggle, tap hint, the 'what's tired' choices */
.sound .wave { display: none; }
.sound[aria-pressed="true"] .wave { display: inline; }
.sound[aria-pressed="true"] .mute { display: none; }

.tap-hint {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px);
  font-size: .95rem; font-weight: 500; white-space: nowrap; animation: pulse 2.2s ease-in-out infinite;
}
.tap-hint svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pulse { 0%, 100% { opacity: .95; } 50% { opacity: .6; } }

.bottom {
  position: absolute; inset: auto 0 0; padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  display: grid; gap: 12px; justify-items: center;
}
.say {
  max-width: 100%; margin: 0; padding: 10px 16px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(12px); font-size: 1rem; line-height: 1.5; font-weight: 500; text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4); transition: opacity .25s ease;
}
.say b { color: var(--gold); font-weight: 700; margin-right: 4px; }
.say.fade { opacity: 0; }

.cta {
  width: 100%; max-width: 420px; padding: 18px 20px; border: 0; border-radius: 18px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #1d160c;
  font-size: 1.18rem; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 10px 30px rgba(185, 141, 53, .45), inset 0 1px 0 rgba(255, 255, 255, .5);
  text-decoration: none; text-align: center; display: block; animation: glow 2.6s ease-in-out infinite;
}
.cta:active { transform: translateY(1px); }
@keyframes glow { 0%, 100% { box-shadow: 0 10px 30px rgba(185, 141, 53, .4), inset 0 1px 0 rgba(255, 255, 255, .5); } 50% { box-shadow: 0 10px 44px rgba(226, 189, 107, .7), inset 0 1px 0 rgba(255, 255, 255, .5); } }
.fine { margin: 0; font-size: .78rem; opacity: .72; text-align: center; }
.skip { background: none; border: 0; font-size: .86rem; opacity: .75; padding: 2px 8px; text-decoration: none; color: #fff; }

.choices { width: 100%; max-width: 420px; display: grid; gap: 10px; justify-items: stretch; }
.choices.center { justify-items: center; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 18px; border-radius: 16px;
  background: rgba(255, 255, 255, .12); border: 1px solid var(--line); backdrop-filter: blur(12px);
  font-size: 1.05rem; font-weight: 700; text-align: left;
}
.choice span { font-size: 1.3rem; }
.choice:active { background: rgba(226, 189, 107, .3); border-color: var(--gold); }

/* ---------- the in-page flow ---------- */
.flow-top {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
}
.flow-top .info { flex: 1; min-width: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.flow-top small { display: block; font-size: .8rem; opacity: .8; }
.flow-top strong { display: block; font-size: 1.2rem; line-height: 1.3; }
.flow-top .status { font-size: .82rem; color: var(--gold); }
.timer { position: relative; width: 66px; height: 66px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 5; }
.timer .track { stroke: rgba(255, 255, 255, .2); }
.timer .bar { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 188.5; transition: stroke-dashoffset .3s linear; }
.timer b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.progress { position: absolute; left: 16px; right: 16px; top: calc(6px + env(safe-area-inset-top)); display: flex; gap: 3px; }
.progress i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
.progress i.done { background: var(--gold); }
.progress i.now { background: rgba(226, 189, 107, .6); }

/* the user's own camera: a small mirrored picture-in-picture, tap to enlarge */
.pip {
  position: absolute; right: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); width: 30%; aspect-ratio: 3 / 4;
  border-radius: 16px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .55); background: #000;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .5); transition: width .3s ease; padding: 0;
}
.pip.big { width: 52%; }
.pip video, .pip canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pip.mirror video, .pip.mirror canvas { transform: scaleX(-1); }
.pip .score {
  position: absolute; left: 6px; top: 6px; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px;
  display: grid; place-items: center; font-size: .9rem; font-weight: 700; background: rgba(0, 0, 0, .55);
  border: 2px solid rgba(255, 255, 255, .4);
}
.pip .score.good { border-color: var(--ok); }
.pip .score.ok { border-color: var(--gold); }
.pip .lost { position: absolute; inset: auto 0 0; padding: 4px; font-size: .72rem; text-align: center; background: rgba(0, 0, 0, .55); }

/* the camera step: a demo of what the analysis looks like, before the user allows the camera */
.cam-demo {
  position: absolute; right: 12px; bottom: calc(330px + env(safe-area-inset-bottom)); width: 42%; aspect-ratio: 3 / 4;
  border-radius: 18px; overflow: hidden; border: 2px solid rgba(226, 189, 107, .85); background: #000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55); animation: pop .45s ease-out;
}
.cam-demo video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-demo .label {
  position: absolute; inset: 0 0 auto; padding: 6px 8px; font-size: .74rem; font-weight: 700; text-align: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent);
}
.cam-demo .score {
  position: absolute; left: 8px; top: 30px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: rgba(0, 0, 0, .55); border: 3px solid var(--ok);
}
.cam-demo .tip {
  position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; border-radius: 10px; font-size: .8rem;
  font-weight: 700; text-align: center; background: rgba(20, 17, 14, .72); border: 1px solid var(--line);
  transition: opacity .25s ease;
}
.cam-demo .tip.good { color: var(--ok); }
.cam-demo .tip.fix { color: var(--gold); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.controls { display: flex; gap: 14px; justify-content: center; }
.summary { margin: 0; padding: 16px 18px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); text-align: center; width: 100%; max-width: 420px; }
.summary strong { display: block; font-size: 1.25rem; margin-bottom: 4px; }

/* the /play start card: which class, with whom, where the phone goes */
.intro-card {
  width: 100%; max-width: 420px; margin: 0; padding: 16px 18px; border-radius: 18px; background: var(--glass);
  border: 1px solid var(--line); backdrop-filter: blur(12px); display: grid; gap: 8px;
}
.intro-card h1 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.intro-card .tagline { margin: 0; opacity: .85; font-size: .92rem; }
.intro-card .setup { margin: 0; font-size: .86rem; line-height: 1.55; color: var(--gold); }
.coach-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.coach-pick a {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; color: #fff;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .08); text-decoration: none; font-size: .9rem; font-weight: 700;
}
.coach-pick a[aria-current="true"] { border-color: var(--gold); background: rgba(226, 189, 107, .22); }
.coach-pick img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

/* in-app browsers (Facebook, Instagram, WeChat...): a guide pointing at their menu, top right of the screen */
.inapp {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 6, 4, .9);
  display: grid; align-items: start; justify-items: center; padding: calc(110px + env(safe-area-inset-top)) 18px 24px;
  overflow-y: auto; font-family: var(--font);
}
.inapp-arrow {
  position: fixed; z-index: 51; top: calc(4px + env(safe-area-inset-top)); right: 14px; width: 64px; height: 96px;
  fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(5px, -8px); } }
.inapp-card {
  width: 100%; max-width: 400px; padding: 20px 18px; border-radius: 20px; background: rgba(28, 24, 20, .96);
  border: 1px solid var(--line); display: grid; gap: 12px; justify-items: center; text-align: center; color: #fff;
}
.inapp-card h2 { margin: 0; font-size: 1.2rem; line-height: 1.35; }
.inapp-card p { margin: 0; font-size: .9rem; line-height: 1.5; opacity: .85; }
.inapp-card ol { list-style: none; margin: 2px 0; padding: 0; width: 100%; display: grid; gap: 10px; counter-reset: s; }
.inapp-card li {
  counter-increment: s; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, .08); text-align: left; font-weight: 700; font-size: 1rem;
}
.inapp-card li::before { content: counter(s); color: var(--gold); font-size: 1.1rem; width: 1em; }
.inapp-card li small { display: block; font-weight: 500; font-size: .8rem; opacity: .7; }
.inapp-icon {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #1d160c;
  font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.inapp-icon svg { width: 22px; height: 22px; fill: none; stroke: #1d160c; stroke-width: 1.8; }
.inapp-card h2:focus { outline: none; }
.inapp-link {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08);
  color: #fff; font: inherit; font-size: 16px;
}

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .tap-hint, .cta, .inapp-arrow { animation: none; } }
  
