:root {
  color-scheme: light;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --blue-900: #0a2463;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --cyan-600: #0891b2;
  --text: #172033;
  --muted: #526075;
  --surface: rgba(255, 255, 255, 0.96);
  --border: #dce1f0;
  --danger: #b91c1c;
  --success: #15803d;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--blue-900);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  color: var(--text);
  background: linear-gradient(145deg, #071b4a 0%, #16469d 55%, #0f7490 100%);
}

button,
input {
  font: inherit;
}

.background-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background-color: #0a2463;
  background-image:
    url("../assets/images/poster-desktop.jpg"),
    linear-gradient(145deg, #071b4a, #16469d 55%, #0f7490);
  background-position: center;
  background-size: cover;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 15, 45, 0.56);
}

.container {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
}

.registration-card {
  padding: 38px 34px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.title {
  margin: 0 0 28px;
  color: var(--blue-900);
  font-size: clamp(1.25rem, 4vw, 1.55rem);
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.step.hidden,
.status-message.hidden,
.loading.hidden {
  display: none;
}

.instruction {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--blue-900);
  font-size: 0.9rem;
  font-weight: 650;
}

.optional-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.form-input {
  width: 100%;
  min-height: 48px;
  padding: 11px 15px;
  color: var(--text);
  font-size: 1rem;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.form-input::placeholder {
  color: #8793a7;
}

.form-input:focus-visible {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

.form-input.error {
  color: #7f1d1d;
  background: #fff7f7;
  border-color: #dc2626;
}

.form-input:disabled {
  cursor: wait;
  opacity: 0.7;
}

.status-message {
  margin: 16px 0;
  padding: 12px 14px;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  border: 2px solid;
  border-radius: 10px;
}

.status-message.not-found {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fca5a5;
}

.status-message.multiple {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

.btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 24px;
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.48);
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.btn-primary {
  margin-top: 6px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  box-shadow: 0 5px 18px rgba(37, 99, 235, 0.34);
}

.btn-secondary {
  margin-top: 16px;
  background: linear-gradient(135deg, var(--cyan-600), #06b6d4);
  box-shadow: 0 5px 18px rgba(8, 145, 178, 0.3);
}

.storage-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
}

.result-container {
  animation: fade-in 240ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.result-title {
  margin: 0 0 18px;
  color: var(--success);
  font-size: 1.35rem;
  text-align: center;
}

.student-info {
  margin-bottom: 22px;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid #e2e8f0;
}

.info-row:last-child {
  border-bottom: 0;
}

.info-label {
  flex: 0 0 auto;
  color: var(--blue-900);
  font-weight: 650;
}

.info-value {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.status-registered {
  color: var(--success);
  font-weight: 700;
}

.qr-container {
  text-align: center;
}

.qr-label {
  margin: 0 0 14px;
  color: var(--blue-900);
  font-weight: 650;
}

.qr-code-display {
  width: min(100%, 244px);
  margin-inline: auto;
  padding: 16px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

#qr-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.loading {
  margin-top: 18px;
  color: var(--muted);
  text-align: center;
}

.loading p {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.spinner {
  width: 34px;
  height: 34px;
  margin-inline: auto;
  border: 3px solid #dbe4f3;
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (hover: hover) {
  .btn-primary:not(:disabled):hover,
  .btn-secondary:not(:disabled):hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
  }

}

@media (max-width: 600px) {
  .background-container {
    background-image:
      url("../assets/images/poster-mobile.jpg"),
      linear-gradient(145deg, #071b4a, #16469d 55%, #0f7490);
  }

  body {
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .container {
    margin-block: auto;
  }

  .registration-card {
    padding: 26px 20px;
    border-radius: 16px;
  }

  .title {
    margin-bottom: 22px;
  }

  .info-row {
    flex-direction: column;
    gap: 3px;
  }

  .info-value {
    text-align: left;
  }
}

@media (max-width: 360px) {
  .registration-card {
    padding: 22px 14px;
    border-radius: 14px;
  }

  .student-info {
    padding: 14px;
  }

  .qr-code-display {
    width: min(100%, 210px);
    padding: 12px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  body {
    align-items: flex-start;
  }

  .registration-card {
    margin-block: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
