:root {
  /* Instaheats is white type on black, set like a contest poster.
     Colour belongs to the surfers: jerseys only. Jersey red also marks time-up and delete. */
  --bg: #0A0A0A;
  --fg: #FFFFFF;
  --muted: #A8A8A8;
  --rule: #444444;
  --fill: #1F1F1F;
  --warn: #D7263D;
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, sans-serif;
  color-scheme: only dark;
}
/* Samsung Internet's dark mode repaints pages it thinks are light: white buttons go grey and
   jersey colours go muddy. It looks for the colour-scheme meta tag and for a dark-mode media
   query to decide a page already has its own dark theme. This rule is that signal. */
@media (prefers-color-scheme: dark) { :root { color-scheme: only dark; } }
@media (prefers-color-scheme: light) { :root { color-scheme: only dark; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 17px/1.4 var(--body);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 540px; margin: 0 auto; padding: 16px 16px 124px; }
h1, h2, h3, .num { font-family: var(--display); }
h1, h2 { text-wrap: balance; text-transform: uppercase; font-weight: 800; margin: 0; }
h1.wm { font-size: min(36.5vw, 198px); line-height: .8; letter-spacing: -.025em; margin: 18px 0 0 -4px; }
h1.head { font-size: clamp(64px, 24vw, 120px); line-height: .82; letter-spacing: -.02em; margin: 10px 0 14px -2px; }
h2 { font-size: clamp(44px, 15.5vw, 84px); line-height: .86; letter-spacing: -.015em; overflow-wrap: anywhere; }
h2.plain { font-size: 40px; line-height: .95; }
h3 { font-size: 17px; margin: 30px 0 0; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-bottom: 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
h1.wm .ln { display: block; overflow: hidden; padding: .06em 0 .03em; margin: -.06em 0 -.03em; }
h1.wm .in { display: block; }
/* Logo reveal, "heat sheet": the bars arrive like scores coming in, then each line of the
   name rises from behind an edge. Every start state lives in the keyframes, so with motion
   switched off the poster is simply there. */
.reveal .mark .tile { transform-box: fill-box; transform-origin: center; animation: rv-tile .4s cubic-bezier(.16,.84,.24,1) both; }
.reveal .mark .bar { transform-box: fill-box; transform-origin: left center; animation: rv-grow .5s cubic-bezier(.16,.84,.24,1) both; animation-delay: calc(.2s + var(--n) * .11s); }
.reveal .wm .in { animation: rv-rise .8s cubic-bezier(.16,.84,.24,1) both; animation-delay: calc(.5s + var(--l) * .13s); }
.reveal .late { animation: rv-up .6s cubic-bezier(.16,.84,.24,1) 1.15s both; }
.reveal .late.l2 { animation-delay: 1.27s; }
@keyframes rv-tile { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }
@keyframes rv-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rv-rise { from { transform: translateY(108%); } to { transform: none; } }
@keyframes rv-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.lede { font-size: 18px; color: #C8C8C8; margin: 20px 0 0; max-width: 24em; }

:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
::selection { background: var(--fg); color: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 56px; padding: 12px 18px; border-radius: 12px;
  background: var(--fg); color: var(--bg); font: 600 22px var(--display);
  text-transform: uppercase; letter-spacing: .03em;
  transition: transform .12s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1.5px var(--fg); }
.btn.quiet { background: transparent; color: var(--muted); min-height: 44px; font-size: 18px; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.top { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 4px; }
.back { font: 600 18px var(--display); text-transform: uppercase; color: var(--muted); min-height: 44px; padding-right: 12px; letter-spacing: .04em; }
.markbtn { display: inline-flex; min-height: 44px; align-items: center; }
.markbtn svg, .mark { width: 40px; height: 40px; display: block; }

/* setup form */
.card { border: 1.5px solid var(--rule); border-radius: 14px; padding: 14px 16px; }
label { display: block; font: 600 16px var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
input[type=text], textarea, select {
  width: 100%; font: 500 18px var(--body); color: var(--fg); background: var(--bg);
  border: 1.5px solid var(--fg); border-radius: 10px; padding: 12px;
}
::placeholder { color: #7A7A7A; opacity: 1; }
input[type=text] { min-height: 52px; }
select { -webkit-appearance: none; appearance: none; min-height: 52px; padding-right: 40px; font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px; }
input:focus, textarea:focus, select:focus { outline: none; box-shadow: 0 0 0 2px var(--fg); }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
textarea.bad { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.fielderror { color: #FF6B7D; font-weight: 600; margin: 8px 0 0; }

/* new comp steps */
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; min-height: 52px; border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--fg); font: 600 21px var(--display); text-transform: uppercase;
              transition: background .15s ease, color .15s ease; }
.seg button.on { background: var(--fg); color: var(--bg); }
.countnote { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; }
.countnote .count { font: 700 22px var(--display); text-transform: uppercase; }
.countnote .repeat { flex-basis: 100%; font-size: 15px; font-weight: 600; }
.planrow { border-top: 1px solid var(--rule); padding: 12px 0; display: flex; gap: 14px; }
.planrow b { font: 700 20px/1.2 var(--display); text-transform: uppercase; width: 96px; flex: none; overflow-wrap: anywhere; }
.planrow span { flex: 1; }
.bigstat { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 14px 0; display: flex; gap: 14px; align-items: center; }
.bigstat .num { font: 800 84px/.8 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rules { color: var(--muted); font-size: 15px; margin: 14px 0 0; }

/* the draw, spun: each seat runs through names and eases to a stop on the one drawn.
   The idle loop repeats seamlessly (the strip holds the names twice), and the stop curve
   starts at the idle speed so there is no jolt where one hands over to the other. */
.reel { flex: 1; min-width: 0; height: 30px; overflow: hidden; }
.reel .strip, .reel .strip span { display: block; }
.reel .strip span { height: 30px; line-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spin .strip { animation: reel-stop 1.1s cubic-bezier(.3,.4,.2,1) calc(var(--idle) * var(--loops)) both,
                          reel-idle var(--idle) linear 0s var(--loops); will-change: transform; }
.spin .reel { animation: reel-lock .4s ease calc(var(--idle) * var(--loops) + .7s) both; }
@keyframes reel-idle { from { transform: translateY(0); } to { transform: translateY(calc(var(--k) * -30px)); } }
@keyframes reel-stop { from { transform: translateY(0); } to { transform: translateY(calc(var(--k) * -60px)); } }
@keyframes reel-lock { from { opacity: .4; } to { opacity: 1; } }

/* Insta Heat: one field per jersey */
.qrow { display: flex; gap: 10px; align-items: stretch; margin-top: 10px; }
.qrow .qband { width: 16px; flex: none; border: 1.5px solid var(--fg); border-radius: 3px; }
.qrow input { flex: 1; min-height: 56px; font: 600 22px var(--display); text-transform: uppercase; }
.qrow input::placeholder { text-transform: uppercase; }

/* raced sports: lanes are numbers, never colours */
.seg.two { display: grid; grid-template-columns: 1fr 1fr; }
.lane { min-width: 24px; height: 22px; padding: 0 4px; flex: none; display: inline-flex; align-items: center; justify-content: center;
        border: 1.5px solid var(--fg); border-radius: 4px; font: 700 15px/1 var(--display); font-variant-numeric: tabular-nums; }
.btn .jersey, .btn .lane { margin-right: 10px; }
.surfer.race { display: flex; align-items: center; gap: 14px; padding: 12px 0; min-height: 72px; }
.surfer.race .lanebig { width: 46px; flex: none; text-align: center; font: 800 46px/.9 var(--display); font-variant-numeric: tabular-nums; color: #777; }
.surfer.race .inner { flex: 1; min-width: 0; display: block; }
.surfer.race .who { align-items: center; }
.surfer.race .total { font-size: 38px; }
.surfer.race.in .lanebig { color: var(--fg); }
.surfer.race:not(.in)[disabled] .name { color: var(--muted); }

/* division tabs: words, not pills */
.tabs { display: flex; gap: 20px; overflow-x: auto; margin: 14px 0 0; }
.tab { flex: none; min-height: 44px; font: 700 22px var(--display); text-transform: uppercase; color: #777; border-bottom: 3px solid transparent; }
.tab.on { color: var(--fg); border-bottom-color: var(--fg); }

/* jerseys */
.jersey { width: 11px; height: 22px; border-radius: 2px; flex: none; display: inline-block; border: 1.5px solid var(--fg); }
.j0 { background: #D7263D; } .j1 { background: #FFFFFF; } .j2 { background: #F6C90E; }
.j3 { background: #1B65C9; } .j4 { background: #1E9E5A; } .j5 { background: #0A0A0A; }

/* numbered blocks: comps and heats */
.blk { display: flex; gap: 14px; width: 100%; text-align: left; padding: 14px 0; border-top: 1px solid var(--rule); align-items: flex-start; transition: opacity .15s ease; }
.blk:active { opacity: .7; }
.blk .no { font: 800 60px/.82 var(--display); width: 66px; flex: none; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.blk.done .no { color: #555; }
.blk .ls { flex: 1; min-width: 0; }
.blk .line { display: flex; align-items: center; gap: 9px; min-height: 30px; font: 600 19px/1.2 var(--display); text-transform: uppercase; }
.blk .line .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk .line .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.blk .line.out { color: #777; }
.blk .state { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; min-height: 22px; }
.blk .cname { font: 700 28px/1 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.blk .csub { color: var(--muted); font-size: 15px; margin-top: 5px; }
.blk .go { font: 600 34px/.8 var(--display); color: var(--muted); align-self: center; }
.podium .no { color: var(--fg); }
.pill { font: 700 15px var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pill.next { color: var(--fg); border: 1.5px solid var(--fg); border-radius: 4px; padding: 0 7px; }
.pill.live { background: var(--fg); color: var(--bg); border-radius: 4px; padding: 1px 8px; display: inline-flex; align-items: center; gap: 6px; }
.pill.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--bg); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.through { font: 700 15px var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.links { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 10px; }
.link { min-height: 44px; font: 600 18px var(--display); text-transform: uppercase; letter-spacing: .03em;
        text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.link.danger { color: #FF6B7D; }

/* heat screen */
.kicker { font: 700 17px var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
.clock { padding: 10px 0 12px; }
.clock .time { display: inline-block; font: 800 min(36vw, 204px)/.8 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums;
               padding: var(--ct, .05em) var(--cr, .1em) var(--cb, .15em) var(--cl, .1em); margin-left: calc(var(--cl, .1em) * -1); border-radius: .08em;
               transition: background .4s ease, transform .4s ease; }
/* Time up: a red block with the same space on every side of the digits. The padding is always
   there, so nothing below moves when the block appears; the block slides in to sit on the margin. */
.clock.over .time { background: var(--warn); transform: translateX(var(--cl, .1em)); }
/* Measured in Barlow Condensed 800: digits run 0 to .71em above the baseline, the colon 0 to .50em.
   Lifting it .1em puts its middle on the digits' middle. */
.clock .colon { position: relative; top: -.1em; }
.clocklinks { display: flex; flex-wrap: wrap; gap: 0 22px; }
.clock #clocknote { margin-top: 8px; }
.clock .link { font-size: 16px; min-height: 44px; color: var(--muted); display: block; }
.closed { margin: 0 0 6px; padding: 10px 12px; border-radius: 10px; background: var(--fill); font-size: 16px; }
.surfer { display: block; width: 100%; text-align: left; border-top: 1px solid var(--rule); padding: 12px 0 12px 24px; position: relative; transition: opacity .15s ease; }
.surfer:active { opacity: .7; }
.surfer[disabled] { cursor: default; } .surfer[disabled]:active { opacity: 1; }
.surfer .band { position: absolute; left: 0; top: 10px; bottom: 10px; width: 12px; border: 1.5px solid var(--fg); border-radius: 2px; }
.surfer .who { display: flex; align-items: baseline; gap: 8px; }
.surfer .place { font: 700 20px var(--display); color: #8A8A8A; text-transform: uppercase; }
.surfer.is-through .place { color: var(--fg); }
.surfer .name { flex: 1; font: 600 23px/1.1 var(--display); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.surfer .total { font: 700 44px/.9 var(--display); font-variant-numeric: tabular-nums; }
.surfer .waves { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; min-height: 28px; align-items: center; }
.chip { font: 600 18px var(--display); padding: 2px 9px; border-radius: 6px; background: #2A2A2A; color: #9A9A9A; font-variant-numeric: tabular-nums; }
.chip.counts { background: var(--fg); color: var(--bg); }
.surfer .needs { margin-left: 6px; font: 700 16px var(--display); text-transform: uppercase; }

.dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--rule); }
.dock .in { max-width: 508px; margin: 0 auto; }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center;
         animation: fade .2s ease both; z-index: 5; }
.sheet { width: 100%; max-width: 540px; max-height: 94vh; overflow-y: auto; background: var(--bg);
         border-top: 1.5px solid var(--fg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
         animation: rise .28s cubic-bezier(.2,.8,.2,1) both; }
.scrim.still, .scrim.still .sheet { animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .who { display: flex; align-items: center; gap: 10px; }
.sheet h2 { font-size: 34px; line-height: 1; letter-spacing: 0; font-weight: 700; }
.sheet .readout { font: 800 96px/.9 var(--display); text-align: center; margin: 10px 0 12px; font-variant-numeric: tabular-nums; }
.pad { display: grid; gap: 8px; }
.pad.num { grid-template-columns: repeat(3, 1fr); }
.pad.num .key { min-height: 62px; font-size: 30px; }
.readout .dim { color: #3A3A3A; }
.key { min-height: 54px; border-radius: 10px; background: var(--fill); font: 600 26px var(--display);
       transition: background .15s ease, color .15s ease, transform .1s ease; }
.key:active { transform: scale(.95); }
.key.on { background: var(--fg); color: var(--bg); }
.key[disabled] { opacity: .3; pointer-events: none; }
.padlabel { font: 600 15px var(--display); text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin: 12px 0 6px; }
.sofar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.sofar button { min-height: 48px; min-width: 56px; padding: 4px 12px; border-radius: 8px; box-shadow: inset 0 0 0 1.5px var(--fg);
                font: 600 20px var(--display); transition: background .15s ease; }
.sofar button.armed { background: var(--warn); box-shadow: none; text-transform: uppercase; }
pre.share { white-space: pre-wrap; font: 400 15px/1.45 var(--body); background: var(--fill); border-radius: 10px; padding: 12px;
            max-height: 50vh; overflow: auto; -webkit-user-select: all; user-select: all; }

#toast { position: fixed; left: 50%; bottom: 104px; transform: translate(-50%, 16px); background: var(--fg); color: var(--bg);
         padding: 10px 16px; border-radius: 999px; font: 600 16px var(--body); opacity: 0; pointer-events: none;
         transition: opacity .25s ease, transform .25s ease; z-index: 9; width: max-content; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
