:root {
  --bg: #f4faff; /* Clean light background */
  --panel: #ffffff; /* White panels */
  --panel2: #f1ebe4; /* Light warm gray for secondary panels */
  --text: #1b588f; /* University blue for text */
  --muted: #644d31; /* Brown for secondary text */
  --line: #b0b0b0; /* Light gray for borders */
  --accent: #6699cc; /* Light blue for accents */
  --ok: #4ade80; /* Green for success */
  --err: #ff6b6b; /* Red for errors */
  --radius: 16px;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: #fffafa;
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
  font-weight: 400;
}
/* Video background */
#videoBg {
  position: fixed;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  transform: translate(-50%, -50%) rotate(0deg);
  z-index: 0;
  object-fit: fill;
}

.hidden {
  display: none !important;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: #1e6195;
  border-bottom: none;
  box-shadow: 0 4px 20px rgba(27, 88, 143, 0.25);
  position: relative;
  overflow: hidden;
}

.topbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.brand {
  position: relative;
  z-index: 1;
  height: 90%;
}

.brandLogo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-image {
  width: 70px;
  height: 70px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.brandTitle {
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
  font-size: 22px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.brandSub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
  font-weight: 400;
}

.screens {
  flex: 1;
  position: relative;
  overflow: auto;
}
.screen {
  /* position: absolute;
  inset: 0; */
  height: 100%;
  width: 100%;
  display: none;
  padding: 24px;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.center {
  height: 100%;
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.center.wide {
  justify-content: space-evenly;
}

.h1 {
  font-size: 36px;
  margin: 0;
  color: #1b588f;
  font-weight: 700;
}
.h2 {
  font-size: 28px;
  margin: 0;
  color: #1b588f;
  font-weight: 600;
}
.p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}
.p.subtle {
  font-size: 14px;
  color: #928069;
  opacity: 0.8;
}

.grid2 {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.cardBtn {
  border: none;
  border-radius: 20px;
  background: #ffffff;
  padding: 28px 20px;
  color: #1b588f;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 6px 20px rgba(27, 88, 143, 0.25),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: hidden;
}

.cardBtn:hover,
.cardBtn:active {
  transform: translateY(-4px);
  box-shadow:
    0 12px 28px rgba(27, 88, 143, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.cardImage {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gender-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
  transition: transform 0.3s ease;
}

.cardBtn:hover .gender-image {
  transform: scale(1.05);
}

.cardBtn:active .gender-image {
  transform: scale(0.98);
}

.cardTitle {
  margin-top: 12px;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.3px;
}

.btnPrimary,
.btnGhost {
  border-radius: 14px;
  padding: 16px 28px;
  font-weight: 600;
  border: none;
  width: min(420px, 100%);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btnPrimary {
  background: #1b588f;
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(27, 88, 143, 0.25);
}

.btnPrimary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%);
  transform-origin: 50% 50%;
}

.btnPrimary:hover,
.btnPrimary:active {
  background: #154470;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(27, 88, 143, 0.35);
}

.btnPrimary:hover::after {
  animation: ripple 1s ease-out;
}

.btnGhost {
  background: #ffffff;
  color: #1b588f;
  border: 2px solid rgba(27, 88, 143, 0.2);
}

.btnGhost:hover,
.btnGhost:active {
  background: rgba(27, 88, 143, 0.15);
  color: #154470;
  border-color: #1b588f;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(27, 88, 143, 0.15);
}

.btnPrimary:disabled {
  background: #b0b0b0;
  color: #ffffff;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btnGhost:disabled {
  background: rgba(176, 176, 176, 0.1);
  color: #b0b0b0;
  border-color: #b0b0b0;
  cursor: not-allowed;
  transform: none;
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  100% {
    transform: scale(40, 40);
    opacity: 0;
  }
}

.row {
  width: min(520px, 100%);
  display: flex;
  gap: 16px;
  justify-content: center;
}

.row .btnPrimary,
.row .btnGhost {
  width: auto;
  min-width: 180px;
  padding: 16px 32px;
}
.form {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: #ffffff;
  text-align: left;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.label {
  display: block;
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 14px;
  color: #1b588f;
}

.seg {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.segBtn {
  border: 2px solid #e0e0e0;
  background: #ffffff;
  color: #644d31;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}
.segBtn.active {
  border-color: #6699cc;
  background: rgba(102, 153, 204, 0.1);
  color: #1b588f;
}
.select {
  width: 100%;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  background: #ffffff;
  color: #1b588f;
  padding: 14px 16px;
  font-weight: 500;
  font-size: 15px;
}

.cameraWrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 24px;
  padding-top: 20px;
}
.cameraHeader {
  width: min(720px, 100%);
  text-align: center;
}
.cameraFrame {
  width: 500px;
  aspect-ratio: 3 / 4;
  border-radius: 24px;
  border: 2px solid #e0e0e0;
  background: #f1ebe4;
  overflow: hidden;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.cameraFrame video {
  width: 100%;
  max-width: 500px;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

/* Face guide - FIXED VERSION */
.faceGuide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.faceGuide::before {
  content: '';
  position: absolute; /* Change to absolute positioning */
  top: 38%; /* Match the vertical position of the radial-gradient */
  left: 50%;
  transform: translate(-50%, -50%); /* Center it properly */

  /* FIX: Use the smaller dimension to ensure perfect circle */

  /* Alternative: Always use vmin which is the smaller dimension */
  width: 20rem;
  height: 20rem;

  max-width: 70%;
  max-height: 70%;
  border: 8px dashed rgba(102, 153, 204);
  border-radius: 50%;
  animation: pulse 2.5s ease-in-out infinite;
}

/* Adjust for smaller screens */
@media (max-height: 600px) {
  .faceGuide::before {
    /* Use vmin to maintain perfect circle */
    width: 40vmin;
    height: 40vmin;
  }
}

@keyframes pulse {
  0%,
  100% {
    border-color: rgba(102, 153, 204, 0.6);
  }
  50% {
    border-color: rgba(102, 153, 204, 0.9);
  }
}
/* Countdown */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #1b588f;
  opacity: 0;
  pointer-events: none;
}

.countdown.show {
  opacity: 1;
  animation: pop 0.7s ease both;
}
@keyframes pop {
  0% {
    transform: scale(0.92);
    opacity: 0;
  }
  40% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Flash */
.flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}
.flash.on {
  animation: flash 0.25s ease both;
}
@keyframes flash {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}

.cameraControls {
  width: min(720px, 100%);
  display: flex;
  gap: 16px;
  justify-content: center;
}

.previewBox {
  width: 500px;
  border-radius: 20px;
  /* height: 90%; */
  border: 2px solid #e0e0e0;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.previewBox img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.stylesGrid {
  width: min(820px, 100%);
  margin: 12px auto 0;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@media (min-width: 900px) {
  .stylesGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.styleCard {
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  background: #ffffff;
  padding: 0;
  color: var(--text);
  transition: all 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 350px !important;
  position: relative;
}

.styleCard:hover,
.styleCard:active {
  border-color: #6699cc;
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.styleThumb {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1ebe4;
  max-height: 350px !important;
  position: relative;
}

/* Gradient overlay on thumb for better text readability */
.styleThumb::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px; /* Increased height for label background */
  background: linear-gradient(to top, rgba(0, 0, 0, 0.3), transparent);
}

.styleLabel {
  display: none;
  position: absolute; /* Changed to absolute */
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: rgba(255, 255, 255); /* Semi-transparent white */
  backdrop-filter: blur(10px); /* Glass effect */
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  font-size: 18px;
  color: #1b588f;
  min-height: 60px;
  border-bottom: #ffffff;
  border-left: #ffffff;
  border-right: #ffffff;
  border-top: 1px solid rgba(255, 255, 255, 0.3); /* Subtle top border */
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* Soft shadow for depth */
}

.badge {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  background: rgba(255, 255, 255, 0.9);
  color: #644d31;
  font-weight: 500;
}

.loading-container {
  text-align: center;
  animation: fadeIn 0.5s ease;
  text-align: center;
  padding: 20px;
  animation: fadeIn 0.5s ease;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  background: #ffffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin-bottom: -10px;
}

.spinner-container {
  width: 160px;
  height: 160px;
  margin: 40px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gradient-spinner {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(transparent, #1b588f);
  -webkit-mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 8px),
    #fff 0
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #fff 0);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-subtitle {
  color: #644d31;
  margin: 10px 0 30px;
  font-size: 16px;
  opacity: 0.8;
}

/* Improved progress bar */
.progressWrap {
  width: min(420px, 100%);
  margin-top: 30px;
}

.progressBar {
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(27, 88, 143, 0.2);
  overflow: hidden;
  background: #ffffff;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1b588f, #6699cc);
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.progressFill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.progressDots {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 20px;
  pointer-events: none;
}

.dot {
  width: 6px;
  height: 6px;
  background: rgba(27, 88, 143, 0.2);
  border-radius: 50%;
  animation: pulseDot 1.5s infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}
.dot:nth-child(3) {
  animation-delay: 0.4s;
}

.progressText {
  margin-top: 15px;
  margin-bottom: 30px;
  color: #1b588f;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
}

/* Animations */
@keyframes bounce {
  0% {
    transform: translateY(0) rotate(-5deg);
  }
  100% {
    transform: translateY(-20px) rotate(5deg);
  }
}

@keyframes shadow {
  0% {
    opacity: 0.3;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0.6;
    transform: translateX(-50%) scale(0.8);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes pulseDot {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.8;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Restart Button Styles */
.restart-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #1b588f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.restart-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

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

.restart-btn.visible {
  opacity: 1;
  pointer-events: all;
}

.qrBox {
  width: 400px;
  height: 400px;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.qrBox img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 32px;
  padding: 14px 24px;
  border-radius: 14px;
  border: none;
  background: #1b588f;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(27, 88, 143, 0.2);
  max-width: 90%;
  text-align: center;
}
.toast.show {
  opacity: 1;
}

.welcome-card {
  text-align: center;
  padding: 40px;
  animation: fadeIn 0.5s ease;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  background: #ffffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.option-header {
  text-align: center;
  padding: 20px;
  animation: fadeIn 0.5s ease;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  background: #ffffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin-bottom: -10px;
}
.text-white {
  color: #ffffff !important;
  font-size: 40px;
}
.welcome-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

.welcome-text {
  font-size: 18px;
  color: #644d31;
  margin: 10px 0 30px;
}

/* Simple animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Heading bounce effect */
.h2.bounce {
  animation: bounce 2s infinite;
}

/* Subtitle */
.option-subtitle {
  color: #644d31;
  font-size: 16px;
  margin: 0;
  padding-top: 8px;
}

.ss-main {
  height: 47px !important;
}
.ss-single-selected {
  height: 47px !important;
  border-radius: 12px !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}

.ss-search {
  display: none !important;
}

.ss-option-selected {
  background: #1b588f !important;
  color: #ffffff !important;
}
/* Better segment buttons */
.segBtn {
  flex: 1;
  min-width: 120px;
  border: 2px solid #e0e0e0;
  background: #ffffff;
  color: #644d31;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.segBtn.active {
  border-color: #1b588f;
  background: #1b588f;
  color: #ffffff;
  font-weight: 600;
}

.segBtn:hover:not(.active) {
  border-color: #6699cc;
  background: rgba(102, 153, 204, 0.05);
  color: #1b588f;
}

/* Bounce animation */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}
