/* Palette pulled from treehacks.com: sky gradient, deep canopy teal, moss, lime glow.
   Layout borrows ESPN's medal tracker: live ticker, top-3 bar cards, dense standings table. */
:root {
  --sky-top: #6fa6c1;
  --sky-mid: #a9cfe0;
  --sky-low: #e9eff1;
  --ink: #0f2f3d;          /* canopy teal, used as text */
  --ink-soft: #46606b;
  --line: rgb(15 47 61 / .12);
  --line-strong: #0f2f3d;
  --glass: rgb(255 255 255 / .66);
  --glass-strong: rgb(255 255 255 / .86);
  --glass-edge: rgb(255 255 255 / .9);
  --field: rgb(255 255 255 / .75);
  --deep: #003e55;         /* buttons, nav */
  --deep-text: #e9eff1;
  --moss: #3f6b3c;
  --lime: #d6ec6f;
  --lime-ink: #2f4a12;
  --glow: rgb(214 236 111 / .55);
  --cyan-glow: rgb(111 214 236 / .45);
  --warn: #8a5a00;
  --warn-soft: #fbefcf;
  --bad: #a3261b;
  --bad-soft: #fbe3df;
  --gold: #e3b54c;
  --silver: #b9c0c4;
  --bronze: #c98a52;
  --c1: #1f5e74;
  --c2: #6fb3cf;
  --c3: #4f8a3f;
  --c4: #a9c93f;
  --c-other: #8a9a8f;
  --display: "Lexend Zetta", "Arial Black", sans-serif;
  --body: "Electrolize", "Trebuchet MS", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky-top: #0b1d24;
    --sky-mid: #10303c;
    --sky-low: #0d2027;
    --ink: #e4eef1;
    --ink-soft: #93adb6;
    --line: rgb(138 189 205 / .16);
    --line-strong: #8abdcd;
    --glass: rgb(16 48 60 / .62);
    --glass-strong: rgb(16 48 60 / .9);
    --glass-edge: rgb(138 189 205 / .22);
    --field: rgb(8 24 30 / .7);
    --deep: #8abdcd;
    --deep-text: #08181e;
    --moss: #8fc36f;
    --lime-ink: #1b2a08;
    --warn: #f3c45a;
    --warn-soft: rgb(243 196 90 / .14);
    --bad: #ff8a7a;
    --bad-soft: rgb(255 138 122 / .14);
    --c1: #2f8fae;
    --c2: #8acbe3;
    --c3: #6fae5a;
    --c4: #c9e265;
    --c-other: #7d8f86;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.5 var(--body);
  background: var(--sky-low) linear-gradient(180deg, var(--sky-top) 0, var(--sky-mid) 380px, var(--sky-low) 900px) no-repeat;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 400; line-height: 1.15; }
h1 { font-family: var(--display); font-size: 1.35rem; letter-spacing: -.02em; }
h2 { font-family: var(--display); font-size: .95rem; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--sky-top) 70%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-edge);
}
.brand {
  font-family: var(--display); font-size: .9rem; letter-spacing: -.03em; text-decoration: none; white-space: nowrap;
}
.brand .amp { color: var(--deep); }
.topbar .spacer { flex: 1; }
.topbar nav { display: none; gap: 2px; }
.topbar nav a {
  padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--ink-soft);
}
.topbar nav a.on { background: var(--deep); color: var(--deep-text); }
.whoami { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* ── Ticker (ESPN-style) ── */
.ticker {
  overflow: hidden; border-bottom: 1px solid var(--glass-edge);
  background: var(--glass-strong);
}
.ticker-track { display: flex; width: max-content; animation: ticker 60s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.tick {
  display: flex; align-items: center; gap: 8px; padding: 7px 18px; text-decoration: none;
  border-right: 1px solid var(--line); font-size: .82rem; white-space: nowrap;
}
.tick-pts { font-family: var(--display); font-size: .78rem; color: var(--moss); }
.tick-time { color: var(--ink-soft); }
@keyframes ticker { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker { overflow-x: auto; }
  .ticker-track { animation: none; }
}

main { max-width: 860px; margin: 0 auto; padding: 22px 16px 120px; }

/* ── Bottom tabs (phones) ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: var(--glass-strong); border-top: 1px solid var(--glass-edge);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; padding: 4px 8px;
  font-size: .72rem; text-decoration: none; color: var(--ink-soft);
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--ink); }
.tabbar a.post .ic {
  display: grid; place-items: center; width: 44px; height: 44px; margin-top: -16px; border-radius: 50%;
  background: var(--deep); color: var(--deep-text);
  box-shadow: 0 0 0 4px var(--glass-strong), 0 6px 18px var(--cyan-glow);
}
.count-dot {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
}
.tabbar .count-dot { position: absolute; margin: -4px 0 0 14px; }
.tabbar a { position: relative; }
@media (min-width: 760px) {
  .topbar nav { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 48px; }
}

.page-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--moss); }
.live::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--moss);
  box-shadow: 0 0 0 3px rgb(79 138 63 / .2);
}
.section { padding: 18px; margin-bottom: 18px; }
.section > h2 { margin-bottom: 14px; }
.stack > * + * { margin-top: 12px; }

/* ── Leader cards: the one loud element ── */
.leaders {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 22px;
}
.leader {
  display: flex; flex-direction: column; padding: 14px 14px 16px; text-decoration: none; min-width: 0;
}
.leader.r1 { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime), 0 10px 40px var(--glow); }
.leader-head { display: flex; align-items: center; gap: 8px; min-height: 2.6em; }
.leader-head .team-name { font-size: .92rem; line-height: 1.2; }
.medal {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-family: var(--display); font-size: .72rem; color: #fff;
  background: var(--gold); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .15);
}
.medal.m2 { background: var(--silver); }
.medal.m3 { background: var(--bronze); }
.bars {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; align-items: end;
  height: 128px; margin: 12px 0 6px; border-bottom: 1px solid var(--line);
}
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: .78rem; margin-bottom: 3px; }
.bar-fill { width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .6s ease; }
.bar-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; }
.bar-labels span { font-size: .62rem; color: var(--ink-soft); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-total { margin-top: 12px; text-align: center; }
.leader-total strong { display: block; font-family: var(--display); font-weight: 400; font-size: 2rem; letter-spacing: -.04em; line-height: 1; }
.leader-total span { font-size: .8rem; color: var(--ink-soft); }
@media (max-width: 640px) {
  .leaders {
    grid-auto-columns: 78%; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 -16px 22px; padding: 4px 16px 14px; scrollbar-width: none;
  }
  .leaders::-webkit-scrollbar { display: none; }
  .leader { scroll-snap-align: center; }
}

/* ── Standings table ── */
.table-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 8px; padding: 0 2px; }
.standings { width: 100%; border-collapse: collapse; font-size: .92rem; }
.standings-wrap { padding: 4px 6px 6px; overflow: hidden; }
.standings th {
  padding: 10px 8px 8px; font-weight: 400; font-size: .78rem; color: var(--ink-soft); text-align: right;
  border-bottom: 2px solid var(--line-strong); vertical-align: bottom;
}
.standings th button {
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: inherit; line-height: 1.2;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px;
}
.standings th button.on { color: var(--ink); text-decoration-color: var(--ink); }
.standings th.c-team, .standings td.c-team { text-align: left; }
.standings td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.standings tr:last-child td { border-bottom: 0; }
.standings .c-rank { width: 40px; text-align: center; padding-left: 4px; padding-right: 0; }
.standings .c-total { background: rgb(214 236 111 / .28); }
.standings th.c-total { color: var(--ink); }
.standings td.c-total { font-family: var(--display); font-size: 1rem; letter-spacing: -.03em; }
.standings td.c-team a { text-decoration: none; display: block; }
.standings td.c-team a:hover .team-name { text-decoration: underline; }
.standings tr.mine td { background: rgb(111 179 207 / .16); }
.standings tr.mine td.c-team { box-shadow: inset 3px 0 0 var(--deep); }
.standings .zero { color: var(--ink-soft); opacity: .6; }
.rank-num { display: inline-grid; place-items: center; width: 26px; height: 26px; font-size: .85rem; }
.team-name { overflow-wrap: anywhere; }
.breakdown { display: none; font-size: .76rem; color: var(--ink-soft); margin-top: 2px; }
.flash td { animation: flash 1.6s ease; }
@keyframes flash { 0%, 35% { background: var(--glow); } }
@media (max-width: 640px) {
  .standings .c-cat { display: none; }
  .breakdown { display: block; }
}

/* ── Forms ── */
label { display: block; font-size: .9rem; margin-bottom: 5px; }
.hint { color: var(--ink-soft); font-size: .8rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--deep); outline-offset: -1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--glass-strong); cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--deep); border-color: var(--deep); color: var(--deep-text); }
.btn.good { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 11px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; padding: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.error { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; color: var(--ink-soft); cursor: pointer; }
.seg button.on { background: var(--deep); color: var(--deep-text); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--glass); border-radius: 999px;
  padding: 6px 13px; font-size: .85rem; cursor: pointer; color: var(--ink-soft);
}
.chip.on { background: var(--deep); border-color: var(--deep); color: var(--deep-text); }

/* ── Sign-in ── */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; padding: 28px 24px 24px; }
.login .wordmark { font-family: var(--display); font-size: 1.5rem; letter-spacing: -.04em; text-align: center; line-height: 1.1; }
.login .wordmark .amp { color: var(--deep); }
.login .sub { text-align: center; margin: 8px 0 22px; color: var(--ink-soft); }
.demo-banner { background: var(--warn-soft); color: var(--warn); font-size: .82rem; padding: 7px 16px; text-align: center; }
.demo-banner select { width: auto; padding: 3px 8px; margin-left: 6px; }

/* ── Team page ── */
.team-hero { display: flex; gap: 16px; align-items: flex-end; padding: 20px; margin-bottom: 18px; }
.team-hero h1 { font-size: 1.15rem; line-height: 1.25; }
.team-hero .roles { margin-top: 8px; font-size: .88rem; color: var(--ink-soft); }
.team-hero .total { text-align: right; }
.team-hero .total strong { display: block; font-family: var(--display); font-weight: 400; font-size: 2.4rem; letter-spacing: -.05em; line-height: 1; }

/* ── Feed ── */
.feed { display: grid; gap: 16px; align-items: start; }
@media (min-width: 760px) { .feed.two { grid-template-columns: 1fr 1fr; } }
.post { overflow: hidden; }
.post-head { display: flex; gap: 10px; align-items: flex-start; padding: 13px 14px 11px; }
.post-head .team-name { font-size: .95rem; text-decoration: none; }
.post-meta { display: flex; gap: 10px; font-size: .8rem; color: var(--ink-soft); }
.photo {
  display: block; width: 100%; aspect-ratio: 4 / 3; background: var(--line);
  border: 0; padding: 0; cursor: zoom-in;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-body { padding: 11px 14px 14px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; white-space: nowrap; }
.pill.approved { background: var(--lime); color: var(--lime-ink); font-family: var(--display); font-size: .72rem; letter-spacing: -.02em; padding: 4px 10px; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.removed, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.note { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--field); font-size: .85rem; }
.admin-tools { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.admin-tools input[type=number] { width: 80px; padding: 6px 8px; }
.admin-tools input[type=text] { padding: 7px 9px; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }

/* ── Post form ── */
.options { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--field);
}
.option input { accent-color: var(--deep); width: 18px; height: 18px; margin: 0; }
.option:has(input:checked) { border-color: var(--deep); box-shadow: 0 0 0 1px var(--deep), 0 4px 16px var(--cyan-glow); }
.option .pts-tag { font-family: var(--display); font-size: .85rem; color: var(--moss); white-space: nowrap; }
.dropzone {
  display: grid; place-items: center; gap: 6px; padding: 26px; margin: 0; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--ink-soft); border-radius: 12px; color: var(--ink-soft); background: var(--field);
}
.dropzone svg { width: 30px; height: 30px; }
.dropzone img { max-width: 100%; max-height: 320px; border-radius: 8px; }
.dropzone input { display: none; }

/* ── Admin tables ── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table td, .table th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-weight: 400; font-size: .8rem; color: var(--ink-soft); }
.table input[type=text], .table input[type=number] { padding: 7px 8px; }
.table input[name=name] { min-width: 150px; }
.table input[type=number] { width: 64px; }
.table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--deep); }
.scroll-x { overflow-x: auto; }
.code-box { font-family: var(--display); font-size: 1.1rem; letter-spacing: .02em; }

/* ── Misc ── */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px);
  background: var(--deep); color: var(--deep-text); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 8px 24px var(--cyan-glow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { #toast { bottom: 32px; } }
.lightbox {
  position: fixed; inset: 0; z-index: 40; background: rgb(6 20 26 / .9);
  display: grid; place-items: center; padding: 16px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--deep); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.post-title { font-size: 1.02rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.admin-only {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); font-size: .66rem; line-height: 1.4;
}
.tabbar .admin-only { margin: 1px 0 0; font-size: .58rem; padding: 0 5px; }
.demo-banner.admin-demo { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: center; padding: 9px 16px; }
.demo-controls { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.demo-controls .btn { color: var(--warn); border-color: var(--warn); background: transparent; }
