:root {
  --cny-red: #d32f2f;
  --cny-crimson: #b71c1c;
  --cny-gold: #ffc107;
  --cny-amber: #ff8f00;
  --fire-gradient: linear-gradient(135deg, #d32f2f 0%, #ff6f00 50%, #ffc107 100%);
  --font-display: 'Crimson Pro', serif;
  --font-body: 'DM Sans', sans-serif;
  --glow-gold: 0 0 40px rgba(255, 193, 7, 0.5);
  --shadow-deep: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-body);
  background: #0d0208;
  color: #fff;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-layers {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(211, 47, 47, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 193, 7, 0.12) 0%, transparent 50%);
  animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.lanterns {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.lantern {
  position: absolute;
  width: 60px;
  height: 80px;
  background: var(--fire-gradient);
  border-radius: 30px 30px 15px 15px;
  opacity: 0.12;
  animation: float 12s ease-in-out infinite;
}

.lantern:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
}

.lantern:nth-child(2) {
  left: 30%;
  animation-delay: 3s;
}

.lantern:nth-child(3) {
  left: 50%;
  animation-delay: 6s;
}

.lantern:nth-child(4) {
  left: 70%;
  animation-delay: 9s;
}

.lantern:nth-child(5) {
  left: 90%;
  animation-delay: 2s;
}

@keyframes float {
  0% {
    transform: translateY(-100px);
    opacity: 0;
  }

  10% {
    opacity: 0.12;
  }

  90% {
    opacity: 0.12;
  }

  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

.photobooth {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 50px 20px 35px;
  text-align: center;
  border-bottom: 3px solid var(--cny-gold);
  background: linear-gradient(180deg, rgba(183, 28, 28, 0.3) 0%, transparent 100%);
}

.year-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--cny-gold);
  background: rgba(255, 193, 7, 0.1);
  border: 2px solid var(--cny-gold);
  padding: 8px 24px;
  border-radius: 50px;
  margin-bottom: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.main-title {
  font-family: var(--font-display);
  font-size: clamp(42px, 7vw, 82px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  background: var(--fire-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255, 193, 7, 0.5));
}

.subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.75);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

.capture-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.capture-container {
  width: 100%;
  max-width: 900px;
}

.mode-selector {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 30px;
}

.mode-btn {
  font-size: 15px;
  font-weight: 600;
  padding: 14px 32px;
  border: 2px solid var(--cny-gold);
  border-radius: 50px;
  background: rgba(255, 193, 7, 0.1);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-btn:hover {
  background: rgba(255, 193, 7, 0.2);
  color: var(--cny-gold);
}

.mode-btn.active {
  background: var(--cny-gold);
  color: #000;
  box-shadow: var(--glow-gold);
}

.camera-frame {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(13, 2, 8, 0.6);
  backdrop-filter: blur(20px);
  border: 3px solid var(--cny-gold);
  box-shadow: var(--shadow-deep), 0 0 100px rgba(211, 47, 47, 0.3);
}

.video-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 75%;
  background: #000;
}

#webcam,
#previewImage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#previewImage {
  display: none;
}

#previewImage.active {
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(183, 28, 28, 0.3) 0%, rgba(13, 2, 8, 0.8) 100%);
  text-align: center;
  padding: 40px;
}

.placeholder.hidden {
  display: none;
}

.placeholder-icon {
  font-size: 80px;
  margin-bottom: 20px;
  color: var(--cny-gold);
}

.placeholder-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--cny-gold);
  margin-bottom: 10px;
}

.placeholder-subtext {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.overlay-corner {
  position: absolute;
  width: 60px;
  height: 60px;
  border: 3px solid var(--cny-gold);
  pointer-events: none;
  opacity: 0.6;
  z-index: 10;
}

.overlay-corner.top-left {
  top: 20px;
  left: 20px;
  border-right: none;
  border-bottom: none;
}

.overlay-corner.top-right {
  top: 20px;
  right: 20px;
  border-left: none;
  border-bottom: none;
}

.overlay-corner.bottom-left {
  bottom: 20px;
  left: 20px;
  border-right: none;
  border-top: none;
}

.overlay-corner.bottom-right {
  bottom: 20px;
  right: 20px;
  border-left: none;
  border-top: none;
}

.upload-zone {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(183, 28, 28, 0.3) 0%, rgba(13, 2, 8, 0.8) 100%);
  border: 3px dashed var(--cny-gold);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
}

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

.upload-zone:hover {
  background: linear-gradient(135deg, rgba(183, 28, 28, 0.5) 0%, rgba(13, 2, 8, 0.9) 100%);
}

.upload-zone.drag-over {
  border-style: solid;
  background: rgba(255, 193, 7, 0.2);
}

#fileInput {
  display: none;
}

.controls {
  margin-top: 30px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  font-size: 16px;
  font-weight: 600;
  padding: 16px 40px;
  border: none;
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: var(--fire-gradient);
  color: #000;
  box-shadow: 0 8px 24px rgba(211, 47, 47, 0.4);
  font-size: 18px;
}

.btn-primary:hover:not(:disabled) {
  transform: scale(1.05) translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cny-gold);
  border: 2px solid var(--cny-gold);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 193, 7, 0.2);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.status-bar {
  margin-top: 24px;
  padding: 20px;
  background: rgba(255, 193, 7, 0.1);
  border: 2px solid var(--cny-gold);
  border-radius: 16px;
  text-align: center;
  display: none;
}

.status-bar.active {
  display: block;
}

.status-text {
  font-size: 16px;
  color: var(--cny-gold);
  font-weight: 600;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 193, 7, 0.2);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--fire-gradient);
  width: 0%;
  transition: width 0.3s;
}

.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.result-modal.active {
  display: flex;
}

.result-content {
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(13, 2, 8, 0.9);
  border: 3px solid var(--cny-gold);
  border-radius: 24px;
  padding: 40px;
  position: relative;
  box-shadow: var(--shadow-deep);
  margin: auto;
}

.result-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  background: var(--fire-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 30px;
}

.result-image {
  width: 100%;
  border-radius: 16px;
  border: 2px solid var(--cny-gold);
  margin-bottom: 30px;
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--cny-gold);
  color: var(--cny-gold);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
}

.close-modal:hover {
  background: var(--cny-gold);
  color: #000;
  transform: rotate(90deg);
}

.footer {
  padding: 30px 20px;
  text-align: center;
  border-top: 2px solid var(--cny-gold);
  background: linear-gradient(0deg, rgba(183, 28, 28, 0.2) 0%, transparent 100%);
}

.footer-blessing {
  font-size: 18px;
  font-weight: 600;
  color: var(--cny-gold);
  margin-bottom: 12px;
}

.footer-links {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--cny-gold);
  text-decoration: none;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-links a:hover {
  color: var(--cny-amber);
  transform: translateY(-2px);
}

@media (max-width: 768px) {
  .main-title {
    font-size: 42px;
  }

  .mode-selector {
    flex-direction: column;
  }

  .mode-btn {
    justify-content: center;
  }

  .controls {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }

  .result-content {
    padding: 30px 20px;
    max-height: 85vh;
    border-radius: 16px;
  }

  .result-title {
    font-size: 24px;
    margin-bottom: 20px;
  }

  .result-image {
    margin-bottom: 20px;
    border-radius: 12px;
  }

  .result-actions {
    flex-direction: column;
    gap: 12px;
  }

  .result-actions .btn {
    width: 100%;
  }

  .close-modal {
    width: 40px;
    height: 40px;
    top: 15px;
    right: 15px;
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .result-modal {
    padding: 10px;
  }

  .result-content {
    padding: 60px 15px 20px;
    max-height: 90vh;
    border-radius: 12px;
    border-width: 2px;
  }

  .result-title {
    font-size: 20px;
    margin-bottom: 15px;
  }

  .result-image {
    margin-bottom: 15px;
  }

  .result-actions .btn {
    padding: 14px 24px;
    font-size: 15px;
  }

  .close-modal {
    width: 36px;
    height: 36px;
    top: 10px;
    right: 10px;
    font-size: 18px;
  }
}

/* Recent Results Modal */
.recent-results-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.recent-results-modal {
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(13, 2, 8, 0.9);
  border: 3px solid var(--cny-gold);
  border-radius: 24px;
  padding: 40px;
  position: relative;
  box-shadow: var(--shadow-deep);
  margin: auto;
}

.recent-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.recent-result-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--cny-gold);
  cursor: pointer;
  transition: all 0.3s;
  aspect-ratio: 1;
}

.recent-result-item:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(255, 193, 7, 0.5);
}

.recent-result-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.recent-result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  color: var(--cny-gold);
  font-size: 18px;
  font-weight: 600;
  gap: 8px;
}

.recent-result-item:hover .recent-result-overlay {
  opacity: 1;
}

.recent-result-overlay i {
  font-size: 32px;
}

.recent-result-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 768px) {
  .recent-results-modal {
    padding: 30px 20px;
  }

  .recent-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .recent-results-overlay {
    padding: 10px;
  }

  .recent-results-modal {
    padding: 60px 15px 20px;
    border-radius: 12px;
  }

  .recent-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .recent-result-date {
    font-size: 9px;
    padding: 6px;
  }
}