* {
  box-sizing: border-box;
}

/* Anything marked hidden stays hidden, even if a style below sets display */
[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 24px 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f8;
  color: #1f2933;
}

/* ---------- Header ---------- */

.page-header {
  max-width: 720px;
  margin: 0 auto 24px;
  text-align: center;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: #1c3d8f;
}

.banner {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ---------- Centred single column ---------- */

.layout {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  width: 100%;
  padding: 28px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.card > h2 {
  margin: 0 0 4px;
  color: #d9480f;
  text-align: center;
}

.form-card > .note {
  text-align: center;
}

/* Phones: a little less padding so the form has more room */
@media (max-width: 600px) {
  body {
    padding: 16px 12px;
  }
  .card {
    padding: 18px 14px;
  }
  fieldset {
    padding: 12px;
  }
}

/* ---------- Form ---------- */

.note {
  font-size: 0.85rem;
  color: #7b8794;
}

fieldset {
  border: 1px solid #e4e7eb;
  border-radius: 8px;
  padding: 16px;
  margin: 0 0 16px;
  min-width: 0;
}

legend {
  padding: 0 6px;
  font-weight: 600;
  color: #d9480f;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.row .field {
  flex: 1 1 220px;
  min-width: 0;
}

.field {
  margin-bottom: 12px;
}

.field > label,
.label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px;
  font: inherit;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  background: #ffffff;
  min-width: 0;
  max-width: 100%;
  display: block;
}

/* iPhone Safari draws date boxes wider than the screen unless told not to */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
  text-align: left;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #ffa94d;
  border-color: #ffa94d;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 0;
}

.choices label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.terms {
  text-align: center;
}

.terms .terms-label {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.terms input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
}

.terms a {
  color: #1c3d8f;
}

.invalid input,
.invalid select,
.invalid textarea {
  border-color: #e03131;
}

.error-text {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #e03131;
}

.form-error {
  padding: 10px;
  border-radius: 6px;
  background: #fff5f5;
  color: #c92a2a;
  text-align: center;
}

button {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: #d9480f;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  background: #c2410c;
}

button:disabled {
  background: #adb5bd;
  cursor: wait;
}

button.secondary {
  color: #1f2933;
  background: #e4e7eb;
}

button.secondary:hover {
  background: #cbd2d9;
}

/* ---------- Success message ---------- */

.success {
  text-align: center;
}

.success h2 {
  color: #2f9e44;
}

.reg-id {
  font-family: Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  padding: 10px;
  background: #f1f3f5;
  border-radius: 6px;
  word-break: break-all;
}

/* ---------- Checking status / Bib No on success ---------- */

.checking {
  padding: 40px 0;
  text-align: center;
  color: #7b8794;
}

.success-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.success-numbers > div {
  flex: 1 1 160px;
}

.success-numbers p {
  margin: 6px 0;
}

/* ---------- Registration closed message ---------- */

.closed {
  text-align: center;
  padding: 24px 0;
}

.closed h2 {
  color: #c92a2a;
}

/* ---------- Footer ---------- */

.page-footer {
  max-width: 720px;
  margin: 32px auto 0;
  padding: 24px 16px;
  text-align: center;
  color: #ffffff;
  background: #2f9e44;
  border-radius: 12px;
}

.page-footer p {
  margin: 6px 0;
}

.page-footer .support {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.95rem;
}

.page-footer a {
  color: #ffffff;
  font-weight: 600;
  word-break: break-all;
}

.tagline {
  font-size: 1.2rem;
  font-weight: 700;
}

/* ---------- Terms and Conditions (shown below the checkbox) ---------- */

.terms-panel {
  margin-top: 12px;
  text-align: left;
  border: 1px solid #cbd2d9;
  border-radius: 8px;
  background: #f8f9fa;
}

.terms-text {
  max-height: 320px;
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.terms-text h3 {
  margin: 0 0 8px;
  text-align: center;
  color: #d9480f;
}

.terms-text h4 {
  margin: 14px 0 4px;
  color: #1c3d8f;
}

.terms-text ul {
  margin: 0;
  padding-left: 20px;
}

.terms-actions {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #cbd2d9;
}
