:root {
  --purple: #5a3d7a;        /* Monica's door */
  --purple-dark: #3f2958;
  --purple-light: #7a58a0;
  --yellow: #f4c542;        /* peephole frame */
  --orange: #c9622c;        /* Central Perk couch */
  --green: #2f6b45;         /* Central Perk sign */
  --cream: #fbf3e0;
  --ink: #2a1d38;
  --red: #e5403c;
  --blue: #3b8ed4;
  --dot-y: #f6c42b;
  --ok: #3aa85b;
  --bad: #d9413b;
  --radius: 16px;
  --logo: "Permanent Marker", "Comic Sans MS", cursive;
  --body: "Varela Round", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--cream);
  background:
    radial-gradient(ellipse at top, var(--purple-light), transparent 60%),
    var(--purple);
  background-attachment: fixed;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}

main { max-width: 640px; margin: 0 auto; }

/* F·R·I·E·N·D·S */
.logo {
  font-family: var(--logo);
  font-size: clamp(34px, 11vw, 56px);
  letter-spacing: .04em;
  text-align: center;
  padding: 18px 0 6px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
  user-select: none;
}
.logo i {
  display: inline-block;
  width: .17em; height: .17em;
  border-radius: 50%;
  margin: 0 .1em;
  vertical-align: .35em;
}
.logo .r { background: var(--red); }
.logo .y { background: var(--dot-y); }
.logo .b { background: var(--blue); }

.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.subtitle, .big {
  font-family: var(--logo);
  font-weight: normal;
  text-align: center;
  color: var(--yellow);
  margin: 4px 0 8px;
}
.subtitle { font-size: 24px; }
.big { font-size: 30px; }
.lead { text-align: center; margin: 0 0 18px; opacity: .9; }
h2 { font-family: var(--logo); font-weight: normal; font-size: 22px; margin: 14px 0 10px; }
h3 { margin: 0 0 8px; font-size: 16px; color: var(--ink); }

.card {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.18);
}
label { display: block; font-weight: bold; margin-bottom: 6px; }
input, select {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border: 2px solid var(--purple-light);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 12px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  font: inherit;
  font-size: 18px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  margin: 0 0 12px;
  transition: transform .08s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--orange); color: #fff; box-shadow: 0 4px 0 #8f4119; }
.btn.ghost { background: transparent; color: var(--cream); border: 2px solid var(--cream); }
.btn.back {
  width: auto; min-height: 44px; margin: 0;
  padding: 0 16px; font-size: 16px; white-space: nowrap; flex: none;
  background: var(--purple-dark); color: var(--cream);
}

/* Quiz */
.sticky {
  position: sticky; top: 0; z-index: 2;
  background: var(--purple);
  padding: 6px 0 4px;
  margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.progress {
  display: flex; justify-content: space-between;
  font-size: 15px; margin-bottom: 6px; opacity: .95;
}
.frame {
  border: 7px solid var(--yellow);
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 0 3px var(--purple-dark), 0 8px 18px rgba(0,0,0,.35);
}
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.step { display: none; }
.step.active { display: block; }
.step-head { display: flex; align-items: center; gap: 12px; }
.step-head h2 { margin: 12px 0; }

.season-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.season-grid button {
  aspect-ratio: 1;
  min-height: 52px;
  font-family: var(--logo);
  font-size: 26px;
  border: 0;
  border-radius: 14px;
  background: var(--cream);
  color: var(--purple);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.season-grid button:nth-child(3n+1) { border-bottom: 5px solid var(--red); }
.season-grid button:nth-child(3n+2) { border-bottom: 5px solid var(--dot-y); }
.season-grid button:nth-child(3n) { border-bottom: 5px solid var(--blue); }
.season-grid button:active { transform: scale(.94); }

.ep-list { list-style: none; margin: 0; padding: 0; }
.ep-list button {
  display: flex; gap: 12px; align-items: center;
  width: 100%; min-height: 52px;
  text-align: left;
  font: inherit; font-size: 16px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 0; border-radius: 12px;
  background: var(--cream); color: var(--ink);
  cursor: pointer;
}
.ep-list button b {
  flex: none;
  width: 36px; height: 36px; line-height: 36px;
  text-align: center;
  border-radius: 50%;
  background: var(--purple); color: #fff;
  font-size: 15px;
}
.ep-list button:active { background: var(--yellow); }

.answers { list-style: none; margin: 0; padding: 0; }
.answers li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px dashed #d8cbb0;
  font-size: 14px; line-height: 1.35;
}
.answers li:last-child { border-bottom: 0; }
.answers img {
  flex: none; width: 112px; aspect-ratio: 16 / 9; object-fit: cover;
  border: 3px solid var(--yellow); border-radius: 8px;
}
.answers .marks { font-size: 13px; margin-bottom: 2px; }
.answers .marks span { font-weight: bold; }
.answers .ok { color: var(--ok); }
.answers .bad { color: var(--bad); }
.answers small { display: block; opacity: .7; margin-top: 2px; }

/* Results */
.scoreline { display: flex; justify-content: center; gap: 14px; margin: 0 0 16px; }
.scoreline div {
  background: var(--cream); color: var(--ink);
  border-radius: 14px; padding: 10px 18px; text-align: center; min-width: 120px;
}
.scoreline b { display: block; font-family: var(--logo); font-size: 34px; color: var(--orange); font-weight: normal; }

/* Matrix */
.matrix-card { padding: 10px; }
.matrix-card svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.dot-info { text-align: center; font-size: 14px; margin: 6px 0 0; min-height: 1.4em; }
.save-status { text-align: center; font-size: 13px; opacity: .7; margin: 2px 0 0; }
.highlight { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.highlight select { margin: 0; font-size: 16px; padding: 8px 10px; }
.m-box-label { font-family: var(--logo); font-size: 11px; fill: var(--purple-dark); text-anchor: middle; opacity: .85; }
.m-box-label.hot { font-family: var(--logo); font-size: 13px; fill: var(--purple-dark); opacity: 1; }
.m-box-label.huh { font-family: var(--logo); font-size: 26px; fill: var(--purple); opacity: .75; }
.m-axis { font-size: 9px; fill: var(--ink); text-anchor: middle; }
.m-axis-title { font-size: 11px; font-weight: bold; fill: var(--ink); text-anchor: middle; }
.m-dot { fill: #9d93a8; stroke: #fff; stroke-width: 1; cursor: pointer; }
.m-dot.mine { fill: var(--dot-y); stroke: var(--ink); }
.m-dot.now { fill: var(--red); stroke: #fff; stroke-width: 2; }
.m-pulse { fill: none; stroke: var(--red); stroke-width: 2; animation: pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }

.top { margin: 0; padding-left: 26px; }
.top li { padding: 6px 0; border-bottom: 1px dashed #d8cbb0; font-size: 15px; }
.top li span { float: right; font-weight: bold; }
.top li.me { color: var(--orange); font-weight: bold; }
.top .empty { list-style: none; margin-left: -26px; opacity: .7; }

@media (prefers-reduced-motion: reduce) {
  .screen, .m-pulse { animation: none; }
}
