/* Hexathlon — an honours board for a very serious weekend of silly games.
   Navy field, gold leaf, engraved serif headings, scoreboard mono numbers. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,900&family=DM+Sans:wght@400;500;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --field: #0a1826;
  --field-2: #0d1e30;
  --panel: #10233a;
  --panel-2: #16304b;
  --line: #21456d;
  --line-soft: #1a3550;
  --ink: #f2f6fb;
  --ink-dim: #8ba6c4;
  --ink-faint: #5c7997;

  --gold: #e7b23e;
  --gold-bright: #ffd97a;
  --gold-deep: #9a7220;

  --bronze: #c67b46;
  --silver: #b8c4d0;
  --tier-gold: #e7b23e;

  --champ: #e7b23e;
  --chump: #d8695f;
  --up: #4fc281;

  --r: 10px;
  --pad: clamp(14px, 4vw, 22px);
  --maxw: 720px;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }

html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; max-width: 100%; }

body {
  font-family: var(--sans);
  background: var(--field);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  background-image:
    radial-gradient(1100px 600px at 50% -8%, rgba(231, 178, 62, 0.10), transparent 60%),
    linear-gradient(180deg, #0b1a2b, #0a1826 40%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------- shell ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad) 28px; }

/* in-page footer link (added by mountShell) — scroll to it, it's not in the nav */
.pagefoot {
  max-width: var(--maxw); margin: 10px auto 0;
  padding: 20px var(--pad) calc(92px + env(safe-area-inset-bottom));
  text-align: center; border-top: 1px solid var(--line-soft);
}
.pagefoot a {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.pagefoot a:hover { color: var(--gold); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  /* clear the status bar / Dynamic Island in an installed PWA */
  padding: calc(10px + env(safe-area-inset-top)) var(--pad) 10px;
  background: rgba(9, 20, 33, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .crest { width: 34px; height: 34px; border-radius: 7px; flex: none;
  box-shadow: 0 0 0 1px var(--line), 0 2px 10px rgba(0,0,0,0.4); }
.topbar .title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar .title b {
  font-family: var(--display); font-weight: 900; font-size: 18px;
  letter-spacing: 0.02em; color: var(--gold-bright);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .title span { font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.12em; }
.topbar .spacer { flex: 1; }
.topbar .who {
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  white-space: nowrap;
}
.topbar .who.hm { color: var(--gold); border-color: var(--gold-deep); }

/* ---------- status line ---------- */
.statusline {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 16px 2px 10px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.live { background: var(--up); box-shadow: 0 0 0 4px rgba(79, 194, 129, 0.18); animation: pulse 2s infinite; }
.dot.final { background: var(--gold); }
@keyframes pulse { 50% { opacity: 0.45; } }
.statusline .livelink {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold); border: 1px solid var(--gold-deep); border-radius: 999px; padding: 3px 10px;
  white-space: nowrap; max-width: 62%; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- section ---------- */
.section { margin-top: 30px; }
.section > h2 {
  font-family: var(--mono); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.22em; color: var(--gold);
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.section > h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

/* ---------- standings ledger ---------- */
.ledger { display: flex; flex-direction: column; gap: 4px; }
.row {
  position: relative; overflow: hidden;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center; gap: 10px;
  padding: 12px 14px 12px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: var(--r);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s;
}
/* comparable "how much of the leader's total" bar behind each row */
.row .rowbar {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0; pointer-events: none;
  border-radius: var(--r) 0 0 var(--r);
  background: linear-gradient(90deg, rgba(139,166,196,0.26), rgba(139,166,196,0.05));
  border-right: 1px solid rgba(139,166,196,0.13);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.row > .rank, .row > .who2, .row > .total, .row > .row-detail { position: relative; z-index: 1; }
.row.leader { border-left-color: var(--gold); background: linear-gradient(90deg, rgba(231,178,62,0.13), var(--panel) 55%); }
.row.leader .rowbar { background: linear-gradient(90deg, rgba(231,178,62,0.24), rgba(231,178,62,0.06)); }
.row.chumpwatch { border-left-color: rgba(216, 105, 95, 0.6); }
.row.flash { animation: flash 1.1s ease; }
@keyframes flash { 0% { background: rgba(231, 178, 62, 0.32); } 100% {} }

.row .rank {
  font-family: var(--display); font-weight: 900; font-size: 22px;
  color: var(--ink-faint); text-align: center; font-variant-numeric: tabular-nums;
}
.row .rank.has-medal { font-size: 18px; font-weight: 400; }
.row.leader .rank, .row .rank.medal { color: var(--gold); }
.row .rank.silver { color: var(--silver); }
.row .rank.bronze { color: var(--bronze); }

.row .who2 { min-width: 0; }
.row .name {
  font-family: var(--display); font-weight: 600; font-size: 19px;
  letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .sub {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  display: flex; gap: 8px; margin-top: 2px;
}
.row .tag { color: var(--ink-dim); }
.row .tag.core { color: var(--gold); }

.row .total {
  font-family: var(--mono); font-weight: 500; font-size: 21px;
  font-variant-numeric: tabular-nums; text-align: right; letter-spacing: -0.01em;
}
.row .total small { font-size: 11px; color: var(--ink-faint); display: block; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 400; }

/* per-activity strip under a row (expandable) */
.row-detail {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px; margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.chipscore { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.chipscore b { display: block; color: var(--ink); font-size: 14px; font-weight: 500; }
.chipscore.tier-bronze b { color: var(--bronze); }
.chipscore.tier-silver b { color: var(--silver); }
.chipscore.tier-gold b { color: var(--tier-gold); }

/* ---------- hex activity chips ---------- */
.hexrow {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}

.hexchip {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 7px; padding: 12px 4px 10px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.hexchip .hx {
  width: 46px; height: 46px; display: grid; place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--panel-2); border: 0; color: var(--ink-dim);
}
.hexchip .hx svg { width: 24px; height: 24px; }
/* tier colour — the hexagon carries it */
.hexchip.tier-bronze .hx { background: color-mix(in srgb, var(--bronze) 40%, var(--panel-2)); color: color-mix(in srgb, var(--bronze) 55%, var(--ink)); }
.hexchip.tier-silver .hx { background: color-mix(in srgb, var(--silver) 34%, var(--panel-2)); color: color-mix(in srgb, var(--silver) 55%, var(--ink)); }
.hexchip.tier-gold   .hx { background: color-mix(in srgb, var(--tier-gold) 40%, var(--panel-2)); color: color-mix(in srgb, var(--tier-gold) 60%, var(--ink)); }
.hexchip .lbl { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hexchip .st { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.hexchip .st.done { color: var(--up); }
.hexchip .st.live { color: var(--gold-bright); }
.hexchip .st.pending { color: var(--ink-faint); }
.hexchip.is-live { border-color: var(--gold-deep); box-shadow: 0 0 0 1px var(--gold-deep) inset; }

/* ---------- trophy case ---------- */
.cases { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.case {
  border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  background: var(--panel); position: relative; overflow: hidden;
}
.case .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); }
.case .v { font-family: var(--display); font-weight: 900; font-size: 26px; margin-top: 4px; }
.case .meta { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.case.champ { border-color: var(--gold-deep); background: linear-gradient(160deg, rgba(231,178,62,0.16), var(--panel) 60%); }
.case.champ .v { color: var(--gold-bright); }
.case.chump .v { color: var(--chump); }
.case .stamp {
  position: absolute; right: -10px; top: 8px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-faint);
  transform: rotate(8deg); border: 1px solid var(--line); padding: 3px 22px;
}

.pool {
  margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; background: var(--panel); display: flex; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
}
.pool .amt { font-family: var(--mono); font-size: 20px; color: var(--gold-bright); }
.pool .split { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); }

/* ---------- generic cards / forms ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--pad); margin-top: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim); }
.input, select.input {
  background: var(--field-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; color: var(--ink); width: 100%;
}
.input:focus, select.input:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 16px; font-family: var(--mono); font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.btn.primary { background: var(--gold); color: #1a1204; border-color: var(--gold); font-weight: 500; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.pill {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim);
}
.pill.bronze { color: var(--bronze); border-color: color-mix(in srgb, var(--bronze) 50%, var(--line)); }
.pill.silver { color: var(--silver); border-color: color-mix(in srgb, var(--silver) 40%, var(--line)); }
.pill.gold { color: var(--tier-gold); border-color: var(--gold-deep); }

.muted { color: var(--ink-dim); }
.err { color: var(--chump); font-family: var(--mono); font-size: 13px; }
.ok { color: var(--up); font-family: var(--mono); font-size: 13px; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--ink-dim);
}
.empty h3 { font-family: var(--display); font-weight: 900; font-size: 24px; color: var(--ink); margin-bottom: 8px; }

/* bottom nav — fixed to the very bottom edge; the home-indicator area is
   padded so tap targets clear it, but the bar's fill runs to the edge.
   Solid fill + no backdrop-filter: iOS Safari can detach/shift a fixed element
   that has a backdrop-filter during navigation. */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: #0b1a2b;
  border-top: 1px solid var(--line);
  padding: 7px 4px calc(4px + env(safe-area-inset-bottom));
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); padding: 4px 9px;
}
.nav a.on { color: var(--gold); }
.nav a svg { width: 20px; height: 20px; }

/* draw reveal slots (Draws page + per-activity bracket draws) */
.slot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.slot .k { font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.1em; min-width: 52px; }
.slot .v { font-family: var(--display); font-weight: 600; font-size: 19px; }
.slot.spinning .v { color: var(--ink-dim); filter: blur(0.5px); opacity: 0.75; }
.slot.landed { border-color: var(--gold-deep); animation: lockin 0.42s cubic-bezier(0.2, 1.4, 0.4, 1); }
.slot.landed .v { color: var(--gold-bright); }
@keyframes lockin {
  0% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(231,178,62,0.5); }
  40% { transform: scale(1.015); box-shadow: 0 0 0 5px rgba(231,178,62,0.16); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231,178,62,0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
