:root {
  --green: #1f7a5a;
  --green-dark: #155c43;
  --green-soft: #e7f4ee;
  --ink: #1c2b24;
  --muted: #6b7d74;
  --line: #dce7e1;
  --bg: #f4f8f5;
  --white: #ffffff;
  --danger: #c0392b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(20, 60, 45, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 50% -8%, #d8efe4 0%, transparent 60%),
    var(--bg);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px calc(10px + env(safe-area-inset-top));
  padding-top: max(14px, env(safe-area-inset-top));
}
.event-label {
  text-align: center;
  line-height: 1.1;
  flex: 1;
  min-width: 0;
}
.event-label span {
  font-weight: 700;
  color: var(--green-dark);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-label small { color: var(--muted); font-size: 12px; }

.icon-btn {
  border: none;
  background: var(--white);
  width: 40px; height: 40px;
  border-radius: 12px;
  font-size: 18px;
  box-shadow: var(--shadow);
}

.lang-toggle {
  display: inline-flex;
  background: var(--white);
  border-radius: 12px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 9px;
}
.lang-btn.active { background: var(--green); color: #fff; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
}

.card-head { text-align: center; margin-bottom: 16px; }
.deco { color: #cfa94a; letter-spacing: 6px; font-size: 12px; margin-bottom: 6px; }
.card-head h1 { margin: 0; font-size: 24px; color: var(--green-dark); }
.event-hero { margin: 10px 0 2px; font-size: 21px; font-weight: 800; color: var(--ink); line-height: 1.15; }
.event-hero.muted { color: var(--muted); font-weight: 600; }
.event-date-hero { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Form ---------- */
form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 13px; font-weight: 600; color: var(--ink); }
.req { color: var(--danger); }

input, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px; /* evita zoom en iOS */
  background: #fbfdfc;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px #f7e2df; }
textarea { resize: none; }

/* ---------- Selfie ---------- */
.selfie-area { }
.selfie-empty {
  width: 100%;
  min-height: 150px;
  border: 2px dashed var(--green);
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.cam-icon { font-size: 38px; }

.cam-live { position: relative; border-radius: 14px; overflow: hidden; background: #000; }
.cam-live video {
  width: 100%;
  display: block;
  max-height: 60vh;
  object-fit: cover;
  transform: scaleX(-1); /* espejo, selfie natural */
}
.cam-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
}
.shutter {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}
.shutter:active { transform: scale(.94); }

.shot { position: relative; }
.shot img { width: 100%; border-radius: 14px; display: block; transform: scaleX(-1); }
.ghost-btn {
  border: none;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.ghost-btn.small {
  position: absolute;
  bottom: 10px; right: 10px;
  box-shadow: var(--shadow);
}

/* ---------- Submit ---------- */
.submit {
  border: none;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  padding: 15px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(31,122,90,.3);
  margin-top: 4px;
}
.submit:active { transform: translateY(1px); }
.submit:disabled { opacity: .6; }
.submit.outline { background: #fff; color: var(--green-dark); border: 2px solid var(--green); box-shadow: none; }

/* ---------- Success ---------- */
.success { text-align: center; padding: 40px 22px; }
.success-emoji { font-size: 60px; }
.success h2 { color: var(--green-dark); margin: 8px 0; }
.success p { color: var(--muted); margin: 0 0 22px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(20,40,32,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; z-index: 40;
}
.modal-card {
  background: #fff; border-radius: var(--radius);
  padding: 22px 18px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-card h3 { margin: 0; color: var(--green-dark); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .submit { flex: 1; margin: 0; }
.modal-actions .ghost-btn { background: var(--green-soft); color: var(--green-dark); }
.card-link { text-align: center; margin: 4px 0 0; }
.card-link a { color: var(--green); font-weight: 600; text-decoration: none; font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; z-index: 50;
  box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
.toast.err { background: var(--danger); }

[hidden] { display: none !important; }
