/* ===========================================================================
   Duck race draw — "race day at the pond"
   Visual language borrowed from village duck races and horse racing race
   cards: numbered saddle cloths, silks, heats, a results board. Daylight, not
   dashboard.
   Signature: the silk chip — each duck's number set in Impact on that duck's
   own colour, repeated on the duck, the results board and the winner card.
   =========================================================================== */

:root {
  --wash:      #cfe9f2;   /* pale pond aqua, the page itself */
  --wash-deep: #b3dbe9;
  --paper:     #ffffff;
  --ink:       #0c2231;   /* harbour navy — all text */
  --ink-2:     #4a6a7d;   /* secondary text */
  --ink-3:     #7d99a8;   /* captions */
  --rule:      #cddde5;

  --pond:      #0d6e8a;
  --pond-deep: #08475c;
  --sun:       #ffc22e;   /* duck yellow — the primary accent */
  --sun-deep:  #e5a300;
  --flame:     #f2622c;   /* beak orange — actions and the winner */
  --reed:      #2e8b57;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  --display: 'Impact', 'Haettenschweiler', 'Arial Narrow Bold', 'Franklin Gothic Bold', sans-serif;
  --sans: ui-sans-serif, system-ui, 'Segoe UI', Roboto, Helvetica, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --shadow: 0 1px 2px rgba(12,34,49,.06), 0 6px 18px rgba(12,34,49,.07);
  --shadow-lg: 0 2px 4px rgba(12,34,49,.07), 0 18px 44px rgba(12,34,49,.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 460px at 50% -180px, #fff5d8 0%, transparent 62%),
    linear-gradient(var(--wash), var(--wash-deep) 620px, var(--wash-deep));
  background-attachment: fixed;
}

.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 20px 80px; }

a { color: #0b6b86; }
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--flame); outline-offset: 2px; border-radius: 4px;
}

/* ------------------------------------------------------------- masthead */
.top { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 3px; }
.top h1 {
  margin: 0; font-size: clamp(26px, 4.6vw, 38px); font-weight: 900;
  letter-spacing: -.03em; line-height: 1.05;
}
.sub { color: var(--ink-2); font-size: 14.5px; margin-bottom: 24px; max-width: 62ch; }
.sub b { color: var(--ink); }

.pill {
  font: 700 10.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 99px; color: var(--ink);
  background: var(--sun); border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.pill.live { background: var(--reed); color: #fff; }

.mini {
  font: 600 13px var(--sans); color: var(--ink-2); text-decoration: none;
  background: rgba(255,255,255,.7); border: 1px solid var(--rule);
  border-radius: 99px; padding: 6px 12px; cursor: pointer;
}
.mini:hover { color: var(--ink); border-color: var(--ink-3); background: #fff; }
.mini.del { color: #b4441f; }

/* ----------------------------------------------------------------- hero
   The page opens with the product itself: a pond of numbered ducks. */
.hero {
  position: relative; border: 2px solid var(--ink); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 18px; box-shadow: 7px 7px 0 var(--ink);
  background: var(--pond-deep);
}
.hero canvas {
  display: block; width: 100%; height: 232px;
  border-top: 5px solid var(--reed);
}
.hero-copy {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center; gap: 9px;
  padding: 0 clamp(18px, 5vw, 46px);
  background: linear-gradient(100deg, rgba(4,38,50,.93) 0%, rgba(4,38,50,.78) 42%, rgba(4,38,50,0) 78%);
}
.hero-copy h1 {
  margin: 0; color: #fff; font-weight: 900; letter-spacing: -.04em;
  font-size: clamp(30px, 6.4vw, 52px); line-height: .95;
  text-shadow: 0 2px 14px rgba(0,0,0,.35);
}
.hero-copy p {
  margin: 0; color: #cfeaf4; font-size: 14.5px; max-width: 34ch; line-height: 1.5;
}
.hero-copy .pill { box-shadow: 2px 2px 0 rgba(0,0,0,.45); }

/* the three steps, as an actual sequence */
.steps {
  list-style: none; counter-reset: s; margin: 0 0 26px; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.steps li {
  counter-increment: s; position: relative;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 14px 16px 15px 16px; font-size: 13.2px; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.steps li::before {
  content: counter(s); display: grid; place-items: center;
  width: 29px; height: 29px; margin-bottom: 8px;
  font: 400 19px/1 var(--display); color: var(--ink);
  background: var(--sun); border: 1.5px solid var(--ink); border-radius: 50%;
  box-shadow: 2px 2px 0 var(--ink);
}
.steps li b { display: block; color: var(--ink); font-size: 14.5px; font-weight: 750; margin-bottom: 2px; }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-lg); margin-bottom: 14px; overflow: hidden;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--rule); flex-wrap: wrap;
  background: linear-gradient(#fff, #f6fbfd);
}
.card-head h2 {
  margin: 0; font-size: 16.5px; font-weight: 800; letter-spacing: -.015em;
  display: flex; align-items: center; gap: 10px;
}
.card-head .step {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  font: 400 17px/1 var(--display); color: var(--ink);
  background: var(--sun); border: 1.5px solid var(--ink); border-radius: 50%;
}
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 18px 18px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .07em; }
input[type=text] {
  width: 100%; margin-top: 6px; font: 15px var(--sans); color: var(--ink);
  background: #fbfdfe; border: 1.5px solid var(--rule);
  border-radius: var(--r-sm); padding: 10px 12px;
}
input[type=text]:focus { border-color: var(--pond); background: #fff; }
textarea {
  width: 100%; min-height: 180px; color: var(--ink); background: #fbfdfe;
  border: 1.5px solid var(--rule); border-radius: var(--r-sm); padding: 12px;
  font: 13px/1.6 var(--mono); resize: vertical;
}
textarea:focus { border-color: var(--pond); background: #fff; }

/* ------------------------------------------------------------ preview */
.preview { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; margin-top: 14px; }
.pv {
  flex: 1 1 108px; background: #f2fafd; border: 1px solid var(--rule);
  border-radius: var(--r-sm); padding: 10px 12px;
}
.pv b { display: block; font: 700 21px/1.15 var(--mono); letter-spacing: -.03em; color: var(--pond); }
.pv span { font-size: 11.5px; color: var(--ink-2); }
.pv-note, .go-note { font-size: 13px; color: var(--ink-2); }
.pv-note { flex: 1 1 100%; }
.warn { color: #a8431c; font-weight: 600; }
.empty, .none { color: var(--ink-2); font-size: 14px; }

/* -------------------------------------------------------------- buttons */
button { font: 650 14.5px var(--sans); cursor: pointer; }
button, .cta {
  background: var(--ink); color: #fff; border: 0;
  border-radius: 99px; padding: 9px 18px;
}
button:hover { background: #17384c; }
button.ghost {
  background: #fff; color: var(--ink); border: 1.5px solid var(--rule);
}
button.ghost:hover { background: #f3fafc; border-color: var(--ink-3); }
button:disabled { opacity: .4; cursor: not-allowed; }

.go { text-align: center; margin: 26px 0 8px; }
.cta {
  font: 800 19px var(--sans); letter-spacing: -.01em;
  background: var(--flame); color: #fff;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 14px 34px; transition: transform .12s ease, box-shadow .12s ease;
}
.cta:hover:not(:disabled) { background: #ff6f38; transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.cta:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.cta:disabled { background: #b9cdd6; border-color: #8fa9b5; box-shadow: 4px 4px 0 #8fa9b5; }
.go-note { margin-top: 11px; }

/* --------------------------------------------------------- the pond */
.stage {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
}
.stage-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 18px; flex-wrap: wrap;
  background: linear-gradient(#fff, #f6fbfd); border-bottom: 1px solid var(--rule);
}
.stage-head h2 { margin: 0; font-size: 17px; font-weight: 850; letter-spacing: -.02em; }
.stage-head .meta { color: var(--ink-2); font-size: 13px; }

/* the water sits inset, like looking down into a pond */
/* One height for every race. The lean of the start and finish lines is a
   function of the water's height, so a taller canvas in the final made its
   lines slope differently from race 1's — the two stages have to match. */
canvas#track {
  display: block; width: 100%; height: 490px;
  background: var(--pond-deep);
  border-top: 5px solid var(--reed);      /* the grass bank */
  box-shadow: inset 0 8px 22px rgba(0,0,0,.28);
}

.controls {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px; flex-wrap: wrap;
  border-top: 1px solid var(--rule); background: #fafdfe;
}
input[type=range] { accent-color: var(--pond); flex: 1; min-width: 130px; }
.clock { font: 600 13px var(--mono); color: var(--ink-2); min-width: 62px; }

/* ------------------------------------------------------- results board */
.cols { display: grid; grid-template-columns: 1fr 306px; gap: 14px; align-items: start; }
@media (max-width: 880px) { .cols { grid-template-columns: 1fr; } }

.board {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow);
}
.board h3 {
  margin: 0; padding: 13px 16px; font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2);
  border-bottom: 1px solid var(--rule); background: linear-gradient(#fff, #f6fbfd);
}
.board ol { list-style: none; margin: 0; padding: 6px; max-height: 438px; overflow-y: auto; }
.board li {
  display: flex; align-items: center; gap: 10px; padding: 5px 8px;
  border-radius: var(--r-sm); font-size: 13.5px;
}
.board li .pos {
  width: 20px; text-align: right; font: 600 12px var(--mono); color: var(--ink-3);
}
.board li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board li .pct { font: 600 11.5px var(--mono); color: var(--ink-3); }
/* a row that opens to show who is riding that duck */
.board li.has-riders { flex-wrap: wrap; cursor: pointer; }
.board li.has-riders .nm::after {
  content: ' ▾'; color: var(--ink-3); font-size: 11px;
}
.board li.open .nm::after { content: ' ▴'; }
.riders {
  display: none; flex-basis: 100%; margin: 6px 0 2px;
  max-height: 168px; overflow-y: auto;
  background: #f2fafd; border: 1px solid var(--rule); border-radius: var(--r-sm);
  padding: 7px 9px;
}
.board li.has-riders:hover .riders,
.board li.open .riders { display: block; }
.riders span {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  padding: 1.5px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.riders .seat { color: var(--ink-3); font-style: italic; font-weight: 500; }

.board li.lead { background: #fff6dd; }
.board li.win { background: var(--sun); box-shadow: inset 0 0 0 1.5px var(--ink); }
.board li.win .nm { font-weight: 800; }
.board li.win .pos, .board li.win .pct { color: #6b5304; }

/* the signature: a saddle cloth carrying the duck's number in its own colour */
.silk {
  flex: none; display: grid; place-items: center;
  min-width: 26px; height: 24px; padding: 0 5px;
  font: 400 16px/1 var(--display); letter-spacing: .01em;
  color: #fff; -webkit-text-stroke: .5px rgba(0,0,0,.55);
  background: hsl(var(--h, 40) 78% 46%);
  border: 1.5px solid var(--ink); border-radius: 5px;
  box-shadow: 1.5px 1.5px 0 rgba(12,34,49,.35);
}
.silk.lg { min-width: 44px; height: 40px; font-size: 27px; border-radius: 7px; box-shadow: 3px 3px 0 var(--ink); }

/* ------------------------------------------------------------- winner */
.winner {
  display: none; margin: 16px 0; padding: 24px 22px; text-align: center;
  background:
    repeating-linear-gradient(45deg, #fff8e2 0 14px, #fff3d0 14px 28px);
  border: 2px solid var(--ink); border-radius: var(--r-lg);
  box-shadow: 6px 6px 0 var(--ink);
}
.winner.on { display: block; animation: pop .5s cubic-bezier(.2,.9,.3,1.35); }
@keyframes pop { from { transform: scale(.93) translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }
.winner .who {
  font-size: clamp(28px, 6vw, 46px); font-weight: 900; letter-spacing: -.035em;
  line-height: 1.05; margin: 4px 0;
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.winner .det { color: #6b5304; font-size: 14px; font-weight: 600; margin-top: 6px; }
.winner button { margin-top: 14px; background: var(--ink); }

/* --------------------------------------------------------------- misc */
.note {
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 5px solid var(--sun); border-radius: var(--r);
  padding: 13px 16px; font-size: 13.5px; color: var(--ink-2); margin: 16px 0;
  box-shadow: var(--shadow);
}
.note b { color: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tile { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 13px 15px; box-shadow: var(--shadow); }
.tile b { display: block; font: 700 24px/1.1 var(--mono); letter-spacing: -.04em; color: var(--pond); }
.tile span { font-size: 11.5px; color: var(--ink-2); }

h2.sect {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-2); margin: 30px 0 11px;
}

/* Race nav + a status strip of fixed height. The result is announced in here
   and inside the water, never in a banner that appears above the race and
   shoves it down the page. */
.navrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; }
.navrow .links { margin: 0; }
.status {
  flex: 1; min-width: 210px; min-height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-radius: 99px;
  background: var(--paper); border: 1px solid var(--rule);
  font-size: 14px; font-weight: 650; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.status .st-dot {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-3);
}
.status.racing { border-color: var(--pond); color: var(--ink); }
.status.racing .st-dot { background: var(--pond); animation: blip 1s infinite; }
.status.ready .st-dot { background: var(--sun); }
.status.won {
  background: var(--sun); border-color: var(--ink); color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.status.won .st-dot { background: var(--ink); }
@keyframes blip { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.mini.home { font-weight: 700; }

.links { display: flex; gap: 9px; flex-wrap: wrap; margin: 16px 0; }
.links a {
  color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 700;
  background: var(--paper); border: 1.5px solid var(--rule);
  border-radius: 99px; padding: 8px 16px;
}
.links a:hover { border-color: var(--ink-3); }
.links a.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* saved draws */
.draw {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 12px 15px; margin-bottom: 9px; box-shadow: var(--shadow);
}
.draw-main { flex: 1; min-width: 190px; }
.draw-main b { font-weight: 750; }
.draw-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.draw-act { display: flex; gap: 7px; flex-wrap: wrap; }

/* collapsible detail */
.more {
  margin-top: 22px; background: rgba(255,255,255,.6);
  border: 1px solid var(--rule); border-radius: var(--r); padding: 0 16px;
}
.more summary {
  cursor: pointer; padding: 13px 0; font-weight: 750; font-size: 14px;
  color: var(--ink); list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '▸ '; color: var(--flame); }
.more[open] summary::before { content: '▾ '; }
.more summary.quiet { font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.more summary.quiet:hover { color: var(--ink); }
.more-body { padding-bottom: 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.68; }
.more-body p { margin: 0 0 12px; }
.more-body b { color: var(--ink); }

/* Technical detail nobody needs in order to use this — present for anyone
   checking the draw, small enough never to compete with the race. */
.tech { font-size: 11.5px; line-height: 1.6; color: var(--ink-2); }
.tech b { color: var(--ink); font-weight: 700; }
.tech .kv { display: block; margin-top: 6px; word-break: break-all;
  font: 10.5px var(--mono); color: var(--ink-3); }
.tech table.log { font-size: 10.5px; }
.tech table.log th { font-size: 9.5px; }
.tech .scroll { max-height: 230px; }

.scroll { max-height: 320px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--r-sm); background: #fff; }
table.log { width: 100%; border-collapse: collapse; font-size: 12px; }
table.log th, table.log td { padding: 5px 9px; text-align: left; border-bottom: 1px solid var(--rule); }
table.log th { color: var(--ink-2); font-weight: 700; text-transform: uppercase;
  font-size: 9.5px; letter-spacing: .09em; background: #f6fbfd; position: sticky; top: 0; }
table.log td.n { font-family: var(--mono); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.hash { color: var(--ink-3); word-break: break-all; }

/* ------------------------------------------------------------- narrow */
@media (max-width: 720px) {
  .steps { grid-template-columns: 1fr; }
  /* stack the copy at the top and let the scrim fall away, so the ducks are
     still visible underneath rather than drowned by a full-height wash */
  .hero canvas { height: 272px; }
  .hero-copy {
    justify-content: flex-start; padding-top: 20px;
    background: linear-gradient(180deg, rgba(4,38,50,.94) 0%, rgba(4,38,50,.88) 48%,
                rgba(4,38,50,.35) 74%, rgba(4,38,50,0) 100%);
  }
  .hero-copy p { max-width: 30ch; }
  .fields { grid-template-columns: 1fr; }
  .wrap { padding: 20px 14px 64px; }
  canvas#track { height: 380px; }
  .cta { width: 100%; }
}

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

/* ------------------------------------------------------- sign-in bar
   States the page needs to distinguish: signed out, signed in but not yet
   approved, approved, and sign-in failed. Failing silently at the last click
   is the worst of these, so each gets its own colour and its own sentence. */
.authbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 5px solid var(--ink-3);
  border-radius: var(--r); padding: 12px 16px; margin-bottom: 18px;
  font-size: 14px; color: var(--ink-2); box-shadow: var(--shadow);
}
.authbar span { flex: 1; min-width: 200px; }
.authbar b { color: var(--ink); }
.authbar code {
  background: #eef6fa; border: 1px solid var(--rule);
  border-radius: 5px; padding: 1px 6px; font-size: 12px; color: var(--ink);
}
.authbar.ok { border-left-color: var(--reed); }
.authbar.warnbar { border-left-color: var(--sun-deep); }
.authbar.bad { border-left-color: #c2410c; }
