:root {
  --blue-top: #2f63ef;
  --blue-bottom: #2c56ec;
  --screen-bg: #f1f1f3;
  --panel-bg: #ecebed;
  --white: #ffffff;
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.72);
  --status-text: #7f7f88;
  --note-bg: #f2dde1;
  --note-text: #db6e73;
  --header-shadow: 0 10px 24px rgba(37, 74, 182, 0.18);
  --phone-shadow: 0 24px 60px rgba(29, 41, 82, 0.14);
  --font-ui: "Montserrat", "Segoe UI", sans-serif;
  --font-weight-semi-bold: 550;
  --font-weight-bold: 700;
  --font-size-booking-title: 1.5rem;
  --font-size-status-strip: 0.7rem;
  --font-size-countdown: 12cqw;
  --font-size-booked-on-display: 7.5cqw;
  --font-size-distance: 3cqw;
  --font-size-ticket-type: 3.2cqw;
  --font-size-card-default: 3.7cqw;
  --booked-on-display-width: 62%;
  --countdown-width: 36%;
  --countdown-seconds-width: 2.75ch;
  --countdown-window-height: 1.2em;
  --color-distance-text: #474c53;

  /* Ajusta aqui las coordenadas de cada texto sobre la tarjeta.
     En los campos del bloque `Right align`, la `x` se mide desde la derecha. */
  /* Left align */
  --ticket-type-x: 2.5%;
  --ticket-type-y: 70.5%;
  --origin-station-x: 2.5%;
  --origin-station-y: 46.6%;
  --valid-from-x: 2.5%;
  --valid-from-y: 66%;
  --name-x: 2.5%;
  --name-y: 84.5%;
  --id-type-x: 2.5%;
  --id-type-y: 93%;
  /* Center align */
  --countdown-y: 9%;
  --distance-y: 46.7%;
  --booked-on-display-y: 22.8%;
  /* Right align */
  --destination-station-x: 2.5%;
  --destination-station-y: 46.6%;
  --season-ticket-x: 2.5%;
  --season-ticket-y: 40%;
  --booked-on-x: 2.5%;
  --booked-on-y: 55.5%;
  --valid-till-x: 3%;
  --valid-till-y: 66%;
  --age-x: 2.5%;
  --age-y: 84.5%;
  --id-number-x: 2.5%;
  --id-number-y: 93%;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: -webkit-fill-available;
  margin: 0;
  min-height: 100%;
}

body {
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: var(--font-ui);
  background-color: var(--blue-bottom);
  background:
    radial-gradient(circle at top left, rgba(89, 132, 255, 0.24), transparent 30%),
    linear-gradient(180deg, #e6ebff 0%, #f6f7fb 48%, #ececef 100%);
  color: #1d1d1f;
}

.app-shell {
  height: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: -webkit-fill-available;
  width: 100%;
  overflow: hidden;
}

.phone-screen {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: -webkit-fill-available;
  background: var(--screen-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hero {
  min-height: calc(70px + env(safe-area-inset-top));
  padding: calc(0px + env(safe-area-inset-top)) 14px 14px 14px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--blue-top) 0%, var(--blue-bottom) 100%);
  box-shadow: var(--header-shadow);
}

.icon-button,
.share-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: transparent;
  color: inherit;
}

.share-button {
  color: #ffffff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.icon-button svg,
.share-button svg {
  width: 18px;
  height: 18px;
}

.icon-button svg {
  fill: currentColor;
}

.share-button svg {
  display: block;
  fill: #ffffff;
  overflow: visible;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eyebrow,
.subline {
  margin: 0;
}

.eyebrow {
  font-size: var(--font-size-booking-title);
  line-height: 1;
  font-weight: var(--font-weight-semi-bold);
  letter-spacing: -0.03em;
}

.subline {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.status-strip {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--status-text);
  font-size: var(--font-size-status-strip);
  letter-spacing: -0.02em;
}

.content-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

.ticket-panel {
  flex: 1;
  position: relative;
  background: #ecebed;
  padding: 12px 14px calc(72px + env(safe-area-inset-bottom));
}

.ticket-card-wrap {
  width: 100%;
  position: relative;
  container-type: inline-size;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.ticket-card {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 12px;
}

.ticket-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-field {
  position: absolute;
  display: block;
  max-width: 34%;
  color: #232a36;
  font-size: var(--font-size-card-default);
  font-weight: var(--font-weight-semi-bold);
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.field-countdown,
.field-distance,
.field-booked-on-display {
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.field-countdown {
  top: var(--countdown-y);
  width: var(--countdown-width);
  max-width: var(--countdown-width);
  color: #d33535;
  font-size: var(--font-size-countdown);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
  overflow: hidden;
}

.countdown-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.08em;
  width: 100%;
}

.countdown-minutes,
.countdown-separator {
  flex: 0 0 auto;
}

.countdown-window {
  position: relative;
  display: block;
  width: var(--countdown-seconds-width);
  height: var(--countdown-window-height);
  overflow: hidden;
}

.countdown-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.countdown-current {
  transform: translateY(0);
}

.countdown-next {
  transform: translateY(-100%);
}

.field-countdown.is-animating .countdown-current {
  transition: transform 320ms linear, opacity 320ms linear;
  transform: translateY(100%);
  opacity: 0.2;
}

.field-countdown.is-animating .countdown-next {
  transition: transform 320ms linear, opacity 320ms linear;
  transform: translateY(0);
}

.field-origin-station {
  top: var(--origin-station-y);
  left: var(--origin-station-x);
  max-width: 44%;
}

.field-ticket-type {
  top: var(--ticket-type-y);
  left: var(--ticket-type-x);
  max-width: 72%;
  font-size: var(--font-size-ticket-type);
  font-weight: 400;
}

.field-destination-station {
  top: var(--destination-station-y);
  right: var(--destination-station-x);
  max-width: 44%;
  text-align: right;
}

.field-distance {
  top: var(--distance-y);
  max-width: 24%;
  color: var(--color-distance-text);
  font-size: var(--font-size-distance);
  font-weight: 400;
}

.field-booked-on-display {
  top: var(--booked-on-display-y);
  min-width: var(--booked-on-display-width);
  width: max-content;
  max-width: none;
  color: #d8881f;
  font-size: var(--font-size-booked-on-display);
  font-weight: var(--font-weight-semi-bold);
  white-space: nowrap;
}

.field-season-ticket {
  top: var(--season-ticket-y);
  right: var(--season-ticket-x);
  max-width: 28%;
  font-weight: var(--font-weight-bold);
  text-align: right;
}

.field-booked-on {
  top: var(--booked-on-y);
  right: var(--booked-on-x);
  max-width: 34%;
  text-align: right;
}

.field-valid-from {
  top: var(--valid-from-y);
  left: var(--valid-from-x);
}

.field-valid-till {
  top: var(--valid-till-y);
  right: var(--valid-till-x);
  text-align: right;
}

.field-name {
  top: var(--name-y);
  left: var(--name-x);
  max-width: 52%;
}

.field-age {
  top: var(--age-y);
  right: var(--age-x);
  max-width: 10%;
  text-align: right;
}

.field-id-type {
  top: var(--id-type-y);
  left: var(--id-type-x);
  max-width: 24%;
}

.field-id-number {
  top: var(--id-number-y);
  right: var(--id-number-x);
  max-width: 42%;
  text-align: right;
}

.warning-note {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  padding: 8px 18px;
  border-radius: 16px;
  background: var(--note-bg);
  color: var(--note-text);
  font-size: 0.8rem;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 8px 20px rgba(209, 123, 132, 0.12);
}

.editor-open {
  overflow: hidden;
}

.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.editor-modal[hidden] {
  display: none;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 42, 0.45);
  backdrop-filter: blur(2px);
}

.editor-panel {
  position: relative;
  width: min(100%, 520px);
  max-height: min(84vh, 760px);
  overflow: auto;
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 60px rgba(22, 30, 59, 0.22);
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.editor-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: var(--font-weight-bold);
  color: #18213a;
}

.editor-close {
  border: 0;
  background: transparent;
  color: #50607d;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-label {
  font-size: 0.84rem;
  font-weight: var(--font-weight-semi-bold);
  color: #5a6781;
}

.editor-input {
  width: 100%;
  border: 1px solid #d7ddea;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: #1a2338;
  background: #f9fbff;
}

.editor-input:focus {
  outline: 2px solid rgba(44, 86, 236, 0.18);
  border-color: #6688f4;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.editor-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: var(--font-weight-semi-bold);
  cursor: pointer;
}

.editor-button-secondary {
  background: #eef2fb;
  color: #394662;
}

.editor-button-primary {
  background: #2c56ec;
  color: #ffffff;
}

@media (max-width: 420px) {
  .phone-screen {
    width: 100%;
    min-height: 100vh;
  }

  .eyebrow {
    font-size: 1.55rem;
  }

  .status-strip {
    font-size: 0.88rem;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .warning-note {
    font-size: 0.73rem;
    bottom: 14px;
  }
}
