:root {
  --red: #c62828;
  --green: #2e7d32;
  --gold: #ffeb3b;
  --bg-dark: #0b1020;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-main: #222;
  --snow-color: rgba(255, 255, 255, 0.9);
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
}

/* Snowy gradient background */
.snowy-bg {
  min-height: 100vh;
  background: radial-gradient(circle at top, #263238, #000814);
  color: #fff;
  display: flex;
  flex-direction: column;
}

/* Simple snow overlay */
.snow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(var(--snow-color) 1px, transparent 1px),
    radial-gradient(var(--snow-color) 1px, transparent 1px);
  background-size: 20px 20px, 30px 30px;
  background-position: 0 0, 10px 10px;
  opacity: 0.3;
  animation: snowfall 20s linear infinite;
  z-index: 0;
}

@keyframes snowfall {
  from {
    transform: translateY(-50px);
  }
  to {
    transform: translateY(50px);
  }
}

/* Layout */
.app-header,
.app-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1rem;
}

.app-header {
  background: linear-gradient(90deg, var(--red), var(--green));
  box-shadow: var(--shadow-soft);
}

.logo-text {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.app-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem 1rem 2.5rem;
}

.app-footer {
  font-size: 0.8rem;
  color: #ddd;
}

/* Card */
.card {
  width: 100%;
  max-width: 960px;
  background: var(--card-bg);
  color: var(--text-main);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.card-highlight {
  border: 2px solid var(--green);
}

.card-title {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  color: var(--red);
}

.card-subtitle {
  margin: 0 0 1rem;
  color: #555;
}

.card-header-flex {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  min-width: 180px;
  flex: 1;
}

.form-group label {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.form-group input {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
}

.form-group input:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-primary {
  background: linear-gradient(90deg, var(--red), var(--green));
  color: #fff;
}

.btn-secondary {
  background: #eceff1;
  color: #37474f;
}

.btn-accent {
  background: var(--green);
  color: #fff;
}

.btn:hover {
  filter: brightness(1.05);
}

/* Table */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
}

.data-table thead {
  background: rgba(220, 237, 200, 0.8);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(248, 248, 248, 0.8);
}

.qr-thumb {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.qr-thumb-large {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid #ddd;
  background: #fff;
}

.small-text {
  font-size: 0.75rem;
  color: #777;
}

/* Status & errors */
.error-msg {
  background: rgba(198, 40, 40, 0.1);
  border-left: 4px solid var(--red);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #b71c1c;
}

.assigned-name {
  margin-top: 1rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green);
  text-align: center;
}

/* Spacing utilities */
.mt-1 {
  margin-top: 0.75rem;
}

.mt-2 {
  margin-top: 1.25rem;
}

/* Dramatic reveal helpers */
.hidden {
  display: none !important;
}

/* Overlay for dramatic reveal */
.reveal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.reveal-overlay.hidden {
  display: none !important;
}

.reveal-modal {
  background: radial-gradient(circle at top, #ffe082, #fff3e0);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-soft);
  border: 3px solid var(--green);
  position: relative;
  overflow: hidden;
}

/* twinkling stars inside modal */
.reveal-modal::before {
  content: "";
  position: absolute;
  inset: -50%;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.8) 1px, transparent 1px);
  background-size: 12px 12px;
  opacity: 0.3;
  animation: twinkle 10s linear infinite;
}

.reveal-modal > * {
  position: relative;
  z-index: 1;
}

@keyframes twinkle {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50px, 50px, 0);
  }
}

/* === Countdown styling (3 → 2 → 1 via CSS) === */

/* Countdown container */
.reveal-countdown {
  position: relative;
  height: 3.2rem;
  margin-bottom: 0.5rem;
}

/* Individual digits */
.reveal-countdown .digit {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  font-size: 3rem;
  font-weight: 800;
  color: var(--red);
  text-shadow: 0 0 10px rgba(198, 40, 40, 0.8);
  animation-name: countdownDigit;
  animation-duration: 2.4s;
  animation-fill-mode: forwards;
  animation-iteration-count: 1;
  animation-play-state: paused;
}

/* Start the countdown animation only when overlay is active */
.reveal-overlay.active .reveal-countdown .digit {
  animation-play-state: running;
}

/* Each digit appears at a different time */
.reveal-countdown .digit-3 {
  animation-delay: 0s;
}
.reveal-countdown .digit-2 {
  animation-delay: 0.8s;
}
.reveal-countdown .digit-1 {
  animation-delay: 1.6s;
}

@keyframes countdownDigit {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  40% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
}

/* Name styling */
.reveal-name {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.5rem 0;
  word-break: break-word;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 0.6s ease-out 2.4s,
    transform 0.6s ease-out 2.4s;
}

/* When overlay is active, show the name after the countdown */
.reveal-overlay.active .reveal-name {
  opacity: 1;
  transform: scale(1);
  animation: glowPulse 1.4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%,
  100% {
    text-shadow:
      0 0 10px rgba(76, 175, 80, 0.8),
      0 0 20px rgba(255, 255, 255, 0.9);
  }
  50% {
    text-shadow:
      0 0 4px rgba(76, 175, 80, 0.5),
      0 0 10px rgba(255, 255, 255, 0.6);
  }
}

.reveal-tip {
  font-size: 0.9rem;
  color: #4e342e;
}

.reveal-wrapper {
  margin-top: 1rem;
  text-align: center;
}

.btn-small {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.data-table td button.btn-small {
  margin-right: 0.25rem;
}

/* Mobile tweaks for reveal */
@media (max-width: 480px) {
  .reveal-name {
    font-size: 1.6rem;
  }

  .reveal-countdown .digit {
    font-size: 2.3rem;
  }
}

/* Mobile responsiveness */
@media (max-width: 720px) {
  .card {
    padding: 1.2rem;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .form-inline {
    flex-direction: column;
  }

  .logo-text {
    font-size: 1rem;
  }
}
