/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Noto+Sans+Tamil:wght@400;600;700&family=Playfair+Display:wght@400;700;900&display=swap');

:root {
  /* Youth theme variables (Sunrise energy) */
  --youth-bg: linear-gradient(160deg, #0A1628 0%, #1a2d5a 40%, #8B4513 80%, #C9A84C 100%);

  /* Carmel theme variables (Night Watch purple) */
  --carmel-bg: linear-gradient(160deg, #0d0221 0%, #1a0533 30%, #2d1b69 65%, #C9A84C 100%);

  /* Shared palette colors */
  --gold: #C9A84C;
  --gold-light: #E8D5A3;
  --gold-glow: rgba(201, 168, 76, 0.25);
  --white: #FFFFFF;
  --white-muted: rgba(255, 255, 255, 0.65);
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(201, 168, 76, 0.2);
  --success: #4CAF50;
  --radius: 16px;
  --radius-sm: 8px;
}

/* Global resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Lato', sans-serif;
  color: var(--white);
  min-height: 100vh;
  padding: 0;
  background-attachment: fixed;
  background-size: cover;
  display: flex;
  flex-direction: column;
}

/* Youth page styling classes */
body.youth-theme {
  background: var(--youth-bg) no-repeat fixed;
  background-size: cover;
}

/* Carmel page styling classes */
body.carmel-theme {
  background: var(--carmel-bg) no-repeat fixed;
  background-size: cover;
}

body.tamil {
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 17px;
}

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.portal-wrapper {
  max-width: 600px;
  margin: 0 auto;
}

/* Typography styles */
h1,
h2,
h3,
h4 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
}

body.tamil h1,
body.tamil h2,
body.tamil h3,
body.tamil h4 {
  font-family: 'Noto Sans Tamil', sans-serif;
}

/* Cards style */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Instruction box style */
.instruction-box {
  border: 2px solid var(--gold);
  background: rgba(201, 168, 76, 0.1);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  line-height: 1.6;
}

.instruction-box h4 {
  color: var(--gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Input boxes & form styles */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(201, 168, 76, 0.3);
  border-radius: var(--radius-sm);
  color: white;
  font-size: 16px;
  /* CRITICAL: prevents iOS zoom on inputs */
  padding: 16px;
  font-family: inherit;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

/* Primary Button style */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #C9A84C, #E8D5A3, #C9A84C);
  color: #0A1628;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  padding: 18px;
  cursor: pointer;
  font-family: inherit;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
  box-shadow: 0 4px 20px var(--gold-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #E8D5A3, #C9A84C, #E8D5A3);
  box-shadow: 0 6px 24px rgba(201, 168, 76, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  box-shadow: none;
}

/* Alert boxes */
.alert {
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.5;
}

.alert-warning {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid var(--warning);
  color: #ffb74d;
}

.alert-success {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid var(--success);
  color: #81c784;
}

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

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Leaderboard details */
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.leaderboard-title {
  font-size: 1.3rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs-container {
  display: flex;
  gap: 6px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--white-muted);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.tab-btn.active {
  background: var(--gold);
  color: #0A1628;
  border-color: var(--gold);
  font-weight: 700;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.2s;
}

.leaderboard-item:hover {
  transform: translateX(4px);
}

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

.leaderboard-rank {
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.leaderboard-name {
  font-weight: 600;
}

.leaderboard-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-count {
  background: rgba(10, 22, 40, 0.5);
  border: 1px solid var(--card-border);
  color: var(--gold-light);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

body.carmel-theme .badge-count {
  background: rgba(13, 2, 33, 0.5);
}

.badge-streak {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid var(--warning);
  color: #ff9800;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

/* Special Rank Highlighting */
.leaderboard-item.rank-1 {
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.25), rgba(201, 168, 76, 0.05));
  border-color: var(--gold);
}

.leaderboard-item.rank-1 .leaderboard-rank {
  background: var(--gold);
  color: #0A1628;
}

.leaderboard-item.rank-2 {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.2), rgba(192, 192, 192, 0.05));
  border-color: rgba(192, 192, 192, 0.4);
}

.leaderboard-item.rank-2 .leaderboard-rank {
  background: #c0c0c0;
  color: #0A1628;
}

.leaderboard-item.rank-3 {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.05));
  border-color: rgba(205, 127, 50, 0.4);
}

.leaderboard-item.rank-3 .leaderboard-rank {
  background: #cd7f32;
  color: white;
}

/* Success Celebration Elements */
.celebrate-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 22, 40, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

body.carmel-theme .celebrate-overlay {
  background: rgba(13, 2, 33, 0.85);
}

.celebrate-card {
  background: linear-gradient(145deg, #0f2038, #050b14);
  border: 2px solid var(--gold);
  border-radius: 24px;
  padding: 36px 24px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

body.carmel-theme .celebrate-card {
  background: linear-gradient(145deg, #1f0b3b, #070112);
}

/* Success animations */
@keyframes checkBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  60% {
    transform: scale(1.2);
  }

  80% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes burst {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }

  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.9;
    box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4);
  }

  70% {
    transform: scale(1.05);
    opacity: 1;
    box-shadow: 0 0 0 10px rgba(201, 168, 76, 0);
  }

  100% {
    transform: scale(1);
    opacity: 0.9;
    box-shadow: 0 0 0 0 rgba(201, 168, 76, 0);
  }
}

.success-check-wrapper {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  position: relative;
}

.success-check {
  font-size: 80px;
  line-height: 1;
  animation: checkBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  display: block;
  text-align: center;
}

.success-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 40px;
  pointer-events: none;
  animation: burst 0.8s ease-out forwards;
}

.celebrate-card h3 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  color: white;
}

.celebrate-card p {
  color: var(--white-muted);
  margin-bottom: 20px;
}

.verse-box {
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-style: italic;
  line-height: 1.6;
  text-align: justify;
  margin-bottom: 20px;
  font-size: 15px;
}

.verse-ref {
  display: block;
  font-weight: 700;
  color: var(--gold-light);
  margin-top: 8px;
  text-align: right;
  font-style: normal;
}

.counter-box {
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 24px;
}

/* Visual Carmel Grid */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin: 16px 0;
}

@media (max-width: 480px) {
  .slot-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
  }
}

.slot-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  font-size: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: bold;
}

.slot-cell:hover {
  transform: scale(1.1);
  z-index: 2;
}

.slot-cell.done {
  background: #4CAF50;
  color: white;
}

.slot-cell.missed {
  background: #f44336;
  color: white;
}

.slot-cell.current {
  background: var(--gold);
  color: #0A1628;
  animation: pulse 1.5s infinite;
  border: 2px solid white;
}

.slot-cell.empty {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white-muted);
}

.slot-cell.upcoming {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.3);
}

/* Coverage progress bar */
.coverage-bar {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  overflow: hidden;
  margin: 10px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.coverage-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, var(--gold));
  border-radius: 7px;
  width: 0%;
  transition: width 1.2s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Carmel Tamil specific grid buttons */
.tamil-names-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 440px) {
  .tamil-names-grid {
    grid-template-columns: 1fr;
  }
}

.name-grid-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-grid-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--gold-light);
}

.name-grid-btn.assigned-highlight {
  border: 2px solid var(--gold);
  background: rgba(201, 168, 76, 0.12);
  font-weight: 700;
}

.name-grid-btn.selected {
  background: var(--gold) !important;
  color: #0A1628 !important;
  font-weight: 700;
  border-color: var(--gold) !important;
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.3);
}

/* Footers */
.portal-footer {
  margin-top: 40px;
  text-align: center;
  padding: 24px 0;
  border-top: 1px solid var(--card-border);
  font-size: 14px;
  color: var(--white-muted);
}

.portal-footer a {
  color: var(--gold-light);
  text-decoration: none;
  font-weight: 600;
}

.portal-footer a:hover {
  text-decoration: underline;
}

.visitor-count-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 20px;
  font-size: 13px;
  color: var(--white-muted);
}

/* Mobile Optimizations */
@media (max-width: 480px) {
  .container {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  body.tamil {
    font-size: 16px;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .btn-primary {
    font-size: 16px;
    padding: 16px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {

  *,
  .success-check,
  .coverage-fill,
  .slot-cell.current {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}