:root {
  --olive: #7a8b6f;
  --olive-dark: #4f6354;
  --terracotta: #b85440;
  --mustard: #d4a437;
  --cream: #f5f1e8;
  --brown: #5a3220;
  --ink: #241813;
  --line: rgba(90, 50, 32, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at top, #e8dcc4 0%, #b8997a 55%, #5a4632 100%);
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.postcard-wrap {
  position: relative;
  width: min(92vw, 390px);
  aspect-ratio: 9 / 14;
  filter: drop-shadow(0 28px 34px rgba(22, 14, 9, 0.45));
}

.flip-stage {
  perspective: 2200px;
}

.flip-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.4, 0, 0.2, 1);
}

.is-show-back .flip-card,
.is-flipping-to-back .flip-card {
  transform: rotateY(180deg);
}

.is-flipping-to-front .flip-card {
  transform: rotateY(360deg);
}

.is-flipping-to-back,
.is-flipping-to-front {
  pointer-events: none;
}

.card-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face-back {
  transform: rotateY(180deg);
}

.postcard {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 24px;
}

.postcard-front {
  background:
    linear-gradient(180deg, rgba(20, 15, 11, 0.02) 0%, rgba(20, 15, 11, 0.08) 100%),
    url("/static/front-card.png?v=cardbg1") center / cover no-repeat,
    linear-gradient(160deg, #8a9b7e 0%, var(--olive) 52%, var(--olive-dark) 100%);
  color: white;
}

.front-title {
  position: absolute;
  top: 28px;
  left: 26px;
  right: 26px;
  z-index: 1;
}

.front-title h1 {
  margin: 0;
  color: white;
  font-size: 64px;
  line-height: 0.95;
  letter-spacing: 0;
}

.front-subtitle {
  position: absolute;
  left: 66px;
  width: 175px;
  bottom: 32%;
  margin: 0;
  transform: rotate(-90deg);
  transform-origin: left bottom;
  font-size: 16px;
  z-index: 1;
}

.photo-placeholder {
  position: absolute;
  right: 30px;
  bottom: 170px;
  width: 168px;
  height: 224px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.42);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.64);
  background: rgba(255, 255, 255, 0.08);
}

.stamp-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(245, 241, 232, 0.97);
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  z-index: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brown);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stamp-panel label,
.field span {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid #cdbd9c;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fffaf0;
}

button,
.admin-actions a,
.submit-band {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  color: white;
  background: var(--brown);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.danger-button {
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 8px 12px;
  color: white;
  background: #8f3b2f;
  font-weight: 800;
}

.attempt-note {
  margin: 10px 0 0;
  color: rgba(36, 24, 19, 0.72);
  font-size: 13px;
}

.error-box {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(117, 31, 18, 0.32);
  border-radius: 10px;
  color: #751f12;
  background: rgba(255, 235, 222, 0.86);
}

.error-box p {
  margin: 0;
}

.error-box p + p {
  margin-top: 4px;
}

.rsvp-form .error-box {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.2;
}

.rsvp-form .error-box p + p {
  margin-top: 2px;
}

.is-shaking {
  animation: shake 0.5s ease both;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.banned-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 36px;
  color: var(--cream);
  text-align: center;
  background: #2a1a14;
}

.banned-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.banned-card p {
  margin: 0;
  color: rgba(245, 241, 232, 0.84);
}

.banned-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 34px;
  font-weight: 800;
}

.postcard-back,
.postcard-thanks {
  padding: 22px;
  color: var(--cream);
  background:
    radial-gradient(circle at 18% 16%, rgba(245, 241, 232, 0.14) 0 2px, transparent 3px),
    radial-gradient(circle at 75% 30%, rgba(245, 241, 232, 0.12) 0 2px, transparent 3px),
    linear-gradient(155deg, #c26049 0%, var(--terracotta) 64%, #8f3b2f 100%);
}

.rsvp-form.postcard-back {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px 22px;
}

.back-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  border-bottom: 3px solid var(--mustard);
  padding-bottom: 12px;
}

.back-header p,
.thanks-header p {
  margin: 0;
  color: #ffe4a1;
  font-weight: 800;
}

.back-header h1,
.thanks-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  text-align: right;
}

.rsvp-form .back-header {
  margin-bottom: 2px;
  padding-bottom: 10px;
}

.rsvp-form .back-header p {
  font-size: 16px;
}

.rsvp-form .back-header h1 {
  font-size: 30px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.rsvp-form .field {
  margin-bottom: 0;
}

.rsvp-form .field span {
  margin-bottom: 5px;
  font-size: 14px;
  line-height: 1.15;
}

.rsvp-form input {
  height: 42px;
  padding: 8px 10px;
}

.person-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  gap: 6px;
}

.stepper button {
  padding: 0;
  min-height: 42px;
  border-radius: 10px;
  color: var(--brown);
  background: var(--mustard);
  font-size: 20px;
}

.stepper input {
  text-align: center;
}

.rsvp-form .stepper {
  grid-template-columns: 36px minmax(0, 1fr) 36px;
}

.rsvp-form .stepper button {
  min-height: 42px;
}

.attend-grid {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.attend-card {
  display: block;
  cursor: pointer;
}

.attend-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.attend-card span {
  display: block;
  padding: 12px 14px;
  border: 1px solid rgba(245, 241, 232, 0.34);
  border-radius: 12px;
  color: var(--cream);
  background: rgba(90, 50, 32, 0.22);
  font-weight: 800;
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
}

.attend-card input:checked + span {
  color: var(--brown);
  background: #f4d276;
  border-color: #f4d276;
}

.attend-card input:focus-visible + span {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

.attending-fields.is-hidden {
  display: none;
}

.meal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}

.rsvp-form .meal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 12px 0 2px;
}

.meal-card {
  display: block;
  cursor: pointer;
}

.meal-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.meal-card span {
  display: block;
  padding: 13px 14px;
  border: 1px solid rgba(245, 241, 232, 0.34);
  border-radius: 12px;
  color: var(--cream);
  background: rgba(90, 50, 32, 0.22);
  font-weight: 800;
}

.rsvp-form .meal-card span {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  text-align: center;
  font-size: 14px;
  line-height: 1.12;
}

.meal-card input:checked + span {
  color: var(--brown);
  background: #f4d276;
  border-color: #f4d276;
}

.lunch-fields {
  display: none;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 4px;
}

.lunch-fields.is-open {
  display: grid;
}

.rsvp-form .lunch-fields {
  margin-top: 0;
}

.rsvp-form .lunch-fields.is-open {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rsvp-form .lunch-fields .field span {
  min-height: 29px;
  display: flex;
  align-items: end;
  font-size: 13px;
}

.rsvp-form .lunch-fields .stepper {
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 4px;
}

.rsvp-form .lunch-fields .stepper button {
  min-height: 38px;
  font-size: 18px;
}

.rsvp-form .lunch-fields input {
  height: 38px;
  padding: 6px 4px;
}

.submit-band {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  color: var(--brown);
  text-align: center;
  background: var(--mustard);
}

.rsvp-form .submit-band {
  min-height: 44px;
  margin-top: 2px;
  padding: 12px;
}

.flip-preview {
  display: flex;
  flex-direction: column;
}

.preview-lines {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.preview-lines span {
  display: block;
  height: 44px;
  border-radius: 10px;
  background: rgba(245, 241, 232, 0.88);
}

.preview-meals {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.preview-meals span {
  display: block;
  padding: 14px;
  border-radius: 12px;
  color: var(--brown);
  background: #f4d276;
  font-weight: 800;
}

.preview-qr span {
  width: 150px;
  height: 150px;
  border-radius: 12px;
  background:
    linear-gradient(90deg, #111 12px, transparent 12px) 0 0 / 30px 30px,
    linear-gradient(#111 12px, transparent 12px) 0 0 / 30px 30px,
    white;
}

.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.postcard-thanks {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.thanks-header {
  border-bottom: 3px solid var(--mustard);
  padding-bottom: 14px;
}

.thanks-header h1 {
  margin-top: 8px;
  text-align: left;
}

.summary-card {
  padding: 14px;
  border-radius: 12px;
  color: var(--ink);
  background: rgba(245, 241, 232, 0.92);
}

.summary-card p {
  margin: 0;
}

.summary-card p + p {
  margin-top: 6px;
}

.qr-band {
  margin: 0 -22px;
  padding: 18px 22px;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--brown);
  text-align: center;
  background: var(--mustard);
  font-weight: 800;
}

.qr-band img {
  width: 168px;
  height: 168px;
  border-radius: 12px;
  background: white;
}

.qr-band p {
  margin: 0;
}

.edit-link {
  display: block;
  overflow-wrap: anywhere;
  padding: 12px;
  border-radius: 10px;
  color: var(--cream);
  background: rgba(90, 50, 32, 0.34);
  font-size: 13px;
}

.text-card {
  position: relative;
}

.text-card p {
  font-size: 18px;
  line-height: 1.5;
}

.admin-shell {
  width: min(1120px, 100%);
  padding: 26px;
  border-radius: 18px;
  background: rgba(245, 241, 232, 0.97);
  box-shadow: 0 28px 34px rgba(22, 14, 9, 0.28);
}

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

.admin-header h1 {
  margin: 0;
  font-size: 34px;
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-totals {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.row-absage {
  color: rgba(36, 24, 19, 0.5);
}

.admin-totals div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.admin-totals strong,
.admin-totals span {
  display: block;
}

.admin-totals strong {
  font-size: 28px;
}

.admin-totals span {
  color: rgba(36, 24, 19, 0.68);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-delete-cell {
  white-space: nowrap;
}

.admin-delete-cell form {
  margin: 0;
}

th {
  color: var(--brown);
  font-size: 13px;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .page-shell {
    padding: 12px;
  }

  .photo-placeholder {
    right: 18px;
    width: 142px;
    height: 190px;
  }

  .admin-shell {
    padding: 18px;
  }

  .admin-header {
    align-items: start;
    flex-direction: column;
  }

  .admin-totals {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flip-card,
  .is-shaking {
    animation: none;
    transition: none;
  }
}
