/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #ffffff;
  /* Pure white to blend with logo background */
  --bg-secondary: #ffffff;
  /* Pure white cards */
  --text-primary: #2c2c2e;
  /* Deep charcoal primary text */
  --text-secondary: #8a8a8e;
  /* Slate gray secondary text */
  --color-live: #ff3b30;
  /* Vibrant red for live indicator */
  --color-border: transparent;
  /* Seamless borders for flat blending */
  --shadow-card: none;
  /* Flat styling to blend elements */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font-family);
  background-color: #ffffff;
  /* Blends the desktop background as well */
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile Wrapper Shell */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.08);
  position: relative;
}

/* App Header */
.app-header {
  background-color: var(--bg-secondary);
  padding: 2px 16px;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-img {
  max-width: 200px;
  width: 70%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Main Content Area */
.app-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-grow: 1;
}

/* Premium Card Layout */
.card {
  background-color: var(--bg-secondary);
  border-radius: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Webcam Live Stream */
.video-container {
  width: 100%;
  background-color: #0a0a0c;
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.webcam-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(10, 10, 12, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  color: #ffffff;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.loading-overlay p {
  font-size: 14px;
  font-weight: 400;
  color: #a1a1aa;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 1s linear infinite;
}

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

/* Live Badge Indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(255, 59, 48, 0.08);
  padding: 4px 10px;
  border-radius: 100px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-live);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4);
  animation: pulse 1.6s infinite;
}

.live-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-live);
  letter-spacing: 0.05em;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(255, 59, 48, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
  }
}

/* Rules Section */
.rules-container {
  width: 100%;
  background-color: #ffffff;
  display: flex;
  justify-content: center;
}

.rules-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

/* Fullscreen Control Buttons */
.control-btn {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 5;
}

.control-btn:hover {
  background-color: rgba(0, 0, 0, 0.7);
  transform: scale(1.08);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn svg {
  display: block;
}

.fullscreen-btn {
  bottom: 16px;
  right: 16px;
  display: flex;
}

.exit-fullscreen-btn {
  top: 16px;
  right: 16px;
  display: none;
  /* Only visible in fullscreen */
}

/* Native Fullscreen API Styling */
.video-container:fullscreen {
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0 !important;
}

.video-container:fullscreen .webcam-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container:fullscreen .exit-fullscreen-btn {
  display: flex;
}

.video-container:fullscreen .fullscreen-btn {
  display: none;
}

/* Safari Webkit Native Fullscreen */
.video-container:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.video-container:-webkit-full-screen .webcam-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container:-webkit-full-screen .exit-fullscreen-btn {
  display: flex;
}

.video-container:-webkit-full-screen .fullscreen-btn {
  display: none;
}

/* Custom Fallback Fullscreen (iOS / non-supported elements) */
.video-container.is-custom-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0 !important;
}

.video-container.is-custom-fullscreen .webcam-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container.is-custom-fullscreen .exit-fullscreen-btn {
  display: flex;
}

.video-container.is-custom-fullscreen .fullscreen-btn {
  display: none;
}

/* Landscape orientation simulation for iOS portrait mode */
@media (orientation: portrait) {

  /* Rotates the custom full-screen container on iOS to landscape */
  .video-container.is-custom-fullscreen {
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    transform-origin: center;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: -50vw;
    margin-left: -50vh;
  }
}

/* App Footer */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background-color: var(--bg-secondary);
}

.app-footer p {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Media Queries for Desktop Styling Adjustments */
@media (min-width: 480px) {
  body {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .app-container {
    border-radius: 30px;
    min-height: calc(100vh - 40px);
    overflow: hidden;
  }
}