<script lang="ts">
	import { resolve } from '$app/paths';
	import type { ComputedAreas, ComputedSeries, HorizontalRule } from '$lib/chart';
	import { AptitudeLevel, downhillAccelEnterChance, frontModeEnterChance, moveLaneModifier, paceUpEnterChance, Phase, RUNNING_STYLES, RunningStyle, sectionSpeed, skillWitCheck, spotStruggleDuration, spotStruggleSpeed, spurtSpeed, Stat, uphillMod } from '$lib/race';
	import Skill from '$lib/Skill.svelte';
	import StatChart from '$lib/StatChart.svelte';
	import Sec from '../Sec.svelte';

	let raceLen = $state(2000);
	let secSpeedStyle = $state(RunningStyle.FrontRunner);

	function mean2(x: [number, number]): number {
		return (x[0] + x[1]) * 0.5;
	}
	function modemean(x: number, bonus: number, p: number): number {
		return x * (1 - p) + x * bonus * p;
	}

	const secSpeedS = 1200;
	const secSpeedA = 1000;
	const secSpeedExample = $derived(sectionSpeed(raceLen, secSpeedS, secSpeedS*1.1, RunningStyle.FrontRunner, Phase.EarlyRace));
	const secSpeedInfo = $derived(secSpeedExample.map((x) => x.toFixed(2)).join(' to '));
	const secSpeedPassTime = $derived.by(() => {
		const sSecSpeed = mean2(sectionSpeed(raceLen, secSpeedS, secSpeedS*1.1, RunningStyle.FrontRunner, Phase.MidRace));
		const sMode = frontModeEnterChance(secSpeedS*1.1);
		const sOvertakeSpeed = modemean(sSecSpeed, 1.05, sMode);
		const aSecSpeed = mean2(sectionSpeed(raceLen, secSpeedA, secSpeedA, RunningStyle.FrontRunner, Phase.MidRace));
		const aMode = frontModeEnterChance(secSpeedA);
		const aSpeedupSpeed = modemean(aSecSpeed, 1.04, aMode);
		const r = 2/(sOvertakeSpeed - aSpeedupSpeed);
		return r.toFixed(1);
	});

	const frontModeCheckSeries: ComputedSeries[] = [
		{ label: "Aptitude S", y: (x) => 100*frontModeEnterChance(x*1.1) },
		{ label: "Aptitude A", y: (x) => 100*frontModeEnterChance(x) },
	];
	const skillCheckSeries: ComputedSeries[] = [
		{ label: "1 of 1", y: (x) => 100*skillWitCheck(x, 1, 1) },
		{ label: "1 of 2 or 2 of 2", y: (x) => 100*(skillWitCheck(x, 2, 1) + skillWitCheck(x, 2, 2)) },
		{ label: "2 of 2", y: (x) => 100*skillWitCheck(x, 2, 2) },
	];
	const ssBoostSeries: ComputedSeries = { label: "Target Speed Boost", y: (x) => spotStruggleSpeed(x) };
	const ssDurSeries: ComputedSeries[] = [
		{ label: "Front Runner S", y: (x) => spotStruggleDuration(x, AptitudeLevel.S) },
		{ label: "Front Runner A", y: (x) => spotStruggleDuration(x, AptitudeLevel.A) },
	];
	const laneComboSeries: ComputedSeries = {label: "Target Speed Boost", y: (x) => moveLaneModifier(x) };
	const lcYRule: HorizontalRule[] = [
		{ label: "+0.35", y: 0.35 },
		{ label: "+0.45", y: 0.45 },
	];
	const uphillSeries: ComputedSeries[] = [
		{ label: "+2 Hill", y: (x) => uphillMod(x, 2.0) },
		{ label: "+1.5 Hill", y: (x) => uphillMod(x, 1.5) },
		{ label: "+1 Hill", y: (x) => uphillMod(x, 1.0) },
	];
	const uphillYRule: HorizontalRule[] = [
		{ label: "Dominator", y: -0.25 },
	];
	const downhillSeries: ComputedSeries[] = [
		{ label: "Style S", y: (x) => downhillAccelEnterChance(x * 1.1) * 100 },
		{ label: "Style A", y: (x) => downhillAccelEnterChance(x) * 100 },
	];
	const secIsFront = $derived(secSpeedStyle === RunningStyle.FrontRunner || secSpeedStyle === RunningStyle.GreatEscape);
	const secSpeedSeries: Array<ComputedAreas | null> = $derived([
		{
			label: "Early Race",
			y1: (x) => sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[0],
			y2: (x) => sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[1],
		},
		{
			label: "Mid Race",
			y1: (x) => sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[0],
			y2: (x) => sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[1],
		},
		secIsFront ? {
			label: "Early Race + Mean Speed-Up Mode",
			y1: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[0], 1.04, frontModeEnterChance(x)),
			y2: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[1], 1.04, frontModeEnterChance(x)),
		} : {
			label: "Early Race + Mean Pace-Up Mode",
			y1: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[0], 1.04, paceUpEnterChance(x)),
			y2: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.EarlyRace)[1], 1.04, paceUpEnterChance(x)),
		},
		secIsFront ? {
			label: "Mid Race + Mean Speed-Up Mode",
			y1: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[0], 1.04, frontModeEnterChance(x)),
			y2: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[1], 1.04, frontModeEnterChance(x)),
		} : {
			label: "Mid Race + Mean Pace-Up Mode",
			y1: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[0], 1.04, paceUpEnterChance(x)),
			y2: (x) => modemean(sectionSpeed(raceLen, x, x, secSpeedStyle, Phase.MidRace)[1], 1.04, paceUpEnterChance(x)),
		},
	]);
</script>

<article class="mx-auto max-w-4xl text-justify">
	<Sec h="1" id="top" class="text-center">Front Runner Black Magic</Sec>
	<p>
		Front runners are playing a fundamentally different game versus other running styles. Building them isn't too hard, and their
		careers tend to be easy, but some of the things you need (and don't need) to make a <i>really good</i> front runner are surprising.
	</p>
	<p>
		This document is advanced material. The target audience intends to win Champions Meet Group A Finals and either wants to use
		front runners to do it or wants to understand what front runners they need to beat. This is meant for players who are already
		strong at training: players who can take a target stat line and skill set and turn it into a horse. This document is about the
		mechanics that determine what those stat lines and skill sets should be.
	</p>

	<Sec h="2" id="me">About Me</Sec>
	<p>
		About three weeks after Global launched, my friend told me to get a job, so I sent him a screenshot of me clicking the install
		button on Umamusume. Since then, I have been a mostly-F2P player, with the single exception of the First Anniversary SSR pick
		ticket. (I haven't even spent the accompanying paid carats.)
	</p>
	<p>
		I'm committed to running exclusively triple fronts for every Champions' Meet, starting since CM8 Sagittarius Cup (Arima
		Kinen). When I'm not training for CM, I'm usually making front runner parents, and was at one time the owner of the Seiun Sky
		with the most white sparks on global. I have a lot of experience training, running, and watching front runners.
	</p>
	<p>
		That said, most of the information here is ultimately my interpretations of <a
			href="https://docs.google.com/document/d/15VzW9W2tXBBTibBRbZ8IVpW6HaMX8H0RP03kq6Az7Xg/edit?usp=sharing"
			target="_blank"
			rel="noopener noreferrer">kuromiAK's Race Mechanics doc</a
		>. Many of those interpretations are also informed by the exceptionally knowledgeable folks on the
		<a href="https://discord.gg/SyAVkbBSkx" target="_blank" rel="noopener noreferrer">GameTora Discord server</a>.
		I may present some of the information from the race mechanics doc in chart form, but I will generally leave out exact mechanic numbers and conditions;
		the doc is already the place for that information.
	</p>
	<p>
		I want to share the knowledge I've accrued about front runners, because teaching is my favorite thing. Definitely not just to
		rationalize running triple fronts for every CM even though it's not actually very good and most of my favorite horses are late
		surgers.
	</p>

	<Sec h="2" id="mechanics">Race Mechanics</Sec>
	<p>
		Very quick gloss of race fundamentals. Races are divided into four phases: early race, mid race, late race, and last spurt
		phase. They are also divided into twenty-four equal length sections. Early race is sections 1 to 4, mid race is sections 5 to
		16, late race is sections 17 to 20, and last spurt phase is sections 21 to 24. Spot Struggle can start between 150m and the
		end of section 5, and is forced to end at the start of section 9. Position Keep ends after section 10.
	</p>
	<p>
		The numeric value of acceleration depends on the Power stat, dueling, surface aptitude, uphills, race phase, running style. At
		the start of early race, horses accelerate from 3 m/s to the early race <i>base target speed</i>, which varies by race
		distance and running style but is generally on the order of 20 m/s. At the start of late race, if they have enough HP remaining for their last spurt, horses
		accelerate from the mid race base target speed to their spurt speed, which varies by speed stat, distance aptitude, running style, race
		distance, and guts stat, in decreasing order of effect. "Last spurt" and "last spurt phase" are different and
		unrelated things; the latter is only used in the condition for <Skill skill={200512} hint="homestretch haste" mention />.
	</p>
	<p>
		Speed skills add a flat amount of target speed, generally +0.15 m/s for white skills, +0.25 m/s for double circle skills and
		some inherited uniques, +0.35 m/s for gold skills and most speed uniques, and +0.45 m/s for a handful of speed uniques. Accel
		skills similarly add a flat amount of acceleration, typically +0.1 or +0.2 m/s² for white skills and inherited uniques, or +0.3
		or +0.4 m/s² for gold skills and uniques.
	</p>

	<Sec h="3" id="runaway">Runaway</Sec>
	<p>
		The skill <Skill skill={202051} hint="runaway" /> converts front runners into the <i>Great Escape</i> running style. However, no player has ever uttered
		the words "Great Escape" when talking about Umamusume, presumably because Runaway is a much cooler name.
		("Great Escape" is a direct translation of Japanese 大逃げ <i>oonige</i>, whereas "Front Runner" is a more liberal localization of 逃げ <i>nige</i> that technically just means "escape.")
	</p>
	<p>
		Runaways are still front runners for all purposes.
		The main difference is just different numbers for things like base speed and acceleration, stamina to HP conversion, and distance thresholds for running modes.
		Other mechanics that are specific to front runners also apply to runaways.
	</p>

	<Sec h="2" id="win-cons">Win Conditions</Sec>
	<p>
		On Global today, competitive horses usually have stat lines that are pretty similar to each other.
		Races, therefore, are more often won by skills &ndash; typically acceleration skills that activate at the start of late race.
		Front runners have strong options.
	</p>
	<ul class="list-disc pl-4 mb-4">
		<li>
			<Skill skill={900201} hint="angling" />, sometimes called Rod, is the second best skill in the game.
			Because only the horse in first place gets it, everything about training front runners becomes a matter of being in front at the start of late race, true to name.
		</li>
		<li>
			On long distance tracks, <Skill skill={900681} hint="vc" /> takes that role instead.
			The front two horses get it, which opens the opportunity for multi-front builds using <Skill skill={200492} hint="nn" mention />/<Skill skill={200491} hint="nsm" mention /> &ndash;
			especially because VC tracks aren't subject to the final corner spread that makes those skills worse on sprints and miles &ndash;
			but otherwise the function is the same.
		</li>
		<li>
			On those sprints where Angling is dead, the front-specific options include <Skill skill={900141} hint="pasta" /> (VPP, or Pasta) and <Skill skill={910451} hint="mummy creek" /> (HCreek),
			It takes both of them to equal Angling, so such sprints may be better served gambling on <Skill skill={200651} hint="turbo sprint" mention />, <Skill skill={200371} hint="rushing gale" mention />, and possibly <Skill skill={200551} hint="unrestrained" mention /> instead.
			Front runners are especially strong on sprints for <a href="#spot-struggle">other reasons</a> anyway.
		</li>
	</ul>
	<p>
		<Skill skill={200491} hint="nsm" /> is the best skill in the game.
		Unfortunately, for the most part, it's bad on front runners; generally not a win condition.
		Activating NSM requires not being in first, which means whoever <i>was</i> used Angling and is pulling away from you before you accumulate the blocked time to activate it.
		Again, VC tracks may be an exception if you specifically build for it.
	</p>

	<Sec h="2" id="pdm">Pace Down Mode</Sec>
	<p>
		During the first 41.67% of the race, <i>position keep</i> is busy arranging each running style into their respective packs.
		The primary mechanism for this is pace down mode (PDM), which activates whenever a horse gets what their style defines as too close to first place.
	</p>
	<p>
		Watch a MANT late surger with 1000+ power and wit in a daily legend race.
		As long as they don't get blocked, they should <a href="#section-speed">slide forward</a> throughout the early race.
		Then, around when they reach the pace chaser pack, they'll suddenly start moonwalking back to the rest of the late surgers, often near the back of the group.
		That's PDM.
	</p>
	<p>
		On lesser running styles, early race and sometimes mid race speed skills are effectively converted from distance gain into HP conservation via PDM.
		The thing that really makes front runners good is that they don't have to worry about that &ndash; they aren't subject to PDM at all.
		Their mid race speed skills always gain distance.
	</p>

	<Sec h="2" id="front-modes">Speed-Up and Overtake Modes</Sec>
	<p>
		Instead of pace-down and pace-up, front runners have speed-up (+4% target speed for first among that front type) and overtake (+5% for not-first) modes.
		Entering these modes requires meeting certain conditions relating to positioning, which collectively can be read as "solo fronts are heavily penalized."
		They also require passing a wit check, with the same chance for both modes.
	</p>
	<div class="w-full h-60 md:h-96 max-w-3xl mx-auto">
		<StatChart class="h-full w-full max-w-3xl mx-auto" stat={Stat.Wit} y={frontModeCheckSeries} yLabel="Entry Chance (% each 2 seconds)" range={[0, 50]} xRule={1200} />
	</div>

	<Sec h="2" id="skill-timing">Skill Timing</Sec>
	<p>Thought experiment.</p>
	<p>
		Picture two cars driving on a straight freeway, both at exactly 59 mph because I am American, adjacent lanes, keeping exactly
		side by side.
	</p>
	<p>
		The one on the right then drives 1 mph faster for three seconds, creating a slight gap between them before returning to the
		previous speed. They now maintain this new gap.
	</p>
	<p>
		There is a 65 mph speed limit sign. As each of the cars pass it, they accelerate at identical rates from 59 to 69 mph over a
		duration of exactly 10.2 seconds.
	</p>
	<p>
		Since the car on the right is slightly ahead from the speed skill it used, it reaches the speed limit sign first, so it starts
		accelerating first.
	</p>
	<p>
		Until the left car reaches the sign, the right car is building a speed advantage. Having a higher speed during the accel
		period, it continually increases the gap it had, until both of them have reached the new target speed.
	</p>
	<p>
		Now the left car drives 1 mph faster for three seconds. It closes the gap between them by the same distance that the right
		car's speed skill had done prior to the speed limit change.
	</p>
	<p>
		However, since the right car also added a distance advantage over the accel period, it remains slightly ahead of the left car.
	</p>
	<p>
		This thought experiment shows that speed skills are actually more valuable before late race than during it. Thus, front
		runners not having to worry about PDM is even more of an advantage.
	</p>

	<Sec h="2" id="gate-skills">Gate Skills</Sec>
	<p>
		Gate skills are <Skill skill={201601} hint="gw" /> (GW), <Skill skill={200531} hint="ttl" /> (TTL), and <Skill skill={200431} hint="conc" /> (Conc), as well as all green skills including <Skill skill={202051} hint="runaway" mention />.
		These skills activate the moment the race starts.
	</p>
	<p>
		GW is an absolutely mandatory skill for all front runners.
		Even runaway blockers should have it, otherwise they will be passed by the normal fronts they're trying to block.
		It requires three other gate skills, which should be active greens to avoid overreliance on wit checks.
		For reference, the chart below shows proc chances of one of one, one of two, or two of two skills with wit checks.
	</p>
	<div class="w-full h-60 md:h-96 mb-4">
		<StatChart class="h-full w-full max-w-3xl mx-auto" stat={Stat.Wit} y={skillCheckSeries} yLabel="% Chance" range={[50, 100]} xRule={1000} />
	</div>
	<p>
		TTL or its white version <Skill skill={200532} hint="el" /> must be combined with GW if they want any chance of being first out of early race.
		Since the main source of TTL is the Mihono Bourbon Wit SSR from the first Halloween event, VBourbon can suffice with EL.
		(The other TTL option is the Twin Turbo SSR that does generate a lot of stats but requires winning three 50/50s to get the gold skill.)
	</p>
	<p>
		Conc is less critical.
		It's worth taking on horses who have it, but it isn't worth using support card slots just to get it.
		On the other hand, its white version <Skill skill={200432} hint="focus" /> is bad; its only real use is as a backup gate skill for GW when you don't have enough greens available.
	</p>

	<Sec h="2" id="spot-struggle">Spot Struggle</Sec>
	<p>
		For each of runaways and non-runaways, there is at most one spot struggle per race. Runaways will not spot struggle with
		non-runaways, nor vice-versa. When a spot struggle triggers, all front runnners of that type within range participate; I've
		had a horse join while in 6th a couple times.
	</p>
	<p>
		Spot struggle provides a target speed bonus that scales with the guts stat. If it isn't cut short, which will approximately
		never happen, its duration also scales with the guts stat. Unlike skills, its duration <i>does not</i> scale with race distance.
	</p>
	<div class="grid w-full h-60 md:h-96 grid-cols-2 mb-4">
		<StatChart stat={Stat.Guts} y={ssBoostSeries} yLabel="Speed Bonus (m/s)" range={[0, 0.3]} />
		<StatChart stat={Stat.Guts} y={ssDurSeries} yLabel="Duration (s)" range={[0, 12]} />
	</div>
    <p>
        Spot struggle also greatly increases HP consumption.
        For normal front runners, the rate is slightly less than Rushed.
        For runaways, it's more than double Rushed. (This is the reason people say you can't get enough stamina for runaways on Global.)
        Actually getting Rushed during spot struggle dramatically increases HP consumption, much more than just adding them together; red-light green-light pretty much guarantees that horse won't spurt.
    </p>
	<p>
		In medium+ races, the extra HP consumption is a serious consideration; front runners need more stamina and recoveries than other styles.
		At 1600m and shorter, the fact that Spot Struggle doesn't scale with race distance means that it can be worth multiple gold speed skills in total distance gained.
		See the <a href={resolve('/mspeed')}>mechanical speed calculator</a> for precise analysis.
	</p>

	<Sec h="2" id="lane-combo">Lane Combo</Sec>
	<p>
		While under the influence of a skill that increases lane movement speed (shoe icon skills), and while actively changing lanes (i.e. moving sideways), horses gain a (forward) target speed boost that scales with power.
		This was a change Global received with the Unity Cup scenario.
	</p>
	<div class="w-full h-60 md:h-96 mb-4">
		<StatChart class="h-full w-full max-w-3xl mx-auto" stat={Stat.Power} y={laneComboSeries} yLabel="Speed Boost" yRule={lcYRule} range={[0.2, 0.5]} />
	</div>
	<p>
		Front runners have access to the skill <Skill skill={201262} hint="dd" />, which forces a horse who uses it to move outward to a specific distance from the rail.
		DD almost always ends shortly before the horse has finished accelerating to early race speed, so it does not convert the move lane speed modifier into distance.
	</p>
	<p>
		We get advantage from move lane speed modifier by following DD with <Skill skill={200452} hint="pp" /> or <Skill skill={210052} hint="ignited wit" />.
		DD created an opportunity for those return skills to convert into huge forward speed.
		This setup is called <i>lane combo</i>.
	</p>
	<p>
		Lane combo is only viable on tracks where early race ends before or at most very early into the first corner.
		Since PP and Ignited WIT are <span class="font-mono">phase_random==0</span> skills, they can activate at the very end of late race.
		If there's a corner there, and your horse is still on the outside from DD, you are now physically running a longer distance than those on the inside.
		That can more than undo the gain from the lane combo itself.
	</p>
	<p>
		The <a href={resolve('/mspeed')}>mechanical speed calculator</a> has an approximation of lane combo's benefit.
		A more precise lane combo simulator <a href="https://lanecalc.hf-uma.net/" target="_blank" rel="noopener noreferrer">exists</a>,
		but I am not sufficiently confident in my Japanese to try to guide readers through it.
		<!-- TODO(zeph): i could totally annotate a picture though -->
	</p>

	<Sec h="2" id="slopes">Slopes</Sec>
	<p>
		Different slopes can be of different angles; the <i>SlopePer</i> parameter is positive for uphills and negative for downhills.
		SlopePer values that currently exist on tracks include 1, 1.5, and 2, positive or negative.
	</p>

	<Sec h="3" id="uphills">Uphills</Sec>
	<p>
		Running uphill carries a penalty to target speed.
		This penalty scales negatively with the power stat; that is, higher power means faster uphill running.
		It scales positively with slope angle.
	</p>
	<div class="w-full h-60 md:h-96 mb-4">
		<StatChart class="w-full max-w-3xl h-full mx-auto" stat={Stat.Power} y={uphillSeries} yLabel="Speed Modifier (m/s)" yRule={uphillYRule} range={[-2, 0]} />
	</div>
	<p>
		Note that surface aptitude <i>does not</i> affect uphill speed, nor power generally.
		It only affects acceleration.
	</p>
	<p>
		The practical impact is that steep early- and mid-race hills filter out front runners with low power.
		Even with an otherwise perfect build, an 800 power VBourbon is likely to be passed by a 1280 power (<Skill skill={200152} hint="firm" mention /> + <Skill skill={200282} hint="comp spirit" mention />) Seiun Sky.
	</p>
	
	<Sec h="3" id="downhills">Downhills</Sec>
	<p>
		Running downhill allows horses to enter <i>downhill accel mode</i>.
		Contrary to its name, downhill accel mode does not affect acceleration at all;
		it gives horses a target speed boost that scales with the slope angle, plus lowered HP consumption via a flat multiplier.
	</p>
	<p>
		Entering downhill accel mode requires passing a wit check.
		The success rate scales linearly with wit.
		Style aptitude <i>does</i> affect the chance to pass the check.
		Its duration is random with a geometric distribution; it does not scale with stats.
	</p>
	<div class="w-full h-60 md:h-96 mb-4">
		<StatChart class="w-full max-w-3xl h-full mx-auto" stat={Stat.Wit} y={downhillSeries} yLabel="Entry Chance (% each second)" range={[0, 60]} />
	</div>
	<p>
		Similar to uphills disproportionately rewarding front runners with higher power, downhills tend to reward high wit.
		However, the random elements of downhill accel mode mean that lower wit horses may still keep up on downhills, depending on luck.
		Conversely, the HP savings on long downhills can be enough to drop a recovery skill or two on some tracks.
	</p>

	<Sec h="2" id="section-speed">Section Speed</Sec>
	<p>
		Each section, each horse gets a random modifier to target speed.
		The modifier's range is determined by the wit stat.
		(Curiously, the calculation uses both wit as modified by style proficiency and green skills as well as base wit.)
	</p>
	<div class="w-full h-60 md:h-96 mb-24 md:mb-20">
		<StatChart class="w-full max-w-3xl h-full mx-auto mb-12 md:mb-10" stat={Stat.Wit} yArea={secSpeedSeries} yLabel="Section Speed (m/s)" range={[17.5, 22.5]} plotOptions={{color: {legend: true}}} />
		<div class="flex w-full md:max-w-2xl mx-auto">
			<label class="hidden md:inline flex-1 my-auto text-sm text-right pr-2" for="secSpeedRaceLen">Race Length</label>
			<input class="flex-1 md:flex-2 max-w-40 my-auto" type="range" id="secSpeedRaceLen" min="1000" max="3600" step="100" bind:value={raceLen} />
			<span class="flex-1 my-auto text-sm pl-2">{raceLen}m</span>
			<label class="hidden md:inline flex-1 my-auto text-sm text-right pr-2" for="secSpeedStyle">Style</label>
			<select class="flex-1 my-auto text-sm" id="secSpeedStyle" bind:value={secSpeedStyle}>
				{#each RUNNING_STYLES as [name, style] (style)}
					<option value={style}>{name}</option>
				{/each}
			</select>
		</div>
	</div>
	<p>
		Section speed is generally very small; at {secSpeedS} wit with style S, it has a range of about -0.15% to 0.5% of race base speed.
		For a front runner at {raceLen}m, that translates to an actual speed range of {secSpeedInfo} m/s.
	</p>
	<p>
		It isn't negligible, though, since it applies during the portion of the race where front runners are trying to become frontest runners.
		All else equal, including the effects of <a href="#front-modes">running modes</a>, such a horse blocked in front by a {secSpeedA} wit front A horse will pass in {secSpeedPassTime} seconds on average at mid race speeds.
	</p>

	<Sec h="2" id="phase-speed">Phase Speed</Sec>
	<p>
		Race base speed is multiplied by the strategy&ndash;phase coefficient for each horse.
		As the name suggests, SPC is different per running style and per race phase.
		It's the thing that makes runaways take off in early race, and the thing that makes pace chaser promotion scary in late race (for those not using any of the correct running style).
	</p>
	<p>
		Front runners, and even moreso runaways, have particularly punishing SPC for late race.
		This makes sense; if they weren't forced to be substantially slower than the late surgers they're thirty meters ahead of at late race start, then they would be guaranteed to win every time.
	</p>
	<p>
		Late race, or more precisely the last spurt, is also the only place where the speed stat and distance aptitude apply.
		In terms of lengths gained, distance S actually does more for front runners than any other style due to SPC.
	</p>

	<Sec h="2" id="stats">Stats</Sec>
	<Sec h="3" id="speed">Speed</Sec>
	<!-- speed matters less than for other styles; corollary: distance S matters less -->
	<Sec h="3" id="power">Power</Sec>
	<!-- uphills; surface S -->
	<Sec h="3" id="guts">Guts Actually Matters (Sometimes)</Sec>
	<!-- spot struggle (again?) -->
	<Sec h="3" id="wit">Wit</Sec>
	<!-- position keep; front S -->
	<Sec h="2" id="skills">Skills</Sec>
	<Sec h="3" id="gate-skills">Gate Skills</Sec>
	<!-- gw, ttl, conc -->
	<Sec h="3" id="lane-combo">Lane Combo</Sec>
	<!-- dd, pp, ignited wit -->
	<Sec h="3" id="front-speed-skills">Speed Skills &ndash; Front Runner Exclusives</Sec>
	<!-- escape artist, front/distance corners/straights, leader's pride, speed eater (mile) -->
	<Sec h="3" id="generic-speed-skills">Speed Skills &ndash; Generic</Sec>
	<!-- thh, ramp up, pto, slipstream -->
	<Sec h="3" id="spurt-skills">Spurt Skills</Sec>
	<!-- barcarole, triumphant pulse, all i've got -->
	<Sec h="3" id="others-skills">Other Horses' Skills</Sec>
	<!-- all-seeing eyes; sfv, u=ma2, generally pos 3-4 skills -->
	<Sec h="2" id="teams">CM Teams</Sec>
	<Sec h="3" id="solo-front">Solo Front</Sec>
	<!-- front is not an ace; should probably be a runaway -->
	<Sec h="3" id="double-front">Double Front</Sec>
	<!-- ace front and backup -->
	<Sec h="3" id="triple-front">Triple Front</Sec>
	<!-- ace front, support, and backup; killing pos 3-4 skills -->
	<Sec h="2" id="umas">Front Runners</Sec>
	<Sec h="3" id="coc">Christmas Oguri Cap</Sec>
	<Sec h="3" id="taiki-shuttle">Taiki Shuttle &amp; Curren Chan</Sec>
	<Sec h="3" id="future-fronts">Future Important Fronts</Sec>
	<!-- rickey, kitasan white, halloween mayano -->
	<Sec h="3" id="future-runaways">Future Runaways</Sec>
	<Sec h="2" id="career">Career</Sec>
	<p>
		Most front runners enjoy easy careers thanks to strong kits and little chance to be blocked. This chapter details the minutia
		of career races, especially in MANT.
	</p>
	<Sec h="3" id="career-skills">Taking Skills</Sec>
	<p>
		Contrary to advice I sometimes see, you can, in fact, take skills during career without Fast Learner. When you take skills
		mid-run without Fast Learner, and you happen to get it later, you effectively lose 10% of the SP you spent to that point.
		However, you also <i>prune</i> hints: taking the first level of a skill removes it from the pools for support card hint bubbles,
		MANT rivals, UC bursts, and everything else except events that grant specific hints. Each front-specific skill you own improves
		your chance of getting skills you don't have hints for.
	</p>
	<p>
		<b>Early Lead</b> is a snap take skill. The <i>only</i> time to sit on Early Lead is when you happen to get the first +1 hint
		the turn before inspiration. (Even then, I'd probably still take it.) Early Lead is one of the strongest skills in terms of
		lengths gained, it applies to all tracks and conditions, and <i>it saves late starts</i>, which are your only source of losses
		on most races after junior year. Moreover, it has a base cost of only 120 SP; even if you do get Fast Learner after taking it,
		your opportunity cost was 12 SP. If you prune Early Lead and a hint lands on Fast-Paced or Leader's Pride instead, you gave up
		that potential 12 SP to save 18. It's incredibly good to take early.
	</p>
	<p>
		On parent runs, or exactly one of your three CM horses, <b>Lone Wolf</b> is another snap take. Base cost of 60 SP for +40 speed,
		which can secure a lot of races, especially early in career. Be extremely careful not to take it on multiple horses on a team. Save
		and quit from the career if you need to check. It's technically better to have it on two horses than zero, but it's tremendously
		better than that to have it on one.
	</p>
	<p>
		<b>Angling and Scheming</b> is a strong consideration as a mid-career take. Inheritance events are more likely to activate green
		sparks than white sparks, so the risk of missing out on SP by taking it early is higher. However, Angling is an almost automatic
		win condition for career (outside a few certain tracks). Taking Angling early can save a lot of clocks, and it can rescue runs that
		don't get what is normally the minimum speed to win races before summer.
	</p>
	<p>
		<b>Front Runner Savvy</b> is a skill you will pretty much always want at least the first level of. Wit is a strong stat for front
		runners, and Savvy is a guaranteed Groundwork trigger. It's also the second cheapest front-specific skill, after Dodging Danger.
		On parent runs, it might be worth sitting on it until the +2 or +3 hint, because taking the second level gives a slightly boosted
		chance to generate the spark, and hints save twice as much SP on the double circle.
	</p>
	<p>
		<b>Front Runner Straightaways</b> and <b>Corners</b> are strong and cheap. If you've taken Early Lead and Angling, they probably
		won't change the outcomes of any races, but it's still reasonable to take the first level to prune. As a corollary, outside parent
		runs, you should have a specific distance in mind, so your distance straights/corners should also be quick takes.
	</p>
	<p>
		If you get a +3 hint, <b>Focus</b> can act as a backup to Early Lead to prevent late starts that can kill your horse. Without a
		+3 hint, it's expensive for the magnitude of its effect. It's also not a great skill for an ace on its own, so it's pretty skippable
		in general if you aren't expecting Conc.
	</p>
	<Sec h="3" id="niigata-1600">Niigata Junior Stakes</Sec>
	<p>
		Niigata Junior Stakes is the first non-sprint graded race in career, which means it's very likely to be one you run. It's also
		an oddly anti-front race. Late race starts a good bit past the final corner, which means front runners don't have any skills
		that can secure a win. (Unless you're inheriting Pasta? But VPP isn't really a good take mid-career.)
	</p>
	<p>
		An interesting consequence of the shape of Niigata 1600 is that duels can start before late race. If you're doing a guts
		build, having that happen will give quite a good chunk of accel and speed for the entire spurt, which is usually enough to get
		the win. Duels are also pretty likely, because career races have more runners—as long as you're not a solo front.
	</p>
	<p>
		If you do commit to the race and find yourself as the only front runner, switch to pace. You cannot win this race as a solo
		front.
	</p>
	<p>
		As a corollary, you also cannot win this race with B mile. A miraculous start can get to 350 speed for this race; a B mile
		runner with 350 speed is equivalent to an A mile runner with only 207 speed in career. See the <a href={resolve('/spurt')}
			>spurt calculator</a
		>. (This race is why I made it.)
	</p>
	<Sec h="3" id="jbc-sprint">JBC Sprint</Sec>
	<p>
		An even more anti-front track is Ooi 1200 Dirt. This one is actively malicious. Visually, it looks like late race starts on a
		corner, but the portion before the stretch is a special <i>neither corner nor straight</i> property. That means Angling won't activate,
		and Pasta is delayed (though still within the accel period).
	</p>
	<p>
		Fortunately, JBC Sprint is after summer, which means you should be able to stat diff your opponents. If you are planning to
		win this race, e.g. for the +30 stat epithet for doing it twice, you may want to prioritize a bit of extra speed training, or
		take Front Straights/Corners. Don't be too surprised if you lose a clock or five to a Taiki Shuttle rival.
	</p>
	<Sec h="3" id="3k">Kikuka Sho &amp; Tenno Sho (Spring)</Sec>
	<p>
		The main concern with 3K races is always stamina. Front runners are punished on long distances because they convert stamina to
		HP less efficiently than other styles.
	</p>
	<p>
		A stat line like x/450/x/500/600 should be enough for a guts/wit build to win Kikuka Sho against most rivals, possibly at the
		expense of a clock or two. TSS seems to need something more like x/700/x/700/700 if you don't have any recoveries; I haven't
		tested much without them, because I don't like throwing away my runs.
	</p>
	<p>
		Since approximately every front runner career will either be Valentine's Bourbon, whose unique skill has a recovery component,
		or have Bourbon Wit, who gives the option for a guaranteed Moxie hint on her first chain event, you'll almost always have a
		recovery available to take. Kitasan Black is the exception, since she has TTL built in. Regardless, if you end up overstam at
		the end of the run, buying Moxie can be -162 SP, which is certainly not a trivial amount.
	</p>
	<p>
		An alternative option to buying a recovery is to switch to Late Surger for those races. I've won Kikuka Sho with circa 300
		stamina this way. Personally, I've decided I prefer buying Moxie in MANT so that rivals have a chance to give a useful skill,
		but it's probably the wrong choice.
	</p>
	<p>
		All that said, the stamina requirement is instantly much higher if the rival is Super Creek, Mejiro McQueen, or Rice Shower.
		As rivals, those three will have very strong HP-oriented builds: on TSS, 650 stamina and at least one gold recovery. You will
		burn clocks rolling for them to fail wit checks unless you also have a gold.
	</p>
	<p>
		One last consideration for front runners on 3K races: Angling is a dead skill. If you're borderline on stamina, you'll have a
		hard time if you're on Long C.
	</p>
	<Sec h="3" id="kitasan-black">Kitasan Black</Sec>
	<p>
		Kitasan Black doesn't get the easy careers that other front runners do. For one thing, if you're training Kitasan, you
		probably don't have Sei as a parent since their uniques don't mesh (except on Nakayama 2500). Kitasan's own unique is also
		very weak outside of long races and unable to even activate on some miles, notably Niigata 1600. And for early races, notably
		Niigata 1600, you likely won't even have the opportunity to get Front Straights/Corners, especially since you don't need
		Bourbon Wit.
	</p>
	<p>
		Kitasan benefits a lot from running as a Pace Chaser early on, just for the higher effective speed. Rivals are best defeated
		with your intended style, but in career, winning is more important than front running.
	</p>
    <Sec h="2" id="cm">My CM Teams</Sec>
	<Sec h="3" id="cm13">CM13 &ndash; Taurus Cup (Tokyo Derby)</Sec>
	<p>
		Maruzensky's unique is live as an order&le;5 for approximately everyone.
		Filling the ranks with front runners should be a strong means to delay it for later positions, especially COC.
	</p>
	<p>
		I even considered using Maruzensky herself, since she's a front runner.
		That line of thought led me to some interesting experiments in Umalator.
		Redshift hits 25m into the start of late race, as a 0.4 accel on Maruzen and 0.2 inherited, just like Angling.
		It turns out that that delay has a substantial impact.
		Sei with Redshift beats Maruzen with Angling by about 0.4 lengths.
	</p>
	<p>
		The story doesn't end there, either.
		As it turns out, Redshift gains less than half a length for Sei.
		Ines Fujin's unique (which has a strong version on Tokyo turf specifically) is worth about 0.2 lengths more!
		So, for Sei specifically, Ines Fujin is the ideal inherit, not Maruzensky.
	</p>
	<p>
		Realistically, my team comp probably should be Seiun Sky, VBourbon, and Maruzensky.
		However, we run our oshis, and Silence Suzuka is my favorite front runner, so she's going in.
		The question then becomes whether to run VBourbon or Maruzen.
	</p>
	<p>
		Maruzensky has the advantage of working even as far back as 5th place.
		However, what does that actually beat?
		She's a front runner, so she can only outrun another front runner, and only if she has a significantly higher spurt speed than whoever got Angling.
		That basically means she needs to be a guts horse hoping for duels, which in turn means probably both of Professor and Escape Artist aren't happening. That's tough.
	</p>
	<p>
		On the other hand, Maruzen isn't relying on a wit check for her big accel.
		She's also free to take VBourbon or Ines Fujin as her non-Angling inherit, whereas VBourbon is forced into Sei and Maruzen parents.
		So, basically, what Maruzen would be trying to beat is a VBourbon who hits both Angling and Redshift (&gt;80% chance), matching 0.4 accels but winning in spurt speed.
	</p>
	<p>
		I'm not convinced that's good for my comp.
		I'd rather just be that VBourbon, having approximately every good front runner skill built in.
		So, final team comp:
	</p>
	<ol class="list-decimal pl-4 mb-4">
		<li>
			Seiun Sky as a gambler, where the gamble is getting into first in midrace.
		</li>
		<li>
			VBourbon as an ace.
			1200 wit is basically mandatory thanks to the requirement of double accels.
			Final Push won't be a bad take as a gamble-y backup.
		</li>
		<li>
			Silence Suzuka as Silence Suzuka.
			If you prefer winning over running your favorites, this should be Maruzensky instead.
		</li>
	</ol>
    <Sec h="3" id="cm12">CM12 &ndash; Aries Cup (Satsuki Sho)</Sec>
    <p>
        One of COC's best tracks, because U=ma2 is at worst only slightly less good than 777 as a trigger.
		If there is any other front runner, triple front pushes pace COC out of range for U=ma2, making her at best as reliable as the usual.
    </p>
	<ol class="list-decimal pl-4 mb-4">
		<li>
			Seiun Sky's Angling is a 0.4 accel that lasts for the entire accel period, better than COC's 0.3 that's only up for 2/3 of it.
			I want her to be my ace in front, so capped wit, high power, strong spot struggles, huge mid-race skills.
			Didn't get a guts build to come together after three weeks of attempts, so switched to a standard speed/power/wit build and got a high roll on the first try.
			1181/786/1185/474/1185 A/A/S.
		</li>
		<li>
			VBourbon is a horse that exists. She can beat other people's front runners, so great as a backup.
			Ideally she lets Sei in front, but it's better to let this happen naturally off the lack of TTL than to force low stats.
			Second attempt got charming and fast learner for free, medium S, and manageable stats. Skill hints were a bit sparse, but not worth rolling more.
			1164/662/1010/599/1167 A/S/A.
		</li>
		<li>
			Silence Suzuka is my favorite front runner, so I will run her.
			Her primary task is to be in third or fourth so COC can't be, so I don't need amazing stats.
			To maximize her effectiveness, there are two possible plans:
			I could make her a debuffer, which needs 1200 power and wit but no other stats matter,
			or I could experiment with something wacky like NSM into duels.
			The latter sounds more fun, even if it is obviously bad.
			First attempt didn't get aptitudes but did get Lone Wolf to disable it for everyone else and surprisingly decent stats, which is good enough for me;
			her job isn't to win anyway.
			<!-- TODO: stat line -->
		</li>
	</ol>
	<p>
		Win rates after 40: VBourbon 35%, Sei 17.5%, Suzuka 15%. Not quite executing the plan, but I'll take the wins.
	</p>
	<p>
		Win rates after 80: VBourbon 30%, Sei 22.5%, Suzuka 12.5%. I believe this is my best round 2 performance ever.
		I lose more to other fronts than to COC. "Most dominant racing horse for a year" continues to get trounced by the wacky triple front build.
	</p>
	<Sec h="3" id="cm11">CM11 &ndash; Pisces Cup (Hanshin 3200 Heavy Rain)</Sec>
	<p>
		N.B. This CM was before I started writing this document, so henceforth, there is much less info.
	</p>
	<p>
		Late race starts on the back stretch, which means the end closers are out to play.
	</p>
	<ol class="list-decimal pl-4 mb-4">
		<li>
			Kitasan Black is a snap take.
			Her unique is the only reliable accel outside of Straightaway Spurt, and it's quite a lot better.
			1200/1200/816/777/742 A/S/A.
		</li>
		<li>
			VBourbon's unique has a built-in recovery, which makes her the perfect choice as the survivor if stamina debuffers show up.
			<!-- TODO: stat line -->
		</li>
		<li>
			Silence Suzuka is coming.
			1200/1145/653/608/1000 A/A/A.
		</li>
	</ol>
	<p>
		I floundered on parenting and ended up with not enough time to make runners.
		Suzuka had more wit than Kitasan could handle, so I rarely got Kitasan uniques.
	</p>
	<p>
		Win rates after 80: VBourbon 31.25%, Kitasan 21.25%, Suzuka 2.5%.
	</p>
	<p>
		Extremely unlucky finals gave me third place for the first time ever.
	</p>
	<Sec h="3" id="cm10">CM10 &ndash; Aquarius Cup (February Stakes)</Sec>
	<p>
		Everyone is terrified of Taiki Shuttle, who has a 3-4 ult.
		Triple fronts would like to have a word.
		It's a dirt track, but every horse can run dirt if you're brave enough.
	</p>
	<ol class="list-decimal pl-4 mb-4">
		<li>
			Smart Falcon is the obvious choice, being the only actual dirt front runner to exist.
			Her unique isn't terribly strong for this track, but her gold skills are &ndash; Trending makes it extremely difficult for others to overtake her.
			1200/467/920/410/930 A/S/A.
		</li>
		<li>
			Silence Suzuka in runaway mode will make positioning much easier.
			I don't have to think about Unrestrained on my other horses because they won't be able to get in position for it anyway.
			Other Suzukas will be rare because she has G dirt and people don't realize distance aptitude hardly matters for runaways.
			1200/674/820/470/774 B/A/A.
		</li>
		<li>
			Taiki Shuttle is a front runner now.
			She has B dirt and C front at base. Very easy to fix.
			Falco's mid-race is probably stronger than Taiki's between her unique and Trending, so Taiki should often be in position for her ult in this build.
			<!-- TODO: stat line -->
		</li>
	</ol>
	<p>
		This is probably the strongest gameplan I've been able to use, but I failed to execute it properly.
		In particular, this was the CM that taught me through experience how important mid race speed skills are for front runners.
		Final win rate was a bit over 50%, including my first ever five win round 2 entry.
		Insane luck with Unrestrained at the same time as Angling made Suzuka the champion of the Aquarius Cup.
	</p>
	<Sec h="2" id="history">Version History</Sec>
	<ul class="list-disc pl-4">
		<li>2026-05-03: CM13 planning.</li>
		<li>2026-04-27: First draft of mechanics section, had the thought to add my CM plans and results.</li>
		<li>2026-04-27: First draft of intro and career sections</li>
	</ul>
</article>
