* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --cyan: #67e8f9;
  --cyan-soft: rgba(103, 232, 249, 0.18);
  --purple: #a78bfa;
  --pink: #f0abfc;
  --rose: #fb7185;
  --bg: #02030a;
  --panel: rgba(2, 6, 23, 0.58);
  --border: rgba(125, 249, 255, 0.24);
  --text: #dff7ff;
  --muted: rgba(223, 247, 255, 0.66);
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 16%, rgba(56, 189, 248, 0.16), transparent 32%),
    radial-gradient(circle at 84% 18%, rgba(240, 171, 252, 0.12), transparent 30%),
    radial-gradient(circle at 50% 88%, rgba(124, 58, 237, 0.16), transparent 44%),
    linear-gradient(180deg, rgba(2, 6, 23, 0.05), rgba(0, 0, 0, 0.48));
  z-index: 1;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#webcam {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 220px;
  height: 164px;
  object-fit: cover;
  transform: scaleX(-1);
  border: 1px solid rgba(103, 232, 249, 0.55);
  border-radius: 24px;
  background: #000;
  opacity: 0.74;
  z-index: 8;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 32px rgba(56, 189, 248, 0.28),
    0 0 70px rgba(167, 139, 250, 0.18);
}

#webcam.hidden {
  display: none;
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.glass {
  pointer-events: auto;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(2, 6, 23, 0.78), rgba(15, 23, 42, 0.44)),
    var(--panel);
  backdrop-filter: blur(18px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.045) inset,
    0 26px 90px rgba(0, 0, 0, 0.38),
    0 0 48px rgba(14, 165, 233, 0.14);
}

.panel {
  position: absolute;
  left: 22px;
  top: 22px;
  width: min(440px, calc(100vw - 44px));
  padding: 18px;
  border-radius: 28px;
  overflow: hidden;
  transition:
    width 0.22s ease,
    padding 0.22s ease,
    border-radius 0.22s ease,
    transform 0.22s ease;
}

.panel::before,
.gesture-help::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    120deg,
    rgba(103, 232, 249, 0.18),
    transparent 28%,
    transparent 72%,
    rgba(240, 171, 252, 0.13)
  );
  mask: linear-gradient(#000, transparent 58%);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding-right: 58px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.12em;
  font-weight: 950;
  color: white;
  text-shadow: 0 0 18px rgba(103, 232, 249, 0.82);
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pulse-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow:
    0 0 16px var(--cyan),
    0 0 38px var(--purple);
  animation: pulse 1.25s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(0.76);
    opacity: 0.62;
  }

  to {
    transform: scale(1.2);
    opacity: 1;
  }
}

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

.status-grid div,
.gesture-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.44);
  border-radius: 18px;
  padding: 11px 12px;
}

.status-grid span,
.gesture-card span,
.control-row label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid b {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(103, 232, 249, 0.45);
}

.gesture-card {
  margin-top: 12px;
}

.gesture-card strong {
  display: block;
  margin-top: 5px;
  color: #fff;
  font-size: 17px;
  min-height: 26px;
  text-shadow: 0 0 14px rgba(240, 171, 252, 0.4);
}

.gesture-card small {
  display: block;
  color: var(--cyan);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-row {
  margin-top: 12px;
}

select,
input[type="range"],
button {
  width: 100%;
}

select {
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid rgba(103, 232, 249, 0.26);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.86);
  color: var(--text);
  outline: none;
  font-weight: 800;
}

input[type="range"] {
  margin-top: 9px;
  accent-color: var(--cyan);
}

.toggles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 12px;
}

.toggles label {
  color: rgba(223, 247, 255, 0.78);
  font-size: 12px;
}

.toggles input {
  accent-color: var(--cyan);
}

button {
  margin-top: 14px;
  padding: 13px 14px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  color: #031018;
  background: linear-gradient(135deg, #67e8f9, #8b5cf6 54%, #f0abfc);
  font-weight: 950;
  letter-spacing: 0.08em;
  box-shadow:
    0 0 22px rgba(103, 232, 249, 0.33),
    0 0 46px rgba(167, 139, 250, 0.18);
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:disabled {
  cursor: default;
  opacity: 0.8;
}

.hud-toggle {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 2;
  width: auto;
  min-width: 48px;
  min-height: 34px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 999px;
  color: rgba(223, 247, 255, 0.9);
  background: rgba(2, 6, 23, 0.68);
  box-shadow: 0 0 18px rgba(103, 232, 249, 0.16);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.1em;
}

.hud-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(240, 171, 252, 0.5);
  filter: none;
}

.panel.is-collapsed {
  width: min(230px, calc(100vw - 44px));
  padding: 14px 62px 14px 14px;
  border-radius: 22px;
}

.panel.is-collapsed .brand {
  margin-bottom: 0;
  padding-right: 0;
}

.panel.is-collapsed .brand h1 {
  max-width: 120px;
  font-size: 13px;
  line-height: 1.2;
}

.panel.is-collapsed .brand p,
.panel.is-collapsed .status-grid,
.panel.is-collapsed .gesture-card,
.panel.is-collapsed .control-row,
.panel.is-collapsed .toggles,
.panel.is-collapsed #startBtn,
.panel.is-collapsed .hint {
  display: none;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.gesture-help {
  position: absolute;
  right: 22px;
  top: 22px;
  width: min(290px, calc(100vw - 44px));
  border-radius: 24px;
  padding: 15px;
}

.gesture-help h2 {
  position: relative;
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: white;
}

.gesture-list {
  position: relative;
  display: grid;
  gap: 7px;
}

.gesture-list span {
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.46);
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: rgba(223, 247, 255, 0.78);
  font-size: 12px;
}

.corner {
  position: fixed;
  z-index: 6;
  width: 120px;
  height: 120px;
  pointer-events: none;
  opacity: 0.5;
}

.corner.top-left {
  left: 16px;
  top: 16px;
  border-left: 1px solid rgba(103, 232, 249, 0.38);
  border-top: 1px solid rgba(103, 232, 249, 0.38);
}

.corner.bottom-right {
  right: 16px;
  bottom: 16px;
  border-right: 1px solid rgba(240, 171, 252, 0.38);
  border-bottom: 1px solid rgba(240, 171, 252, 0.38);
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 48%, rgba(0, 0, 0, 0.42) 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 7px,
      rgba(125, 249, 255, 0.025) 8px,
      transparent 9px
    );
  mix-blend-mode: screen;
}

.hy-game-return {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 30;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 999px;
  color: rgba(223, 247, 255, 0.88);
  background: rgba(2, 6, 23, 0.62);
  box-shadow: 0 0 28px rgba(103, 232, 249, 0.16);
  backdrop-filter: blur(14px);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
  pointer-events: auto;
}

.hy-game-return:hover {
  color: #fff;
  border-color: rgba(240, 171, 252, 0.48);
}

@media (max-width: 900px) {
  .gesture-help {
    display: none;
  }
}

@media (max-width: 640px) {
  #webcam {
    width: 142px;
    height: 106px;
    right: 10px;
    bottom: 10px;
  }

  .hy-game-return {
    left: 10px;
    bottom: 124px;
  }

  .panel {
    left: 10px;
    top: 10px;
    width: calc(100vw - 20px);
    padding: 14px;
  }

  .panel.is-collapsed {
    width: min(210px, calc(100vw - 20px));
    padding: 12px 58px 12px 12px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .hint {
    display: none;
  }
}
