:root {
  --bg-primary: #050b14;
  --bg-secondary: #0a1526;
  --bg-card: rgba(13, 27, 49, 0.88);
  --bg-card-hover: rgba(19, 39, 70, 0.95);
  --border-color: rgba(255, 183, 3, 0.18);
  --border-active: rgba(255, 183, 3, 0.85);

  --primary-gold: #ffb703;
  --primary-amber: #fb8500;
  --peacock-teal: #00b4d8;
  --peacock-blue: #0077b6;
  --saffron: #f77f00;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 20px rgba(255, 183, 3, 0.3);
  --shadow-teal: 0 0 20px rgba(0, 180, 216, 0.28);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(0, 180, 216, 0.14) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(255, 183, 3, 0.09) 0%, transparent 50%),
    radial-gradient(circle at 0% 50%, rgba(247, 127, 0, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.45;
  position: relative;
  overflow-x: hidden;
}

/* Peacock Watermark Motif */
.bg-peacock-watermark {
  position: fixed;
  top: -40px;
  right: -50px;
  width: 260px;
  height: 260px;
  background: url("/assets/peacock-feather.svg") no-repeat center center;
  background-size: contain;
  opacity: 0.035;
  filter: brightness(0) invert(1);
  pointer-events: none;
  z-index: 0;
}

/* App Container */
#app {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1.5rem;
  position: relative;
  z-index: 1;
}

/* Compact Sticky Header - Fixed at Top */
.app-header {
  position: sticky;
  top: 0.5rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.85rem;
  background: rgba(10, 21, 38, 0.96);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* SMALL PROPORTIONAL ISKCON LOGO (2X) */
.brand-logo-img {
  width: 54px !important;
  height: 38px !important;
  max-width: 54px !important;
  max-height: 38px !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  filter: drop-shadow(0 0 6px rgba(255, 183, 3, 0.5));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 40%, var(--primary-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.3px;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--peacock-teal);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Live Clock Badge */
.live-clock {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-gold);
  background: rgba(255, 183, 3, 0.12);
  border: 1px solid rgba(255, 183, 3, 0.3);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  display: inline-block;
}

/* Connection Status Badge */
.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(10, 21, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.connection-badge.connected .connection-dot {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-badge.reconnecting .connection-dot {
  background-color: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse 1.5s infinite;
}

.connection-badge.disconnected .connection-dot {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

/* Screen Transitions */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: screenFade 0.25s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes screenFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card Surface */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.15rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--peacock-teal), var(--primary-gold), var(--saffron));
}

/* Screen Headers */
.screen-header {
  text-align: center;
  margin-bottom: 1rem;
}

.festive-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 800;
  color: var(--primary-gold);
  background: rgba(255, 183, 3, 0.12);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.35rem;
  border: 1px solid rgba(255, 183, 3, 0.3);
}

.screen-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
}

.screen-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Forms */
.form-group {
  margin-bottom: 0.85rem;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.75rem 0.95rem;
  background: rgba(5, 11, 20, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-gold);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, 0.2);
  background: rgba(5, 11, 20, 0.95);
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.3px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-amber) 100%);
  color: #050b14;
  box-shadow: 0 4px 16px rgba(251, 133, 0, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(251, 133, 0, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Waiting Screen */
.waiting-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.75rem 1.25rem;
  flex: 1;
}

.waiting-graphic-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.waiting-peacock-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 0 10px rgba(0, 180, 216, 0.7));
  animation: floatFeather 3s ease-in-out infinite;
}

.pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--primary-gold);
  animation: ripple 2s cubic-bezier(0.1, 0.2, 0.3, 1) infinite;
  opacity: 0;
}

@keyframes floatFeather {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes ripple {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.student-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 180, 216, 0.12);
  border: 1px solid rgba(0, 180, 216, 0.35);
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--peacock-teal);
  font-weight: 700;
}

.waiting-status-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(5, 11, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  margin: 1.25rem 0 0.4rem;
}

.live-dot-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

.waiting-headline {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.waiting-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 300px;
  line-height: 1.35;
}

/* Question Screen */
.question-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.question-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #f87171;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ef4444;
  box-shadow: 0 0 6px #ef4444;
  animation: pulse 1s infinite;
}

.speed-bonus-badge {
  font-size: 0.75rem;
  color: var(--primary-gold);
  font-weight: 700;
  background: rgba(255, 183, 3, 0.1);
  border: 1px solid rgba(255, 183, 3, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.question-text {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.35;
  color: #fff;
}

/* Interactive Options */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary-gold);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

.option-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.option-btn.selected {
  border-color: var(--primary-gold);
  background: rgba(255, 183, 3, 0.18);
  box-shadow: 0 0 16px rgba(255, 183, 3, 0.45);
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--primary-gold);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.option-btn.selected .option-letter {
  background: var(--primary-gold);
  color: #050b14;
}

.option-text {
  flex: 1;
  line-height: 1.3;
}

/* Submission Locked Banner */
.submission-status {
  display: none;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(10, 21, 38, 0.96) 100%);
  border: 1.5px solid #10b981;
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  text-align: center;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
  animation: fadeIn 0.25s ease;
}

.submission-status.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.submission-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1rem;
  font-weight: 800;
  color: #34d399;
}

.status-check-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #10b981;
  color: #050b14;
  font-weight: 900;
  font-size: 0.8rem;
}

.submission-status-detail {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.waiting-next-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fbbf24;
  margin-top: 0.25rem;
}

/* Leaderboard Screen */
.leaderboard-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.personal-result-banner {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.22), rgba(255, 183, 3, 0.18));
  border: 1.5px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-gold);
}

.personal-result-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-muted);
}

.personal-result-highlight {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--primary-gold);
  margin-top: 0.15rem;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary-gold);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
}

.lb-item.top-5 {
  border-color: rgba(255, 183, 3, 0.35);
  background: rgba(255, 183, 3, 0.08);
}

.lb-item.is-me {
  border-color: var(--peacock-teal);
  background: rgba(0, 180, 216, 0.18);
  box-shadow: var(--shadow-teal);
}

.lb-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.lb-rank {
  font-weight: 900;
  font-size: 1.05rem;
  min-width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.lb-rank.gold { color: #ffd700; }
.lb-rank.silver { color: #e2e8f0; }
.lb-rank.bronze { color: #cd7f32; }

.lb-student-info {
  min-width: 0;
}

.lb-student-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-student-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.lb-time {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-gold);
  background: rgba(255, 183, 3, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Waiting Next Card - Prominent at Top of Leaderboard */
.waiting-next-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.65rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(10, 21, 38, 0.95) 100%);
  border: 1.5px solid rgba(255, 183, 3, 0.5);
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(255, 183, 3, 0.22);
  animation: pulseCard 2.5s infinite ease-in-out;
}

.waiting-next-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px var(--primary-gold));
  flex-shrink: 0;
}

.waiting-next-title {
  font-weight: 800;
  color: var(--primary-gold);
  font-size: 0.92rem;
}

.waiting-next-subtitle {
  color: var(--text-main);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  animation: slideUp 0.25s ease;
  pointer-events: auto;
}

.toast.error {
  background: rgba(239, 68, 68, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.success {
  background: rgba(16, 185, 129, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.info {
  background: rgba(0, 180, 216, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsiveness (360px - 414px) */
@media (max-width: 414px) {
  #app { padding: 0.6rem 0.75rem 1.25rem; }
  .screen-title { font-size: 1.25rem; }
  .question-text { font-size: 1.05rem; }
  .option-btn { min-height: 48px; font-size: 0.9rem; padding: 0.7rem 0.85rem; }
}

@media (max-width: 360px) {
  .brand-title { font-size: 0.95rem; }
  .screen-title { font-size: 1.15rem; }
  .live-clock { display: none; }
}
