/* Hand Ninja — dark zen theme. */

:root {
  --bg: #07090f;
  --text: #eef2ff;
  --dim: #8b93a7;
  --panel: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.16);
  --cyan: #7df9ff;
  --gold: #ffd700;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(125, 249, 255, 0.08), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(255, 158, 63, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  flex-wrap: wrap;
}

.hud-group { display: flex; gap: 8px; }

.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.chip.score {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  border-color: rgba(255, 215, 0, 0.4);
  min-width: 74px;
  text-align: center;
}

.chip.logo { color: var(--cyan); font-weight: 800; }

button.chip { color: var(--text); cursor: pointer; transition: background 100ms; }
button.chip:hover { background: rgba(255, 255, 255, 0.15); }

@media (max-width: 430px) {
  .chip.logo { display: none; }
}

/* ---------- layout ---------- */
#wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 14px calc(10px + env(safe-area-inset-bottom));
}

#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3; /* replaced with the real video ratio at startup */
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1); /* mirror */
}

#overlay { position: absolute; }

#hint {
  margin: 0;
  color: var(--dim);
  font-size: 0.95rem;
  text-align: center;
}
#hint strong { color: var(--cyan); }

/* ---------- start button ---------- */
#startBtn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 44px;
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(125, 249, 255, 0.16), rgba(255, 158, 63, 0.16));
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  z-index: 10;
  backdrop-filter: blur(6px);
}

#startBtn .big { font-size: 2.4rem; }
#startBtn:disabled { opacity: 0.6; cursor: wait; }
#startBtn:hover:not(:disabled) { background: linear-gradient(135deg, rgba(125, 249, 255, 0.28), rgba(255, 158, 63, 0.28)); }

#status {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ff7675;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0 16px;
  text-shadow: 0 1px 3px #000;
  z-index: 10;
  margin: 0;
}

/* ---------- loading overlay ---------- */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(7, 9, 15, 0.75);
  z-index: 9;
  font-weight: 600;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--cyan);
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

footer {
  text-align: center;
  color: var(--dim);
  font-size: 0.75rem;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
}

/* wide screens: give the stage more height */
@media (orientation: landscape) and (min-height: 600px) {
  #stage { max-width: 100%; }
}
