/* Movie Match brand, applied with restraint.
   Warm cream and soft neutrals carry the UI; Deep Plum handles text,
   outlines, and primary elements. The Crayon Curves palette (Sunny
   Yellow, Vibrant Orange, Sky Blue, Fresh Green) appears only as small
   splashes: the mascot, rank badges, selected states, and tiny
   highlights. The movie posters bring the colour; the UI stays quiet.
   Averia Libre display type and the wobbly hand-drawn mascot keep it
   friendly. */
:root {
  --cream: #fff7ea;
  --paper: #fffdf6;
  --ink: #3d2c4e;          /* Deep Plum */
  --muted: #7d6c8c;
  --orange: #f95d3b;       /* Vibrant Orange */
  --orange-dark: #d63f24;
  --sunny: #ffc531;        /* Sunny Yellow */
  --sunny-soft: #ffeec2;
  --sky: #7fa8c9;          /* Sky Blue, muted and dusty */
  --sky-soft: #e6eff7;
  --leaf: #5fb760;         /* Fresh Green */
  --leaf-soft: #e7f6e7;
  --pink: #ff9fb2;
  --neutral: #f3ecdd;   /* soft neutral for quiet fills */
  --radius: 22px;
  --wobble: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --wobble-alt: 18px 240px 20px 230px / 230px 20px 240px 18px;
  --shadow: 4px 5px 0 rgba(61, 44, 78, 0.85);
  --shadow-soft: 3px 4px 0 rgba(61, 44, 78, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(340px 200px at 8% 0%, rgba(255, 201, 60, 0.16), transparent 70%),
    var(--cream);
  color: var(--ink);
  font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  padding-bottom: 100px;
}
h1, h2, h3, .display {
  font-family: "Averia Libre", "Fredoka", "Nunito", system-ui, sans-serif;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}
p { line-height: 1.5; }
.hidden { display: none !important; }
.error { color: var(--orange-dark); font-weight: 700; }
.ok { color: #1e7d4f; font-weight: 700; }
.fineprint { color: var(--muted); font-size: 0.85rem; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* Wobbly squiggle divider, used under titles */
.squiggle {
  height: 10px; margin: 2px 0 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='10' viewBox='0 0 60 10'%3E%3Cpath d='M2 6 Q 10 1, 18 6 T 34 6 T 50 6 T 58 6' fill='none' stroke='%233d2c4e' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 60px 10px;
  opacity: 0.4;
}

/* Header */
.topbar {
  max-width: 560px; margin: 0 auto; padding: 16px 16px 4px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.9rem; margin: 0; color: var(--ink); transform: rotate(-1.2deg); }
.brand h1 .match-word { color: var(--sunny); text-shadow: 2px 2px 0 var(--ink); }
.scribble-underline {
  height: 9px; margin-top: 1px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='9' viewBox='0 0 60 9'%3E%3Cpath d='M2 5 Q 10 1, 18 5 T 34 5 T 50 5 T 58 5' fill='none' stroke='%233d2c4e' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-x; background-size: 60px 9px;
}
.tagline { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; }
.brand-mascot .mascot { width: 46px; height: 50px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* Mascot animation (SVG lives in index.html template) */
.mascot { display: block; animation: mascot-bob 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot-eye { animation: mascot-blink 4.6s infinite; transform-origin: center; transform-box: fill-box; }
.mascot-arm-l { animation: mascot-wave-l 3.2s ease-in-out infinite; transform-origin: 30px 80px; }
.mascot-arm-r { animation: mascot-wave-r 3.2s ease-in-out infinite; transform-origin: 90px 80px; }
@keyframes mascot-bob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-5px) rotate(1.5deg); } }
@keyframes mascot-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.08); } }
@keyframes mascot-wave-l { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-10deg); } }
@keyframes mascot-wave-r { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(10deg); } }
.celebrate-mascot .mascot { width: 120px; height: 130px; margin: 0 auto; animation: mascot-celebrate 0.7s ease-in-out infinite; }
@keyframes mascot-celebrate { 0%, 100% { transform: translateY(0) rotate(-5deg) scale(1); } 50% { transform: translateY(-14px) rotate(5deg) scale(1.07); } }

.mascot-bar {
  display: flex; gap: 12px; align-items: center;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  padding: 10px 16px; margin: 12px 0 18px;
  box-shadow: var(--shadow-soft);
  transform: rotate(-0.4deg);
}
.mascot-bar-art .mascot { width: 54px; height: 59px; flex: none; }
.mascot-says { margin: 0; font-size: 1rem; font-weight: 600; }

/* Panels and forms */
.card.panel {
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--wobble);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.panel:nth-of-type(even) { border-radius: var(--wobble-alt); }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; font-weight: 700; color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"] {
  background: #fff; border: 2.5px solid var(--ink); color: var(--ink);
  border-radius: 14px 4px 14px 4px / 4px 14px 4px 14px; padding: 12px; font-size: 1rem; font-family: inherit;
}
input:focus { outline: 3px solid var(--sunny); outline-offset: 1px; }
.btn {
  border: 3px solid var(--ink); border-radius: 999px 60px 999px 60px / 60px 999px 60px 999px;
  padding: 12px 22px; font-size: 1rem; cursor: pointer; font-weight: 800;
  font-family: "Averia Libre", "Nunito", sans-serif;
  box-shadow: var(--shadow-soft); transition: transform 0.08s ease, background 0.2s;
}
.btn:active { transform: translate(2px, 3px) scale(0.98); box-shadow: 1px 1px 0 rgba(61,44,78,0.9); }
.btn-primary { background: var(--ink); color: var(--cream); }
.btn-primary:hover { background: #2c1e3d; }
.btn-secondary { background: var(--paper); color: var(--ink); }
.btn-ghost { background: var(--paper); color: var(--ink); box-shadow: none; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; }
.seg { display: flex; background: var(--neutral); border: 2.5px solid var(--ink); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg-btn { flex: 1; border: none; background: transparent; color: var(--ink); padding: 10px; border-radius: 999px; font-size: 1rem; cursor: pointer; font-family: "Averia Libre", sans-serif; font-weight: 600; }
.seg-btn.active { background: var(--ink); color: var(--cream); font-weight: 800; }

/* Couple setup */
.couple-options { display: grid; gap: 16px; }
.couple-option { background: var(--paper); border: 2.5px dashed var(--ink); border-radius: var(--wobble-alt); padding: 16px; }
.invite-result { margin-top: 12px; }
.invite-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.7rem; font-weight: 700; letter-spacing: 0.12em;
  color: var(--ink); background: var(--neutral); border: 3px dashed var(--ink);
  border-radius: var(--wobble); padding: 10px 14px; text-align: center; margin: 8px 0;
}
.invite-code.small { font-size: 1.05rem; padding: 4px 12px; display: inline-block; }

/* Swipe deck */
.card-stack { position: relative; min-height: 570px; }
.swipe-card {
  position: absolute; inset: 0; background: var(--paper); border: 3px solid var(--ink);
  border-radius: 26px 8px 26px 8px / 8px 26px 8px 26px;
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; touch-action: pan-y; user-select: none;
}
.swipe-card.behind { transform: scale(0.96) translateY(10px) rotate(1deg); opacity: 0.65; pointer-events: none; }
.swipe-card.dragging { transition: none; }
.swipe-card:not(.dragging) { transition: transform 0.25s ease, opacity 0.25s ease; }
.poster-wrap { position: relative; height: 295px; flex: none; background: var(--neutral); border-bottom: 3px solid var(--ink); }
.poster-wrap img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.poster-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; text-align: center; padding: 20px;
  background: var(--neutral);
}
.poster-fallback .pf-title { font-family: "Averia Libre", sans-serif; font-weight: 800; font-size: 1.8rem; color: var(--ink); transform: rotate(-1.5deg); }
.poster-fallback .pf-year { color: var(--orange-dark); font-weight: 800; }
.stamp {
  position: absolute; top: 16px; font-weight: 800; font-size: 1.25rem; letter-spacing: 0.06em;
  padding: 6px 14px; border-radius: 12px 4px 12px 4px; border: 3.5px solid; opacity: 0; pointer-events: none;
  font-family: "Averia Libre", sans-serif; background: rgba(255, 253, 247, 0.9);
}
.stamp.yes { right: 16px; color: #1e7d4f; border-color: #1e7d4f; transform: rotate(8deg); }
.stamp.no { left: 16px; color: var(--orange); border-color: var(--orange); transform: rotate(-8deg); }
.card-body { padding: 16px 18px 18px; overflow-y: auto; }
.card-body h2 { font-size: 1.5rem; margin-bottom: 2px; }
.meta { color: var(--muted); font-weight: 700; font-size: 0.9rem; margin: 0 0 8px; }
.synopsis { margin: 0 0 12px; font-size: 0.98rem; }
.why-note {
  background: var(--neutral); border: 2.5px dashed var(--ink);
  padding: 8px 12px; border-radius: var(--wobble); font-size: 0.9rem; font-weight: 600; margin-bottom: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  background: #fff; color: var(--ink); border: 2px solid var(--ink);
  padding: 3px 10px; border-radius: 999px 40px 999px 40px / 40px 999px 40px 999px; font-size: 0.78rem; font-weight: 700;
}
.chip.service { background: var(--neutral); }
.trailer-box { margin-top: 4px; }
.trailer-frame { position: relative; padding-top: 56.25%; border-radius: 14px; overflow: hidden; background: #000; border: 2.5px solid var(--ink); }
.trailer-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* The four interest rating buttons: the deck's primary control */
.rating-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 6px; }
.rate-btn {
  font-family: "Averia Libre", "Nunito", sans-serif; font-weight: 700; font-size: 1rem;
  padding: 13px 4px; border: 3px solid var(--ink); border-radius: var(--wobble);
  cursor: pointer; box-shadow: var(--shadow-soft); color: var(--ink);
  transition: transform 0.1s ease;
}
.rate-btn:active { transform: scale(0.94) rotate(-1deg); }
.rate-0 { background: var(--paper); }
.rate-1 { background: var(--paper); }
.rate-2 { background: var(--sunny-soft); }
.rate-3 { background: var(--orange); color: #fff; }
.ratings-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip.tier-top { background: var(--sunny); }
.chip.tier-strong { background: var(--leaf); color: #fff; }
.chip.tier-match { background: var(--sky); color: #fff; }
.pi-tier { display: block; font-size: 0.72rem; font-weight: 800; color: var(--muted); margin-top: 2px; }
.hint { text-align: center; color: var(--muted); font-weight: 600; font-size: 0.85rem; margin: 4px 12px 0; }

/* Lists (matches, leaderboard) */
.panel-title { font-size: 1.5rem; margin-top: 4px; }
.panel-sub { color: var(--muted); font-weight: 600; margin-top: 0; }
.movie-list { display: flex; flex-direction: column; gap: 10px; }
.movie-row {
  display: flex; gap: 12px; background: var(--paper); border: 2.5px solid var(--ink);
  border-radius: var(--wobble); padding: 10px; align-items: center; box-shadow: 2px 3px 0 rgba(61,44,78,0.4);
}
.movie-row:nth-child(odd) { transform: rotate(-0.3deg); }
.movie-row:nth-child(even) { transform: rotate(0.3deg); border-radius: var(--wobble-alt); }
.movie-row img, .movie-row .row-fallback {
  width: 54px; height: 78px; object-fit: cover; border-radius: 10px 4px 10px 4px; flex: none;
  background: var(--sunny-soft); border: 2px solid var(--ink);
}
.row-fallback { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.movie-row h3 { margin: 0 0 2px; font-size: 1.05rem; }
.movie-row p { margin: 0; color: var(--muted); font-weight: 600; font-size: 0.83rem; }
.rank-badge {
  flex: none; width: 40px; height: 40px; border-radius: 50% 46% 52% 48% / 48% 52% 46% 54%;
  background: var(--sunny); border: 2.5px solid var(--ink);
  color: var(--ink); font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-family: "Averia Libre", sans-serif;
}
.reason { color: var(--orange-dark) !important; }
.empty-note { color: var(--muted); font-weight: 600; text-align: center; padding: 24px 8px; }

/* Movie Night */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 10px; margin: 12px 0; }
.pick-item {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 16px 6px 16px 6px / 6px 16px 6px 16px;
  padding: 8px; cursor: pointer; text-align: center; color: var(--ink); font: inherit;
  box-shadow: 2px 3px 0 rgba(61,44,78,0.4);
}
.pick-item img, .pick-item .row-fallback { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; margin-bottom: 6px; border: 2px solid var(--ink); }
.pick-item .pi-title { font-size: 0.82rem; font-weight: 700; display: block; line-height: 1.25; }
.pick-item.selected { border-color: var(--orange); background: var(--sunny-soft); transform: rotate(-1deg) scale(1.02); }
.pick-item { position: relative; }
.pi-rank {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: var(--orange); color: #fff; font-family: "Averia Libre", "Nunito", sans-serif;
  font-size: 0.8rem; padding: 1px 8px; border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 2px 2px 0 rgba(61, 44, 78, 0.55);
}
.ballot-heading { margin: 14px 0 6px; }
.pick-count {
  font-family: "Averia Libre", "Nunito", sans-serif; font-weight: 700; font-size: 1.15rem;
  text-align: center; margin: 10px 0; color: var(--ink);
}
.mn-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.rank-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.drag-handle {
  cursor: grab; touch-action: none; font-size: 1.15rem; line-height: 1; color: var(--muted);
  padding: 6px 4px; margin: -6px 0; user-select: none; -webkit-user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.ballot-item { transition: transform 0.15s ease; }
.ballot-item.dragging {
  transition: none; position: relative; z-index: 3;
  box-shadow: var(--shadow); background: var(--sunny-soft);
}
.ballot-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ballot-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: var(--wobble-alt);
  padding: 7px 10px; box-shadow: var(--shadow-soft); font-size: 0.95rem;
}
.ballot-btns { display: inline-flex; gap: 4px; }
.mini-btn {
  font: inherit; font-weight: 800; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--neutral); color: var(--ink); cursor: pointer; line-height: 1;
}
.mini-btn:disabled { opacity: 0.35; cursor: default; }

.crossover-banner {
  background: var(--sunny-soft); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--wobble);
  padding: 18px; text-align: center; margin-bottom: 14px; box-shadow: var(--shadow);
  transform: rotate(-0.5deg);
}
.crossover-banner h3 { font-size: 1.6rem; margin-bottom: 4px; }
.status-pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 800;
  background: #fff; color: var(--orange-dark); border: 2.5px solid var(--ink);
}
.status-pill.done { color: #1e7d4f; }

/* Settings */
.services-list { display: flex; flex-direction: column; gap: 8px; }
.service-row {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: var(--wobble);
  padding: 12px 14px; cursor: pointer; color: var(--ink); font-size: 1rem; font-weight: 700;
}
.service-row input { width: 21px; height: 21px; accent-color: var(--orange); }

/* Tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  display: flex; background: rgba(255, 253, 247, 0.98); border-top: 3px solid var(--ink);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 20;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--muted); font-size: 0.72rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 4px 0;
  font-family: "Nunito", sans-serif;
}
.tab-btn .tab-ico { font-size: 1.25rem; }
.tab-btn.active { color: var(--ink); font-weight: 800; }

/* Overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(61, 44, 78, 0.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-card {
  background: var(--paper); border: 3.5px solid var(--ink); border-radius: var(--wobble);
  padding: 28px 24px; text-align: center; max-width: 380px; width: 100%;
  box-shadow: var(--shadow); transform: rotate(-0.6deg);
}
.overlay-card h2 { color: var(--orange); font-size: 1.9rem; }
#match-title { font-size: 1.2rem; font-weight: 800; }

@media (min-width: 640px) {
  .couple-options { grid-template-columns: 1fr 1fr; }
  .poster-wrap { height: 340px; }
}
