* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 35%, #f4f5f7 100%);
  color: #0f172a;
  min-height: 100vh;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid #e2e8f0;
}

.public-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.public-icon { font-size: 1.6rem; }

.public-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.public-tagline {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.register-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) clamp(16px, 3vw, 32px) 48px;
}

.register-page-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 1.85rem);
  font-weight: 800;
}

.register-subtitle {
  margin: 8px 0 0;
  color: #64748b;
  line-height: 1.55;
  max-width: 72ch;
}

.register-card {
  background: #fff;
  border-radius: 18px;
  padding: clamp(20px, 2.5vw, 32px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  margin-top: 20px;
}

.register-panel {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.register-panel:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.register-panel-head h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.register-panel-head p {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: #64748b;
}

.register-grid {
  display: grid;
  gap: 16px 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.register-field-full { grid-column: 1 / -1; }

.register-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.register-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 0.92rem;
}

.register-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.register-textarea { min-height: 96px; resize: vertical; }

.register-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.register-btn {
  min-width: 200px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
}

.register-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.register-btn-secondary {
  background: #fff;
  color: #4338ca;
  border: 2px solid #c7d2fe;
  margin-top: 8px;
}

.register-btn-secondary:hover:not(:disabled) {
  background: #eef2ff;
}

.register-success-actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.register-house-lookup {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

.register-house-lookup h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.register-house-hint {
  margin: 0 0 14px;
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.45;
}

.register-house-qr {
  display: block;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #fff;
}

.register-house-link {
  color: #4338ca;
  font-weight: 600;
  word-break: break-all;
}

.register-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.hidden { display: none !important; }

.register-success-card, .register-closed-card { text-align: center; }

.register-success-icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%; background: #dcfce7; color: #166534;
  font-size: 1.85rem; font-weight: 800; line-height: 64px;
}

.register-ref-box {
  display: inline-flex; flex-direction: column; gap: 4px;
  padding: 14px 24px; border-radius: 12px;
  background: #f8fafc; border: 1px solid #e2e8f0; margin: 16px 0;
}

.register-ref-value {
  font-size: 1.25rem; font-weight: 800;
  font-family: ui-monospace, Consolas, monospace; color: #1d4ed8;
}

.register-loading { text-align: center; color: #64748b; padding: 40px; }

.public-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
}

.pricing-banner {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
}

.registration-type-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.registration-type-option {
  display: block;
  cursor: pointer;
}

.registration-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.registration-type-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #fff;
  min-height: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.registration-type-option input:checked + .registration-type-card {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.registration-type-card strong {
  font-size: 0.98rem;
}

.registration-type-card span:last-child {
  font-size: 0.85rem;
  color: #64748b;
}

.register-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
}

.register-checkbox-label input {
  margin-top: 3px;
}

.photo-upload-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.photo-instructions {
  margin: 0;
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.45;
}

.photo-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.photo-choice-btn {
  flex: 1 1 140px;
  max-width: 220px;
  text-align: center;
}

.photo-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}

.photo-preview-wrap {
  width: 140px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.photo-preview-wrap img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 35 / 45;
  object-fit: cover;
}

.photo-retake-btn {
  display: block;
  width: 100%;
  padding: 8px;
  border: none;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #4338ca;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.photo-retake-btn:hover {
  background: #eef2ff;
}

.photo-camera-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.65);
}

.photo-camera-modal.hidden {
  display: none;
}

.photo-camera-dialog {
  width: min(100%, 400px);
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.photo-camera-dialog h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  text-align: center;
}

.photo-camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 35 / 45;
  max-height: min(62vh, 480px);
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
}

.photo-camera-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.photo-face-guide {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 52%;
  height: 62%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45);
  pointer-events: none;
  z-index: 2;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.photo-face-guide.is-ready {
  border-color: #4ade80;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35);
}

.photo-camera-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  margin: 0;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.85));
}

.photo-camera-hint.is-good {
  color: #bbf7d0;
}

.photo-camera-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.photo-camera-actions .register-btn,
.photo-camera-actions .register-btn-secondary {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.rules-agreement-dialog {
  width: min(100%, 520px);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.rules-agreement-dialog h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.rules-agreement-intro {
  margin: 0 0 12px;
  color: #475569;
  font-size: 0.95rem;
}

.rules-agreement-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.95rem;
  max-height: 40vh;
}

.rules-agreement-sign label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.rules-agreement-sign .register-input {
  width: 100%;
  box-sizing: border-box;
}

.rules-signature-readonly {
  background: #f8fafc;
  color: #0f172a;
  cursor: default;
  user-select: none;
}

.register-field-error {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 0.9rem;
}

.rules-agreement-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.rules-agreement-actions .register-btn,
.rules-agreement-actions .register-btn-secondary {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
