/* challenge.css — PLAY & CREATE CHALLENGE.
 *
 * Kept as its own file rather than folded into style.css: this feature is
 * additive and self-contained (its own screens, its own components), so
 * isolating it here means it can be reviewed, changed or (if ever needed)
 * torn out without touching the base game's stylesheet at all.
 *
 * Deliberately reuses style.css's existing tokens instead of inventing a
 * second palette: the cyan→purple gradient (#8ff8ff/#4f8cff/#6a3bff), the
 * glass-panel recipe (rgba(16,18,40,.55) + blur(10px) + a faint white
 * border), body text #e9edff, muted #9a8fb5, the earnings-green #14f195
 * and warning-amber #ffd166 already used for money and highlights, and the
 * Orbitron/Inter font pair. Buttons stay the existing .btn/.btn.alt — this
 * file only styles the content AROUND them: panels, stat grids, steps, the
 * visibility picker, and challenge-list rows.
 */

.chal-panel {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-radius: var(--r-lg);
  background: rgba(16, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  text-align: left;
}

.chal-panel.wide {
  max-width: 720px;
  margin: auto;
}

.chal-heading {
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 900;
  letter-spacing: var(--ls-title);
  text-transform: uppercase;
  font-size: var(--fs-page);
  background: linear-gradient(100deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.chal-sub {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #9a8fb5;
  text-shadow: var(--menu-halo);
  text-align: center;
  margin-top: -10px;
}

/* ---- score / trophy callout (create screen) ----
 * One row: label · score · run id + eligibility · trophy. The run id is
 * here (not its own QUALIFYING RUN field) so the whole thing costs one
 * line. */

.chal-score-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: rgba(20, 241, 149, 0.08);
  border: 1px solid rgba(20, 241, 149, 0.35);
}

.chal-score-card .k {
  font-size: 11px;
  letter-spacing: 3px;
  color: #9a8fb5;
}

.chal-score-card .v {
  font-size: 24px;
  font-weight: 800;
  color: #eafff6;
  text-shadow: 0 0 12px rgba(20, 241, 149, 0.5);
}

.chal-score-card .meta {
  margin-left: auto;
  font-size: 12px;
  letter-spacing: 1px;
  color: #9a8fb5;
}

.chal-score-card .meta b {
  color: #efe7ff;
  letter-spacing: 1.5px;
}

.chal-qual-ok {
  margin-left: 8px;
  color: #59e0a0;
  letter-spacing: 1.5px;
}

.chal-trophy {
  font-size: 26px;
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.6));
}

.chal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: rgba(20, 241, 149, 0.18);
  color: #39ff8f;
  border: 1px solid rgba(57, 255, 143, 0.4);
  text-transform: uppercase;
}

.chal-badge.new,
.chal-badge.beaten {
  background: rgba(255, 209, 102, 0.16);
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.45);
}

.chal-badge.expired {
  background: rgba(154, 143, 181, 0.14);
  color: #9a8fb5;
  border-color: rgba(154, 143, 181, 0.35);
}

/* ---- form fields (entry fee, duration, message, @handle) ---- */

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

.chal-field label {
  font-size: 11px;
  letter-spacing: 2px;
  color: #9a8fb5;
}

.chal-field .row {
  display: flex;
  gap: 8px;
}

.chal-field .row .chal-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.chal-field .row .chal-select {
  flex: 0 0 auto;
  width: auto;
}

.chal-input,
.chal-select {
  width: 100%;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: #e9edff;
  background: rgba(6, 6, 20, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.chal-input::placeholder {
  color: #8b83a8;
}

.chal-input:focus,
.chal-select:focus {
  border-color: #4f8cff;
}

.chal-input.money {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 16px;
}

/* ---- prize amount: dollars in, SOL out ---- */

.chal-money-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.chal-money-wrap .chal-input {
  width: 100%;
  padding-left: 30px;
}

.chal-money-sym {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #9a8fb5;
  pointer-events: none;
}

.chal-convert {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.25);
}

.chal-convert-eth {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  color: #e9edff;
}

.chal-convert.muted .chal-convert-eth {
  font-family: "Inter", sans-serif;
  font-weight: 400;
  color: #9a8fb5;
}

.chal-convert-rate {
  color: #9a8fb5;
  white-space: nowrap;
}

.chal-convert.error {
  background: rgba(255, 92, 92, 0.08);
  border-color: rgba(255, 92, 92, 0.35);
}

.chal-convert.error .chal-convert-eth {
  font-family: "Inter", sans-serif;
  font-weight: 400;
  color: #ff8c8c;
}

.chal-link-btn {
  font-family: "Orbitron", sans-serif;
  font-size: 10px;
  letter-spacing: 1px;
  color: #4f8cff;
  background: none;
  border: 1px solid rgba(79, 140, 255, 0.4);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

.chal-link-btn:hover {
  background: rgba(79, 140, 255, 0.12);
}

.chal-hint-inline {
  font-size: 11px;
  color: #9a8fb5;
  letter-spacing: 0.5px;
}

.chal-counter {
  font-size: 10px;
  color: #9a8fb5;
  text-align: right;
}

/* pill-style option groups: duration and visibility */

.chal-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chal-pill {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  color: #c9c3de;
  transition:
    border-color 0.15s,
    color 0.15s,
    background 0.15s;
}

.chal-pill:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.chal-pill.on {
  color: #04040e;
  background: linear-gradient(100deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
  border-color: transparent;
}

/* two short fields side by side (X handle + message) */
.chal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

@media (max-width: 560px) {
  .chal-field-row {
    grid-template-columns: 1fr;
  }
}

/* ---- fee breakdown ---- */

.chal-fee-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
}

.chal-fee-row {
  display: flex;
  justify-content: space-between;
  color: #b7b0cf;
}

.chal-fee-row.total {
  color: #fff;
  font-weight: 800;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

/* the dollar equivalent beside an SOL figure */
.chal-fee-row em {
  font-style: normal;
  font-weight: 400;
  color: #9a8fb5;
  margin-left: 6px;
}

/* ---- share links ---- */

.chal-share-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

.chal-share-link {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #8ff8ff;
  /* wraps instead of truncating: this is the only place the challenge code
     is rendered, so an ellipsis made it unreadable rather than merely tidy */
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.chal-copy-btn {
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #e9edff;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
}

.chal-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---- challenge detail / accept screen ---- */

.chal-creator-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #9a8fb5;
}

.chal-creator-row b {
  color: #e9edff;
  font-size: 14px;
}

.chal-target {
  font-size: 15px;
  color: #c9c3de;
  text-align: center;
}

.chal-target b {
  color: #ffd166;
}

.chal-beat {
  text-align: center;
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(30px, 7vw, 48px);
  color: #fff;
  text-shadow: 0 0 22px rgba(79, 140, 255, 0.55);
}

.chal-beat .num {
  background: linear-gradient(100deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* italic glyphs overhang the span's box; background-clip: text only
     paints inside it, so the last digit's slant came out transparent */
  padding: 0 0.14em;
  margin: 0 -0.14em;
}

.chal-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
}

.chal-stat-grid .stat {
  align-items: center;
  gap: 3px;
}

.chal-stat-grid .stat .k {
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
}

.chal-stat-grid .stat .v {
  font-size: 20px;
}

@media (max-width: 480px) {
  .chal-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* status pill: ACTIVE / COMPLETED / EXPIRED / SETTLED ... */

.chal-status {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: #c9c3de;
}

.chal-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chal-status.active {
  background: rgba(57, 255, 143, 0.14);
  color: #39ff8f;
}

.chal-status.completed,
.chal-status.settled {
  background: rgba(255, 209, 102, 0.16);
  color: #ffd166;
}

.chal-status.expired,
.chal-status.cancelled {
  background: rgba(255, 92, 92, 0.14);
  color: #ff8c8c;
}

.chal-status.pending {
  background: rgba(79, 140, 255, 0.16);
  color: #8ab4ff;
}

/* step list: connect X → connect wallet → pay → accept */

.chal-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chal-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.chal-step.done {
  border-color: rgba(57, 255, 143, 0.4);
  background: rgba(57, 255, 143, 0.06);
}

.chal-step .num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: #c9c3de;
}

.chal-step.done .num {
  background: #39ff8f;
  color: #04040e;
}

.chal-step .body {
  flex: 1;
  text-align: left;
}

.chal-step .title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #e9edff;
}

.chal-step .desc {
  font-size: 11px;
  color: #9a8fb5;
}

.chal-step .action {
  flex: 0 0 auto;
}

/* small ghost/gold action buttons used inside steps, sized down from .btn */
.chal-step-btn {
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  color: #04040e;
  border: none;
  background: linear-gradient(100deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
}

.chal-step-btn:hover {
  filter: brightness(1.12);
}

.chal-step-btn[disabled] {
  /* `opacity` here faded the dark ink and the bright plate together, which
     collapsed the label to ~1.9:1 rather than dimming it. Same explicit
     disabled skin .chal-wallet-btn[disabled] below already uses. */
  background: var(--btn-off-fill, #2a2f4a);
  color: var(--btn-off-ink, #aab3d0);
  cursor: default;
  filter: none;
}

/* ---- inline payment progress (kept inside chal-view, not a full screen
   swap — the wait is a few seconds, and a hard cut is more jarring than
   a status line that updates in place) ---- */

/* One row: spinner left, text right. As wide as the CTA under it on the
   accept screen (--chal-cta-w, set on .chal-accept) and as the panel on
   the create screen, so it never shrinks to a "Connecting…" stub or jumps
   in size between stages. */
.chal-pay-progress {
  width: 100%;
  max-width: var(--chal-cta-w, none);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.3);
  font-size: 12px;
  line-height: 1.4;
  color: #c9c3de;
  text-align: left;
}

.chal-pay-progress.error {
  background: rgba(255, 92, 92, 0.1);
  border-color: rgba(255, 92, 92, 0.4);
  color: #ffb3b3;
}

/* Deposit stages come in main.js's wallet-screen markup; only its head/sub
   text is wanted here — the spinner already says "in flight". */
.chal-pay-progress .dep-status {
  display: contents;
}

.chal-pay-progress .dep-dot {
  display: none;
}

.chal-pay-progress .dep-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chal-pay-progress .dep-head {
  font-size: 13px;
  font-weight: 700;
  color: #e9edff;
}

.chal-pay-progress.error .dep-head {
  color: #ffb3b3;
}

.chal-pay-progress .dep-sub {
  color: #a9b1d1;
}

.chal-pay-progress .chal-spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
}

.chal-progress-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin: 0 3px;
  border-radius: 50%;
  background: #ff5c5c;
}

.chal-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #8ff8ff;
  animation: chal-spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes chal-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- outcome screen (won / failed / completed-by-other) ----
   One card, .chal-result, with a .won / .fail / .completed / .pending
   modifier that only swaps the accent. Everything on it is a named block
   in source order: crest, title, sub, compare, stats, money, actions,
   foot. The card is wider than .chal-panel on purpose — the stats row
   and the reward/settlement pair sit side by side down to tablet width
   and stack under it. */

/* The body is a shrink-to-fit flex item of the screen; without a width of
   its own the card's `width: 100%` resolves against its own content and a
   phone gets a sideways scroll. The top padding is the crest's room — it
   hangs 58px above the card, and a scroll container can't reach content
   pushed above its own start. */
#chal-outcome-body {
  width: 100%;
  padding-top: 44px;
}

/* The accent is the game's own: gold for a win (NEW BEST, a won pot),
   the mint the WIPEOUT title glows in for a miss, --cyan for a round that
   closed on someone else. The glass itself is the same as .crash-card and
   .results-card — mint/violet corners on the dark plate. */
.chal-result {
  --acc: #ffe600;
  --acc-2: #fff6b0;
  --acc-rgb: 255, 230, 0;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 26px 20px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(var(--acc-rgb), 0.08) 0%, transparent 60%),
    linear-gradient(115deg, rgba(31, 240, 200, 0.08) 0%, transparent 38%),
    linear-gradient(295deg, rgba(122, 43, 255, 0.14) 0%, transparent 40%),
    rgba(10, 12, 30, 0.72);
  backdrop-filter: blur(14px);
  border: 1.5px solid rgba(150, 170, 255, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 50px rgba(var(--acc-rgb), 0.14);
  text-align: center;
}

.chal-result.fail {
  --acc: #1ff0c8;
  --acc-2: #8ff8ff;
  --acc-rgb: 31, 240, 200;
}

.chal-result.completed,
.chal-result.pending {
  --acc: #4f8cff;
  --acc-2: #8ff8ff;
  --acc-rgb: 79, 140, 255;
}

/* crest: two flags flanking the trophy, sat on the card's top edge */
.chal-result-crest {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  margin-top: -58px;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(var(--acc-rgb), 0.5));
}

.chal-result-crest .trophy {
  font-size: 64px;
  animation: chal-trophy-pop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.chal-result-crest .trophy.dim {
  font-size: 48px;
  filter: saturate(0.6);
}

.chal-result-crest .flag {
  width: 58px;
  height: 58px;
  margin-bottom: 4px;
  color: #ddd;
  transform-origin: 10% 90%;
  animation: chal-flag-wave 1.6s ease-in-out infinite;
}

.chal-result-crest .flag.l {
  transform: rotate(-18deg);
}

.chal-result-crest .flag.r {
  transform: scaleX(-1) rotate(-18deg);
  animation-delay: -0.8s;
}

.chal-result-crest .flag svg {
  width: 100%;
  height: 100%;
}

@keyframes chal-trophy-pop {
  from {
    transform: scale(0.3) translateY(20px);
    opacity: 0;
  }
}

@keyframes chal-flag-wave {
  50% {
    transform: rotate(-12deg);
  }
}

.chal-result-crest .flag.r {
  animation-name: chal-flag-wave-r;
}

@keyframes chal-flag-wave-r {
  50% {
    transform: scaleX(-1) rotate(-12deg);
  }
}

.chal-result-title {
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 900;
  letter-spacing: var(--ls-title);
  text-transform: uppercase;
  font-size: clamp(28px, 5.4vw, 52px);
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 28px #1ff0c8,
    0 4px 24px rgba(0, 0, 0, 0.6);
}

.chal-result-title .hot {
  color: var(--acc);
  text-shadow:
    0 0 28px rgba(var(--acc-rgb), 0.7),
    0 4px 24px rgba(0, 0, 0, 0.6);
}

.chal-result-title .cool {
  color: #8ab4ff;
}

.chal-result-sub {
  margin-top: -6px;
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-size: clamp(11px, 1.5vw, 15px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #d9d4ee;
}

/* YOUR SCORE vs TARGET DISTANCE */
.chal-result-compare {
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  margin-top: 6px;
}

.chal-result-compare .box {
  flex: 1 1 0;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 14px 18px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(150, 170, 255, 0.28);
}

.chal-result-compare .box.lead {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 8px),
    rgba(var(--acc-rgb), 0.1);
  border-color: rgba(var(--acc-rgb), 0.85);
  box-shadow: 0 0 28px rgba(var(--acc-rgb), 0.28);
}

.chal-result-compare .box .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--ls-label);
  color: #c9c3de;
}

.chal-result-compare .box .k svg {
  width: 18px;
  height: 18px;
  color: var(--acc-2);
}

.chal-result-compare .box .v {
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(26px, 4.6vw, 44px);
  line-height: 1;
  padding-right: 0.1em;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(79, 140, 255, 0.55);
}

.chal-result-compare .box:last-child .v {
  color: var(--purple);
  filter: brightness(1.25);
  text-shadow: 0 0 18px rgba(122, 43, 255, 0.6);
}

.chal-result-compare .vs {
  flex: 0 0 auto;
  align-self: center;
  width: 48px;
  height: 48px;
  margin: 0 -8px;
  z-index: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 12px;
  color: #e9edff;
  background: #151833;
  border: 1.5px solid rgba(150, 170, 255, 0.4);
  box-shadow: 0 0 0 5px rgba(10, 12, 30, 0.9);
}

.chal-result-margin {
  margin-top: -6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #14f195;
}

.chal-result-margin svg {
  width: 16px;
  height: 16px;
  padding: 2px;
  border-radius: 50%;
  background: #14f195;
  color: #04040e;
}

.chal-result-margin.miss {
  color: #c9c3de;
}

/* RACE TIME · TOP SPEED · AVG SPEED · ATTEMPTS */
.chal-result-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.chal-result-stats .tile {
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(150, 170, 255, 0.2);
  text-align: left;
}

.chal-result-stats .ico {
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #e9edff;
}

.chal-result-stats .ico svg {
  width: 18px;
  height: 18px;
}

.chal-result-stats .k {
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--ls-label);
  color: #9a8fb5;
}

.chal-result-stats .v {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  white-space: nowrap;
}

.chal-result-stats .v small {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #c9c3de;
}

/* YOUR REWARD + settlement card */
.chal-result-money {
  width: 100%;
  display: grid;
  /* minmax(0, …): a bare fr track floors at its content's min-content, and
     the link row's one-line URL would push the card past a phone's edge */
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  text-align: left;
}

.chal-result-money .reward,
.chal-result-money .settle {
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(150, 170, 255, 0.2);
}

.chal-result-money .reward .k {
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--ls-label);
  color: #c9c3de;
}

.chal-result-money .total {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1;
  color: var(--acc);
  text-shadow: 0 0 18px rgba(var(--acc-rgb), 0.4);
}

.chal-result-money .total svg {
  width: 34px;
  height: 34px;
  color: var(--acc-2);
  flex-shrink: 0;
}

.chal-result-money .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  color: #c9c3de;
}

.chal-result-money .row span:last-child {
  font-variant-numeric: tabular-nums;
  color: #e9edff;
}

.chal-result-money .row.sum {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(150, 170, 255, 0.2);
  font-weight: 700;
}

.chal-result-money .row.sum span:last-child {
  color: #14f195;
}

.chal-result-money .settle {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 12px;
  align-content: center;
  row-gap: 4px;
}

.chal-result-money .settle .badge {
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  color: #04040e;
  background: #14f195;
}

.chal-result-money .settle .badge svg {
  width: 22px;
  height: 22px;
}

.chal-result-money .settle .t {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #14f195;
}

.chal-result-money .settle .d {
  font-size: 12px;
  line-height: 1.5;
  color: #c9c3de;
}

.chal-result-money .settle .btn {
  grid-column: 2;
  justify-self: start;
  margin-top: 8px;
}

.chal-result-money .settle.wait .badge {
  background: rgba(255, 230, 0, 0.18);
  color: #ffe600;
}

.chal-result-money .settle.wait .badge .chal-spinner {
  margin: 0;
  border-top-color: #ffe600;
}

.chal-result-money .settle.wait .t {
  color: #ffe600;
}

.chal-result-money .settle.bad .badge {
  background: rgba(122, 43, 255, 0.35);
  color: #fff;
}

.chal-result-money .settle.bad .t {
  color: #c9c3de;
}

.chal-result-msg {
  max-width: 640px;
  font-size: 13px;
  line-height: 1.6;
  color: #c9c3de;
}

/* actions: three across on the won card, primary in the middle */
.chal-result-actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}

.chal-result-actions .btn {
  flex: 1 1 200px;
  max-width: 360px;
  gap: var(--sp-2);
  white-space: nowrap;
  text-decoration: none;
}

.chal-result .btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* foot: the challenge link + the share nudge */
.chal-result-foot {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  text-align: left;
}

.chal-result-foot .link,
.chal-result-foot .note {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(150, 170, 255, 0.2);
}

.chal-result-foot .link .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--ls-label);
  color: #c9c3de;
}

.chal-result-foot .link .k svg {
  width: 16px;
  height: 16px;
  color: var(--acc-2);
}

.chal-result-foot .link .url {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.35);
  font-size: 12px;
  color: #e9edff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chal-result-foot .copy {
  cursor: pointer;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #e9edff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.chal-result-foot .copy:hover {
  background: rgba(255, 255, 255, 0.16);
}

.chal-result-foot .copy svg {
  width: 16px;
  height: 16px;
}

.chal-result-foot .note {
  font-size: 12px;
  line-height: 1.45;
  color: #c9c3de;
}

.chal-result-foot .note .ico {
  font-size: 20px;
  flex-shrink: 0;
}

.chal-result-foot .note b {
  color: var(--acc);
}

.chal-result-foot .link:only-child {
  grid-column: 1 / -1;
}

/* confetti: a full-screen layer under the card (the screen is the
   positioned ancestor), each piece falling from above the viewport on its
   own --x / --d / --dl set inline by challengeUI.js's confettiMarkup() */
.chal-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.chal-confetti i {
  position: absolute;
  top: -20px;
  left: min(var(--x), calc(100% - var(--w)));
  width: var(--w);
  height: var(--h);
  border-radius: 2px;
  opacity: 0;
  animation: chal-confetti-fall var(--d) linear var(--dl) 3;
}

@keyframes chal-confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--r));
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--dx), 105vh, 0) rotate(calc(var(--r) + 540deg));
    opacity: 0.9;
  }
}

@media (max-width: 760px) {
  .chal-result {
    padding: 22px 16px 16px;
    gap: 12px;
  }

  .chal-result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chal-result-money,
  .chal-result-foot {
    grid-template-columns: minmax(0, 1fr);
  }

  .chal-result-actions .btn {
    flex-basis: 100%;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .chal-result-compare {
    flex-direction: column;
    gap: 8px;
  }

  .chal-result-compare .box {
    max-width: none;
  }

  .chal-result-compare .vs {
    margin: -14px 0;
  }

  .chal-result-crest .trophy {
    font-size: 52px;
  }

  .chal-result-crest .flag {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chal-confetti,
  .chal-result-crest .flag,
  .chal-result-crest .trophy {
    animation: none;
  }
}

.chal-outcome-msg {
  text-align: center;
  font-size: 13px;
  color: #c9c3de;
  line-height: 1.6;
}

/* ---- my challenges / history rows ---- */

.chal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.chal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: rgba(20, 4, 40, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.chal-row .main {
  flex: 1;
  min-width: 0;
}

.chal-row .title {
  font-size: 13px;
  font-weight: 700;
  color: #e9edff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chal-row .meta {
  font-size: 11px;
  color: #9a8fb5;
}

.chal-row .amt {
  flex: 0 0 auto;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 13px;
}

.chal-row .amt.in {
  color: #39ff8f;
}

.chal-row .amt.out {
  color: #ff8c8c;
}

.chal-empty {
  font-size: 12px;
  color: #9a8fb5;
  text-align: center;
  padding: 24px 0;
}

/* small icon-button used for X connect state, matches .btn.alt sizing but
   compact enough to sit inside a step row / score card */
.chal-x-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e9edff;
}

.chal-x-chip.connected {
  color: #39ff8f;
  border-color: rgba(57, 255, 143, 0.4);
  background: rgba(57, 255, 143, 0.08);
}

/* ---- CREATE CHALLENGE: desktop two-column layout ----
 * Phone and tablet get a single centered column (.chal-panel.wide alone,
 * with the LOCK / RACE AGAIN / BACK row under it) — unchanged. Only above
 * the desktop breakpoint does .chal-create-side appear and the layout
 * switch to a grid, so nothing below that width renders any differently
 * than before this block existed.
 *
 * The desktop grid is the multiplayer lobby's (see "Multiplayer lobby —
 * the card layout" in style.css): the form panel on the left, the
 * DISTANCE / BEST + car column on the right at the YOUR VEHICLE card's
 * width, and the action row under both, left-aligned, outside the panel
 * — the same three pieces, same widths, same gaps. */

.chal-create-layout {
  width: 100%;
  /* the panel's own cap (.chal-panel.wide), so the action row under it
     on tablet is no wider than the panel it belongs to */
  max-width: 720px;
  margin: auto;
}

.chal-create-side {
  display: none;
}

/* Desktop only — the wrapper is invisible to layout below that, so the
   heading and the score card stack in the panel's column as they always
   have. */
.chal-create-head {
  display: contents;
}

/* The form has to fit one desktop viewport with the CREATE button
   visible, so the create panel is denser than the other chal panels. */
.chal-create-layout .chal-panel.wide {
  gap: 12px;
  padding: 18px 20px;
}

.chal-create-layout .chal-heading {
  font-size: clamp(22px, 3vw, 30px);
}

@media (min-width: 1100px) {
  /* The lobby reserves the wallet chip's row on top (#lobby in style.css):
     a form this tall top-anchors on short viewports, and without the
     reservation its top-right corner runs under the chip. Only with the
     form up — the no-run and share cards stay centred as before. */
  #chal-create:has(.chal-create-layout) {
    padding-top: calc(var(--chips-top) + var(--chips-h) + var(--sp-3));
  }

  /* .screen centres its children, which makes the body shrink-to-fit;
     the grid needs the screen's full width to reach the lobby's 1180 */
  #chal-create-body {
    width: 100%;
  }

  .chal-create-layout {
    display: grid;
    /* #lobby-body's columns and gap */
    grid-template-columns: minmax(0, 1fr) minmax(280px, 310px);
    grid-template-areas:
      "form side"
      "actions actions";
    gap: var(--sp-4);
    align-items: stretch;
    max-width: 1180px; /* #lobby's --lobby-w */
    margin: auto;
  }

  .chal-create-layout .chal-panel.wide {
    grid-area: form;
    margin: 0;
    max-width: none;
  }

  /* the side column stretches to the panel's height like the lobby's
     vehicle card does — the car card takes the slack, the image centred
     in it, the stats pinned to its foot */
  .chal-create-side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    min-width: 0;
  }

  .chal-create-side .chal-car-card {
    flex: 1 1 auto;
  }

  .chal-create-side .chal-car-card img {
    margin: auto 0;
  }

  /* DISTANCE over BEST: two stats side by side need ~380px, the lobby's
     column is 310 */
  .chal-create-side .chal-run-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chal-create-side .chal-run-stat + .chal-run-stat {
    padding-left: 0;
    padding-top: 10px;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* the lobby's head row: title left, the number card right */
  .chal-create-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
  }

  .chal-create-head .chal-heading {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
  }

  /* the score card becomes the capacity card's shape: label / number /
     the run line under it */
  .chal-create-head .chal-score-card {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas:
      "k k"
      "v trophy"
      "meta meta";
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    padding: 8px 14px;
  }

  .chal-create-head .chal-score-card .k {
    grid-area: k;
  }

  .chal-create-head .chal-score-card .v {
    grid-area: v;
  }

  .chal-create-head .chal-score-card .chal-trophy {
    grid-area: trophy;
    font-size: 20px;
  }

  .chal-create-head .chal-score-card .meta {
    grid-area: meta;
    margin-left: 0;
  }

  /* the lobby's MAP / RACE TIME rows: label on the left, chips beside it */
  .chal-create-layout .chal-field:has(> .chal-pills) {
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }

  .chal-create-layout .chal-field:has(> .chal-pills) > label {
    flex: 0 0 auto;
    min-width: 92px;
  }

  .chal-create-layout .chal-field:has(> .chal-pills) > .chal-pills {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* and PRIZE AMOUNT the same way (its ≈ ETH line keeps the row below) */
  .chal-create-layout .chal-field:has(> .row) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 14px;
    row-gap: 6px;
  }

  .chal-create-layout .chal-field:has(> .row) > label {
    min-width: 92px;
  }

  .chal-create-layout .chal-field:has(> .row) > .chal-convert {
    grid-column: 1 / -1;
  }

  /* #lobby .screen-actions: under both columns, left-aligned, buttons
     sized to their labels */
  .chal-create-layout .screen-actions {
    grid-area: actions;
    margin-top: 0;
    width: auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }

  .chal-create-layout .screen-actions > .btn {
    width: auto;
    min-width: 150px;
  }

  /* one desktop viewport with the row visible: a notch tighter than the
     phone column, where there is room to scroll */
  .chal-create-layout .chal-panel.wide {
    gap: 10px;
  }

  .chal-create-layout .chal-fee-breakdown {
    gap: 4px;
    padding: 8px 14px;
  }

  .chal-create-layout .chal-step {
    padding: 10px 14px;
  }

  /* the 0/140 counter sits on the MESSAGE label's line instead of on a
     line of its own under the input */
  .chal-create-layout .chal-field:has(> .chal-counter) {
    position: relative;
  }

  .chal-create-layout .chal-field > .chal-counter {
    position: absolute;
    top: 0;
    right: 0;
    line-height: 13px; /* the label's line, so the two share a baseline */
  }
}

/* the run's DISTANCE / BEST as one plate: icon | label-over-value cells,
   hairline-divided, with the HUD's cyan→purple gradient as the bottom edge.
   Same plate and border as .chal-car-card so the two stack as one column. */
.chal-run-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 14px 18px 16px;
  border-radius: var(--r-md);
  overflow: hidden;
}

/* both side cards sit on the CREATE panel's own bluish plate (.chal-panel),
   not the black one, so the column reads as one surface with the form */
.chal-run-card,
.chal-car-card {
  background: rgba(16, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
}

.chal-run-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
}

.chal-run-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chal-run-stat + .chal-run-stat {
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.chal-run-stat .ico {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.06);
}

.chal-run-stat .ico svg {
  width: 20px;
  height: 20px;
}

.chal-run-stat .txt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chal-run-stat .k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #8b8fa8;
}

.chal-run-stat .v {
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #f2f3ff;
  white-space: nowrap;
}

.chal-run-stat.dist .ico {
  color: var(--cyan);
  filter: drop-shadow(0 0 6px rgba(79, 140, 255, 0.55));
}

.chal-run-stat.best .ico {
  color: #c9a4ff;
  filter: drop-shadow(0 0 6px rgba(122, 43, 255, 0.55));
}

.chal-car-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: var(--r-md);
}

.chal-car-card img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 170px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

.chal-car-name {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #c9c3de;
}

.chal-car-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chal-car-stat {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 10px;
}

.chal-car-stat .k {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #8b8fa8;
}

.chal-car-stat .bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.chal-car-stat .bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #7fe9ff, #6aa8ff 55%, #a06bff);
}

.chal-car-stat .v {
  font-family: "Orbitron", sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #e8e6f5;
  min-width: 52px;
  text-align: right;
}

/* ============================================================
   ACCEPT CHALLENGE screen (#chal-view) — the shared-link landing
   page. Own block rather than a variant of .chal-panel: it is a
   centered marketing-style column (creator → score → prize card →
   two connect steps → one CTA), not a form panel.
   ============================================================ */

.chal-accept {
  --chal-cta-w: 460px;
  width: 100%;
  max-width: 1120px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 24px;
  text-align: center;
}

.chal-from-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #c9c3de;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chal-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 24px;
  color: #04040e;
  background: linear-gradient(140deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
  box-shadow: 0 0 0 3px rgba(10, 12, 30, 0.9), 0 0 0 5px rgba(79, 140, 255, 0.55);
  margin-top: 6px;
}

.chal-handle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: #fff;
}

.chal-verified {
  width: 20px;
  height: 20px;
}

.chal-handle-sub {
  font-size: 13px;
  color: #9a8fb5;
  margin-top: -6px;
}

.chal-taunt {
  font-size: 19px;
  font-weight: 600;
  color: #e9edff;
  margin-top: 6px;
}

/* the big BEAT <score> headline: white word, teal number, white unit */
.chal-accept .chal-beat {
  font-size: clamp(34px, 8vw, 56px);
  letter-spacing: 1px;
  margin: 2px 0;
}

.chal-accept .chal-beat .num {
  background: linear-gradient(100deg, #3ff0c4 0%, #14f195 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.chal-accept .chal-beat .unit {
  font-size: 0.55em;
  color: #fff;
}

.chal-beat-sub {
  font-size: 13px;
  color: #9a8fb5;
  margin-top: -4px;
}

/* ---- prize / mode / score card + the stats strip under it ---- */

.chal-info-card {
  width: 100%;
  max-width: 620px;
  margin-top: 10px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: rgba(16, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(79, 140, 255, 0.28);
}

.chal-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.chal-info .k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: #9a8fb5;
}

.chal-info .v {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 7px 0 4px;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.chal-info .ic {
  font-size: 17px;
}

.chal-info .s {
  font-size: 11px;
  color: #9a8fb5;
}

.chal-info-sep {
  height: 1px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.1);
}

.chal-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.chal-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
}

.chal-meta .chip {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 14px;
  background: rgba(79, 140, 255, 0.16);
}

.chal-meta .n {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
}

.chal-meta .l {
  font-size: 11px;
  color: #9a8fb5;
}

/* ---- the connect-wallet step ---- */

.chal-steps-card {
  width: 100%;
  max-width: 900px;
  margin-top: 14px;
  padding: 18px 22px;
  border-radius: var(--r-lg);
  background: rgba(16, 18, 40, 0.5);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  text-align: left;
}

.chal-step2-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chal-step2-text {
  flex: 1;
}

.chal-step2-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: #c9c3de;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.chal-step2-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #fff;
  margin: 8px 0 5px;
}

.chal-step2-desc {
  font-size: 12px;
  line-height: 1.45;
  color: #9a8fb5;
}

.chal-step2-note {
  margin-top: 10px;
  font-size: 11px;
  color: #9a8fb5;
}

.chal-step2-note.right {
  text-align: right;
}

.chal-step2-note b {
  color: #14f195;
}

.chal-step2.done .chal-step2-title {
  color: #39ff8f;
}

.chal-wallet-btn {
  cursor: pointer;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 14px 22px;
  border-radius: var(--r-md);
  border: none;
}

.chal-btn-ic {
  width: 16px;
  height: 16px;
}

.chal-wallet-btn {
  background: linear-gradient(100deg, #8ff8ff 0%, #4f8cff 52%, #6a3bff 115%);
  color: #04040e;
}

.chal-wallet-btn:hover {
  filter: brightness(1.08);
}

.chal-wallet-btn[disabled] {
  cursor: default;
  filter: none;
  background: rgba(57, 255, 143, 0.14);
  color: #39ff8f;
  box-shadow: inset 0 0 0 1.5px rgba(57, 255, 143, 0.4);
}

/* ---- the single CTA ---- */

.chal-accept-cta {
  width: 100%;
  max-width: var(--chal-cta-w);
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chal-accept-btn {
  width: 100%;
  font-size: clamp(15px, 2.4vw, 20px);
  padding: 18px 24px;
}

.chal-accept-note {
  font-size: 11px;
  color: #9a8fb5;
}

@media (max-width: 780px) {
  .chal-step2-note.right {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .chal-info-grid,
  .chal-meta-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* stacked stat rows share one icon column: centre the group as a whole
     instead of each row on its own width */
  .chal-meta-grid {
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
  }

  .chal-meta {
    justify-content: flex-start;
  }

  .chal-step2-main {
    flex-direction: column;
    align-items: stretch;
  }
}

/* explanatory paragraph on the "no qualifying run" state */
.chal-note {
  font-size: 12px;
  line-height: 1.7;
  color: #9a8fb5;
  text-align: center;
  margin: 4px 0 18px;
}

/* ============================================================
   MY CHALLENGES page (#chal-mine) — sits in the shared settings
   shell (style.css) but reads like BET & PLAY: header trio, a
   segmented tab strip, one glass card per challenge straight on
   the scene, then CREATE + BACK on one row. No outer plate.
   ============================================================ */

#chal-mine .chal-mine-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

#chal-mine .chal-mine-head .bet-title.mp-heading {
  margin-top: 2px;
}

/* a sentence, not the eyebrow-style caps the shell's sub uses */
.chal-mine-sub {
  margin-top: 0;
  max-width: 440px;
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: var(--ls-body);
  line-height: 1.45;
  text-transform: none;
}

/* CREATE and BACK share one row; BACK keeps the shell's button but not its
   stand-alone top margin, CREATE takes BACK's height so the pair line up */
.chal-mine-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

#chal-mine .chal-mine-actions .settings-back-btn {
  margin-top: 0;
}

.chal-mine-create {
  --btn-h: 48px;
  font-size: var(--fs-btn-sm);
  letter-spacing: var(--ls-btn-sm);
  padding: 0 var(--sp-6);
  white-space: nowrap;
}

/* the content box is not a plate here — the cards are the plates, the same
   way #settings-screen strips its own .settings-content */
#chal-mine .settings-content {
  width: min(760px, 100%);
  gap: 12px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  /* the list scrolls inside its own box, the same way HISTORY's #tx-list
     does, so the header, tabs and CREATE + BACK stay put however long it
     gets. The cards have no shadow or hover transform, so clipping at
     the box edge costs nothing. */
  max-height: 44vh;
  overflow-y: auto;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#chal-mine .settings-content::-webkit-scrollbar {
  display: none;
}

/* ---- tab strip: the wallet screen's segmented control, four tracks ---- */

.chal-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(560px, 100%);
  padding: 4px;
  border-radius: 10px;
  background: rgba(8, 8, 22, 0.8);
}

.chal-tab {
  border: none;
  padding: 10px 0;
  border-radius: var(--r-sm);
  background: none;
  font-family: "Orbitron", sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 2px;
  color: #9a8fb5;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* the same 44px touch floor every other tab/chip in the app gets */
@media (pointer: coarse) {
  .chal-tab {
    min-height: var(--h-md);
  }
}

.chal-tab b {
  color: #fff;
  margin-left: 2px;
}

.chal-tab:hover:not(.on) {
  color: #e9edff;
}

.chal-tab.on {
  background: rgba(79, 140, 255, 0.18);
  color: #e9edff;
  box-shadow: inset 0 0 0 1px rgba(120, 170, 255, 0.5);
}

/* ---- cards ---- */

.chal-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.chal-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 14px;
  border-radius: var(--r-md);
  background: rgba(16, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.chal-card:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(26, 30, 60, 0.7);
}

.chal-card.closed {
  border-color: rgba(255, 255, 255, 0.09);
}

.chal-card.closed .chal-card-thumb img {
  filter: saturate(0.5) brightness(0.75) drop-shadow(0 12px 16px rgba(0, 0, 0, 0.6));
}

/* the frozen-in car, framed the way YOUR VEHICLE frames it: the thumb PNGs
   carry ~25% clear margin, so the image is drawn oversize on a tinted
   plate and clipped by the box */
.chal-card-thumb {
  --veh-tint: #4f8cff;
  position: relative;
  flex: 0 0 auto;
  width: 132px;
  height: 88px;
  overflow: hidden;
  border-radius: var(--r-md);
  border: 1px solid rgba(120, 150, 255, 0.14);
  background:
    radial-gradient(80% 60% at 50% 100%, color-mix(in srgb, var(--veh-tint) 18%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(14, 18, 44, 0.35), rgba(6, 8, 24, 0.6));
}

.chal-card-thumb::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 8%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--veh-tint) 55%, #4f8cff), transparent);
  filter: blur(14px);
  opacity: 0.8;
}

.chal-card-thumb img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 165%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.6));
}

.chal-card-thumb .chal-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
}

.chal-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* YOUR CHALLENGE / BY @racer */
.chal-card-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: #9a8fb5;
  text-transform: uppercase;
}

.chal-card-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chal-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.chal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #c9c3de;
  white-space: nowrap;
}

.chal-chip svg,
.chal-card-when svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: #8ab4ff;
}

.chal-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11px;
  color: #9a8fb5;
}

.chal-card-when {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #c9c3de;
}

.chal-card-foot .in {
  color: #39ff8f;
  font-weight: 700;
}

.chal-card-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.chal-card-actions .btn {
  gap: 6px;
}

.chal-card-actions svg {
  width: 14px;
  height: 14px;
}

/* loading / not connected / error / empty tab */
.chal-mine-notice {
  width: 100%;
  padding: 28px 20px;
  border-radius: var(--r-lg);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #9a8fb5;
  background: rgba(16, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
}

@media (max-width: 560px) {
  /* BACK drops to 44px here (style.css); CREATE follows */
  .chal-mine-create {
    --btn-h: 44px;
  }
}

@media (max-width: 760px) {
  /* once thumb + text + two buttons no longer fit one row, the buttons
     take a row of their own (the title would otherwise ellipsise the
     entry fee, its primary number) */
  .chal-card {
    flex-wrap: wrap;
  }

  .chal-card-title {
    white-space: normal;
  }

  .chal-card-actions {
    flex: 1 0 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .chal-tab {
    font-size: 10px;
    letter-spacing: 1px;
    padding: 9px 0;
  }

  .chal-card {
    gap: 12px;
    padding: 12px;
  }

  .chal-card-thumb {
    width: 104px;
    height: 72px;
  }

  .chal-card-thumb img {
    width: 190%;
  }
}

@media (max-width: 380px) {
  /* four Orbitron labels with counts fit one row from 390px up; below
     that (375 / 360 / 320) they wrap, so the strip takes two rows */
  .chal-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- phone widths: the one thing that would not shrink ----
   The X handle is one unbreakable word in 26px Orbitron ("@speedster_
   longhandle" is 360px wide) and pushed #chal-view past a 320–375px
   viewport. Fluid type instead. (The outcome card handles its own
   breakpoints above.) */
.chal-handle {
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  font-size: clamp(18px, 6.5vw, 26px);
  overflow-wrap: anywhere;
}

.chal-handle-sub,
.chal-taunt,
.chal-beat-sub {
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* WAIT card: somebody else holds the challenge's slot — one player at a time */

.chal-busy-card {
  width: 100%;
  max-width: var(--chal-cta-w);
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-radius: var(--r-md);
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.28);
  text-align: center;
}

.chal-busy-title {
  font-size: clamp(14px, 2.2vw, 18px);
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #8ab4ff;
}

.chal-busy-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #c9c3de;
  max-width: 420px;
}

.chal-busy-desc b {
  color: #fff;
}

.chal-busy-timer {
  margin-top: 6px;
  font-size: clamp(34px, 6vw, 48px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  animation: chal-busy-pulse 2s ease-in-out infinite;
}

.chal-busy-sub {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #9a8fb5;
}

@keyframes chal-busy-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chal-busy-timer {
    animation: none;
  }
}

/* The creator's own view (challengeUI.js renderOwnCard): the WAIT card with
   the share row from CHALLENGE CREATED in place of a button. */
.chal-own-card .chal-share-row {
  width: 100%;
  margin-top: 6px;
}

.chal-own-card .btn-row {
  width: 100%;
  margin-top: 6px;
}

/* The queue in front of the slot (challengeQueue.js): the same card as the
   WAIT above, tinted by what it is telling the player — waiting (blue, as
   is), their turn (green), a turn that ran out (red). */
.chal-queue-card .btn-row {
  width: 100%;
  margin-top: 6px;
}

.chal-queue-card .btn-row .btn {
  flex: 1 1 160px;
}

.chal-queue-card .chal-accept-btn {
  width: auto;
}

.chal-queue-card .chal-pay-progress {
  width: 100%;
}

.chal-queue-card .chal-queue-funding {
  width: 100%;
  margin-top: 6px;
}

.chal-queue-est {
  font-size: 13px;
  color: #c9c3de;
}

.chal-queue-est b {
  color: #fff;
}

.chal-queue-card.turn {
  background: rgba(57, 255, 143, 0.08);
  border-color: rgba(57, 255, 143, 0.34);
}

.chal-queue-card.turn .chal-busy-title {
  color: #39ff8f;
}

.chal-queue-card.turn .chal-busy-timer {
  animation: chal-turn-pulse 1s ease-in-out infinite;
}

.chal-queue-card.expired {
  background: rgba(255, 92, 92, 0.08);
  border-color: rgba(255, 92, 92, 0.3);
}

.chal-queue-card.expired .chal-busy-title {
  color: #ff8c8c;
}

@keyframes chal-turn-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chal-queue-card.turn .chal-busy-timer {
    animation: none;
  }
}
