:root {
  --bg: #07070a;
  --surface: rgba(20, 20, 28, 0.55);
  --surface-strong: rgba(28, 28, 38, 0.7);
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f8;
  --muted: rgba(255, 255, 255, 0.55);
  --accent: #ff3e88;
  --accent-2: #4ee3ff;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
}

/* ========== STAGE (top, 75%) ========== */
.stage {
  position: relative;
  flex: 1 1 75%;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

#video, #overlay, #overlay3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#video { transform: scaleX(-1); }

#overlay, #overlay3d { pointer-events: none; }
#overlay3d { z-index: 2; }
#overlay { z-index: 3; }

/* ========== HUD (corners) ========== */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
}

.brand,
.round-badge {
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
          backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.brand {
  font-size: 13px;
  letter-spacing: 6px;
  font-weight: 700;
}

.round-badge {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--muted);
}

/* ========== Live label — dead center, white, prominent ========== */
.merge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  text-align: center;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: white;
  text-transform: lowercase;
  text-shadow: 0 6px 32px rgba(0, 0, 0, 0.7), 0 1px 4px rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 86%;
  line-height: 1.05;
  word-spacing: 0.1em;
}

.merge-text.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.merge-text.pulse {
  animation: pulseText 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pulseText {
  0%   { transform: translate(-50%, -50%) scale(1); }
  35%  { transform: translate(-50%, -50%) scale(1.18); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.subtitle {
  position: absolute;
  bottom: 24px;
  left: 0; right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms;
}

.subtitle.show { opacity: 1; }

.status {
  position: absolute;
  bottom: 14px;
  left: 14px;
  font-size: 10px;
  color: var(--muted);
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  padding: 5px 10px;
  border-radius: 999px;
  font-family: ui-monospace, "SF Mono", monospace;
  z-index: 10;
}

/* ========== TRAY (bottom, 25%) ========== */
.tray {
  flex: 0 0 25%;
  background: rgba(10, 10, 14, 0.78);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
          backdrop-filter: blur(28px) saturate(160%);
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

.tray-title {
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
}

.held-display {
  display: flex;
  gap: 8px;
  align-items: center;
}

.held-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 12px;
  min-width: 110px;
  height: 32px;
  transition: border-color 160ms;
}

.held-slot.left  { box-shadow: inset 0 0 0 1px rgba(255, 62, 136, 0.3); }
.held-slot.right { box-shadow: inset 0 0 0 1px rgba(78, 227, 255, 0.3); }

.held-slot .label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px;
  font-weight: 600;
}

.held-slot img {
  width: 20px;
  height: 20px;
}

.held-slot .held-name {
  color: var(--text);
}

.controls { display: flex; gap: 6px; }

button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--hairline);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, transform 100ms;
}

button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--hairline-strong);
}

button:active { transform: scale(0.96); }

.grid {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  align-content: start;
}

.grid::-webkit-scrollbar { width: 6px; }
.grid::-webkit-scrollbar-track { background: transparent; }
.grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.grid::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

.obj-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  transition: border-color 140ms, background 140ms, transform 140ms, box-shadow 140ms;
}

.obj-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(78, 227, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(78, 227, 255, 0.1);
}

.obj-card.picked {
  animation: pickFlash 320ms ease-out;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 62, 136, 0.4), 0 6px 18px rgba(255, 62, 136, 0.25);
}

@keyframes pickFlash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.obj-card img {
  width: 36px;
  height: 36px;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.obj-card .name {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ========== Permission overlay ========== */
.permission {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  z-index: 100;
  text-align: center;
  padding: 30px;
}

.permission h1 {
  font-size: 56px;
  margin: 0;
  letter-spacing: 14px;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}

.permission p {
  color: var(--muted);
  max-width: 480px;
  line-height: 1.6;
  font-size: 14px;
  margin: 0;
}

.permission button {
  font-size: 14px;
  padding: 14px 36px;
  background: var(--accent);
  border-color: transparent;
  color: white;
  letter-spacing: 2px;
  box-shadow: 0 8px 30px rgba(255, 62, 136, 0.35);
}

.permission button:hover {
  background: #ff5697;
  box-shadow: 0 10px 40px rgba(255, 62, 136, 0.45);
}

.hidden { display: none !important; }
