/* Crease's leaderboard: sticker cards on the dotted sky, a paper podium for
   the top three, and your place pinned to the bottom. */

body {
  min-height: 100vh;
  background-color: var(--sky);
  background-image: radial-gradient(rgba(46, 36, 64, 0.12) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  padding-bottom: 120px; /* room for the pinned card */
}

/* ---- Head ---- */
.board-head { width: 100%; max-width: 600px; margin: 0 auto; padding: 14px 16px 6px; }
.board-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.back-link { font-weight: 800; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .btn { background: #fff; text-decoration: none; }
.board-title { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
.trophy { width: 56px; height: 56px; flex: none; transform: rotate(-6deg); }
.board-title h1 { margin: 0; font: 600 38px/1 var(--serif); letter-spacing: -0.01em; }
.board-rule { margin: 4px 0 0; color: var(--plum-soft); font-weight: 800; font-size: 14px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; max-width: 180px; overflow: hidden; padding: 8px 16px; border: 2.5px solid var(--plum); border-radius: 999px; background: #fff; color: var(--plum); font: 800 15px/1 var(--sans); white-space: nowrap; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 3px 0 var(--plum); }
.tab[aria-pressed="true"] { background: var(--butter); }
.tab.add { border-style: dashed; box-shadow: none; color: var(--plum-soft); }
.tab.add[aria-pressed="true"] { border-style: solid; color: var(--plum); box-shadow: 0 3px 0 var(--plum); }
.tab:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }

.board-main { width: 100%; max-width: 600px; margin: 0 auto; padding: 8px 16px 20px; display: grid; gap: 16px; }
.loading { margin: 30px 0; text-align: center; color: var(--plum-soft); font-weight: 800; }

/* ---- The podium ---- */
.podium { display: grid; grid-template-columns: 1fr 1.12fr 1fr; align-items: end; gap: 10px; margin-top: 30px; }
.step {
  position: relative; display: grid; justify-items: center; gap: 4px; min-width: 0;
  padding: 14px 8px 0; border: 3px solid var(--plum); border-bottom: 0; border-radius: 22px 22px 0 0;
  background: var(--cream); text-align: center; box-shadow: 0 5px 0 var(--plum);
  animation: drop 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both; animation-delay: calc(var(--i) * 0.09s + 0.05s);
}
.step.empty { visibility: hidden; animation: none; }
.step.p1 { padding-top: 22px; background: #fff7d8; }
.step.p2 { transform: rotate(-2deg); }
.step.p3 { transform: rotate(2deg); }
.step.me { background: var(--butter); }
.step .crown { position: absolute; top: -20px; width: 46px; height: 26px; animation: bob 2.4s ease-in-out infinite; }
.step .medal { width: 52px; height: 52px; }
.step.p1 .medal { width: 64px; height: 64px; }
.step .who { max-width: 100%; overflow: hidden; font: 600 18px/1.15 var(--serif); white-space: nowrap; text-overflow: ellipsis; }
.step.p1 .who { font-size: 21px; }
.step .lvl { font-weight: 900; font-size: 15px; }
.step .plinth { display: block; width: calc(100% + 16px); margin-top: 8px; border-top: 3px solid var(--plum); background: repeating-linear-gradient(45deg, #f4a492 0 8px, #f19a87 8px 16px); }
.step.p1 .plinth { height: 64px; }
.step.p2 .plinth { height: 40px; }
.step.p3 .plinth { height: 24px; }
.week { justify-self: center; padding: 2px 8px; border-radius: 999px; background: #fde2dc; color: #a43d31; font-weight: 900; font-size: 11.5px; white-space: nowrap; }
.you-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--plum); color: #fff; font: 900 11px/1.4 var(--sans); vertical-align: 3px; }
.runs { color: var(--plum-soft); font: 800 11px/1 var(--sans); }

/* ---- Everyone else ---- */
.rows { display: grid; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto auto; align-items: center; gap: 10px;
  padding: 10px 12px; border: 2.5px solid var(--plum); border-radius: 16px; background: #fff; box-shadow: 0 3px 0 var(--plum);
  animation: slide 0.4s ease-out both; animation-delay: calc(var(--i) * 0.035s + 0.25s);
}
.row.me { background: var(--butter); transform: scale(1.02); }
.row .rank { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--plum); border-radius: 50%; background: var(--cream); font-weight: 900; font-size: 13px; }
.row .who { overflow: hidden; font-weight: 900; white-space: nowrap; text-overflow: ellipsis; }
.row .lvl { font: 600 20px/1 var(--serif); font-variant-numeric: tabular-nums; }
.row .lvl::before { content: "Level "; color: var(--plum-soft); font: 800 12px/1 var(--sans); }
.remove { width: 28px; height: 28px; padding: 0; border: 2px solid var(--plum); border-radius: 50%; background: #fff; color: var(--plum-soft); font-weight: 900; cursor: pointer; }
.remove[data-sure="1"] { width: auto; padding: 0 8px; border-radius: 999px; background: #fde2dc; color: #a43d31; font-size: 12px; }
.remove-tops { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.remove-top { padding: 4px 10px; border: 2px dashed var(--plum-soft); border-radius: 999px; background: none; color: var(--plum-soft); font: 800 12px/1.3 var(--sans); cursor: pointer; }

/* ---- Cards ---- */
.empty-card, .crew-card, .form-card, .invite-card { padding: 18px; border: 3px solid var(--plum); border-radius: 22px; background: var(--cream); box-shadow: 0 5px 0 var(--plum); }
.empty-card { display: grid; justify-items: start; gap: 8px; }
.empty-card b { font: 600 22px/1.2 var(--serif); }
.empty-card p { margin: 0 0 4px; color: var(--plum-soft); font-weight: 700; }
.crew-card { display: grid; gap: 12px; transform: rotate(-0.5deg); }
.crew-name { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.crew-name h2 { margin: 0; font: 600 28px/1.1 var(--serif); overflow-wrap: anywhere; }
.crew-name span { color: var(--plum-soft); font-weight: 800; font-size: 14px; }
.code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.code { flex: 1; min-width: 0; padding: 10px 14px; border: 2.5px dashed var(--plum); border-radius: 14px; background: #fff; font: 900 18px/1 var(--sans); letter-spacing: 0.08em; white-space: nowrap; user-select: all; }
.crew-tip { margin: 0; color: var(--plum-soft); font-weight: 700; font-size: 14px; }
.leave { justify-self: center; margin-top: 4px; padding: 6px 12px; border: 0; background: none; color: var(--plum-soft); font: 800 14px/1.3 var(--sans); text-decoration: underline; cursor: pointer; }
.leave[data-sure="1"] { color: #a43d31; }

.new-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-card { display: grid; align-content: start; gap: 8px; }
.form-card:nth-child(2) { background: #fff; transform: rotate(0.8deg); }
.form-card h2 { margin: 0; font: 600 24px/1.1 var(--serif); }
.form-card p { margin: 0; color: var(--plum-soft); font-weight: 700; font-size: 14px; }
.form-card label { margin-top: 4px; font-weight: 900; font-size: 13px; }
.form-card input { width: 100%; min-height: 46px; padding: 0 14px; border: 2.5px solid var(--plum); border-radius: 14px; background: #fff; color: var(--plum); font: 800 17px/1 var(--sans); }
.form-card input:focus { outline: 3px solid var(--butter); outline-offset: 1px; }
.form-error { min-height: 0; color: #a43d31 !important; }
.form-error:empty { display: none; }

.invite-card { display: grid; justify-items: start; gap: 6px; background: var(--butter); transform: rotate(-1deg); }
.invite-card[hidden] { display: none; }
.invite-kicker { margin: 0; font: 900 12px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--plum-soft); }
.invite-card h2 { margin: 0; font: 600 30px/1.1 var(--serif); overflow-wrap: anywhere; }
.invite-card p { margin: 0; font-weight: 700; }

/* ---- You, pinned ---- */
.you-card {
  position: fixed; z-index: 20; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px; width: min(568px, calc(100% - 24px)); transform: translateX(-50%);
  padding: 12px 12px 12px 18px; border: 3px solid var(--plum); border-radius: 22px; background: #fff; box-shadow: 0 5px 0 var(--plum);
}
.you-card[hidden] { display: none; }
.you-card.close { background: #fff3c9; animation: nudge 2.8s ease-in-out infinite; }
.you-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.you-text b { font: 600 19px/1.15 var(--serif); }
.you-text span { color: #b2483c; font-weight: 900; font-size: 14px; }
.you-card .btn { flex: none; text-decoration: none; }

@keyframes drop { from { opacity: 0; translate: 0 -24px; } }
@keyframes slide { from { opacity: 0; translate: 0 10px; } }
@keyframes bob { 50% { translate: 0 -3px; rotate: -4deg; } }
@keyframes nudge { 0%, 88%, 100% { rotate: 0deg; } 92% { rotate: -1.2deg; } 96% { rotate: 1.2deg; } }
@media (prefers-reduced-motion: reduce) { .step, .row, .crown, .you-card.close { animation: none !important; } }

@media (max-width: 520px) {
  .board-title h1 { font-size: 32px; }
  .trophy { width: 46px; height: 46px; }
  .podium { gap: 6px; }
  .step { padding-inline: 4px; border-radius: 18px 18px 0 0; }
  .step .who { font-size: 15px; }
  .step.p1 .who { font-size: 17px; }
  .step .lvl { font-size: 13px; }
  .step .medal { width: 42px; height: 42px; }
  .step.p1 .medal { width: 52px; height: 52px; }
  .row { grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 8px; padding: 9px 10px; }
  .row .week { display: none; }
  .new-grid { grid-template-columns: 1fr; }
  .you-text b { font-size: 17px; }
}
