:root {
  --navy: #0b1f3a;
  --accent: #f2a900;
  --bg: #f4f6fa;
  --text: #1c2433;
  --muted: #6b7486;
  --danger: #c0392b;
  --radius: 12px;
  --surface: #fff;     /* cards, menus, panels */
  --line: #d3d8e2;     /* input borders */
  --chip: #e6e9ef;     /* secondary buttons, badges, table rules */
  --ink: var(--navy);  /* headings and prices */
}

/* Dark mode: the switch in the account menu sets data-theme="dark" on <html> (see theme.js). */
:root[data-theme="dark"] {
  color-scheme: dark;  /* dark dialogs, inputs and scrollbars from the browser */
  --bg: #0d1522;
  --text: #e4e8f0;
  --muted: #98a2b5;
  --surface: #172234;
  --line: #34445c;
  --chip: #26344a;
  --ink: #f4f6fa;
}
/* The JustGiving banner in the header, to match */
:root[data-theme="dark"] .fr-card { background: var(--surface); }
:root[data-theme="dark"] .fr-frame { color: var(--text); }
:root[data-theme="dark"] .fr-banner-label, :root[data-theme="dark"] .fr-banner-stats span { color: var(--muted); }
:root[data-theme="dark"] .fr-progress { background: var(--chip); }
:root[data-theme="dark"] .card, :root[data-theme="dark"] .auction-total { box-shadow: 0 2px 12px rgba(0, 0, 0, .35); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Thin header bar: brand · title · pledge in one row, account menu on the right. */
.hero {
  background: linear-gradient(135deg, var(--navy), #1d3f72);
  color: #fff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  padding: .55rem 1.75rem;
  position: relative;
  z-index: 70;
}
.brand { font-size: .85rem; letter-spacing: .2em; text-transform: uppercase; opacity: .85; }
.brand span { color: var(--accent); font-weight: 700; }
.hero h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.pledge { margin: 0; font-size: .9rem; opacity: .9; }
.pledge strong { color: var(--accent); }
.hero h1, .pledge { padding-left: 1rem; border-left: 1px solid rgba(255, 255, 255, .25); }
@media (max-width: 600px) {
  .hero { padding: .5rem 1rem; gap: .25rem .6rem; }
  .brand { font-size: .7rem; letter-spacing: .15em; }
  .hero h1 { font-size: .95rem; padding-left: .6rem; }
  .pledge { width: 100%; order: 5; padding-left: 0; border-left: 0; font-size: .82rem; }
  main { padding: .75rem 1.25rem .5rem; }
  footer { flex-wrap: wrap; gap: .5rem .9rem; padding-bottom: 1.25rem; }
  footer > span { order: 5; width: 100%; text-align: center; }
  .game-icon svg { width: 28px; height: 28px; } /* bigger tap targets */
}

.account { margin-left: auto; position: relative; }
.account-btn {
  background: rgba(255, 255, 255, .12); color: #fff; padding: .35rem .9rem;
  border: 1px solid rgba(255, 255, 255, .25); font-size: .85rem;
}
.account-btn:hover { background: rgba(255, 255, 255, .2); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + .5rem); width: 260px;
  background: var(--surface); color: var(--text); border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2); padding: 1rem;
}
.account-menu p { margin: 0 0 .8rem; font-size: .9rem; }
.account-menu p span { display: block; color: var(--muted); font-size: .8rem; word-break: break-all; }
.account-menu .secondary { width: 100%; }
.admin-link {
  display: block; text-align: center; text-decoration: none;
  border-radius: 8px; padding: .6rem 1rem; margin-bottom: .6rem;
}
.admin-link[hidden] { display: none; }
/* Invisible strip over the gap above the menu, so moving the mouse down from the button keeps it open */
.account-menu::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: .6rem; }

/* Theme controls at the bottom of the account menu: Dark mode switch, and System theme beside it */
.theme-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--chip);
  font-size: .82rem; color: var(--muted);
}
.theme-toggle, .theme-system { display: flex; align-items: center; gap: .45rem; cursor: pointer; white-space: nowrap; }
.theme-toggle:has(input:disabled) { cursor: default; }
.theme-system input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.theme-toggle input {
  appearance: none; margin: 0; width: 32px; height: 18px; border-radius: 999px; flex: none;
  background: var(--line); position: relative; cursor: pointer; transition: background .2s;
}
.theme-toggle input::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s;
}
.theme-toggle input:checked { background: var(--accent); }
.theme-toggle input:checked::before { transform: translateX(14px); }
.theme-toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-btn {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  border: 1px solid #8c8c8c; border-radius: 4px; padding: .55rem .8rem;
  color: #5e5e5e; font-weight: 600; font-size: .92rem; text-decoration: none; background: #fff;
}
.ms-btn:hover { background: #f3f3f3; }

html { overflow-x: clip; }

main { max-width: 1400px; margin: 0 auto; padding: 1rem 1.75rem .5rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(11, 31, 58, .08);
  display: flex;
  flex-direction: column;
}
.card-img-link { display: block; }
.card-title-link { color: inherit; text-decoration: none; }
.card-title-link:hover { text-decoration: underline; }
.card img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; display: block; }
.card .body { padding: .75rem .9rem .85rem; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.card h3 { margin: 0; font-size: 1.05rem; }
.desc { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.35; flex: 1; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stats > div { background: var(--bg); border-radius: 8px; padding: .35rem .6rem; }
.label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bid { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.timer { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer.soon { color: var(--danger); }
.meta { margin: 0; font-size: .8rem; color: var(--muted); }

.bid-form { display: flex; gap: .5rem; }
.input-wrap {
  flex: 1; display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 0 .6rem; background: var(--surface);
}
.input-wrap:focus-within { border-color: var(--ink); }
.input-wrap span { color: var(--muted); }
.input-wrap input { border: 0; outline: 0; width: 100%; padding: .5rem .3rem; font-size: 1rem; background: transparent; }

button { font: inherit; border-radius: 8px; padding: .6rem 1rem; cursor: pointer; border: 0; }
.primary { background: var(--accent); color: var(--navy); font-weight: 700; }
.primary:hover { filter: brightness(1.05); }
.secondary { background: var(--chip); color: var(--text); }
button:disabled, input:disabled { opacity: .5; cursor: not-allowed; }

.card.ended img { filter: grayscale(.8); }

/* You're the highest bidder: a green edge, and "Leading: You" in green */
.card.you-lead { box-shadow: 0 0 0 2px #12a06e, 0 2px 10px rgba(11, 31, 58, .08); }
.card.you-lead .meta { color: #12805c; font-weight: 600; }
:root[data-theme="dark"] .card.you-lead .meta { color: #4cc38a; }

/* "You won" banner above the cards */
.won-banner {
  background: linear-gradient(135deg, #e3f7ee, #fff4d6); color: #12392b; border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1rem; box-shadow: 0 2px 10px rgba(11, 31, 58, .08);
}
.won-banner h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.won-banner ul { margin: 0 0 .4rem; padding-left: 1.2rem; }
.won-banner a { color: inherit; font-weight: 700; }
.won-banner p { margin: 0; font-size: .9rem; }
:root[data-theme="dark"] .won-banner { background: linear-gradient(135deg, #123528, #3a2f10); color: #e4f5ec; }

/* Bid confirmation: large-bid warning and the automatic bidding option */
.bid-warning {
  background: #fff4d6; color: #6b4e00; border: 1px solid #f2d27a; border-radius: 8px; padding: .6rem .75rem; font-size: .9rem;
}
.bid-warning::before { content: "⚠ "; }
:root[data-theme="dark"] .bid-warning { background: #3a2f10; color: #ffe08a; border-color: #6b5a1e; }
dialog label.auto-bid { display: flex; gap: .5rem; align-items: flex-start; margin: .75rem 0; font-size: .9rem; cursor: pointer; }
dialog label.auto-bid[hidden] { display: none; }
dialog label.auto-bid input { margin: .2rem 0 0; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }

dialog {
  border: 0; border-radius: var(--radius); padding: 1.5rem; width: min(420px, 92vw);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(11, 31, 58, .55); }
dialog h2 { margin-top: 0; }
dialog .note { color: var(--muted); font-size: .9rem; }
dialog label { display: block; font-size: .9rem; margin: 1rem 0; }
dialog label input { display: block; width: 100%; margin-top: .3rem; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(calc(100% + 2rem));
  background: var(--navy); color: #fff; padding: .8rem 1.2rem; border-radius: 8px;
  transition: transform .25s ease; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

footer { display: flex; align-items: center; justify-content: center; gap: .4rem; color: var(--muted); font-size: .85rem; padding: .5rem 1rem .75rem; }
dialog label small { display: block; margin-top: .3rem; color: var(--muted); font-size: .8rem; }

/* Live fundraising banner: its own row under the header bar, signed-in users only */
.fr-header { width: 100%; order: 10; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .75rem; padding: .35rem 0 .45rem; }

/* Auction total beside the fundraising banner: same height and card look */
.auction-total {
  height: 90px; padding: 0 24px; display: flex; flex-direction: column; justify-content: center;
  background: var(--surface); color: var(--text); border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
  white-space: nowrap;
}
.auction-total-amount { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.auction-total-label { margin-top: .3rem; font-size: .8rem; color: var(--muted); }
@media (max-width: 760px) {
  .auction-total { height: auto; padding: .6rem 1rem; width: min(728px, 100%); align-items: center; }
  .auction-total-amount { font-size: 2rem; }
}
