@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #080710;
  --bg-card: rgba(18, 16, 32, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Prompt', sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header {
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-cyan));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 32px;
  padding: 32px 40px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1100px) {
  .main-container {
    grid-template-columns: 1fr;
  }
}

/* Viewer Screen */
.viewer-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

#webcam {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera */
  opacity: 0.8;
  transition: opacity 0.5s ease;
}

#webcam.no-mirror {
  transform: scaleX(1);
}

#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  pointer-events: none;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #080710e6;
  backdrop-filter: blur(12px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 0.5s ease;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--accent-color);
  border-bottom-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1.5s infinite linear;
}

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

.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Control Panel */
.control-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: fit-content;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.3);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Grid presets */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.preset-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.15));
  border-color: var(--accent-color);
  color: var(--text-primary);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.preset-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Sliders */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.slider-value {
  color: var(--text-primary);
  font-weight: 600;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan);
  transform: scale(1.1);
}

/* Switches & dropdowns */
.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: var(--transition);
}

.dropdown-select:focus {
  border-color: var(--accent-color);
}

/* Switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 34px;
  border: 1px solid var(--border-color);
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background-color: var(--accent-color);
}

input:checked + .slider-toggle:before {
  transform: translateX(20px);
}

/* Custom Image Upload Dropzone */
.upload-container {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.upload-container.active {
  display: flex;
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.dropzone p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dropzone svg {
  width: 32px;
  height: 32px;
  fill: var(--text-secondary);
  margin-bottom: 8px;
}

.preview-uploaded-img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
}

.upload-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Action Buttons */
.action-btn {
  background: linear-gradient(135deg, var(--accent-color), #2563eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
  font-family: inherit;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 25px -10px rgba(59, 130, 246, 0.6);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.action-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: none;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

/* Overlay Instruction Bar */
.instruction-bar {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.instruction-icon {
  width: 32px;
  height: 32px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

.instruction-text {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.instruction-text strong {
  color: var(--text-primary);
}

footer {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Custom Notification Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(18, 16, 32, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-cyan);
  padding: 12px 24px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast svg {
  width: 20px;
  height: 20px;
  fill: var(--accent-cyan);
}

/* Mini-Game Layout Styles */
.game-panel {
  border: 1px dashed var(--accent-pink);
  background: rgba(236, 72, 153, 0.03);
  position: relative;
  overflow: hidden;
}

.game-score-row {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.game-stat-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

#game-timer {
  color: var(--accent-pink);
  text-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}

/* Game Over Overlay Screen */
.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 7, 16, 0.9);
  backdrop-filter: blur(16px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.game-over-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.game-over-card {
  background: rgba(18, 16, 32, 0.85);
  border: 2px solid var(--accent-pink);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 0 40px rgba(236, 72, 153, 0.25);
  max-width: 380px;
  width: 90%;
  animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.game-over-card h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #fff, var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-over-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.final-score-badge {
  background: rgba(236, 72, 153, 0.1);
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 16px 32px;
  border-radius: 20px;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
}

#final-score-val {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent-pink);
  text-shadow: 0 0 15px rgba(236, 72, 153, 0.6);
  margin-right: 4px;
}

/* Floating HUD Elements inside camera view */
.game-hud-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  z-index: 4;
  pointer-events: none; /* Let clicks pass through to canvas if needed */
}

.hud-item {
  background: rgba(8, 7, 16, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.hud-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.hud-val {
  font-size: 1.3rem;
  font-weight: 800;
}

.hud-time .hud-val {
  color: var(--accent-pink);
  text-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}

.hud-score .hud-val {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

/* In-Viewport Game Start Button */
.game-start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  transition: opacity 0.4s ease;
}

.game-play-btn {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-color));
  box-shadow: 0 0 25px rgba(236, 72, 153, 0.4);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 40px;
  border: none;
  transform: scale(1);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-play-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 35px rgba(236, 72, 153, 0.6);
  background: linear-gradient(135deg, var(--accent-pink), #2563eb);
}

.game-play-btn:active {
  transform: scale(0.98);
}

/* Fullscreen Button and Layout */
.fullscreen-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(8, 7, 16, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: var(--transition);
}

.fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.video-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  background: #000;
}

.video-wrapper:fullscreen #webcam,
.video-wrapper:fullscreen #overlay-canvas {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Leaderboard Board Styling & Row Animations */
#leaderboard-board div::-webkit-scrollbar {
  width: 5px;
}
#leaderboard-board div::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}
#leaderboard-board div::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
#leaderboard-board div::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.leaderboard-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease;
}
.leaderboard-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.75rem;
}
.rank-1 {
  background: linear-gradient(135deg, #ffe066, #f5a623);
  color: #000;
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.5);
}
.rank-2 {
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  color: #000;
  box-shadow: 0 0 8px rgba(148, 163, 184, 0.4);
}
.rank-3 {
  background: linear-gradient(135deg, #ddc0a4, #b45309);
  color: #fff;
  box-shadow: 0 0 8px rgba(180, 83, 9, 0.4);
}
.rank-other {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}


