:root {
  --bg: #04050a;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.42);
  --accent: #7fd4ff;
  --accent-soft: rgba(127, 212, 255, 0.18);
  --accent-line: rgba(127, 212, 255, 0.55);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  opacity: 0.35;
  transition: opacity 1.4s ease;
}
#stage.live { opacity: 1; }
#stage canvas { display: block; }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.72) 100%);
}

/* ---------- Brand ---------- */

#brand {
  position: fixed;
  top: 26px;
  left: 28px;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
#brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.22em;
}
#brand p {
  margin: 5px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 24px;
  right: 28px;
  display: grid;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  transition: opacity 0.3s ease;
}
#hud .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: baseline;
}
#hud span { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 9px; }
#hud b { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------- Webcam PiP ---------- */

#pip {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 232px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  transition: opacity 0.3s ease;
}
#pip video,
#pip canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Mode selfie: tanpa mirror, gerakan terasa terbalik dan sangat sulit dikendalikan. */
#pip video { transform: scaleX(-1); opacity: 0.55; }

/* ---------- Kontrol ---------- */

#ui {
  position: fixed;
  left: 28px;
  bottom: 28px;
  width: 322px;
  transition: opacity 0.3s ease;
}

.panel {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 20, 0.62);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.group { margin-bottom: 14px; }
.group:last-of-type { margin-bottom: 0; }

.group > label {
  display: block;
  margin-bottom: 7px;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.btns { display: flex; flex-wrap: wrap; gap: 6px; }

button {
  position: relative;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
button:hover { background: var(--panel-strong); }
button.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #fff;
}
button.wide { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; }

kbd {
  margin-left: 6px;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}

#record i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.2s ease;
}
#record.recording { border-color: rgba(255, 70, 70, 0.6); background: rgba(255, 60, 60, 0.14); }
#record.recording i { background: #ff4646; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

input[type="text"] {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent-line); }

#text-row { display: none; }
#text-row.visible { display: block; }

.hint {
  margin: 14px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}
.hint b { color: rgba(255, 255, 255, 0.78); font-weight: 600; }

.hidden { opacity: 0; pointer-events: none; }

/* ---------- Gate ---------- */

#gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.7s ease, visibility 0.7s;
  z-index: 10;
}
#gate.gone { opacity: 0; visibility: hidden; }

#gate .card {
  width: min(520px, 100%);
  padding: 34px 34px 30px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 20, 0.82);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  text-align: left;
}
#gate h2 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: 0.2em;
  font-weight: 700;
}
#gate .lead {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.66);
}
#gate .tips {
  margin: 0 0 24px;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--muted);
}
#gate .tips b { color: rgba(255, 255, 255, 0.75); font-weight: 600; }
#gate #start {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 11px;
  background: var(--accent);
  border-color: transparent;
  color: #04121c;
}
#gate #start:hover { filter: brightness(1.08); }
#gate #start:disabled { opacity: 0.5; cursor: default; }

.muted { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 0 0 12px; }
.mono { font-family: var(--mono); font-size: 11px; }
.error { color: #ff7a7a; font-size: 13px; margin: 0 0 10px; }

@media (max-width: 900px) {
  #ui { width: calc(100% - 32px); left: 16px; bottom: 16px; }
  #pip { width: 150px; right: 16px; bottom: auto; top: 70px; }
  #brand p { display: none; }
}
