:root {
  --sky: #2fb0f0;
  --sky-2: #8fd8fb;
  --sky-3: #e6f6ff;
  --forest: #3d4c38;
  --green: #5c9d4c;
  --grass: #7cc242;
  --sun: #f6b324;
  --sun-soft: #fff1c7;
  --lilac: #6a2fb5;
  --coral: #ff7a59;
  --ink: #26311f;
  --muted: #637060;
  --line: #d9e6d3;
  --paper: #ffffff;
  --bg: #eef8fd;
  --radius: 20px;
  --shadow: 0 10px 30px -12px rgba(38, 49, 31, 0.28);
  --font-display: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-2) 0, var(--bg) 420px) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; color: var(--forest); margin: 0; }
h2 { font-size: 30px; font-weight: 800; margin-bottom: 14px; }
h3 { font-size: 21px; font-weight: 700; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px;
  border: 2.5px solid var(--forest); border-radius: 999px;
  background: var(--paper); color: var(--forest);
  font: 700 16px/1 var(--font-body); text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--forest);
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.btn:hover { background: var(--sun-soft); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--forest); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--sun); }
.btn-primary:hover { background: #ffc23d; }
.btn-big { min-height: 56px; font-size: 18px; padding: 14px 28px; width: 100%; }
.btn-danger { border-color: #b23b2a; color: #b23b2a; box-shadow: 0 4px 0 #b23b2a; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; box-shadow: 0 3px 0 var(--forest); border-width: 2px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1 1 auto; }

.card {
  background: var(--paper); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  border: 2px solid rgba(61, 76, 56, .08);
}

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 6px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #fbfdf9;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(47, 176, 240, .18);
}
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: 10px; border-radius: 14px;
  border: 2px solid var(--line); background: #fbfdf9; font-weight: 600; line-height: 1.3;
  transition: all .15s;
}
.choice input:checked + span { border-color: var(--forest); background: var(--sun-soft); box-shadow: inset 0 0 0 1px var(--forest); }
.choice input:focus-visible + span { box-shadow: 0 0 0 4px rgba(47, 176, 240, .3); }
.stepper { display: inline-flex; align-items: center; gap: 4px; border: 2px solid var(--line); border-radius: 999px; padding: 4px; width: max-content; background: #fbfdf9; }
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--sky-3); color: var(--forest); font: 700 22px/1 var(--font-body);
}
.stepper output { min-width: 36px; text-align: center; font-weight: 700; font-size: 18px; }
#going-fields { display: grid; gap: 16px; }
.form-error { color: #b23b2a; font-weight: 600; margin: 0; }

/* ---------- cover / ticket ---------- */
.cover {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-2) 55%, #c9ecff 100%);
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; transition: opacity .3s;
}
.cover.ready { opacity: 1; }
body:not(.opened) { overflow: hidden; }
.cover-inner {
  position: relative; z-index: 2; width: min(420px, 100%);
  padding: max(28px, env(safe-area-inset-top)) 20px 0;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.brand { font: 800 22px/1 var(--font-display); color: var(--lilac); margin: 0; letter-spacing: .3px; }
.brand span { color: var(--lilac); font-weight: 700; }
.cover-to { margin: 0; font-size: 17px; color: var(--forest); }
.cover-to strong { font: 800 30px/1.1 var(--font-display); display: block; text-align: center; }

.ticket {
  width: 100%; display: flex; border-radius: 18px;
  filter: drop-shadow(0 14px 20px rgba(38, 49, 31, .25));
  animation: ticket-in .7s cubic-bezier(.2, .9, .3, 1.2) both .15s;
}
.ticket-main {
  flex: 1; background: var(--paper); padding: 16px 16px 14px;
  border-radius: 18px 0 0 18px;
  -webkit-mask: radial-gradient(circle 10px at 100% 0, transparent 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle 10px at 100% 100%, transparent 98%, #000) bottom/100% 51% no-repeat;
          mask: radial-gradient(circle 10px at 100% 0, transparent 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle 10px at 100% 100%, transparent 98%, #000) bottom/100% 51% no-repeat;
}
.ticket-head { display: flex; justify-content: space-between; font: 800 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: 1.5px; color: var(--green); }
.ticket-no { color: var(--muted); letter-spacing: .5px; }
.route { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 10px; }
.route small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.route b { font: 800 26px/1 var(--font-display); color: var(--forest); text-transform: uppercase; }
.route .right { text-align: right; }
.route-bus { width: 64px; height: 38px; flex: none; animation: bob 1.4s ease-in-out infinite; }
.ticket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding-top: 10px; border-top: 2px dashed var(--line); }
.ticket-grid .wide { grid-column: 1 / -1; }
.ticket-grid .dt { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.ticket-grid .dd { display: block; font-weight: 700; color: var(--forest); font-size: 15px; overflow-wrap: anywhere; }
.ticket-stub {
  width: 64px; flex: none; background: var(--sun); border-radius: 0 18px 18px 0;
  border-left: 3px dashed rgba(61, 76, 56, .45);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px 0;
  -webkit-mask: radial-gradient(circle 10px at 0 0, transparent 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle 10px at 0 100%, transparent 98%, #000) bottom/100% 51% no-repeat;
          mask: radial-gradient(circle 10px at 0 0, transparent 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle 10px at 0 100%, transparent 98%, #000) bottom/100% 51% no-repeat;
  transform-origin: 0 0;
}
.ticket-stub span { writing-mode: vertical-rl; transform: rotate(180deg); font: 800 14px/1 var(--font-display); letter-spacing: 1.5px; text-transform: uppercase; color: var(--forest); }
.barcode { width: 30px; height: 64px; background: repeating-linear-gradient(0deg, var(--forest) 0 2px, transparent 2px 4px, var(--forest) 4px 5px, transparent 5px 8px); border-radius: 2px; }
#open-btn { animation: pulse 2s ease-in-out infinite 1.2s; }
.cover-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.passenger input {
  margin-top: 4px; padding: 8px 12px; border-radius: 10px;
  font: 700 17px var(--font-body); color: var(--forest);
  border: 2px dashed var(--sky); background: var(--sky-3);
}
.passenger input::placeholder { color: #6f9db6; font-weight: 500; }
.cover-hint { margin: 0; font-size: 14px; font-weight: 500; color: var(--forest); text-align: center; }
.cover-hint.error { color: #b23b2a; font-weight: 700; }
.ticket.shake { animation: shake .4s ease; }

.clouds i {
  position: absolute; display: block; background: #fff; border-radius: 999px; opacity: .9;
  width: 140px; height: 36px; animation: drift 38s linear infinite;
}
.clouds i::before, .clouds i::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.clouds i::before { width: 64px; height: 64px; left: 22px; top: -30px; }
.clouds i::after { width: 46px; height: 46px; left: 70px; top: -20px; }
.clouds i:nth-child(1) { top: 9%; left: -20%; }
.clouds i:nth-child(2) { top: 26%; left: 60%; transform: scale(.7); animation-duration: 52s; animation-delay: -20s; }
.clouds i:nth-child(3) { top: 46%; left: 10%; transform: scale(.55); animation-duration: 64s; animation-delay: -40s; opacity: .7; }

.scene { position: absolute; left: 0; right: 0; bottom: 0; height: 30vh; min-height: 150px; z-index: 1; }
.scene svg:first-child { width: 100%; height: 100%; display: block; }
.scene-bus { position: absolute; width: 112px; height: 66px; bottom: 9%; left: 8%; animation: idle .5s ease-in-out infinite alternate; }

.cover.opening .ticket-stub { animation: tear .55s cubic-bezier(.5, 0, .7, .4) forwards; }
.cover.opening .ticket { animation: ticket-out .5s ease-in forwards .35s; }
.cover.opening #open-btn { opacity: 0; transition: opacity .2s; }
.cover.opening .scene-bus { animation: drive-off 1s cubic-bezier(.6, 0, .9, .5) forwards .2s; }
.cover.opening { animation: fade-out .45s ease forwards .85s; }

/* ---------- page ---------- */
.page { width: min(560px, 100%); margin: 0 auto; padding: 16px 16px 110px; }
.hero img { border-radius: var(--radius); box-shadow: var(--shadow); aspect-ratio: 16 / 9; object-fit: cover; width: 100%; height: auto; }
.hero-card { margin-top: -28px; position: relative; margin-inline: 10px; }
.eyebrow { font: 800 15px/1 var(--font-display); color: var(--lilac); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.hero h1 { font-size: 34px; font-weight: 800; margin-bottom: 10px; }
.facts { display: grid; gap: 8px; margin: 14px 0 16px; padding: 12px 14px; background: var(--sky-3); border-radius: 14px; }
.facts div { display: flex; gap: 10px; align-items: center; }
.facts b { color: var(--forest); }
.hero-card .btn { width: 100%; }

.section { margin-top: 44px; }

.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.countdown div {
  background: var(--forest); color: #fff; border-radius: 16px; padding: 14px 4px 10px; text-align: center;
  box-shadow: 0 6px 0 #2b3627;
}
.countdown b { display: block; font: 800 34px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.countdown span { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.countdown-msg { font: 800 22px/1.3 var(--font-display); color: var(--forest); background: var(--sun-soft); padding: 18px; border-radius: 16px; text-align: center; }

.day + .day { margin-top: 22px; }
.day-label {
  display: inline-block; background: var(--forest); color: #fff; font-size: 17px;
  padding: 6px 16px; border-radius: 999px; margin-bottom: 12px;
}
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: var(--sun); border: 2.5px solid var(--forest); }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.timeline b { font-weight: 600; }
.timeline p { margin: 2px 0 0; font-size: 14px; }

.venue-card h3 { margin-bottom: 2px; }
.map { margin-top: 12px; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--sky-3); }
.map iframe { width: 100%; height: 100%; border: 0; display: block; }

.done-title { font: 800 22px/1.3 var(--font-display); color: var(--forest); }
#rsvp-done { border: 2.5px solid var(--green); background: #f4fbef; }

.wall { columns: 2 220px; column-gap: 12px; margin-top: 16px; }
.wish { break-inside: avoid; margin: 0 0 12px; padding: 14px 14px 10px; border-radius: 16px; border: 2px solid rgba(61, 76, 56, .12); }
.wish blockquote { margin: 0 0 8px; white-space: pre-line; overflow-wrap: anywhere; font-size: 15px; }
.wish figcaption { font-size: 13px; color: var(--muted); }
.wish figcaption b { color: var(--forest); }
.tone-sky { background: #e3f5ff; }
.tone-grass { background: #eaf7df; }
.tone-sun { background: var(--sun-soft); }
.tone-lilac { background: #f0e8fb; }
#wall-empty { margin-top: 12px; }


.footer { text-align: center; margin-top: 56px; color: var(--muted); font-size: 14px; }
.footer-bus { width: 90px; height: 52px; margin: 0 auto 6px; display: block; }

.tabbar {
  position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; display: flex; gap: 2px; padding: 6px;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px);
  border: 2px solid var(--forest); border-radius: 999px; box-shadow: var(--shadow);
  width: min(440px, calc(100% - 20px));
}
.tabbar a { flex: 1; text-decoration: none; text-align: center; font-size: 11px; font-weight: 600; color: var(--forest); padding: 4px 0; border-radius: 999px; line-height: 1.2; }
.tabbar a span { display: block; font-size: 18px; line-height: 1.3; }
.tabbar a:active { background: var(--sun-soft); }

.music-toggle {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 30;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  border: 2.5px solid var(--forest); background: var(--paper); color: var(--forest);
  font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 4px 0 var(--forest);
}
.music-toggle.playing { background: var(--sun); }
.music-toggle.playing span { animation: bob 1s ease-in-out infinite; }
.music-toggle:not(.playing)::after {
  content: ""; position: absolute; width: 30px; height: 2.5px; border-radius: 2px;
  background: var(--forest); transform: rotate(-45deg);
}
.credit { font-size: 12px; margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--forest); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600;
  z-index: 80; transition: all .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

@keyframes ticket-in { from { opacity: 0; transform: translateY(30px) rotate(-3deg) scale(.95); } }
@keyframes ticket-out { to { opacity: 0; transform: translateY(-60px) rotate(2deg) scale(.95); } }
@keyframes tear { 40% { transform: rotate(8deg); } to { transform: translate(30px, 260px) rotate(40deg); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes idle { to { transform: translateY(-1.5px); } }
@keyframes drive-off { to { transform: translateX(110vw); } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }
@keyframes pulse { 50% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes drift { to { transform: translateX(140vw); } }
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

@media (min-width: 720px) {
  .page { padding-top: 32px; }
  .hero h1 { font-size: 40px; }
  .invite .page { width: min(1180px, 100%); padding-inline: 28px; }
  #days { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .day { background: var(--paper); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
  .day + .day { margin-top: 0; }
}

/* Desktop: two-column layout instead of one phone-width column. */
@media (min-width: 1024px) {
  .invite .page {
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 32px; align-items: start; padding-top: 40px;
  }
  .invite .page > * { grid-column: 1 / -1; }
  .section { margin-top: 64px; }
  h2 { font-size: 36px; margin-bottom: 18px; }

  .hero { display: grid; grid-template-columns: 7fr 5fr; gap: 32px; align-items: center; }
  .hero-card { margin: 0; padding: 32px; }
  .hero h1 { font-size: 44px; }

  .countdown { gap: 20px; }
  .countdown div { padding: 22px 8px 16px; border-radius: 20px; }
  .countdown b { font-size: 60px; }
  .countdown span { font-size: 14px; }

  .day { padding: 28px; }
  .timeline li { grid-template-columns: 128px 1fr; }
  .timeline time { font-size: 16px; }

  .invite .page > #venue { grid-column: 1 / 6; }
  .invite .page > #rsvp { grid-column: 6 / -1; }
  .venue-card .btn-row { flex-direction: column; }

  #wishes { display: grid; grid-template-columns: 360px minmax(0, 1fr); column-gap: 32px; align-items: start; }
  #wishes h2 { grid-column: 1 / -1; }
  #wish-form { position: sticky; top: 24px; }
  #wall, #wall-empty { grid-column: 2; grid-row: 2; margin-top: 0; }
  .wall { columns: 3 220px; }
}

/* ---------- admin ---------- */
.admin-page { width: min(1100px, 100%); padding-bottom: 48px; }
.login { max-width: 360px; margin: 12vh auto 0; }
.admin-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.admin-header h1 { font-size: 26px; }
.admin-header .btn-row { margin: 0; }
.tabs { display: flex; gap: 6px; margin: 18px 0; overflow-x: auto; padding-bottom: 4px; }
.tabs button { flex: none; border: 2px solid var(--forest); background: var(--paper); color: var(--forest); border-radius: 999px; padding: 8px 16px; font: 600 15px var(--font-body); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--forest); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 24px; }
.stat { background: var(--paper); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font: 800 30px/1.1 var(--font-display); color: var(--forest); }
.stat span { font-size: 13px; color: var(--muted); }
.panel-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.panel-head input { flex: 1 1 220px; max-width: 360px; }
.mt { margin-top: 28px; }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.admin-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.admin-item .btn-row { margin-top: 6px; }
.is-hidden { opacity: .55; }
.qr-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-bottom: 16px; }
.qr-card { text-align: center; }
.qr-card img { margin: 12px auto; width: 220px; height: 220px; image-rendering: pixelated; }
.qr-card p { font-size: 13px; overflow-wrap: anywhere; }

@media print {
  body { background: #fff; }
  .admin-header, .tabs, .no-print, [data-panel]:not([data-panel="qr"]) { display: none !important; }
  [data-panel="qr"] { display: block !important; }
  .card { box-shadow: none; border: 2px solid #ccc; break-inside: avoid; }
}
tr.dupe td { background: var(--sun-soft); }
