/* SQ21 — Signed, Sealed, Supernatural */
:root {
  --night: #070b0e;
  --card: #10171c;
  --card-edge: #1d2830;
  --ink: #e9efe4;
  --ink-soft: #9aa8a3;
  --lime: #d8f31e;
  --lime-deep: #8ea30f;
  --lime-ghost: rgba(216, 243, 30, 0.14);
  --paper: #f3f5e4;
  --paper-ink: #1b2216;
  --coral: #ff8a6b;
  --sky: #9fd3ff;
  --gold: #f4c95d;
  --accent: var(--lime);
  --radius-card: 22px;
  --script: "Kaushan Script", "Brush Script MT", cursive;
  --sans: "Familjen Grotesk", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.is-gold { --accent: var(--gold); }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { width: min(760px, 100%); margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Hero ── */
.hero { position: relative; }
.hero img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 30%;
  background: linear-gradient(to bottom, transparent, var(--night));
}

/* ── The meter: a brush stroke that fills with points ── */
.meter { margin: -8px auto 0; text-align: center; position: relative; z-index: 1; }
.meter-total {
  font-family: var(--script);
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.01em;
  margin: 0;
  text-shadow: 0 0 28px rgba(216, 243, 30, 0.25);
}
.meter-of { margin: 6px 0 0; color: var(--ink-soft); font-size: 1rem; }
.stroke { width: 100%; height: auto; margin-top: 4px; overflow: visible; }
.stroke .track { stroke: var(--card-edge); }
.stroke .fill { stroke: var(--accent); transition: stroke-dashoffset 1.6s cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 0 6px rgba(216,243,30,.45)); }
.stroke .tick { fill: var(--night); stroke: var(--card-edge); stroke-width: 2; }
.stroke .tick.on { fill: var(--accent); stroke: var(--night); }
.meter-next { margin: 4px 0 0; font-size: 1rem; }
.meter-next b { color: var(--accent); font-weight: 600; }
.meter-meta { margin: 6px 0 0; color: var(--ink-soft); font-size: .88rem; }

/* ── Account strip ── */
.account {
  margin: 28px 0 0; padding: 18px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--card-edge);
}
.account h2 { font: 600 1.15rem/1.3 var(--sans); margin: 0 0 4px; }
.account p { margin: 0 0 12px; color: var(--ink-soft); font-size: .95rem; }
.account form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: .9rem; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--night); border: 1px solid var(--card-edge); color: var(--ink);
  font-size: 16px;
}
.field textarea { min-height: 96px; resize: vertical; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 12px 20px; border-radius: 999px;
  background: var(--accent); color: #0a0d05; font-weight: 600; font-size: 1rem;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-quiet { background: transparent; color: var(--ink-soft); border: 1px solid var(--card-edge); }
.signed-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.signed-in strong { color: var(--accent); }
.error { color: var(--coral); font-size: .92rem; min-height: 1.2em; margin: 0; }

/* ── The card ── */
.card {
  position: relative; margin: 32px 0 0; padding: 30px 20px 36px;
  border-radius: var(--radius-card);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(216,243,30,.07), transparent 60%),
    var(--card);
  border: 1px solid var(--card-edge);
  overflow: hidden;
}
body.is-gold .card { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 60px rgba(244,201,93,.25); }
.card-dear { font-family: var(--script); font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1.1; color: var(--accent); margin: 0; position: relative; z-index: 2; }
.card-intro { position: relative; z-index: 2; max-width: 58ch; margin: 10px 0 0; }
.card-intro + .card-intro { margin-top: 10px; color: var(--ink-soft); }

/* Decorative layers: balloons and streamers live in a band above "Dear Coaches", never over text */
.deco { position: relative; height: 0; margin: -30px -20px 0; transition: height .8s ease; }
.deco.has-balloons, .deco.has-streamers { height: 150px; margin-bottom: 4px; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.balloon { position: absolute; width: 46px; animation: bob 6s ease-in-out infinite; }
.balloon svg { width: 100%; height: auto; overflow: visible; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(2deg); } }
.streamer { position: absolute; top: -6px; width: 6px; height: 120px; border-radius: 3px; opacity: .85; transform-origin: top; }
.dot { position: absolute; width: 6px; height: 6px; border-radius: 2px; opacity: .35; }

/* Sections inside the card */
.section { position: relative; z-index: 2; margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h3 { font: 600 1.25rem/1.25 var(--sans); margin: 0; }
.section-head span { color: var(--ink-soft); font-size: .88rem; }
.locked {
  display: flex; gap: 12px; align-items: center;
  padding: 16px; border-radius: 14px;
  border: 1px dashed var(--card-edge); color: var(--ink-soft); font-size: .95rem;
}
.locked b { color: var(--ink); font-weight: 600; }
.locked .lock { font-size: 1.3rem; }

/* Portraits */
.portraits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 10px; }
@media (min-width: 620px) { .portraits { grid-template-columns: repeat(6, 1fr); } }
.portrait { text-align: center; margin: 0; }
.portrait .ring {
  width: 100%; aspect-ratio: 1; border-radius: 50%; padding: 3px;
  background: conic-gradient(var(--accent), var(--lime-deep), var(--accent));
}
.portrait img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--card); }
.portrait figcaption { margin-top: 6px; font-size: .85rem; line-height: 1.25; }
.portrait .count { display: block; color: var(--accent); font-weight: 600; }
.portraits.is-locked .portrait img { filter: grayscale(1) brightness(.35) blur(2px); }
.portraits.is-locked .ring { background: var(--card-edge); }

/* Composer */
.composer { padding: 16px; border-radius: 16px; background: var(--night); border: 1px solid var(--card-edge); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; padding: 10px 8px; line-height: 1.25; border-radius: 10px; border: 1px solid var(--card-edge); background: transparent; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--lime-ghost); border-color: var(--accent); color: var(--accent); }
.composer form { display: grid; gap: 10px; }
.composer .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.composer .hint { color: var(--ink-soft); font-size: .85rem; }
.file-pick { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px dashed var(--card-edge); cursor: pointer; }
.file-pick img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.file-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* Notes: paper on a dark card */
.notes { columns: 2 150px; column-gap: 12px; }
.note {
  break-inside: avoid; margin: 0 0 12px; padding: 14px 14px 10px;
  background: var(--paper); color: var(--paper-ink);
  border-radius: 3px 3px 14px 3px;
  box-shadow: 0 10px 18px -12px rgba(0,0,0,.8);
  transform: rotate(var(--tilt, 0deg));
}
.note.c1 { background: #f3f5e4; } .note.c2 { background: #e3f59a; } .note.c3 { background: #ffd9cc; } .note.c4 { background: #d6ebff; }
.note p { margin: 0; font-size: .98rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .by { margin-top: 10px; font-family: var(--script); font-size: 1.1rem; line-height: 1.2; }
.chip { display: inline-block; margin-top: 8px; padding: 2px 9px; border-radius: 999px; background: rgba(0,0,0,.08); font-size: .78rem; }
.post-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.post-actions button {
  border: 0; background: transparent; cursor: pointer; font-size: .78rem;
  padding: 4px 6px; border-radius: 6px; color: inherit; opacity: .55;
}
.post-actions button:hover { opacity: 1; }
.post-actions .rm { color: #b3261e; opacity: .85; font-weight: 600; }
.reported { font-size: .75rem; color: #b3261e; font-weight: 600; }

/* Selfies: polaroids */
.selfies { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 620px) { .selfies { grid-template-columns: repeat(3, 1fr); } }
.polaroid {
  margin: 0; padding: 8px 8px 10px; background: #fbfbf6; color: var(--paper-ink);
  border-radius: 3px; box-shadow: 0 12px 20px -12px rgba(0,0,0,.85);
  transform: rotate(var(--tilt, 0deg));
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #ddd; }
.polaroid figcaption { padding-top: 8px; font-size: .85rem; line-height: 1.35; overflow-wrap: anywhere; }
.polaroid .by { font-family: var(--script); font-size: 1.05rem; display: block; }

/* Signatures */
.signatures { display: flex; flex-wrap: wrap; gap: 4px 18px; font-family: var(--script); font-size: 1.25rem; color: var(--ink); line-height: 1.5; }
.signatures span:nth-child(3n) { color: var(--accent); }
.signatures span:nth-child(5n+1) { transform: rotate(-3deg); display: inline-block; }

/* Halfway + finale */
.banner { position: relative; z-index: 2; margin-top: 34px; text-align: center; padding: 22px 12px; border-radius: 16px; border: 1px solid var(--accent); background: var(--lime-ghost); }
.banner p { margin: 0; }
.banner .big { font-family: var(--script); font-size: clamp(1.9rem, 8vw, 2.8rem); color: var(--accent); line-height: 1.15; }
.finale { margin-top: 40px; padding: 34px 16px; border-width: 2px; }
.finale .big { font-size: clamp(2.2rem, 10vw, 3.6rem); }
.finale .sub { color: var(--ink); margin-top: 10px; }
.finale-locked { opacity: .8; }
#fireworks { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ── Unlock ladder ── */
.ladder { margin: 36px 0 0; }
.ladder h2, .leaders h2 { font: 600 1.25rem/1.3 var(--sans); margin: 0 0 12px; }
.ladder ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--card-edge); }
.ladder li { position: relative; padding: 0 0 16px 22px; color: var(--ink-soft); }
.ladder li::before {
  content: ""; position: absolute; left: -7px; top: 7px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--night); border: 2px solid var(--card-edge);
}
.ladder li.on { color: var(--ink); }
.ladder li.on::before { background: var(--accent); border-color: var(--accent); }
.ladder li.next::before { border-color: var(--accent); box-shadow: 0 0 0 4px var(--lime-ghost); }
.ladder .pts { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); margin-right: 8px; }
.ladder li.on .pts { color: var(--accent); }
.ladder .desc { display: block; font-size: .88rem; color: var(--ink-soft); }

/* ── Leaders ── */
.leaders { margin: 36px 0 0; }
.leaders ol { margin: 0; padding: 0 0 0 1.4em; }
.leaders li { padding: 4px 0; display: list-item; }
.leaders li span { float: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ── Admin preview bar ── */
.adminbar { position: sticky; top: 0; z-index: 40; background: #241f05; color: var(--gold); padding: 8px 16px; font-size: .88rem; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.adminbar input[type=range] { flex: 1; min-width: 140px; accent-color: var(--gold); }
.adminbar a { color: var(--gold); }
.adminbar .warn { flex-basis: 100%; color: #ffb4a3; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%);
  background: var(--accent); color: #0a0d05; padding: 14px 20px; border-radius: 16px;
  font-weight: 600; z-index: 60; visibility: hidden; transition: transform .45s cubic-bezier(.2,.9,.3,1.2), visibility 0s .45s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .45s cubic-bezier(.2,.9,.3,1.2); }

footer { margin: 48px 0 0; padding: 24px 0 40px; border-top: 1px solid var(--card-edge); color: var(--ink-soft); font-size: .85rem; text-align: center; }
footer p { margin: 4px 0; }

/* Simple pages (register/admin) */
.page { padding: 28px 0 60px; }
.page h1 { font-family: var(--script); color: var(--accent); font-weight: 400; font-size: 2.4rem; margin: 0 0 8px; }
.page .lede { color: var(--ink-soft); margin: 0 0 20px; }
.panel { padding: 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--card-edge); margin-bottom: 18px; }
.panel form { display: grid; gap: 12px; }
.admin-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--card-edge); }
.admin-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.admin-row .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.admin-row .acts button { padding: 6px 12px; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.tab small { display: block; font-size: .78rem; opacity: .75; }
