/* ============================================================
   Word Sprints
   A night athletics meet: floodlit dark surface, chalk lane
   markings, amber lane numbers, and one magenta finish tape
   that only ever appears at the moment you win.
   ============================================================ */

:root {
  --ink:        #0B1620;
  --ink-2:      #12222E;
  --surface:    #17303F;
  --surface-2:  #1E3C4E;
  --line:       #2C5064;
  --chalk:      #EEF3F0;
  --chalk-dim:  #8FA8B5;
  --lane:       #F0B429;
  --finish:     #46D08D;
  --photo:      #FF4D7E;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Archivo", system-ui, -apple-system, sans-serif;
  --data: "DM Mono", ui-monospace, "SF Mono", monospace;

  --tile: 46px;
  --gap: 6px;
  --radius: 4px;
  --pad: clamp(14px, 4vw, 24px);
  /* bottom of the quibo hub badge, plus breathing room */
  --badge-clear: calc(env(safe-area-inset-top, 0px) + 58px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, #1B3A4C 0%, transparent 60%),
    var(--ink);
  color: var(--chalk);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; color: inherit; cursor: pointer; }

.skip {
  position: absolute;
  left: -9999px;
  background: var(--lane);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 99;
}
/* clears the quibo hub badge, which owns the top-left corner */
.skip:focus { left: 12px; top: var(--badge-clear); }

/* ── masthead ─────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: var(--pad) var(--pad) 10px;
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
}

/* home-badge.js injects a fixed pill roughly 125x50 at the top-left,
   above everything and outside our control. The masthead column is
   centred, so it only runs underneath the badge on narrower screens —
   give it room there rather than pushing the wordmark down on desktop. */
@media (max-width: 860px) {
  .masthead { padding-top: var(--badge-clear); }
}

.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(34px, 10vw, 52px);
  line-height: 0.82;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.wordmark span { color: var(--chalk); }
.wordmark em {
  font-style: normal;
  color: var(--lane);
  /* the letters lean forward, like a runner */
  transform: skewX(-7deg);
  transform-origin: left bottom;
}

.meet {
  font-family: var(--data);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  margin: 8px 0 0;
}

.masthead__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--chalk-dim);
  border-radius: 100px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--chalk-dim); color: var(--chalk); }
.chip--quiet { border-color: transparent; padding: 5px 10px; }
.chip--quiet:hover { border-color: var(--line); }
.chip[disabled] { opacity: .35; pointer-events: none; }

/* ── lane selector ────────────────────────────────────────── */

.lanes {
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--pad);
}

.lanes__rail {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
}

.lane-tab {
  position: relative;
  background: transparent;
  border: 0;
  border-radius: 3px;
  padding: 9px 0 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background .15s;
}
.lane-tab:hover { background: var(--surface); }

.lane-tab__no {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--chalk-dim);
  transition: color .15s;
}

.lane-tab__pip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line);
  transition: background .15s, box-shadow .15s;
}

.lane-tab[aria-selected="true"] { background: var(--surface-2); }
.lane-tab[aria-selected="true"] .lane-tab__no { color: var(--lane); }
.lane-tab[data-state="done"] .lane-tab__pip { background: var(--finish); }
.lane-tab[data-state="gaveup"] .lane-tab__pip { background: var(--photo); }
.lane-tab[data-state="started"] .lane-tab__pip { background: var(--lane); }

.lanes__hint {
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  opacity: .65;
  text-align: center;
  margin: 7px 0 0;
}

/* ── the track ────────────────────────────────────────────── */

.track {
  flex: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 18px var(--pad) 0;
}

.track__inner {
  position: relative;
  padding: 18px 0 0;
}

/* the lane line runs the length of the track behind everything */
.track__inner::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 340px;
  transform: translateX(-50%);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  opacity: .45;
  pointer-events: none;
}

.marker { position: relative; text-align: center; }

.marker__tag {
  display: block;
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  margin-bottom: 7px;
}

.marker--start .marker__tag { color: var(--chalk-dim); }
.marker--finish { margin-top: 8px; padding-bottom: 6px; }
.marker--finish .marker__tag { color: var(--lane); }

/* ── letter tiles ─────────────────────────────────────────── */

.tiles {
  display: flex;
  justify-content: center;
  gap: var(--gap);
}

.tile {
  width: var(--tile);
  height: var(--tile);
  display: grid;
  place-items: center;
  font-family: var(--body);
  font-weight: 700;
  font-size: calc(var(--tile) * 0.46);
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
  color: var(--chalk);
  user-select: none;
}

.tile--hit { background: var(--finish); border-color: var(--finish); color: var(--ink); }
.tile--changed { border-color: var(--lane); box-shadow: inset 0 -3px 0 var(--lane); }
.tile--empty { color: transparent; }

.tiles--anchor .tile { background: var(--surface); border-color: var(--surface-2); }
.marker--finish .tiles--anchor .tile {
  background: var(--surface);
  border-color: var(--lane);
  color: var(--lane);
}

/* ── the chain of guesses ─────────────────────────────────── */

.chain { list-style: none; margin: 0; padding: 14px 0 0; }

.chain__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: var(--gap);
  animation: stride .22s ease-out both;
}

.chain__split {
  font-family: var(--data);
  font-size: 11px;
  color: var(--chalk-dim);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}

.chain__pad { width: 22px; flex-shrink: 0; }

@keyframes stride {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* ── entry row ────────────────────────────────────────────── */

.entry { margin: 10px 0 4px; }

.entry__lane {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.entry__split {
  font-family: var(--data);
  font-size: 11px;
  color: var(--lane);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}

.entry__field { position: relative; }

.entry__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  cursor: text;
}
.entry__input:focus { outline: none; }

.tiles--entry .tile { background: var(--ink); border-color: var(--line); }
.tiles--entry .tile--active {
  border-color: var(--chalk);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  0%, 55%  { border-color: var(--chalk); }
  56%,100% { border-color: var(--line); }
}

.entry__go {
  border: 1px solid var(--lane);
  background: var(--lane);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 900;
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 13px;
  height: var(--tile);
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: filter .15s;
}
.entry__go:hover { filter: brightness(1.1); }

.entry__note {
  min-height: 18px;
  margin: 9px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--chalk-dim);
}
.entry__note[data-tone="bad"] { color: var(--photo); }
.entry__note[data-tone="good"] { color: var(--finish); }

.entry[hidden] { display: none; }

.shake { animation: shake .3s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50%      { transform: translateX(-4px); }
}

/* ── finish tape: the one loud moment ─────────────────────── */

.tape {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: 0;
  height: 3px;
  background: var(--photo);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
}
.tape span {
  position: absolute;
  inset: -4px 0;
  background: var(--photo);
  filter: blur(7px);
  opacity: .55;
}

.marker--finish[data-broken="true"] .tape {
  animation: tape-break .75s cubic-bezier(.2,.9,.3,1) forwards;
}
@keyframes tape-break {
  0%   { width: 0; opacity: 1; }
  55%  { width: 130%; opacity: 1; }
  100% { width: 130%; opacity: 0; }
}

.marker--finish[data-broken="true"] .tile { animation: flare .5s ease-out both; }
@keyframes flare {
  0%   { transform: none; }
  40%  { transform: translateY(-7px) scale(1.06); }
  100% { transform: none; }
}

/* ── heads-up display ─────────────────────────────────────── */

.hud {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
  padding: 10px var(--pad) 4px;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  flex-wrap: wrap;
}

.hud__stat { display: flex; align-items: baseline; gap: 6px; }

.hud__k {
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}
.hud__v {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}

.hud__actions { margin-left: auto; display: flex; gap: 2px; }

.foot {
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
  padding: 6px var(--pad) 22px;
  font-size: 12px;
  color: var(--chalk-dim);
  opacity: .6;
}
.foot p { margin: 0; }

/* ── sheets ───────────────────────────────────────────────── */

.sheet {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-2);
  color: var(--chalk);
  max-width: 420px;
  width: calc(100% - 28px);
  padding: 26px 22px 22px;
  position: relative;
}
.sheet::backdrop { background: rgba(4, 12, 18, .78); }

.sheet h2 {
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  text-transform: uppercase;
  margin: 0 0 12px;
}

.sheet p { font-size: 14px; }

.sheet__x {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: 0;
  color: var(--chalk-dim);
  font-size: 15px;
  line-height: 1;
  padding: 6px;
}
.sheet__x:hover { color: var(--chalk); }

.demo { margin: 14px 0; border-left: 2px solid var(--line); padding-left: 12px; }
.demo__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 0;
}
.demo__row span {
  font-family: var(--data);
  font-weight: 500;
  letter-spacing: 0.14em;
  font-size: 15px;
}
.demo__row em {
  font-style: normal;
  font-size: 12px;
  color: var(--chalk-dim);
}
.demo__row--win span { color: var(--finish); }

.chainlist {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 12px 0 16px;
}
.chainlist span {
  font-family: var(--data);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--lane);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 7px;
}

.rules { padding-left: 18px; font-size: 14px; }
.rules li { margin-bottom: 7px; }

.fineprint {
  font-size: 12px;
  color: var(--chalk-dim);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-bottom: 0;
}

/* ── result sheet ─────────────────────────────────────────── */

.sheet--result { text-align: center; }

.result__medal { font-size: 40px; margin: 0 0 2px; line-height: 1; }

.result__head {
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.result__line {
  font-family: var(--data);
  font-size: 13px;
  color: var(--chalk-dim);
  margin: 0 0 14px;
}

.result__grid {
  font-family: var(--data);
  font-size: 15px;
  line-height: 1.35;
  margin: 0 0 16px;
  white-space: pre;
}

.result__share { display: flex; gap: 8px; justify-content: center; }

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--chalk);
  border-radius: 100px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--chalk-dim); }
.btn--primary {
  background: var(--lane);
  border-color: var(--lane);
  color: var(--ink);
  font-weight: 700;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--danger { border-color: var(--photo); color: var(--photo); margin-top: 14px; }

.result__socials {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.social {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--chalk-dim);
  border-radius: 100px;
  padding: 6px 13px;
  font-size: 12px;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.social:hover { border-color: var(--chalk-dim); color: var(--chalk); }

.result__next {
  font-size: 12px;
  color: var(--chalk-dim);
  margin: 16px 0 0;
}

/* ── stats sheet ──────────────────────────────────────────── */

.season { display: flex; flex-direction: column; gap: 6px; }

.season__row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.season__lane {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--lane);
  text-align: center;
}

.season__bar {
  height: 7px;
  background: var(--surface);
  border-radius: 100px;
  overflow: hidden;
}
.season__fill { height: 100%; background: var(--finish); border-radius: 100px; }

.season__num { font-family: var(--data); font-size: 12px; color: var(--chalk-dim); }

.totals {
  display: flex;
  gap: 20px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}
.totals__item { display: flex; flex-direction: column; }
.totals__k {
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}
.totals__v { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.1; }

/* ── responsive + a11y ────────────────────────────────────── */

@media (max-width: 430px) {
  :root { --tile: 40px; --gap: 5px; }
  .masthead__actions { flex-direction: column; }
}

@media (max-width: 360px) {
  :root { --tile: 35px; --gap: 4px; }
}

:focus-visible {
  outline: 2px solid var(--lane);
  outline-offset: 2px;
  border-radius: 2px;
}

.entry__input:focus-visible { outline: none; }
.entry__field:focus-within .tile--active { border-color: var(--chalk); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
