:root {
  --bg: #f2f5f8;
  --surface: #ffffff;
  --ink: #102a43;
  --muted: #52667a;
  --line: #d3dde6;
  --lane: #1f5fd1;
  --lane-ink: #ffffff;
  --gold: #d99a1e;
  --silver: #8c9bab;
  --bronze: #b06a3b;
  --ok: #1d7a4f;
  --bad: #b3261e;
  --warn: #9a6700;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1823; --surface: #14222f; --ink: #e5edf4; --muted: #93a6b8;
    --line: #26394b; --lane: #5b8ff0; --lane-ink: #0d1823;
    --ok: #4cc38a; --bad: #f2877f; --warn: #e3b341;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}
a { color: var(--lane); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font: 800 1.35rem/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: .01em; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; }
.top nav a, .linkish {
  color: var(--muted); text-decoration: none; font: 500 .95rem var(--body);
  padding: .25rem 0; border-bottom: 2px solid transparent;
}
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--lane); }
.top nav a:hover, .linkish:hover { color: var(--ink); }
.badge {
  display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 1em;
  background: var(--bad); color: #fff; font-size: .78rem; text-align: center;
}
.linkish { background: none; border: 0; cursor: pointer; }
.linkish.danger { color: var(--bad); }
form.inline { display: inline; }

main { max-width: 1080px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 4rem; }

h1, h2 { font-family: var(--display); line-height: 1.05; margin: 0 0 .4em; }
h1 { font-size: clamp(2.4rem, 7vw, 4rem); font-weight: 800; }
h2 { font-size: 1.55rem; font-weight: 700; }
.muted, .note, .range { color: var(--muted); }
.note { margin: -.2rem 0 .8rem; font-size: .92rem; }

/* ---------- rankings ---------- */
.hero { margin-bottom: 1.25rem; }
.hero h1 { margin-bottom: .1em; }
.range { margin: 0; font-size: 1.05rem; }

.tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1.75rem; padding-bottom: 2px; }
.tabs a {
  flex: none; padding: .45rem 1rem; border: 1px solid var(--line); border-radius: 2rem;
  color: var(--ink); text-decoration: none; font-weight: 500; background: var(--surface);
}
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.boards { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.board { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem 1.25rem .75rem; }
.board-main { grid-column: 1 / -1; border-top: 5px solid var(--lane); }

.ranks { list-style: none; margin: 0; padding: 0; }
.ranks li {
  display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: .75rem;
  padding: .55rem 0; border-top: 1px solid var(--line);
}
.ranks li:first-child { border-top: 0; }
.pos { font: 800 2rem/1 var(--display); color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.rank-1 .pos { color: var(--gold); font-size: 2.6rem; }
.rank-2 .pos { color: var(--silver); }
.rank-3 .pos { color: var(--bronze); }
.who { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font-weight: 600; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.val { font: 700 1.45rem/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val small { font: 500 .85rem var(--body); color: var(--muted); }
.board-main .ranks li { padding: .75rem 0; }
.board-main .val { font-size: 2rem; }
.board-main .rank-1 .pos { font-size: 3.4rem; }
.empty { color: var(--muted); padding: .5rem 0 1rem; margin: 0; }
.cta-line { margin-top: 2rem; }

/* ---------- avatars ---------- */
.av { flex: none; border-radius: 50%; object-fit: cover; background: var(--line); }
.av-sm { width: 2.25rem; height: 2.25rem; }
.av-lg { width: 6.5rem; height: 6.5rem; }
.av-empty { display: inline-grid; place-items: center; font: 700 1rem var(--display); color: var(--muted); }
.av-lg.av-empty { font-size: 2.6rem; }

/* ---------- forms ---------- */
.form-page { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .9rem; }
.row > * { flex: 1 1 140px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; font-weight: 400; }
input, select, textarea {
  font: 400 1rem var(--body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px; padding: .65rem .75rem; width: 100%;
}
input[type="file"] { padding: .5rem; background: var(--surface); }
input[type="checkbox"] { width: auto; }
.upload { padding: 1rem; border: 2px dashed var(--line); border-radius: 6px; background: var(--surface); }
.btn {
  align-self: flex-start; font: 700 1.1rem var(--display); letter-spacing: .02em;
  padding: .7rem 1.6rem; border: 0; border-radius: 4px; cursor: pointer;
  background: var(--lane); color: var(--lane-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.flash { padding: .7rem 1rem; border-radius: 4px; border-left: 4px solid var(--ok); background: var(--surface); margin: 0 0 1rem; }
.flash-err { border-left-color: var(--bad); }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 1.5rem; }
.profile-head h1 { font-size: clamp(2rem, 6vw, 3rem); margin: 0; }
.profile-head p { margin: .2rem 0; }
.two-col { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; margin-bottom: 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; margin-top: 1.25rem; }
.two-col .panel { margin-top: 0; }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 1.5rem 0; }
.stats div { display: flex; flex-direction: column; border-left: 4px solid var(--lane); padding-left: .8rem; }
.stats .n { font: 800 2.2rem/1.05 var(--display); font-variant-numeric: tabular-nums; }
.stats div span:last-child { color: var(--muted); font-size: .92rem; }

.feed { margin: 0; padding-left: 1.1rem; }
.feed li { margin: .35rem 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); }
td { font-variant-numeric: tabular-nums; }
.status { font-weight: 600; }
.status-approved { color: var(--ok); }
.status-pending { color: var(--warn); }
.status-rejected { color: var(--bad); }

/* ---------- admin review ---------- */
.review-list { display: grid; gap: 1.25rem; margin: 1.25rem 0; }
.review {
  display: grid; grid-template-columns: minmax(140px, 260px) 1fr; gap: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1rem;
}
.shot img { width: 100%; max-height: 460px; object-fit: contain; border-radius: 4px; background: var(--bg); }
.review dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: 0; }
.review dt { color: var(--muted); }
.review dd { margin: 0; font-weight: 600; }
@media (max-width: 560px) {
  .review { grid-template-columns: 1fr; }
  .ranks li { grid-template-columns: 2.4rem 1fr auto; gap: .5rem; }
  .board-main .val { font-size: 1.6rem; }
}

/* ---------- mystery pets ---------- */
.pet-emoji { display: inline-grid; place-items: center; font-size: 1.3rem; line-height: 1; }
.av-lg.pet-emoji { font-size: 3.4rem; }
.you {
  font: 600 .72rem var(--body); font-style: normal; color: var(--lane-ink); background: var(--lane);
  padding: .1em .5em; border-radius: 1em; vertical-align: .15em;
}
.ranks li.me { background: color-mix(in srgb, var(--lane) 9%, transparent); margin: 0 -.6rem; padding-left: .6rem; padding-right: .6rem; border-radius: 4px; }
.mystery {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.25rem;
  background: var(--surface); border: 1px dashed var(--lane); border-radius: 6px;
  padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.mystery p { margin: 0; }
.mystery-head { font: 700 1.35rem/1.15 var(--display); flex-basis: 100%; }
.mystery-open .mystery-head { flex-basis: auto; }
.held { margin: -.5rem 0 1.25rem; }

/* flip from pet to person */
.flip { display: grid; min-width: 0; perspective: 600px; }
.flip > span { grid-area: 1 / 1; min-width: 0; display: flex; align-items: center; backface-visibility: hidden;
  transition: transform .45s cubic-bezier(.3, .7, .3, 1), opacity .3s, visibility .45s; transition-delay: calc(var(--i) * 90ms); }
.face-real { transform: rotateX(-90deg); opacity: 0; visibility: hidden; }
.revealed .face-pet { transform: rotateX(90deg); opacity: 0; visibility: hidden; }
.revealed .face-real { transform: none; opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .flip > span { transition: none; }
}
.ranks .who > span:last-child { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
.flip .who > span:last-child { white-space: normal; }
@media (max-width: 560px) {
  .val { font-size: 1.25rem; }
  .board-main .val { font-size: 1.45rem; }
  .board-main .rank-1 .pos { font-size: 2.8rem; }
}
