*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  background: #000;
  /* So percentage max-height resolves for centered video */
  height: 100%;
  min-height: 100dvh;
}

/* Off-screen decoder — never shown to the user */
.video-source {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: 0;
  overflow: hidden;
}

.main-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  max-width: 100%;
  max-height: 100dvh;
  z-index: 0;
  pointer-events: none;
  background: #000;
}

.main-canvas.is-hidden {
  visibility: hidden;
}

.black-screen {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 1;
}

.black-screen[hidden] {
  display: none !important;
}

.tap-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.tap-effect {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: min(70vw, 320px);
  max-height: min(50vh, 280px);
  width: auto;
  height: auto;
  pointer-events: none;
  user-select: none;
}

#app.is-ready .tap-target {
  cursor: pointer;
}

.tap-target {
  position: absolute;
  inset: 0;
  z-index: 4;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  /* Transparent full-screen shield above video (Android native controls) */
  background: transparent;
}

.status {
  position: absolute;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  color: #f5f5f5;
  font-size: 0.85rem;
  max-width: 90vw;
  text-align: center;
}

.status[hidden] {
  display: none !important;
}

.status.is-error {
  background: rgba(120, 20, 20, 0.9);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  color: #f5f5f5;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-overlay.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  width: min(340px, 88vw);
  text-align: center;
}

.loading-label {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: #c8c8c8;
}

.loading-bar-wrap {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #4f8cff, #7eb6ff);
  transition: width 0.15s ease-out;
}

.loading-percent {
  margin-top: 0.75rem;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Debug: user-agent bar (SHOW_USER_AGENT or ?ua=1) */
.debug-ua-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 0.35rem 0.5rem;
  padding-top: max(0.35rem, env(safe-area-inset-top));
  background: rgba(20, 24, 32, 0.92);
  color: #e8eaed;
  font-size: 0.65rem;
  line-height: 1.35;
  word-break: break-all;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.debug-ua-bar__text {
  font-family: ui-monospace, Consolas, monospace;
}

.debug-ua-bar__hint {
  margin-top: 0.2rem;
  font-size: 0.6rem;
  color: #9aa0a6;
}

.browser-unsupported {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  background: #0a0a0a;
  color: #f5f5f5;
  text-align: center;
}

.browser-unsupported[hidden] {
  display: none !important;
}

.browser-unsupported__panel {
  max-width: 22rem;
}

.browser-unsupported__title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.browser-unsupported__message {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #d0d0d0;
}

.browser-unsupported__detail {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #9aa0a6;
}

.browser-unsupported__detail strong {
  color: #e8eaed;
}
