* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #000;
  color: #fff;
}

body.transparent-bg {
  background: transparent;
}

body.hide-cursor {
  cursor: none;
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.hidden {
  display: none !important;
}

/* Loading Screen */
#loading-screen {
  background: #000;
  z-index: 1000;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #00ff88;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.loading-spinner.small {
  width: 30px;
  height: 30px;
  border-width: 2px;
}

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

#loading-text {
  color: #888;
}

/* Camera Selector Screen */
#camera-screen {
  background: rgba(0, 0, 0, 0.95);
  padding: 20px;
  z-index: 900;
}

#camera-screen h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
}

#camera-preview-container {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16/9;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#camera-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 20px;
}

.camera-option {
  padding: 12px 20px;
  background: #222;
  border: 2px solid transparent;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 1rem;
}

.camera-option:hover {
  background: #333;
}

.camera-option.selected {
  border-color: #00ff88;
  background: #1a3d2a;
}

#confirm-camera-btn {
  padding: 14px 40px;
  background: #00ff88;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

#confirm-camera-btn:hover:not(:disabled) {
  background: #00cc6a;
  transform: scale(1.05);
}

#confirm-camera-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  transform: none;
}

/* Permission Screen */
#permission-screen {
  background: #000;
  z-index: 800;
}

.permission-content {
  text-align: center;
  padding: 20px;
}

.permission-content h2 {
  margin-bottom: 16px;
  color: #ff4444;
}

.permission-content p {
  margin-bottom: 20px;
  color: #888;
}

.permission-content button {
  padding: 12px 30px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.permission-content button:hover {
  background: #444;
}

/* AR Screen */
#ar-screen {
  background: #000;
}

#deepar-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#deepar-canvas.fit-cover {
  object-fit: cover;
}

#deepar-canvas.fit-contain {
  object-fit: contain;
}

#deepar-canvas.fit-fill {
  object-fit: fill;
}

/* Stats Display */
#stats-display {
  position: fixed;
  top: 15px;
  left: 15px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: monospace;
  z-index: 100;
  display: flex;
  gap: 12px;
}

#stats-display.hidden {
  display: none;
}

/* Settings Toggle */
#settings-toggle {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 100;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#settings-toggle:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Settings Menu */
#settings-menu {
  position: fixed;
  top: 70px;
  right: 15px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  min-width: 220px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

#settings-menu.hidden {
  display: none;
}

.settings-group {
  margin-bottom: 16px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-group label {
  display: block;
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.settings-group select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.settings-group select option {
  background: #222;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch.active {
  background: #00ff88;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

.settings-group button {
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.settings-group button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Filter Bar */
#filter-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  z-index: 100;
}

#filter-bar.hidden {
  display: none;
}

#filter-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

#filter-list::-webkit-scrollbar {
  display: none;
}

.filter-item {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.filter-item.active {
  border-color: #00ff88;
  background: rgba(0, 255, 136, 0.2);
}

.filter-emoji {
  font-size: 1.5rem;
}

.filter-name {
  font-size: 0.65rem;
  margin-top: 2px;
  color: #aaa;
}

/* Effect Loading */
#effect-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
}

#effect-loading.hidden {
  display: none;
}

/* UI Modes */
body.ui-minimal #settings-menu,
body.ui-minimal .filter-name {
  display: none;
}

body.ui-none #settings-toggle,
body.ui-none #settings-menu,
body.ui-none #filter-bar,
body.ui-none #stats-display {
  display: none !important;
}
