:root {
  --bg: #14161a;
  --card-bg: #1e2126;
  --text: #edeceb;
  --text-muted: #96979e;
  --accent: #ef7a5f;
  --accent-dark: #f6926a;
  --border: #2d3037;
  --progress-bg: #2a2d33;
  --success: #5fbb7d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Mobile-first base styles. Most visitors will be on a phone, so this is
   the primary layout; the min-width media query near the bottom only
   adjusts things for the minority on desktop. */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding: 20px 12px 56px;
}

.page-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 24px;
}

.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
  line-height: 1.25;
}

.subheading {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.gift-list {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.status-message {
  text-align: center;
  color: var(--text-muted);
}

.gift-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.2s ease;
}

.gift-card.is-fully-claimed {
  opacity: 0.65;
}

.gift-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}

.gift-body {
  flex: 1;
  min-width: 0;
}

.name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 4px;
}

.gift-name {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.want-badge {
  flex-shrink: 0;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: #f4c95d;
  white-space: nowrap;
}

.gift-description {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.gift-link {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.92rem;
  display: inline-block;
  padding: 4px 0;
}
.gift-link:hover { text-decoration: underline; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--progress-bg);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

.gift-card.is-fully-claimed .progress-fill {
  background: var(--success);
}

.progress-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mine-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--progress-bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.mine-note[hidden] {
  display: none;
}

.mine-text {
  font-size: 0.92rem;
  font-weight: 600;
}

.undo-btn {
  background: transparent;
  color: var(--text-muted);
  text-decoration: underline;
  padding: 4px 6px;
  min-height: auto;
  flex-shrink: 0;
}
.undo-btn:hover {
  background: transparent;
  color: var(--text);
}

.claim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.claim-controls[hidden] {
  display: none;
}

.claim-controls .claim-qty {
  width: 72px;
  flex: 0 0 72px;
}

.claim-btn {
  flex: 1;
}

input[type="text"],
input[type="number"] {
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  /* 16px minimum keeps iOS Safari from auto-zooming the page on focus */
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
  width: 100%;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease;
  min-height: 44px;
}

button:hover { background: var(--accent-dark); }

button:disabled {
  background: #3a3d44;
  color: var(--text-muted);
  cursor: not-allowed;
}

.fully-claimed-message {
  font-weight: 600;
  color: var(--success);
  padding-top: 4px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: #3a3d44;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 10;
  text-align: center;
}

.toast.error {
  background: #7a2f2f;
  color: #fbe4e4;
}

/* Wider screens: switch to a compact side-by-side card layout. This is a
   secondary experience — most visitors are expected to be on mobile. */
@media (min-width: 640px) {
  .page-header h1 {
    font-size: 2rem;
  }

  .gift-card {
    flex-direction: row;
    padding: 16px;
  }

  .gift-image {
    width: 96px;
    height: 96px;
  }

  .claim-controls .claim-qty {
    width: 64px;
    flex: 0 0 64px;
  }

  .claim-btn {
    flex: 0 0 auto;
  }

  input[type="text"],
  input[type="number"],
  button {
    min-height: auto;
  }
}

.confetti-piece {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--size, 8px);
  height: var(--size, 8px);
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  transform: translate(var(--x), var(--y));
  animation: confetti-fall var(--duration, 2200ms) ease-in forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes confetti-fall {
  0% {
    transform: translate(var(--x), var(--y)) rotate(0deg);
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(var(--rot));
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece {
    display: none;
  }
}

.ecard-cta-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

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

.modal {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
  padding-right: 24px;
}

.modal-body p {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.modal-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.modal-body li {
  margin-bottom: 10px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-body code {
  background: var(--progress-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  color: var(--text-muted);
  min-height: auto;
  padding: 4px 8px;
  font-size: 1.3rem;
  line-height: 1;
}
.modal-close:hover {
  background: transparent;
  color: var(--text);
}

.modal-cta {
  display: block;
  text-align: center;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 8px;
  margin-top: 6px;
}
.modal-cta:hover {
  background: var(--accent-dark);
}
