*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

/* ????????? */
body.page-select {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: #0f172a;
}

.select-full-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

/* ?????? 1080?1920 ?????????????????????? cqi ????????? */
.select-artboard-wrap {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  pointer-events: none;
}

.select-artboard {
  container-type: inline-size;
  container-name: select-board;
  position: relative;
  width: min(100vw, calc(100dvh * 1080 / 1920));
  aspect-ratio: 1080 / 1920;
  max-height: 100dvh;
  pointer-events: none;
}

/* ??????/??? JS ?????????????? */
.select-character-anchor-row {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--select-character-top-pct, calc(100% * 480 / 1920));
  pointer-events: auto;
}

.select-character-frame {
  box-sizing: border-box;
  width: var(--select-character-width-pct, calc(100% * 590 / 1080));
  margin-left: auto;
  margin-right: auto;
}

/* ????????????????????????? */
.select-character-frame .layer-body {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

/* ????????????????--select-arrow-top-pct?????? 50px???? 150/1080 ??? */
.select-artboard > .select-arrow-side {
  z-index: 1;
}

.select-arrow-side {
  position: absolute;
  top: var(--select-arrow-top-pct, calc(100% * 880 / 1920));
  transform: translateY(-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  /* ?? 150?150?????? 1080 ???? --select-arrow-frac ??? */
  width: calc(100cqi * var(--select-arrow-frac, 0.138889));
  height: calc(100cqi * var(--select-arrow-frac, 0.138889));
  box-sizing: border-box;
}

.select-arrow-side--left {
  left: calc(100cqi * var(--select-arrow-inset-frac, 0.046296));
}

.select-arrow-side--right {
  right: calc(100cqi * var(--select-arrow-inset-frac, 0.046296));
}

/* ??????? 1650px????? */
.select-confirm-slot {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--select-controls-top-pct, calc(100% * 1650 / 1920));
  display: flex;
  justify-content: center;
  padding: 0 calc(100cqi * 16 / 1080);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: auto;
}

/* ???????anniu_bj + ????? 610/1080 ????????????? */
.select-btn-anniu {
  position: relative;
  border: none;
  cursor: pointer;
  min-height: max(44px, calc(100cqi * 52 / 1080));
  width: min(calc(100cqi * var(--select-confirm-width-frac, 0.564815)), 96%);
  padding: 0 calc(100cqi * 28 / 1080);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  background-image: var(--select-anniu-bg, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  font-size: clamp(1.08rem, calc(100cqi * 34 / 1080), 1.5rem);
  font-weight: 700;
  color: #0c4a6e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.select-btn-anniu-text {
  position: relative;
  z-index: 1;
}

/* ???????????????????? */
.page--select {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px
    calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  background: transparent;
}

.page--select--floating {
  position: fixed;
  inset: 0;
  z-index: 4;
  max-width: none;
  pointer-events: none;
}

.page--select--floating .nav-bar,
.page--select--floating .nav-bar a {
  pointer-events: auto;
}

.hint--on-bg {
  color: #e2e8f0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.page-title {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

/* ????????? ? ??(?) ? ?? bg2 cover ? UI(??/??) */
html:has(body.page-shoot) {
  height: 100%;
  background-color: #0f172a;
}

body.page-shoot {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  background-color: #0f172a;
}

.shoot-stack {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
}

.shoot-layer--video {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.shoot-video-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shoot-video-wrap .shoot-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: transparent;
  transform: scale(var(--shoot-live-video-scale, 0.5));
  transform-origin: center center;
}

.shoot-video-wrap .shoot-video.shoot-video--mirror {
  transform: scale(var(--shoot-live-video-scale, 0.5)) scaleX(-1);
}

/* bg2 + ????? 1080?1920 ?????? cover ???--shoot-sync-scale ? shoot.js ??? */
.shoot-layer--sync {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shoot-design-fit {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.shoot-design-canvas {
  position: relative;
  width: 1080px;
  height: 1920px;
  flex-shrink: 0;
  transform: scale(var(--shoot-sync-scale, 1));
  transform-origin: center center;
}

.shoot-design-canvas .shoot-liveview-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.page--shoot.shoot-layer--ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 0
    calc(24px + env(safe-area-inset-bottom, 0px));
  background: transparent;
  pointer-events: none;
}

.page--shoot.shoot-layer--ui .nav-bar,
.page--shoot.shoot-layer--ui .nav-bar a,
.page--shoot.shoot-layer--ui #shoot-status,
.page--shoot.shoot-layer--ui .shoot-actions,
.page--shoot.shoot-layer--ui .shoot-actions button,
.page--shoot.shoot-layer--ui #btn-next {
  pointer-events: auto;
}

.page--shoot .nav-bar {
  flex: 0 0 auto;
  padding-left: 16px;
  padding-right: 16px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}

.page--shoot .nav-bar a {
  color: #f8fafc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.page--shoot #shoot-status,
.page--shoot .shoot-actions,
.page--shoot #btn-next {
  flex: 0 0 auto;
  width: calc(100% - 32px);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.status--on-shoot {
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.status--on-shoot.error {
  color: #fecaca;
}

/* ???????????????????????????? cover */
.page--shoot .shoot-artboard-wrap {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  align-items: stretch;
  justify-content: center;
}

.page--shoot .shoot-artboard {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  align-self: stretch;
}

.shoot-design-canvas .shoot-template-slot {
  position: absolute;
  left: 0;
  right: 0;
  top: 560px;
  z-index: 3;
  pointer-events: none;
  display: flex;
  justify-content: center;
  /* ???? 25px ???????? 10px ??? */
  transform: translateX(calc(-15px / var(--shoot-sync-scale, 1)));
}

.shoot-template-frame {
  position: relative;
  box-sizing: border-box;
  width: var(--select-character-width-pct, calc(100% * 590 / 1080));
  flex-shrink: 0;
}

/* ??????? img ??????????????????? */
.shoot-template-frame--shoot-only {
  aspect-ratio: 478 / 641;
}

.shoot-template-overlay {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ??????? canvas ?????????????? */
.shoot-template-overlay.shoot-template-overlay--hidden {
  display: none !important;
  visibility: hidden;
}

.shoot-template-frame .shoot-preview-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  object-fit: contain;
  background: transparent;
}

/* ?? / ????? anniu_bj.png ?????? HTML?--shoot-primary-bg ? shoot.js ??? */
.shoot-btn-primary {
  position: relative;
  padding: 0 20px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  background-image: var(--shoot-primary-bg, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0c4a6e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.shoot-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.shoot-btn-primary-text {
  position: relative;
  z-index: 1;
}

/* ????? chongpai.png */
.shoot-btn-img {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shoot-btn-img:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.shoot-btn-img img {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}

.shoot-actions {
  margin-top: 12px;
}

.shoot-btn-capture {
  flex: 1;
  min-height: 56px;
}

.shoot-btn-retake {
  width: 64px;
  min-width: 64px;
  min-height: 56px;
}

.shoot-btn-retake img {
  max-height: 56px;
  width: auto;
  margin: 0 auto;
  object-fit: contain;
}

.shoot-btn-confirm-wide {
  width: 100%;
  margin-top: 14px;
  min-height: 56px;
}

a {
  color: #38bdf8;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
}

.page-title {
  text-align: center;
  font-size: 1.1rem;
  margin: 8px 0 16px;
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.nav-bar a {
  text-decoration: none;
  font-size: 1.25rem;
  padding: 8px;
}

/* ?? / ?????? + ???? */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 62vh;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  background: #020617;
}

.stage .layer-bg,
.stage .layer-body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage .layer-body {
  object-fit: contain;
}

/* ???????????????????? */
.stage-select-character {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-height: min(58vh, 520px);
  aspect-ratio: 9 / 16;
  margin: 8px auto 0;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
}

.stage-select-character .layer-body {
  object-fit: contain;
  object-position: center bottom;
}

.arrow-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #166534;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

/* ??????? PNG ?????? js/config.js? */
.btn-icon-arrow {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-arrow img {
  width: 55%;
  height: 55%;
  object-fit: contain;
  pointer-events: none;
}

/* ???????????? PNG????? 150?150????? .btn-icon-arrow img ? 55%? */
.select-artboard > .select-arrow-side img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px 16px;
  border: none;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
  color: #0c4a6e;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.5;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}

.video-wrap video,
.video-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
}

.row-actions .btn-primary {
  flex: 1;
  margin-top: 0;
}

.btn-retake {
  width: 52px;
  min-width: 52px;
  border-radius: 12px;
  border: none;
  background: #334155;
  color: #e2e8f0;
  font-size: 1.2rem;
  cursor: pointer;
}

.input-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.input-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.input-panel input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #475569;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1rem;
}

.status {
  margin-top: 10px;
  font-size: 0.9rem;
}

/* ?????? placeholder-bg3 ?? + ????? + ??????? */
body.page-nickname {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #0f172a;
}

.nick-bg-fill {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
}

/* ? shoot ? .shoot-layer--sync ??????? cover ???????????? contain */
.nick-preview-stack {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ?????? PNG ???????????? 1080?1920 ??????????? compositeOnce ?????? */
.shoot-design-canvas .nick-bg-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 1;
  pointer-events: none;
}

.shoot-design-canvas .nick-preview-final {
  position: absolute;
  left: 50%;
  top: 330px;
  margin-left: -210px;
  width: 400px;
  height: 300px;
  z-index: 2;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  pointer-events: none;
}

.shoot-design-canvas .nick-character-overlay {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%) translateX(calc(-15px / var(--shoot-sync-scale, 1)));
  /* ????????? JS ???????????? */
  width: calc(100% * 590 / 1080);
  height: auto;
  z-index: 3;
  pointer-events: none;
}

.nick-bottom-scrim {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(58vh, 520px);
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, 0.94) 0%,
    rgba(15, 23, 42, 0.55) 45%,
    transparent 100%
  );
}

.page-nickname .nick-top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 12px 12px;
  max-width: 480px;
  margin: 0 auto;
  box-sizing: border-box;
}

.page-nickname .nick-top-nav a {
  color: #f8fafc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.page-nickname .nick-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px));
}

.page-nickname .nick-input-panel {
  margin-top: 0;
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid rgba(220, 252, 231, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.page-nickname .nick-input-panel label {
  color: #f0fdf4;
}

.page-nickname .nick-hint {
  color: #dcfce7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.page-nickname .nick-btn-upload {
  margin-top: 14px;
}

.page-nickname .nick-status {
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.page-nickname .nick-status.error,
.page-nickname .status.error {
  color: #fecaca;
}

.status.error {
  color: #fca5a5;
}

.center-msg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px;
}
