:root {
  --bg-dark: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #f43f5e;
  --secondary-hover: #e11d48;
  --text-main: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --solo-accent: #10b981;
  --team-accent: #8b5cf6;
}

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

body {
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.bg-image {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-image: url('https://offertabs.s3.amazonaws.com/offer/k436bc/site/media/69e10d350ff514.94119405.png');
  background-size: cover;
  background-position: center;
  filter: blur(10px) brightness(0.25);
  z-index: -1;
  transform: scale(1.1);
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* --- HERO --- */
.hero {
  text-align: center;
  padding: 40px 10px;
  margin-bottom: 20px;
  animation: fadeInDown 0.8s ease;
}

.hero .badge {
  display: inline-block;
  background: rgba(244, 63, 94, 0.2);
  color: var(--secondary);
  border: 1px solid rgba(244, 63, 94, 0.5);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 15px;
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.3);
}

.hero h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 15px;
  background: linear-gradient(to right, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
}

.main-container {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* --- GLASS CARD --- */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* --- REGISTRATION FORM --- */
#registration-section {
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  animation: fadeInUp 0.6s ease;
}

.reg-header {
  text-align: center;
  margin-bottom: 25px;
}
.reg-header h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.reg-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}
.form-row {
  display: flex;
  gap: 15px;
}
@media (max-width: 480px) {
  .form-row { flex-direction: column; gap: 0; }
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
  background: rgba(15, 23, 42, 0.8);
}
input.invalid {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.field-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 6px;
  display: block;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* --- BUTTONS --- */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}
.btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

/* Ripple effect */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s linear;
  background-color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid #ef4444;
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* --- LEADERBOARDS --- */
.leaderboards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 40px;
}
@media (max-width: 768px) {
  .leaderboards-container { grid-template-columns: 1fr; }
}

.leaderboard-col {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lb-header {
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.lb-header h3 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.2rem;
  letter-spacing: 0.5px;
}
.solo-theme h3 { color: var(--solo-accent); }
.team-theme h3 { color: var(--team-accent); }

.leaderboard-list {
  padding: 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-height: 200px;
}

/* Flip animation container rules */
.leaderboard-item {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px;
  gap: 12px;
  /* Will-change helps with smooth transforms during flip */
  will-change: transform, opacity;
}

/* Ensure rank 1 stands out */
.leaderboard-item.rank-1 {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(15, 23, 42, 0.6) 100%);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.1);
  transform: scale(1.02);
  margin-bottom: 4px;
  margin-top: 4px;
}
.leaderboard-item.rank-1 .rank-badge {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #000;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
  transform: scale(1.1);
}

.rank-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.lb-photo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.2s;
  background: rgba(255,255,255,0.05);
  opacity: 0;
}
.lb-photo.loaded {
  opacity: 1;
}
.lb-photo:hover {
  transform: scale(1.1);
}

.lb-info {
  flex: 1;
  min-width: 0;
}
.lb-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.lb-votes {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- GALLERY SECTION --- */
.gallery-section-wrapper {
  padding: 0;
  overflow: hidden;
}

.gallery-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.g-tab {
  flex: 1;
  padding: 20px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}
.g-tab:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.g-tab.active {
  color: #fff;
}
.g-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; width: 100%; height: 4px;
  background: var(--primary);
  box-shadow: 0 -2px 10px rgba(59, 130, 246, 0.5);
}
.g-tab[data-cat="SOLO"].active::after { background: var(--solo-accent); box-shadow: 0 -2px 10px rgba(16, 185, 129, 0.5); }
.g-tab[data-cat="TEAM"].active::after { background: var(--team-accent); box-shadow: 0 -2px 10px rgba(139, 92, 246, 0.5); }

.gallery-grid {
  padding: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.gallery-grid.fade-out {
  opacity: 0;
  transform: translateY(15px);
}
@media (max-width: 600px) {
  .gallery-grid { grid-template-columns: 1fr; padding: 20px; }
}

.gallery-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}
.gallery-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
  border-color: rgba(255,255,255,0.2);
}

.card-img-wrap {
  aspect-ratio: 4/5;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: rgba(0,0,0,0.2);
  cursor: pointer;
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  opacity: 0;
}
.card-img-wrap img.loaded {
  opacity: 1;
}
.card-img-wrap:hover img {
  transform: scale(1.05);
}

.card-info {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 15px;
}

.card-caption {
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #e2e8f0;
}

.card-vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.vote-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(255,255,255,0.05);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}
.vote-count svg {
  color: var(--secondary);
}

.vote-btn-wrap {
  flex: 1;
}

.vote-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}
.vote-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.vote-btn.voted {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
  cursor: default;
}
.vote-btn:disabled:not(.voted) {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Pulse animation for voting state */
@keyframes pulse-voting {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1); }
}
.voting-pulse {
  animation: pulse-voting 1s infinite;
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
  color: #93c5fd !important;
}

/* --- LIGHTBOX --- */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox.visible {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox-close {
  position: absolute;
  top: 20px; right: 30px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 50px; height: 50px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.2); transform: translateY(-50%) scale(1.1); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }

.lightbox-content {
  position: relative;
  z-index: 1005;
  display: flex;
  width: 90%;
  max-width: 1200px;
  height: 85vh;
  gap: 20px;
}

.lightbox-img-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(0,0,0,0.5);
  border-radius: 16px;
  overflow: hidden;
  cursor: zoom-in;
}

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--zoom-duration, 0.3s) cubic-bezier(0.2, 0, 0.2, 1);
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--scale, 1));
  will-change: transform;
}

#lightbox-img.zoomed {
  cursor: grab;
}

#lightbox-img.grabbing {
  cursor: grabbing;
}

.lightbox-info {
  width: 350px;
  display: flex;
  flex-direction: column;
  padding: 30px;
  border-radius: 16px;
  overflow-y: auto;
}

.lightbox-caption {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.3;
}

.lightbox-vote-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 2rem;
  font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  color: #fff;
  background: rgba(255,255,255,0.05);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.lightbox-vote-count svg {
  color: var(--secondary);
}

@media (max-width: 900px) {
  .lightbox-content {
    flex-direction: column;
    height: 90vh;
  }
  .lightbox-img-wrapper {
    height: 60vh;
    flex: none;
  }
  .lightbox-info {
    width: 100%;
    flex: 1;
  }
  .lightbox-nav { top: 35%; }
}
@media (max-width: 600px) {
  .lightbox-nav { display: none !important; } /* rely on swipes or taps */
  .lightbox-content { width: 100%; height: 100vh; border-radius: 0; }
  .lightbox-info { border-radius: 0; border: none; border-top: 1px solid var(--border); }
  .lightbox-img-wrapper { border-radius: 0; }
  .lightbox-close { top: 10px; right: 10px; background: rgba(0,0,0,0.5); }
}

/* --- ADMIN --- */
#admin-trigger {
  position: fixed;
  bottom: 0; right: 0;
  width: 50px; height: 50px;
  z-index: 9999;
  cursor: default;
}
.admin-modal-container {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.admin-card {
  width: 100%;
  max-width: 500px;
  position: relative;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.admin-tabs button {
  flex: 1;
  padding: 10px;
  font-size: 0.9rem;
}
.admin-sec {
  flex: 1;
  overflow-y: auto;
  padding-right: 5px;
}
.admin-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 15px;
  text-align: center;
}

/* custom scrollbar for admin table */
.admin-sec::-webkit-scrollbar { width: 6px; }
.admin-sec::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.admin-sec::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* UTILS */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  background: rgba(0,0,0,0.2);
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,0.1);
}
.empty-state h3 { font-family: 'Montserrat', sans-serif; margin-bottom: 10px; color: var(--muted); }

.image-spinner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.loading-pulse {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

#wbx-powered-by-slot {
  margin-top: auto;
  padding-top: 40px;
  padding-bottom: 20px;
  width: 100%;
}
