
:root {
  --gold: #d8b166;
  --gold2: #f0d99a;
  --red: #a71919;
  --panel: rgba(13, 10, 9, .62);
  --text: #fff8e9;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

button {
  font: inherit;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
}

#video,
#glCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#glCanvas {
  z-index: 2;
  pointer-events: none;
}

.mirror {
  transform: scaleX(-1);
}

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 32%, rgba(166, 25, 25, .35), transparent 30%),
    radial-gradient(circle at 50% 72%, rgba(216, 177, 102, .08), transparent 38%),
    #070505;
}

.start-card {
  width: min(92vw, 470px);
  padding: 34px 25px 29px;
  border: 1px solid rgba(216,177,102,.32);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(48,25,20,.88), rgba(10,7,7,.9));
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}

.seal {
  width: 82px;
  height: 82px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  outline: 1px solid rgba(216,177,102,.34);
  outline-offset: 6px;
  border-radius: 22px 8px 22px 8px;
  color: var(--gold2);
  font: 32px/1 "KaiTi", "STKaiti", serif;
}

.start-card h1 {
  font: 600 clamp(30px,8vw,42px)/1.2 "KaiTi","STKaiti",serif;
  letter-spacing: .12em;
}

.subtitle {
  margin-top: 10px;
  color: var(--gold2);
  font-size: 13px;
  letter-spacing: .2em;
}

.intro {
  margin: 23px auto;
  max-width: 365px;
  color: rgba(255,248,233,.73);
  font-size: 14px;
  line-height: 1.85;
}

.primary-btn,
.secondary-btn {
  width: min(260px, 78vw);
  height: 52px;
  border-radius: 999px;
  font-weight: 700;
}

.primary-btn {
  border: 1px solid rgba(255,224,164,.35);
  color: #fffaf1;
  background: linear-gradient(#c32929, #821212);
  box-shadow: 0 9px 28px rgba(126, 13, 13, .38);
}

.secondary-btn {
  margin-top: 11px;
  border: 1px solid rgba(216,177,102,.34);
  color: var(--gold2);
  background: rgba(255,255,255,.045);
}

.start-note {
  margin-top: 16px;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255,255,255,.48);
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  transition: opacity .26s ease;
  pointer-events: none;
}

.hud.ui-hidden {
  opacity: 0;
}

.topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.status {
  justify-self: center;
  max-width: min(78vw, 500px);
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(216,177,102,.28);
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13px;
  text-align: center;
}

.icon-btn,
.round-btn {
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  background: rgba(15,12,11,.66);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 21px;
}

.bottom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  display: grid;
  grid-template-columns: 1fr 84px 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  pointer-events: auto;
}

.control-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,.76);
  font-size: 12px;
}

.round-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 24px;
}

.shutter {
  position: relative;
  width: 80px;
  height: 80px;
  border: 5px solid rgba(255,255,255,.95);
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  box-shadow: 0 7px 26px rgba(0,0,0,.32);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color .18s ease, transform .18s ease;
}

.shutter::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #bd1d1d;
  transition: inset .18s ease, border-radius .18s ease, transform .18s ease;
}

.shutter.holding::after {
  transform: scale(.88);
}

.shutter.recording {
  border-color: #ff6b6b;
  animation: record-pulse 1s ease-in-out infinite;
}

.shutter.recording::after {
  inset: 20px;
  border-radius: 7px;
  background: #e52525;
}

@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,37,37,.28), 0 7px 26px rgba(0,0,0,.32); }
  50% { box-shadow: 0 0 0 9px rgba(229,37,37,0), 0 7px 26px rgba(0,0,0,.32); }
}

.tap-hint {
  position: absolute;
  z-index: 8;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(0,0,0,.38);
  color: rgba(255,255,255,.62);
  font-size: 11px;
  pointer-events: none;
  animation: hintfade 2.4s forwards;
}

@keyframes hintfade {
  0%,50% { opacity: 1; }
  100% { opacity: 0; }
}

.sheet, .preview {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet {
  display: flex;
  align-items: flex-end;
}

.sheet-panel {
  width: 100%;
  padding: 16px 18px max(24px, calc(env(safe-area-inset-bottom) + 14px));
  border-radius: 26px 26px 0 0;
  background: rgba(20,13,11,.94);
  border-top: 1px solid rgba(216,177,102,.3);
}

.sheet-head,
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-head {
  padding: 4px 2px 16px;
}

.sheet-head h2 {
  font: 20px "KaiTi","STKaiti",serif;
}

.text-btn {
  border: 0;
  color: var(--gold2);
  background: transparent;
  padding: 8px;
}

.mask-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.mask-option {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 17px;
  padding: 7px 5px 9px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.04);
}

.mask-option.active {
  border-color: rgba(216,177,102,.75);
  color: #fff;
}

.mask-option img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}

.preview {
  background: #050505;
}

.preview-inner {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 58px 1fr auto;
  padding-top: max(8px, env(safe-area-inset-top));
}

.preview-head {
  padding: 0 16px;
}

.preview-head span {
  width: 42px;
}

#previewImage,
#previewVideo {
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#previewVideo {
  background: #000;
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px max(20px, calc(env(safe-area-inset-bottom) + 12px));
}

.action-btn {
  min-width: 130px;
  height: 46px;
  border: 1px solid rgba(216,177,102,.26);
  border-radius: 999px;
  color: #fff;
  background: rgba(34,23,20,.94);
}

.action-btn.primary {
  background: #941818;
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  #app {
    width: min(520px, 100vw);
    margin: 0 auto;
    box-shadow: 0 0 80px rgba(0,0,0,.6);
  }
}


.version-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 9px;
  border: 1px solid rgba(216,177,102,.32);
  border-radius: 999px;
  color: rgba(240,217,154,.82);
  font-size: 10px;
  letter-spacing: .12em;
}
