:root {
  color-scheme: dark;
  --bg: #070e18;
  --ink: #fbf3e7;
  --accent: #f9d99d;
  --accent-bright: #fff0cd;
  --accent-rgb: 247, 194, 117;
  --border: rgba(234, 205, 161, .19);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 290px;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 45%, #17223a 0%, var(--bg) 70%);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
}
body[data-palette="rose"] {
  --bg: #100b17;
  --accent: #f8b9d2;
  --accent-bright: #ffd9e6;
  --accent-rgb: 247, 161, 197;
  --border: rgba(255, 207, 235, .18);
  background: radial-gradient(ellipse at 50% 45%, #21101e 0%, var(--bg) 70%);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { cursor: wait; opacity: .75; }
.icon {
  width: 21px;
  height: 21px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell {
  display: flex;
  flex-direction: column;
  width: calc(100% - clamp(28px, 3.8vw, 80px));
  height: 100svh;
  min-height: 525px;
  margin: 0 auto;
  padding: 17px 0 24px;
}
.shell > main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.masthead { display: flex; align-items: center; justify-content: flex-end; min-height: 70px; padding-bottom: 15px; }
.tools { display: flex; gap: 9px; align-items: center; }
.palette-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  position: relative;
  isolation: isolate;
  min-inline-size: 0;
  padding: 3px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #080d18a6;
  touch-action: pan-y;
  user-select: none;
}
.palette-switch::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: #f2c9841e;
  border: 1px solid #f4c88f62;
  transition: transform .29s cubic-bezier(.2,.75,.25,1), background .29s, border-color .29s;
}
.palette-switch:has(#tone-rose:checked)::before {
  transform: translateX(100%);
  background: #ed99b725;
  border-color: #f8a5c565;
}
.palette-switch label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 43px;
  min-height: 33px;
  padding: 0;
  border-radius: 999px;
  color: #b9b3bb;
  font-size: .875rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.palette-switch label:hover span { transform: scale(1.1); }
.palette-switch input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.palette-switch label span { width: 12px; height: 12px; border-radius: 50%; background: #ffd591; box-shadow: 0 0 7px #ffc67865; }
#tone-rose + label span { background: #f5a6c2; box-shadow: 0 0 7px #f59ab96d; }
.utility {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 41px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 235, 246, .035);
  color: var(--ink);
  font-size: .875rem;
  white-space: nowrap;
}
.utility .icon { width: 17px; height: 17px; color: var(--accent); }
.utility-icon { width: 41px; min-width: 41px; padding: 0; }
.utility:hover { border-color: rgba(var(--accent-rgb), .6); background: rgba(var(--accent-rgb), .12); }

/* One short step at a time, in the centre of the experience. */
.gesture-guide {
  position: fixed; inset: 0; margin: auto; width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); padding: 26px 32px 24px; overflow: auto;
  color: var(--ink); border: 1px solid rgba(var(--accent-rgb), .38); border-radius: 28px;
  background: radial-gradient(ellipse at 50% 0%, #30435a, #101b2b 62%); box-shadow: 0 28px 110px #0009;
  text-align: center; overscroll-behavior: contain;
}
.gesture-guide[open] { animation: guide-arrive .55s cubic-bezier(.2,.85,.28,1.15) both; }
.gesture-guide::backdrop { background: #040811a6; animation: guide-dim .3s both; }
body[data-palette="rose"] .gesture-guide { background: radial-gradient(ellipse at 50% 0%, #473049, #1d1424 62%); }
.guide-close { position: absolute; top: 14px; right: 14px; z-index: 2; width: 36px; min-width: 36px; min-height: 36px; }
.guide-visual { position: relative; height: 195px; color: var(--accent); margin-bottom: 8px; }
.guide-universe { width: 100%; height: 100%; overflow: visible; }
.guide-orbits { opacity: .3; stroke-width: .7; }
.guide-spruce, .guide-star { opacity: 0; transition: opacity .5s; }
.guide-visual[data-step="1"] :is(.guide-spruce, .guide-star) { opacity: 1; }
.guide-visual[data-step="1"] .guide-orbits { opacity: .08; }
.guide-mote { transform: translate(var(--x), var(--y)); transition: transform 1.8s cubic-bezier(.22,.7,.18,1); }
.guide-visual[data-step="1"] .guide-mote { transform: translate(var(--tx), var(--ty)); }
.guide-mote path { animation: guide-twinkle 2.5s ease-in-out infinite alternate; animation-delay: var(--delay); }
.guide-hand { position: absolute; width: 58px; height: 58px; left: 18px; bottom: 6px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 18px; background: #152339eb; box-shadow: 0 0 22px #05080a50; }
.guide-hand .icon { width: 38px; height: 38px; stroke-width: 1.9; }
.guide-number-art, .guide-gift-art { display: none; }
.guide-visual[data-step="2"] .guide-universe, .guide-visual[data-step="3"] .guide-universe { opacity: .22; }
.guide-visual:is([data-step="2"], [data-step="3"]) .guide-hand { display: none; }
.guide-visual[data-step="2"] .guide-number-art { display: flex; gap: 28px; position: absolute; inset: 0; align-items: center; justify-content: center; font: 600 86px/1 var(--serif); text-shadow: 0 0 20px rgba(var(--accent-rgb), .4); }
.guide-number-art span { animation: guide-float 3s ease-in-out infinite alternate; }
.guide-number-art span:nth-child(2) { animation-delay: -.9s; color: #fff1d3; }
.guide-number-art span:nth-child(3) { animation-delay: -1.8s; }
.guide-visual[data-step="3"] .guide-gift-art { display: block; position: absolute; left: calc(50% - 47px); top: 32px; width: 94px; height: 130px; }
.guide-gift-art span { display: block; width: 74px; height: 89px; padding-top: 10px; margin: 0 auto; border: 1px solid #f4d29a; border-radius: 9px; font: 600 53px/1.2 var(--serif); background: linear-gradient(140deg,#50326a,#251d3e); box-shadow: 0 0 25px #f0c98a4a; animation: guide-float 2.8s ease-in-out infinite alternate; }
.guide-gift-art i { position: absolute; left: -5px; right: -5px; bottom: 32px; height: 18px; border: 1px solid #bd92ce; border-radius: 4px; transform: rotate(-8deg) translateY(-8px); background: linear-gradient(90deg,#8252a0 42%,#f8d3a3 42% 57%,#8252a0 57%); }
.guide-gift-art b { position: absolute; bottom: 0; left: 0; right: 0; height: 38px; border: 1px solid #a87cc1; border-radius: 3px 3px 7px 7px; background: linear-gradient(90deg,#684183 43%,#e5bb87 43% 56%,#684183 56%); }
.gesture-guide p { margin: 0; }
.guide-eyebrow { color: var(--accent); font-size: .875rem; letter-spacing: .13em; }
.gesture-guide h2 { font-size: clamp(1.3rem, 4.6vw, 1.6rem); line-height: 1.35; margin: 10px 0 14px; font-weight: 600; }
#guide-copy { font-size: 1rem; line-height: 1.75; min-height: 84px; color: #e6e2df; }
.guide-tip { min-height: 44px; margin-top: 12px !important; color: #b7b7c2; font-size: .875rem; }
.guide-pages { display: flex; justify-content: center; gap: 2px; margin: 13px 0; }
.guide-pages button { border: 0; padding: 0; width: 34px; height: 30px; background: transparent; display: grid; place-items: center; }
.guide-pages button::after { content: ""; width: 6px; height: 6px; border-radius: 9px; background: #8190a35e; transition: width .25s, background .25s; }
.guide-pages button[aria-current="step"]::after { width: 24px; background: var(--accent); box-shadow: 0 0 9px rgba(var(--accent-rgb), .25); }
.guide-footer { display: flex; justify-content: space-between; gap: 12px; }
.guide-footer button { min-height: 44px; font-size: 1rem; padding-inline: 22px; }
.guide-next { background: var(--accent); color: #192130; border-color: var(--accent); min-width: 132px; }
.guide-next:hover { background: var(--accent-bright); }
#guide-prev:disabled { visibility: hidden; }
.gesture-signal { position: fixed; inset: auto 0 24px; margin: 0 auto; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%; background: #0b1326d9; color: var(--accent); pointer-events: none; overflow: visible; z-index: 20; box-shadow: 0 4px 24px #0004; }
.gesture-signal > svg:first-child { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; transform: rotate(-90deg); }
.signal-track { opacity: .15; }
#signal-progress { stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; transition: stroke-dashoffset .12s linear; }
#signal-digit { display: grid; place-items: center; width: 100%; height: 100%; font: 500 21px/1 var(--sans); }
.signal-check { display: none; position: absolute; right: -3px; bottom: 0; background: #14292a; border-radius: 50%; width: 20px; height: 20px; padding: 2px; }
.gesture-signal[data-confirmed="true"] { color: #a8e6c8; }
.gesture-signal[data-confirmed="true"] .signal-check { display: block; }
@keyframes guide-arrive { from { opacity: 0; transform: translateY(25px) scale(.91); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes guide-dim { from { opacity: 0; } to { opacity: 1; } }
@keyframes guide-twinkle { from { opacity: .5; } to { opacity: 1; } }
@keyframes guide-float { from { transform: translateY(4px); } to { transform: translateY(-7px); } }
@media (max-width: 420px) { .gesture-guide { padding: 24px 22px 20px; } .guide-visual { height: 165px; } }
@media (max-height: 650px) { .guide-visual { height: 120px; } .gesture-guide { padding-top: 18px; } #guide-copy { min-height: 0; } .guide-tip { min-height: 0; } }
@media (prefers-reduced-motion: reduce) { .gesture-guide, .gesture-guide::backdrop, .guide-mote path, .guide-number-art span, .guide-gift-art span { animation: none !important; } .guide-mote { transition: none; } }

.camera-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  max-width: 760px;
  padding: 11px 14px;
  flex: none;
  margin: 0 0 12px auto;
  color: #f6ede8;
  border: 1px solid #ee9b9a52;
  border-radius: 12px;
  background: #221926;
  text-align: start;
}
.camera-note[data-mode="loading"] { border-color: #e2c29157; background: #1b1b26; }
.camera-note strong { font-size: .92rem; }
.camera-note p { margin: 2px 0 0; color: #dacbd4; font-size: .82rem; }
.camera-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.camera-actions .utility { min-height: 34px; padding-inline: 12px; text-decoration: none; }
.camera-device { display: flex; gap: 6px; align-items: center; color: #dacbd4; font-size: .82rem; }
.camera-device select {
  width: min(140px, 45vw);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  background: #121827;
  color: var(--ink);
  font: inherit;
}
@media (max-width: 650px) {
  .camera-note { align-items: start; flex-direction: column; }
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  isolation: isolate;
  border: 1px solid var(--border);
  border-radius: 26px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 58%, #263044 0%, #121e36 36%, #081628 69%, #071321 100%);
}
body[data-palette="rose"] .stage { background: radial-gradient(ellipse at 50% 54%, #331a35, #211326 36%, #121423 72%, #0e101e); }
.art { position: absolute; inset: 0; border-radius: inherit; z-index: -1; overflow: hidden; touch-action: pan-y; cursor: grab; }
.art:active { cursor: grabbing; }
#scene { width: 100%; height: 100%; display: block; }
#camera-video { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#camera-toggle[data-state="active"] .icon { color: #c4cddc; }
#camera-toggle[data-tracking="true"] { border-color: #a4e6bd80; box-shadow: 0 0 13px #74e4b533; }
#camera-toggle[data-armed="true"] .icon { color: #a4e6bd; filter: drop-shadow(0 0 5px #74e4b564); }
#camera-toggle[data-state="loading"] .icon { color: #ffdf9e; }
#camera-toggle[data-state="error"] .icon { color: #f9a6b2; }

#player-dialog {
  width: min(100vw, 960px);
  height: min(100svh, 930px);
  max-width: none;
  max-height: 100svh;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: transparent;
  border: 0;
}
#player-dialog::backdrop {
  background: #050c18c4;
}
.portrait-stage {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  width: 100%;
  height: 100%;
  --box-w: clamp(116px, 22vmin, 225px);
  --wrap: #a52845;
  --lid: #ce4860;
  background: radial-gradient(ellipse at 50% 55%, #6b4a3455, #0c182438 37%, transparent 70%);
}

.portrait-stage[data-team="lakers"] { --wrap: #602d83; --lid: #8b46ad; }
.portrait-stage[data-team="warriors"] { --wrap: #254b91; --lid: #3f70be; }
.portrait-stage[data-team="thunder"] { --wrap: #204f83; --lid: #376aa5; }
.portrait-stage[data-team="knicks"] { --wrap: #a5442a; --lid: #d1653b; }
.halo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#halo-back { z-index: 0; }
#halo-front { z-index: 2; }
.portrait {
  width: min(67vw, 391px, 45svh);
  aspect-ratio: 744 / 1000;
  position: relative;
  z-index: 1;
  padding: 0;
  color: inherit;
  background: #140a17;
  border: 3px solid #e9b365;
  outline: 1px solid #ffe9b5;
  outline-offset: 2px;
  border-radius: clamp(6px, 1.6vw, 12px);
  box-shadow: 0 0 22px #ffdb8a65, 0 0 70px #d6557269, 0 18px 65px #09040bdc;
}
.portrait img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.portrait-stage.revealing .portrait {
  animation: gift-photo 1.44s linear both;
}
.gift-reveal {
  position: absolute;
  z-index: 2;
  bottom: 5.6%;
  left: 50%;
  width: var(--box-w);
  height: calc(var(--box-w) * .69);
  transform: translateX(-50%);
  pointer-events: none;
}
.gift-opening {
  position: absolute;
  inset: -57% -42% 15%;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 65%, #fff6d4f4 0%, #ffc14ee4 14%, #ee8d4867 33%, transparent 69%);
  opacity: .34;
}
.gift-box, .gift-lid {
  position: absolute;
  width: 100%;
  border-radius: 7px;
  border: 1px solid #ffba8265;
  background-image: linear-gradient(90deg, transparent 41%, #e49c49 42%, #f4c871 47%, #ffe7a5 50%, #cf913e 58%, transparent 59%),
    radial-gradient(circle, #ffe8af82 1px, transparent 1.6px), linear-gradient(136deg, #ffffff34, transparent 34%, #350e2c94);
  background-size: auto, 14px 14px, auto;
}
.gift-box {
  inset: 26% 0 0;
  background-color: var(--wrap);
  box-shadow: 0 12px 46px #010510b9, 0 0 38px #ffc27749, inset 0 8px 15px #500f3374;
}
.gift-lid {
  inset: 12% -5% auto;
  width: 110%;
  height: 21%;
  background-color: var(--lid);
  box-shadow: 0 4px 10px #2206278a, inset 0 2px 4px #ffe6b15e;
}
.gift-bow {
  position: absolute;
  left: 43%;
  bottom: 83%;
  width: 14%;
  height: 58%;
  z-index: 1;
  border-radius: 5px;
  background: linear-gradient(110deg, #ad6a24, #ffe9a5 42%, #eeb852 82%);
}
.gift-bow::before, .gift-bow::after {
  content: "";
  position: absolute;
  bottom: 17%;
  width: 176%;
  height: 142%;
  border: 5px solid #efbb62;
  background: #fad28820;
  box-shadow: inset 0 0 5px #fff3c991;
}
.gift-bow::before { right: 80%; border-radius: 70% 90% 20% 80%; transform: rotate(17deg); }
.gift-bow::after { left: 80%; border-radius: 90% 70% 80% 20%; transform: rotate(-17deg); }
.portrait-stage.revealing .gift-reveal { animation: gift-arrive 1.1s cubic-bezier(.2,.83,.2,1) both; }
.portrait-stage.revealing .gift-lid { animation: gift-open 1.36s ease-out both; }
.portrait-stage.revealing .gift-opening { animation: gift-flare 1.36s ease-out both; }
.portrait:focus-visible { outline-color: #ffe6aa; }
.photo-credit {
  position: absolute;
  z-index: 3;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 7px;
  background: #211323;
  color: #f6dcb0;
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
}
.photo-credit:focus-visible { opacity: 1; pointer-events: auto; }
@keyframes gift-arrive {
  0% { opacity: 0; transform: translate(-50%, 52px) scale(.77); }
  27% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  40% { transform: translate(-50%, 1px) scale(1.06,.91); }
  63%, 100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes gift-open {
  0%, 37% { opacity: 1; transform: none; }
  60% { opacity: 1; transform: translate(-64%, -165%) rotate(-31deg); }
  100% { opacity: 0; transform: translate(-118%, 67%) rotate(-42deg); }
}
@keyframes gift-photo {
  0%, 33% { opacity: 0; transform: translate3d(0, 30svh, 0) scale(.12) rotate(-10deg); animation-timing-function: cubic-bezier(.2,.52,.27,1); }
  54% { opacity: 1; transform: translate3d(0, 8svh, 0) scale(.77) rotate(-2deg); animation-timing-function: cubic-bezier(.16,.42,.29,1); }
  79% { opacity: 1; transform: translate3d(0, -3.2svh, 0) scale(1.018) rotate(1deg); animation-timing-function: ease-out; }
  100% { opacity: 1; transform: translate3d(0, -2.4svh, 0) scale(1) rotate(0); }
}
@keyframes gift-flare {
  0%, 36% { opacity: .10; transform: scale(.76); }
  56% { opacity: 1; transform: scale(1.26); }
  100% { opacity: .34; transform: scale(1); }
}

:is(:fullscreen, body[data-filled="true"]) .shell { width: 100%; min-height: 0; padding: 0; }
:is(:fullscreen, body[data-filled="true"]) .masthead {
  position: absolute;
  top: 14px;
  right: clamp(12px, 2vw, 35px);
  z-index: 3;
  min-height: 0;
  padding: 0;
}
:is(:fullscreen, body[data-filled="true"]) .stage { border: 0; border-radius: 0; }
:is(:fullscreen, body[data-filled="true"]) .camera-note {
  position: absolute;
  top: 65px;
  right: clamp(12px, 2vw, 35px);
  z-index: 2;
  max-width: calc(100% - 24px);
}

@media (max-width: 1050px) { .shell { width: calc(100% - 44px); } }
@media (max-width: 760px) {
  .shell { width: calc(100% - 28px); padding-top: 7px; padding-bottom: 16px; }
  .masthead { min-height: 62px; padding-bottom: 7px; }
  .stage { border-radius: 20px; }
}
@media (max-width: 340px) {
  .tools { gap: 5px; }
  .palette-switch label { width: 39px; }
  .utility { padding-inline: 8px; }
  .utility-icon { width: 36px; min-width: 36px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
