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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;
}

/* Canvas container - fullscreen */
#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#canvas-container canvas {
  display: block;
}

/* UI Overlay - on top of canvas */
.ui-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  /* Safe area support for notched devices */
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.ui-overlay > * {
  pointer-events: auto;
}

/* Header / HUD */
.hud {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.controls button {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: rgba(22, 33, 62, 0.9);
  color: #eee;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
  min-height: 44px;
  min-width: 44px;
  backdrop-filter: blur(4px);
}

.controls button:hover:not(:disabled) {
  background: rgba(26, 73, 128, 0.9);
}

.controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Camera Controls */
.camera-controls {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.camera-controls button {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 4px;
  background: rgba(22, 33, 62, 0.9);
  color: #eee;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
  min-width: 48px;
  min-height: 48px;
}

.camera-controls button:hover {
  background: rgba(26, 73, 128, 0.9);
}

.camera-controls button:active {
  background: rgba(15, 52, 96, 0.9);
  transform: scale(0.95);
}

/* Aspect Legend */
.aspect-legend {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.aspect-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: rgba(22, 33, 62, 0.8);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  backdrop-filter: blur(4px);
}

.aspect-item:hover {
  background: rgba(26, 73, 128, 0.9);
  transform: scale(1.05);
}

.aspect-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

.aspect-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.aspect-status {
  display: none;
}

.aspect-item.completed {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(22, 33, 62, 0.9));
  border-color: #4CAF50;
}

.aspect-item.completed .aspect-dot {
  box-shadow: 0 0 8px #4CAF50, inset 0 0 4px rgba(255,255,255,0.5);
}

.aspect-item.active {
  border-color: var(--aspect-color, #fff);
  box-shadow: 0 0 12px var(--aspect-color, rgba(255, 255, 255, 0.3));
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  pointer-events: auto;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  background: #16213e;
  padding: 2rem 3rem;
  border-radius: 12px;
  text-align: center;
}

.overlay-content h2 {
  margin-bottom: 0.5rem;
  color: #4CAF50;
}

.overlay-content p {
  margin-bottom: 1.5rem;
  color: #aaa;
}

.overlay-content button {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 6px;
  background: #4CAF50;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 48px;
}

.overlay-content button:hover {
  background: #45a049;
}

/* Help overlay */
.help-content {
  text-align: left;
  max-width: 400px;
}

.help-content h2 {
  text-align: center;
  margin-bottom: 1rem;
}

.help-content ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.help-content li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.help-content .help-tip {
  font-size: 0.85rem;
  color: #888;
  font-style: italic;
  margin-top: 1rem;
}

.help-content button {
  display: block;
  margin: 1.5rem auto 0;
}

/* Help button style */
#btn-help {
  font-weight: bold;
  font-size: 1.1rem;
  width: 48px;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: #f44;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -100%);
  margin-top: -10px;
}

.tooltip.hidden {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .ui-overlay {
    padding: 0.5rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
  }

  .controls {
    justify-content: center;
  }

  .camera-controls {
    right: max(0.5rem, env(safe-area-inset-right));
    gap: 0.25rem;
  }

  .camera-controls button {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
    min-width: 40px;
    min-height: 40px;
  }

  .aspect-legend {
    gap: 0.5rem;
  }

  .aspect-item {
    padding: 0.4rem 0.6rem;
  }

  .aspect-name {
    font-size: 0.75rem;
  }

  .aspect-dot {
    width: 12px;
    height: 12px;
  }
}
