:root {
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.4);
  --gold-line: rgba(212, 175, 55, 0.28);
  --gold-light: #f7e7b6;
  --ink: #ece2c8;
  --muted: rgba(236, 226, 200, 0.5);
  --serif: 'Optima', 'Palatino Linotype', 'Book Antiqua', 'Songti SC', 'STSong', 'Times New Roman', serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(78% 62% at 50% 46%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.55) 100%),
    radial-gradient(42% 30% at 50% 78%, rgba(212, 175, 55, 0.05), rgba(0, 0, 0, 0) 70%);
}

/* ---------------- loader ---------------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: opacity 0.9s ease;
}

#loader.done {
  opacity: 0;
  pointer-events: none;
}

#loader .ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-top-color: var(--gold);
  animation: spin 1.1s linear infinite;
}

#loader p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- ui layer ---------------- */

#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#ui > * { pointer-events: none; }

#ui .panel,
#ui .top-actions,
#ui .manage,
#ui .modebar,
#ui .cam-box { pointer-events: auto; }

body.ui-hidden #ui > * {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.ui-hidden #ui { pointer-events: none; }

#ui > * {
  transition: opacity 0.45s ease;
}

/* ---------------- help panel ---------------- */

.panel {
  position: absolute;
  top: 24px;
  left: 24px;
  width: 268px;
  padding: 20px 20px 16px;
  background: linear-gradient(160deg, rgba(14, 12, 8, 0.82), rgba(0, 0, 0, 0.7));
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.panel h3 {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gold-line);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 9px;
  text-transform: uppercase;
}

.diamond {
  width: 7px;
  height: 7px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.8);
}

.gestures {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 11px;
}

.gestures li {
  display: flex;
  align-items: center;
  gap: 11px;
}

.gestures .ico {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  font-size: 15px;
  border: 1px solid var(--gold-line);
  border-radius: 7px;
  background: rgba(212, 175, 55, 0.06);
}

.gestures b {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--gold-light);
}

.gestures em {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
}

.divider {
  height: 1px;
  margin: 15px 0 12px;
  background: linear-gradient(90deg, transparent, var(--gold-line), transparent);
}

.tip {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.75;
  letter-spacing: 0.03em;
  color: rgba(236, 226, 200, 0.58);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
}

.tip + .tip { margin-top: 6px; }
.tip.dim { color: rgba(236, 226, 200, 0.34); }

.switch-link {
  color: rgba(212, 175, 55, 0.8);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 1px;
  transition: color 0.3s, border-color 0.3s;
}

.switch-link:hover {
  color: var(--gold-light);
  border-color: var(--gold-light);
}

.credit {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 175, 55, 0.12);
  font-size: 9px;
  letter-spacing: 0.07em;
  line-height: 1.7;
  color: rgba(212, 175, 55, 0.42);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
}

/* ---------------- masthead ---------------- */

.masthead {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: min(90vw, 720px);
}

.masthead h1 {
  margin: 0;
  font-size: 52px;
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 4%, #f6e2a8 45%, #c9962f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(212, 175, 55, 0.35));
}

.masthead p {
  margin: 12px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.42em;
  color: rgba(212, 175, 55, 0.55);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
}

/* ---------------- buttons ---------------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--gold-soft);
  border-radius: 2px;
  background: rgba(12, 10, 6, 0.6);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 0.35s, background 0.35s, box-shadow 0.35s, border-color 0.35s;
}

.btn:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #08060a;
  box-shadow: 0 0 26px rgba(212, 175, 55, 0.45);
}

.btn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.35);
  transition: background 0.3s, box-shadow 0.3s;
}

.btn[aria-pressed="true"] .dot {
  background: #8ef7c4;
  box-shadow: 0 0 10px #8ef7c4;
  animation: breathe 1.9s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn[aria-pressed="true"] {
  border-color: rgba(142, 247, 212, 0.55);
  color: var(--gold-light);
}

.top-actions {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hint {
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(212, 175, 55, 0.42);
}

.manage {
  position: absolute;
  left: 24px;
  bottom: 24px;
}

/* ---------------- webcam ---------------- */

.cam-box {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 168px;
  height: 126px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.18);
  overflow: hidden;
}

.cam-box video,
.cam-box canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-box video {
  transform: scaleX(-1);
  opacity: 0.9;
}

.cam-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.25);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: rgba(247, 231, 182, 0.8);
}

.cam-tag .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(247, 231, 182, 0.3);
}

.cam-tag .dot.live {
  background: #8ef7c4;
  box-shadow: 0 0 8px #8ef7c4;
}

/* ---------------- mode bar ---------------- */

.modebar {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.modes {
  display: flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  background: rgba(10, 8, 4, 0.7);
  backdrop-filter: blur(10px);
}

.mode {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(212, 175, 55, 0.6);
  padding: 8px 20px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  transition: color 0.3s, background 0.3s, border-color 0.3s;
}

.mode b {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.mode span {
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  opacity: 0.65;
}

.mode:hover { color: var(--gold-light); }

.mode.active {
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.95), rgba(178, 140, 30, 0.95));
  border-color: rgba(255, 240, 200, 0.5);
  color: #0a0803;
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.35);
}

.mode.active span { opacity: 0.75; }

.gesture {
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: rgba(247, 231, 182, 0.62);
  padding: 5px 14px;
  border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 999px;
  background: rgba(8, 6, 3, 0.5);
  white-space: nowrap;
  transition: color 0.3s, border-color 0.3s;
}

.gesture.hot {
  color: #0a0803;
  background: linear-gradient(92deg, #f7e7b6, #d4af37);
  border-color: transparent;
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.45);
}

/* ---------------- photo manager ---------------- */

.manager {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
}

.manager h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 150px);
  gap: 18px;
  max-width: min(720px, 92vw);
  max-height: 62vh;
  overflow-y: auto;
  padding: 4px;
}

.grid::-webkit-scrollbar { width: 6px; }
.grid::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.35); border-radius: 3px; }

.thumb {
  position: relative;
  width: 150px;
  height: 150px;
  border: 1px solid var(--gold-soft);
  background: #0a0806;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(120, 12, 20, 0.9);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s;
}

.thumb:hover .del { opacity: 1; }

.thumb .empty {
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(212, 175, 55, 0.45);
}

.manager-actions {
  display: flex;
  gap: 12px;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 20px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 3px;
  background: rgba(10, 8, 4, 0.92);
  color: var(--gold-light);
  font-family: 'PingFang SC', 'Microsoft YaHei', var(--serif);
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  text-align: center;
  z-index: 70;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ---------------- responsive ---------------- */

@media (max-width: 1080px) {
  .masthead h1 { font-size: 42px; }
  .panel { width: 240px; }
}

@media (max-width: 880px) {
  #help { display: none; }
  .masthead { top: 20px; }
  .masthead h1 { font-size: 30px; letter-spacing: 0.1em; }
  .masthead p { font-size: 9px; letter-spacing: 0.24em; margin-top: 8px; }
  .top-actions { top: 16px; right: 14px; gap: 8px; }
  .btn { padding: 8px 13px; font-size: 9px; letter-spacing: 0.14em; }
  .hint { display: none; }
  .manage { left: 14px; bottom: 96px; }
  .cam-box { right: 14px; bottom: 96px; width: 116px; height: 87px; }
  .modebar { bottom: 16px; gap: 8px; }
  .modes { padding: 3px; gap: 2px; }
  .mode { padding: 7px 12px; }
  .mode b { font-size: 10px; }
  .mode span { display: none; }
  .gesture { font-size: 9.5px; padding: 4px 10px; }
  .grid { grid-template-columns: repeat(2, 132px); }
  .thumb { width: 132px; height: 132px; }
  .toast { bottom: 108px; font-size: 10.5px; }
}

@media (max-height: 640px) {
  .masthead { top: 12px; }
  .masthead h1 { font-size: 24px; }
  .masthead p { display: none; }
  .modebar { bottom: 10px; }
  .manage { bottom: 74px; }
  .cam-box { bottom: 74px; width: 104px; height: 78px; }
}


