:root {
  --cream: #FBF7EF;
  --paper: #FFFFFF;
  --green: #008C45;
  --green-deep: #00663A;
  --red: #CD212A;
  --red-deep: #A8191F;
  --ink: #1D2A23;
  --muted: #5B6A61;
  --line: #E8DFCC;
  --flag-white: #E9E3D4;
  --sea: #3E86B5;
  --shadow: 0 1px 2px rgba(29, 42, 35, .05), 0 8px 24px -12px rgba(29, 42, 35, .18);
  --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

.wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* ---------- Hero ---------- */

.hero { text-align: center; }

.flag {
  display: inline-flex;
  width: 48px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(29, 42, 35, .08);
}
.flag span { flex: 1; }
.flag span:nth-child(1) { background: var(--green); }
.flag span:nth-child(2) { background: var(--flag-white); }
.flag span:nth-child(3) { background: var(--red); }

.eyebrow {
  margin: 18px 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--green);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(42px, 11vw, 72px);
  line-height: 1.02;
  letter-spacing: -.01em;
  color: var(--ink);
}
h1 em { font-style: italic; color: var(--red); }

.depart {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.depart time { color: var(--ink); font-weight: 500; }

.local {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Countdown ---------- */

/* A boarding pass: main ticket plus a perforated stub. */
.ticket {
  --notch: 12px;
  display: flex;
  width: 100%;
  /* The notches use a mask, which clips box-shadow, so the card shadow
     and 1px border are reproduced with drop-shadow filters instead. */
  filter:
    drop-shadow(0 0 .6px #D2C5A8)
    drop-shadow(0 1px 1px rgba(29, 42, 35, .05))
    drop-shadow(0 6px 7px rgba(29, 42, 35, .07));
}

.ticket-main, .ticket-stub {
  position: relative;
  overflow: hidden;
  background: var(--paper);
}

/* half-circle notches cut where the stub tears off */
.ticket-main {
  flex: 1;
  min-width: 0;
  padding: 22px 20px 18px;
  border-radius: 20px 0 0 20px;
  -webkit-mask:
    radial-gradient(circle var(--notch) at 100% 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at 100% 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask:
    radial-gradient(circle var(--notch) at 100% 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at 100% 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.ticket-main::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--green) 0 33.3%, var(--flag-white) 33.3% 66.6%, var(--red) 66.6%);
}

.ticket-stub {
  flex: none;
  width: clamp(92px, 26vw, 128px);
  padding: 22px 8px 16px;
  border-radius: 0 20px 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background-image: linear-gradient(var(--line) 50%, transparent 50%);
  background-size: 2px 12px;
  background-repeat: repeat-y;
  background-position: left top;
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at 0 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask:
    radial-gradient(circle var(--notch) at 0 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at 0 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.ticket-stub::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--red);
}

.t-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.t-green { color: var(--green); }

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.t-plane { width: 20px; height: 20px; fill: var(--green); transform: rotate(45deg); }

.t-days { margin-top: 4px; }
.t-days-num {
  display: block;
  font-family: var(--serif);
  font-size: clamp(84px, 26vw, 128px);
  line-height: .95;
  letter-spacing: -.03em;
  color: var(--red);
  font-variant-numeric: lining-nums;
}
.t-days .t-label { margin-top: 2px; color: var(--ink); letter-spacing: .28em; }

.t-route, .t-meta {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.t-meta { margin-top: 10px; padding-top: 10px; justify-content: space-between; }
.t-route b, .t-meta b {
  display: block;
  margin-top: 2px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(17px, 4.8vw, 22px);
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
}
.t-meta b { font-family: var(--sans); font-size: 14px; font-weight: 600; }
.t-right { text-align: right; }
.t-path {
  flex: 1;
  height: 2px;
  margin-bottom: 9px;
  background: radial-gradient(circle, var(--green) 1px, transparent 1.5px) 0 50% / 8px 2px repeat-x;
  position: relative;
}
.t-path::after {
  content: "";
  position: absolute;
  right: -2px; top: 50%;
  width: 7px; height: 7px;
  border-top: 2px solid var(--green);
  border-right: 2px solid var(--green);
  transform: translateY(-50%) rotate(45deg);
}

.t-unit { display: flex; flex-direction: column; align-items: center; }
.t-num {
  font-family: var(--serif);
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1;
  color: var(--green-deep);
  font-variant-numeric: tabular-nums lining-nums;
}
.t-unit .t-label { margin-top: 2px; font-size: 10px; }

.t-barcode {
  width: 70%;
  height: 26px;
  margin-top: 4px;
  opacity: .8;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px,
    var(--ink) 8px 11px, transparent 11px 12px, var(--ink) 12px 13px, transparent 13px 16px);
}

/* ---------- Done state ---------- */

.done { text-align: center; }
.done-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(44px, 12vw, 72px);
  line-height: 1.05;
  color: var(--red);
}
.done-sub { margin: 6px 0 0; color: var(--muted); }

/* ---------- Cards ---------- */

.card {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
}

.card-label {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--green);
}

/* ---------- Phrase ---------- */

.phrase-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.phrase-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.phrase-it {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: clamp(28px, 7.5vw, 36px);
  line-height: 1.15;
  color: var(--ink);
}

.phrase-say {
  margin: 10px 0 0;
  font-size: 17px;
  color: var(--red-deep);
  font-weight: 500;
  letter-spacing: .01em;
}
.say-label {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #FCEBEC;
  color: var(--red-deep);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.phrase-en { margin: 8px 0 0; color: var(--ink); }

.phrase-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.phrase-head .phrase-it { flex: 1; min-width: 0; }

.tip-btn {
  flex: none;
  width: 40px; height: 40px;
  margin-top: 12px;
  display: grid; place-items: center;
  border: 1px solid #CFE6D7;
  border-radius: 50%;
  background: #EEF6F0;
  color: var(--green-deep);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
  -webkit-tap-highlight-color: transparent;
}
.tip-btn svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tip-btn:hover { transform: scale(1.06); }
.tip-btn:active { transform: scale(.94); }
.tip-btn[aria-expanded="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.tip-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* The tip floats over the card, so opening it never changes the card's height. */
.phrase-tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 2;
  padding: 12px 14px;
  border-radius: 14px;
  background: #EEF6F0;
  border: 1px solid #CFE6D7;
  box-shadow: 0 12px 28px -12px rgba(29, 42, 35, .3);
  color: var(--green-deep);
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.97);
  transform-origin: calc(100% - 20px) 0;
  transition: opacity .2s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
}
.phrase-tip::before {
  /* little pointer up to the bulb */
  content: "";
  position: absolute;
  top: -7px;
  right: 14px;
  width: 12px; height: 12px;
  background: inherit;
  border-left: 1px solid #CFE6D7;
  border-top: 1px solid #CFE6D7;
  transform: rotate(45deg);
}
.phrase-tip.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .2s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}
.tip-label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--green);
}

/* Height is set from JS to fit the longest phrase, so the card never jumps. */
.phrase { overflow: hidden; touch-action: pan-y; }
.phrase-body > * {
  transition: opacity .32s ease, transform .4s cubic-bezier(.2, .8, .2, 1);
}
.phrase-body > :nth-child(2) { transition-delay: .05s; }
.phrase-body > :nth-child(3) { transition-delay: .1s; }
.phrase-body > :nth-child(4) { transition-delay: .15s; }
.phrase-body.leave-next > *,
.phrase-body.leave-prev > * {
  opacity: 0;
  transition-duration: .16s;
  transition-delay: 0s;
  transition-timing-function: ease-in;
}
.phrase-body.leave-next > * { transform: translateX(-24px); }
.phrase-body.leave-prev > * { transform: translateX(24px); }
.phrase-body.enter-next > *,
.phrase-body.enter-prev > * { opacity: 0; transition: none; }
.phrase-body.enter-next > * { transform: translateX(28px); }
.phrase-body.enter-prev > * { transform: translateX(-28px); }

.phrase-count { transition: opacity .2s ease; }
.phrase-count.fade { opacity: 0; }

/* words light up as they're spoken */
.phrase-it .w {
  display: inline-block;
  transition: color .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1);
}
.phrase-it.speaking .w { color: #A9B3AD; }
.phrase-it.speaking .w.said { color: var(--ink); }
.phrase-it.speaking .w.now { color: var(--red); transform: translateY(-3px); }
.phrase-it.speaking.no-boundary .w { animation: word-glow 1.6s ease-in-out infinite; color: var(--ink); }
.phrase-it.speaking.no-boundary .w:nth-child(2n) { animation-delay: .15s; }
.phrase-it.speaking.no-boundary .w:nth-child(3n) { animation-delay: .3s; }
@keyframes word-glow {
  0%, 100% { color: var(--ink); }
  50% { color: var(--red); }
}

.speak { min-width: 128px; position: relative; overflow: hidden; }
.speak .eq { display: none; align-items: flex-end; gap: 3px; height: 18px; }
.speak .eq i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: bottom;
  animation: eq .9s ease-in-out infinite;
}
.speak .eq i:nth-child(2) { animation-delay: -.3s; }
.speak .eq i:nth-child(3) { animation-delay: -.6s; }
.speak .eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq {
  0%, 100% { transform: scaleY(.3); }
  50% { transform: scaleY(1); }
}
.speak.is-speaking {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.speak.is-speaking .speak-icon { display: none; }
.speak.is-speaking .eq { display: inline-flex; }
.speak.is-speaking::after {
  /* soft pulse ring */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(0, 140, 69, .45);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, .35); }
  100% { box-shadow: inset 0 0 0 22px rgba(255, 255, 255, 0); }
}

.phrase-actions {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: #D6CAB0; background: #F5EEDF; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .foot-link:focus-visible, .install-close:focus-visible, select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.btn svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.btn.ghost { width: 44px; padding: 0; background: transparent; }
.btn.ghost:hover { background: var(--cream); }
.btn.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn.primary:hover { background: var(--green-deep); border-color: var(--green-deep); }

/* ---------- Install chip + sheet ---------- */

.install-chip {
  display: flex;
  align-items: center;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.chip-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 48px;
  padding: 0 6px 0 8px;
  border: 0;
  background: none;
  border-radius: 999px 0 0 999px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-main img { flex: none; border-radius: 7px; }
.chip-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-main svg, .chip-close svg {
  flex: none; width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.chip-main svg { color: var(--green); }
.chip-close {
  flex: none;
  width: 44px; height: 48px;
  display: grid; place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  border-radius: 0 999px 999px 0;
  color: var(--muted);
  cursor: pointer;
}
.chip-close svg { width: 16px; height: 16px; }
.chip-main:hover, .chip-close:hover { background: var(--cream); }
.chip-main:focus-visible, .chip-close:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

.sheet {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(29, 42, 35, .4);
  overflow: auto;
}
.sheet::backdrop { background: rgba(29, 42, 35, .55); }
.sheet-inner:focus { outline: none; }
.sheet[open] { animation: sheet-in .22s ease-out; }
.sheet-inner { position: relative; padding: 24px 22px 20px; }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 639px) {
  /* bottom sheet on phones */
  .sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }
  .sheet-inner { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
  }
}

.install-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.install-close:hover { background: var(--cream); color: var(--ink); }
.install-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.install-head { display: flex; gap: 14px; align-items: center; padding-right: 36px; }
.install-head img { flex: none; border-radius: 11px; box-shadow: 0 0 0 1px var(--line); }
.install-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.2; }
.install-head p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

.install-steps {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
}
.install-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  font-size: 15px;
  line-height: 1.5;
}
.install-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -1px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #EEF6F0;
  color: var(--green-deep);
  font-size: 13px;
  font-weight: 600;
  display: grid; place-items: center;
}
.install-steps b { font-weight: 600; }
.install-steps .note { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.ico {
  display: inline-block;
  width: 18px; height: 18px;
  vertical-align: -3px;
  margin: 0 2px;
  fill: none; stroke: var(--sea); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.install-device {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.install-device select {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

/* ---------- Scene + footer ---------- */

.scene {
  position: relative;
  width: 100%;
  height: clamp(170px, 24vw, 420px);
  margin-top: 8px;
  line-height: 0;
  /* clip sideways (no horizontal scroll) but let tall shapes rise above the box */
  overflow-x: clip;
  overflow-y: visible;
}
/* On wide screens the art scales to fill the width and its top would be cropped;
   overflow: visible lets the sun and church tower draw above the box instead. */
.scene svg { width: 100%; height: 100%; display: block; overflow: visible; }

.foot {
  position: absolute;
  left: 0; right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.3;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.foot p { margin: 0; font-family: var(--serif); font-style: italic; font-size: 18px; }
.foot-link {
  border: 0;
  background: none;
  padding: 4px 8px;
  color: #fff;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: .9;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

@media (min-width: 640px) {
  .wrap { padding-top: 64px; gap: 32px; }
  .card { padding: 26px 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
