:root {
  --bg: #FFFFFF;
  --text: #212226;
  --gold: #E8A92E;
  --gold-dark: #C68F1F;
  --muted: #6F6F78;
  --border: #E5E5E8;
  --danger: #B3261E;
  --success: #1E8A3B;
  --radius: 16px;
  --radius-sm: 10px;
  --touch: 48px;
  --topbar-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #17181B;
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: fixed;
  inset: 0;
  user-select: none;
}

input, textarea {
  user-select: text;
}

#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
}

/* ---- Screen shell: topbar (fixed) + scrollable content + sticky footer ---- */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  background: var(--bg);
}

.screen.active {
  display: flex;
}

@keyframes screenSlideInRight {
  from { opacity: 0; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes screenSlideInLeft {
  from { opacity: 0; transform: translateX(-36px); }
  to   { opacity: 1; transform: translateX(0); }
}

.screen.active.dir-forward {
  animation: screenSlideInRight 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.screen.active.dir-back {
  animation: screenSlideInLeft 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: calc(var(--safe-t) + 6px) calc(16px + var(--safe-r)) 6px calc(8px + var(--safe-l));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}

.icon-back {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.icon-back:active {
  background: #F0F0F0;
  transform: scale(0.9);
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  flex: 1;
}

.step-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.step-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 200ms ease, transform 200ms ease;
}

.step-dots[data-step="1"] .dot:nth-child(1),
.step-dots[data-step="2"] .dot:nth-child(-n+2),
.step-dots[data-step="3"] .dot:nth-child(-n+3) {
  background: var(--gold);
  transform: scale(1.15);
}

.screen-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 20px 20px calc(24px + var(--safe-b)) calc(20px + var(--safe-l));
  padding-right: calc(20px + var(--safe-r));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.screen-footer {
  flex-shrink: 0;
  padding: 14px calc(20px + var(--safe-r)) calc(14px + var(--safe-b)) calc(20px + var(--safe-l));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 5;
}

/* Screens without chrome (welcome / success) */
#screen-welcome, #screen-success {
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  text-align: center;
  overflow: hidden;
}

.welcome-glow {
  position: absolute;
  top: -30%;
  left: 50%;
  width: 140%;
  padding-bottom: 140%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(232, 169, 46, 0.16) 0%, rgba(232, 169, 46, 0) 65%);
  pointer-events: none;
}

.welcome-cta {
  width: 100%;
  max-width: 420px;
}

/* Discreet staff entry point to the admin login — deliberately low-contrast
   so it doesn't compete with the parent-facing Check In flow. */
.admin-entry {
  position: absolute;
  top: calc(14px + var(--safe-t));
  right: calc(14px + var(--safe-r));
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 150ms ease, background 150ms ease, transform 120ms ease;
  z-index: 2;
}

.admin-entry:active {
  opacity: 0.9;
  background: rgba(0, 0, 0, 0.06);
  transform: scale(0.92);
}

/* Welcome intro choreography — logo pops in and jiggles, then heading,
   subtitle and the CTA reveal in sequence. Replayed every time the kiosk
   returns to Welcome (see playWelcomeIntro() in app.js). */
@keyframes logoPopIn {
  0%   { opacity: 0; transform: scale(0.4) rotate(-10deg); }
  55%  { opacity: 1; transform: scale(1.1) rotate(4deg); }
  75%  { transform: scale(0.96) rotate(-2deg); }
  90%  { transform: scale(1.03) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes welcomeFadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ctaPopIn {
  0%   { opacity: 0; transform: scale(0.7) translateY(10px); }
  60%  { opacity: 1; transform: scale(1.05) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

#screen-welcome.welcome-intro .logo {
  animation: logoPopIn 750ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

#screen-welcome.welcome-intro h1 {
  animation: welcomeFadeSlideUp 500ms ease both;
  animation-delay: 380ms;
}

#screen-welcome.welcome-intro .subtitle {
  animation: welcomeFadeSlideUp 500ms ease both;
  animation-delay: 520ms;
}

#screen-welcome.welcome-intro .welcome-cta {
  animation: ctaPopIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 680ms;
}

.screen-header {
  text-align: center;
  margin-bottom: 20px;
}

.screen-header-left {
  text-align: left;
}

.logo {
  display: block;
  max-width: 220px;
  width: 60%;
  margin: 0 auto 16px;
  position: relative;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 8px;
  text-align: center;
}

.screen-header-left h1 {
  text-align: left;
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 12px;
}

p.subtitle {
  color: var(--muted);
  text-align: center;
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.screen-header-left .subtitle {
  text-align: left;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 12px 28px;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  width: 100%;
  transition: transform 100ms ease, box-shadow 150ms ease, background 120ms ease;
}

.btn-primary {
  background: var(--gold);
  color: #212226;
  box-shadow: 0 4px 14px rgba(232, 169, 46, 0.35);
}

.btn-primary:active {
  background: var(--gold-dark);
  transform: scale(0.94);
  box-shadow: 0 2px 6px rgba(232, 169, 46, 0.3);
}

@keyframes btnPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.9); }
  65%  { transform: scale(1.08); }
  85%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.btn-pop {
  animation: btnPop 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Sparkle burst: little hand-drawn shapes (star / circle / squiggle / dash)
   popping outward from a tapped button, echoing the logo's line art. */
.sparkle-container {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 999;
}

.sparkle {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  animation: sparklePop 700ms cubic-bezier(0.2, 0.8, 0.3, 1) var(--delay, 0ms) forwards;
}

@keyframes sparklePop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translate(calc(-50% + var(--dx) * 0.4), calc(-50% + var(--dy) * 0.4)) scale(1.15) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.6) rotate(var(--rot));
  }
}

.btn-primary:disabled {
  background: #F0DBA9;
  color: #9B9B9B;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:active {
  background: #F5F5F5;
  transform: scale(0.97);
}

.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  min-height: var(--touch);
}

.btn-text:active {
  color: var(--text);
}

.btn-big {
  font-size: 1.3rem;
  padding: 20px 32px;
  border-radius: 999px;
}

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-row .btn {
  flex: 1;
}

/* Cards grouping related fields, app-style elevation */
.form-card {
  background: #FCFBF8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 8px;
  margin-bottom: 20px;
}

.form-card h2 {
  margin-top: 0;
}

/* Form elements */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 16px;
}

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

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
textarea {
  width: 100%;
  min-height: var(--touch);
  font-size: 1.05rem;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  color: var(--text);
  background: #FFFFFF;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(232, 169, 46, 0.18);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.field-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 4px;
  display: none;
}

.field-error.show {
  display: block;
}

.form-error-banner {
  background: #FBEAEA;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  display: none;
}

.form-error-banner.show {
  display: block;
}

/* Child cards */
.child-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  position: relative;
  background: #FFFFFF;
}

.child-card-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.remove-child {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  min-height: 40px;
  min-width: 40px;
  cursor: pointer;
  border-radius: 50%;
}

.remove-child:active {
  background: #F0F0F0;
}

/* Tick-box list (returning parents) */
.tick-list {
  margin-top: 16px;
}

.tick-item {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  min-height: var(--touch);
  background: #FFFFFF;
  transition: border-color 120ms ease, background 120ms ease;
}

.tick-item:has(input:checked) {
  border-color: var(--gold);
  background: #FFF9EC;
}

.tick-item input[type="checkbox"] {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  accent-color: var(--gold);
}

.tick-item-name {
  font-weight: 600;
}

.tick-item-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Waiver */
.waiver-clauses {
  max-height: 38vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  background: #FCFBF8;
}

.waiver-clause {
  margin-bottom: 16px;
}

.waiver-clause h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.waiver-clause p {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.agree-row input[type="checkbox"] {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--gold);
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
}

.consent-row input[type="checkbox"] {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--gold);
}

.consent-row a {
  color: var(--gold-dark);
}

/* Signature pad */
.signature-wrap {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #FAFAFA;
  touch-action: none;
}

#signature-canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
}

.signature-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.signature-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Success screen */
.success-icon {
  margin-bottom: 8px;
}

.success-circle {
  stroke: var(--success);
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: successCircle 500ms ease forwards;
}

.success-check {
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: successCheck 320ms ease forwards 450ms;
}

@keyframes successCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes successCheck {
  to { stroke-dashoffset: 0; }
}

.tap-hint {
  text-align: center;
  color: var(--muted);
  margin-top: 24px;
  font-size: 0.95rem;
}

.spacer-grow {
  flex: 1;
}

/* Global loading overlay — shown during any network call so the kiosk never
   looks frozen, whether it's a slow connection, a slow admin login, etc. */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 150ms ease;
}

.loading-overlay.show {
  display: flex;
  opacity: 1;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(232, 169, 46, 0.25);
  border-top-color: var(--gold);
  animation: spin 700ms linear infinite;
}

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

.loading-text {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.35rem;
  }
  .btn-big {
    font-size: 1.15rem;
  }
}
