:root {
  color-scheme: light;
  --ink: #263437;
  --muted: #657376;
  --cream: #fff9e9;
  --paper: #fffdf5;
  --turquoise: #138f91;
  --turquoise-dark: #086267;
  --red: #d95d3f;
  --red-dark: #963921;
  --gold: #f4b92e;
  --wood: #945127;
  --green: #36784f;
  --streak-heat: 0;
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; min-width: 760px; min-height: 560px; overflow: hidden; }
body { margin: 0; color: var(--ink); background: #9bd8ee; }
button { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 4px solid #075f75; outline-offset: 4px; }

.rodeo {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: #eeb654 url("./art/backdrop-01.webp") center / cover no-repeat;
}
.rodeo::after { position: absolute; z-index: -1; inset: 0; content: ""; background: linear-gradient(180deg, rgba(18,86,126,.01), rgba(96,52,14,.14)); }
.sunwash { position: absolute; z-index: -1; inset: 0; background: radial-gradient(circle at 72% 5%, rgba(255,250,193,.42), transparent 34%); pointer-events: none; }

.hud {
  position: absolute;
  z-index: 20;
  left: 24px;
  right: 24px;
  top: 18px;
  height: 64px;
  display: grid;
  grid-template-columns: 210px 1fr auto;
  align-items: center;
  gap: 18px;
}
.round-chip, .difficulty, .scoreboard { border: 1px solid rgba(63,47,27,.18); background: rgba(255,253,245,.94); box-shadow: 0 5px 0 rgba(88,54,27,.18), 0 12px 28px rgba(79,47,21,.12); backdrop-filter: blur(9px); }
.round-chip { height: 64px; display: grid; align-content: center; padding: 9px 17px; border-radius: 18px; }
.round-chip span, .scoreboard span, .difficulty span { color: var(--muted); font-size: 10px; font-weight: 1000; letter-spacing: .1em; text-transform: uppercase; }
.round-chip strong { margin-top: 2px; font-size: 18px; }
.difficulty { justify-self: center; width: min(340px,100%); padding: 11px 15px; border-radius: 17px; }
.difficulty > i { display: block; height: 8px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: #dedfce; }
.difficulty > i b { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--red)); transition: width 150ms ease-out; }
.scoreboard { height: 64px; display: flex; align-items: stretch; padding: 6px; border-radius: 18px; }
.scoreboard > div { min-width: 76px; display: grid; place-content: center; padding: 0 12px; text-align: center; }
.scoreboard > div + div { border-left: 1px solid #e0dccb; }
.scoreboard strong { min-height: 25px; display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 1px; font-size: 23px; line-height: 1; }
.scoreboard strong b { font: inherit; }
.star-score i { color: #d58b0f; font-size: 19px; font-style: normal; text-shadow: 0 2px #fff; }
.streak-fire { position: relative; width: 15px; height: 20px; display: block; opacity: calc(.35 + var(--streak-heat) * .1); transform: scale(calc(.75 + var(--streak-heat) * .06)); transform-origin: 50% 100%; border-radius: 55% 45% 60% 40%; background: linear-gradient(160deg, #ffd43b 25%, #f47e25 60%, #d94a2f); clip-path: polygon(50% 0, 78% 32%, 100% 62%, 78% 100%, 22% 100%, 0 62%, 26% 39%); transition: transform 150ms ease-out, opacity 150ms ease-out; }

.mascot-zone { position: absolute; z-index: 5; left: 14px; bottom: 10px; width: 250px; height: calc(100% - 100px); pointer-events: none; }
.mascot { position: absolute; left: 0; bottom: -46px; width: 238px; max-height: 74%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 12px 8px rgba(63,38,16,.24)); transform-origin: 52% 88%; transition: transform 150ms ease-out, filter 150ms ease-out; }
.lasso-flourish { position: absolute; left: 141px; bottom: 24%; width: 108px; opacity: .94; transform: rotate(17deg); transform-origin: 22% 78%; filter: drop-shadow(0 5px 3px rgba(70,41,10,.2)); }
.rodeo.is-cheering .mascot { animation: mascot-cheer 650ms ease-out both; }
.rodeo.is-cheering .lasso-flourish { animation: lasso-swing 620ms ease-out both; }
.rodeo.is-missing .mascot { transform: rotate(2deg) scale(.985); filter: drop-shadow(0 12px 8px rgba(63,38,16,.24)) saturate(.86); }

.game-card {
  position: absolute;
  z-index: 4;
  left: 260px;
  right: 24px;
  top: 98px;
  bottom: 22px;
  display: grid;
  grid-template-rows: auto minmax(290px, 1fr) minmax(64px, auto) 64px;
  min-height: 0;
  padding: 24px 30px 22px;
  border: 1px solid rgba(99,65,34,.2);
  border-radius: 28px;
  background: rgba(255,253,245,.955);
  box-shadow: 0 9px 0 rgba(101,61,28,.22), 0 30px 55px rgba(71,45,21,.18);
  backdrop-filter: blur(7px);
}
.mission { min-height: 58px; display: grid; place-items: center; text-align: center; }
.mission h1 { margin: 0; font-size: clamp(30px, 3.35vw, 48px); line-height: 1.02; letter-spacing: -.045em; text-wrap: balance; }
.arena { position: relative; min-height: 290px; display: grid; grid-template-columns: minmax(145px, 185px) minmax(330px, 1fr) minmax(145px, 185px); align-items: center; justify-content: center; gap: 2px; padding-top: 10px; }

.corral { position: relative; z-index: 3; align-self: center; width: 100%; max-width: 185px; height: 220px; padding: 0; border: 0; background: none; cursor: pointer; transition: transform 150ms ease-out, filter 150ms ease-out; }
.gate-art { position: absolute; z-index: 1; left: 0; right: 0; top: 34px; width: 100%; filter: drop-shadow(0 7px 3px rgba(66,39,16,.2)); transform-origin: 8% 55%; transition: transform 150ms ease-out, filter 150ms ease-out; }
.corral-right .gate-art { transform-origin: 92% 55%; }
.corral-sign { position: absolute; z-index: 4; left: 50%; top: 2px; min-width: 96px; padding: 7px 13px; transform: translateX(-50%) rotate(-2deg); border: 2px solid #6d3f22; border-radius: 7px; color: #fff9dd; background: #955329; box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 3px 0 rgba(75,42,19,.16); font-size: 12px; font-weight: 1000; letter-spacing: .09em; text-transform: uppercase; }
.corral-right .corral-sign { transform: translateX(-50%) rotate(2deg); }
.corral strong { position: absolute; z-index: 4; left: 50%; top: 91px; min-width: 118px; padding: 9px; transform: translateX(-50%); border: 3px solid #25363a; border-radius: 13px; color: #25363a; background: #fff6cd; box-shadow: 0 5px 0 rgba(54,40,25,.2); font-size: clamp(23px, 2.25vw, 34px); line-height: 1; transition: color 150ms ease-out, background 150ms ease-out, transform 150ms ease-out; }
.corral:hover:not(:disabled), .corral.is-hovered { transform: translateY(-5px) scale(1.035); filter: saturate(1.12); }
.corral:active:not(:disabled) { transform: translateY(2px) scale(.99); }
.corral:disabled { cursor: default; }
.corral.is-correct strong { color: white; background: var(--green); transform: translateX(-50%) scale(1.06); }
.corral.is-correct .gate-art { animation: gate-open-left 650ms ease-out both; }
.corral-right.is-correct .gate-art { animation-name: gate-open-right; }
.corral.is-wrong .gate-art { animation: gate-thud 470ms ease-out; }

.number-line-wrap { position: relative; z-index: 5; height: 245px; align-self: center; overflow: visible; }
.number-line { display: block; width: 100%; height: 220px; overflow: visible; }
.rail-shadow, .rail { fill: none; stroke-linecap: round; }
.rail-shadow { stroke: rgba(81,47,24,.2); stroke-width: 25; }
.rail { stroke: #92562e; stroke-width: 19; }
.end-knot { fill: none; stroke: #27373a; stroke-width: 7; stroke-linecap: round; }
.midpoint-post path { fill: none; stroke: #805337; stroke-width: 7; stroke-linecap: round; }
.midpoint-post circle { fill: #f2c664; stroke: #805337; stroke-width: 4; }
.midpoint-post.is-pointing { animation: midpoint-pulse 520ms ease-out 2; transform-origin: center; }
.number-token { --token-left: 50%; position: absolute; z-index: 8; left: var(--token-left); top: 39px; width: 98px; height: 98px; display: grid; place-items: center; padding: 0; transform: translateX(-50%); border: 4px solid #27373a; border-radius: 50%; color: #263437; background: var(--gold); box-shadow: 0 8px 0 #b87718, 0 14px 24px rgba(92,55,17,.22); cursor: grab; touch-action: none; transition: left 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out, opacity 150ms ease-out; }
.number-token::before { position: absolute; left: 50%; top: 93%; width: 5px; height: 43px; content: ""; transform: translateX(-50%); border-radius: 5px; background: #27373a; z-index: -1; }
.number-token::after { position: absolute; inset: 8px; content: ""; border: 2px dashed rgba(107,60,9,.38); border-radius: 50%; }
.number-token b { z-index: 2; font-size: clamp(22px, 2.15vw, 32px); letter-spacing: -.055em; }
.number-token.is-long b { font-size: 24px; }
.number-token.is-very-long b { font-size: 19px; }
.number-token:hover:not(:disabled) { transform: translateX(-50%) translateY(-3px) rotate(-2deg); }
.number-token.is-dragging { cursor: grabbing; transform: translateX(-50%) scale(1.09) rotate(2deg); box-shadow: 0 3px 0 #b87718, 0 10px 18px rgba(92,55,17,.2); transition: transform 90ms ease-out, box-shadow 90ms ease-out; }
.number-token.is-caught { animation: token-tumble 650ms ease-out both; }
.number-token.is-rejected { animation: token-bounce 760ms ease-out both; }
.rope-loop { position: absolute; inset: -17px; border: 6px solid #d89320; border-radius: 50%; box-shadow: 0 0 0 2px #7e4819; pointer-events: none; }
.rope-loop::after { position: absolute; left: 45%; top: 91%; width: 8px; height: 56px; content: ""; transform: rotate(-14deg); border-radius: 5px; background: #d89320; box-shadow: 2px 0 #7e4819; }
.drag-hint { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; color: var(--muted); text-align: center; font-size: 13px; font-weight: 850; }

.result { width: min(760px, 95%); min-height: 64px; display: grid; align-content: center; justify-self: center; padding: 10px 22px; opacity: 0; transform: translateY(7px); border-radius: 17px; background: transparent; text-align: center; pointer-events: none; transition: opacity 150ms ease-out, transform 150ms ease-out, background 150ms ease-out; }
.result.is-visible { opacity: 1; transform: none; background: #eef7ee; }
.result.is-hint { opacity: 1; transform: none; background: #fff4dc; }
.result strong { color: var(--green); font-size: 22px; line-height: 1.1; }
.result.is-hint strong { color: #8c4b25; font-size: 17px; }
.result p { margin: 5px 0 0; color: #31494b; font-size: 15px; font-weight: 800; line-height: 1.3; }
.result.is-hint p { margin: 0; }
.actions { min-height: 64px; display: flex; align-items: center; justify-content: center; }
.primary { min-width: 220px; min-height: 52px; padding: 10px 24px; border: 2px solid var(--turquoise-dark); border-radius: 15px; color: white; background: var(--turquoise); box-shadow: 0 6px 0 var(--turquoise-dark); font-size: 16px; font-weight: 1000; cursor: pointer; transition: transform 150ms ease-out, box-shadow 150ms ease-out; }
.primary.is-gold { border-color: #8f5c0d; color: #4f3308; background: var(--gold); box-shadow: 0 6px 0 #a56b0f; }
.primary:hover { transform: translateY(-2px); }
.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 currentColor; }

.corral-dust { position: absolute; z-index: 10; left: 50%; top: 122px; pointer-events: none; }
.corral-dust i { position: absolute; width: 18px; height: 18px; opacity: 0; border-radius: 50% 45% 55% 48%; background: #dca542; }
.corral.is-correct .corral-dust i { animation: dust 680ms ease-out both; }
.corral-dust i:nth-child(1) { --x: -72px; --y: -44px; }
.corral-dust i:nth-child(2) { --x: -38px; --y: -76px; animation-delay: 35ms; }
.corral-dust i:nth-child(3) { --x: 6px; --y: -84px; animation-delay: 65ms; }
.corral-dust i:nth-child(4) { --x: 52px; --y: -61px; animation-delay: 90ms; }
.corral-dust i:nth-child(5) { --x: 73px; --y: -12px; animation-delay: 120ms; }
.star-burst { position: absolute; z-index: 40; right: 105px; top: 46px; opacity: 0; color: #ffd24a; font-size: 38px; line-height: 1; pointer-events: none; text-shadow: 0 3px 0 #a6630e, 0 0 18px white; }
.rodeo.is-celebrating .star-burst { animation: star-pop 720ms ease-out both; }

@keyframes mascot-cheer { 0% { transform: none; } 35% { transform: translateY(-10px) rotate(-7deg) scale(1.05); } 70% { transform: translateY(-3px) rotate(3deg) scale(1.02); } 100% { transform: none; } }
@keyframes lasso-swing { 0% { transform: rotate(17deg); } 35% { transform: translate(25px,-36px) rotate(-48deg) scale(1.12); } 70% { transform: translate(8px,-12px) rotate(30deg); } 100% { transform: rotate(17deg); } }
@keyframes gate-open-left { 0% { transform: perspective(420px) rotateY(0); } 45%, 100% { transform: perspective(420px) rotateY(-64deg) translateX(-8px); filter: drop-shadow(10px 8px 4px rgba(66,39,16,.22)); } }
@keyframes gate-open-right { 0% { transform: perspective(420px) rotateY(0); } 45%, 100% { transform: perspective(420px) rotateY(64deg) translateX(8px); filter: drop-shadow(-10px 8px 4px rgba(66,39,16,.22)); } }
@keyframes gate-thud { 0%, 100% { transform: none; } 38% { transform: translateX(-7px) rotate(-1deg); } 62% { transform: translateX(5px) rotate(1deg); } }
@keyframes token-tumble { 0% { opacity: 1; } 45% { transform: translateX(-50%) translateY(25px) rotate(110deg) scale(.86); } 100% { opacity: 0; transform: translateX(-50%) translateY(82px) rotate(230deg) scale(.46); } }
@keyframes token-bounce { 0% { transform: translateX(-50%) scale(1); } 28% { transform: translateX(-50%) translateY(3px) scale(.92, 1.08); } 44% { transform: translateX(-50%) translateY(-24px) rotate(-7deg) scale(1.03); } 70% { transform: translateX(-50%) translateY(0) rotate(3deg); } 100% { transform: translateX(-50%); } }
@keyframes midpoint-pulse { 50% { transform: scale(1.1); filter: drop-shadow(0 0 11px rgba(244,185,46,.9)); } }
@keyframes dust { 0% { opacity: 0; transform: translate(0,0) scale(.2); } 28% { opacity: .9; } 100% { opacity: 0; transform: translate(var(--x),var(--y)) scale(1.35) rotate(150deg); } }
@keyframes star-pop { 0% { opacity: 0; transform: scale(.2) rotate(-25deg); } 35% { opacity: 1; transform: translateY(-10px) scale(1.45) rotate(10deg); } 70% { opacity: 1; transform: translateY(0) scale(.95) rotate(-3deg); } 100% { opacity: 0; transform: scale(1); } }

.rodeo.is-reduced-motion .number-token { pointer-events: none; cursor: default; }
.rodeo.is-reduced-motion .drag-hint { font-size: 14px; }
.rodeo.is-reduced-motion.is-cheering .mascot,
.rodeo.is-reduced-motion.is-cheering .lasso-flourish,
.rodeo.is-reduced-motion.is-celebrating .star-burst,
.rodeo.is-reduced-motion .corral.is-correct .gate-art,
.rodeo.is-reduced-motion .corral.is-correct .corral-dust i,
.rodeo.is-reduced-motion .number-token.is-caught,
.rodeo.is-reduced-motion .number-token.is-rejected { animation: none; }

@media (max-width: 1000px) {
  .game-card { left: 205px; right: 16px; padding-left: 20px; padding-right: 20px; }
  .mascot-zone { left: -18px; width: 225px; }
  .mascot { width: 220px; }
  .lasso-flourish { left: 126px; width: 98px; }
  .arena { grid-template-columns: 145px minmax(290px,1fr) 145px; }
  .corral { height: 200px; }
  .corral strong { min-width: 102px; top: 83px; }
}

@media (max-height: 700px) {
  .hud { top: 10px; height: 58px; }
  .round-chip, .scoreboard { height: 58px; }
  .game-card { top: 82px; bottom: 14px; grid-template-rows: auto minmax(260px,1fr) minmax(52px,auto) 54px; padding-top: 17px; padding-bottom: 16px; }
  .mission { min-height: 48px; }
  .arena { min-height: 260px; padding-top: 0; }
  .number-line-wrap { height: 225px; }
  .number-line { height: 205px; }
  .number-token { top: 32px; width: 90px; height: 90px; }
  .actions { min-height: 54px; }
  .primary { min-height: 48px; }
  .result { min-height: 52px; }
}

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