/* The game's look: Quiet Slate colours, Slabs chrome (a flat face on a solid lip, no blur, no borders). */
:root {
  --menu: #0E1B19; --dark: #1B3530; --dark-lip: #0A1513; --chalk: #EEF2EA; --ink: #16191A; --felt: #27504A; --maple: #D9A866;
  --cream: #EFE6D2; --cream-lip: #B9AD92; --gold: #F2C230; --gold-lip: #B98F12; --blue: #4B98EE; --blue-lip: #2A69B8; --red: #E0483C;
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --ui: 'Instrument Sans', system-ui, sans-serif;
  --out: cubic-bezier(.22, 1, .36, 1); --gut: max(16px, 4vw);
  --ground: var(--menu); --fg: var(--chalk); --key: #EEF2EA1C;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--ground); color: var(--fg); font: 600 16px/1.3 var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
h1, h2, b, .brand { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; line-height: .84; }
h1 span, .last h2 span { display: block; white-space: nowrap; }
h2 { font-size: clamp(44px, 14vw, 200px); padding-inline: var(--gut); white-space: nowrap; }
section { padding-top: clamp(72px, 12vw, 160px); position: relative; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

/* Slab: the lip is a hard shadow; a press moves the face down onto it at once. */
.slab { --face: var(--dark); --lip: var(--dark-lip); background: var(--face); color: var(--chalk); border: 0; border-radius: 5px; box-shadow: 0 5px 0 var(--lip); }
.cream { --face: var(--cream); --lip: var(--cream-lip); color: var(--ink); }
.m2 { --face: var(--blue); --lip: var(--blue-lip); color: var(--ink); } .m3 { --face: var(--red); --lip: #A52B22; } .m4 { --face: #8448C8; --lip: #5A2B93; }
.m5 { --face: #EC7428; --lip: #B04F12; color: var(--ink); } .m6 { --face: #3FBF7F; --lip: #2A8C5A; color: var(--ink); }
button { font: inherit; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button.slab:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--lip); }
button.slab[disabled] { opacity: .45; cursor: default; }
.go { min-height: 58px; padding: 0 24px; width: 100%; } .go b { font-size: 24px; letter-spacing: -.02em; }
.chip { font: 700 12px/1 var(--ui); letter-spacing: .04em; text-transform: uppercase; background: var(--dark); color: var(--chalk); box-shadow: 0 3px 0 var(--dark-lip); border-radius: 3px; padding: 7px 9px; margin-left: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; letter-spacing: -.02em; } .brand img { border-radius: 8px; }

/* Balls: flat disc, hard offset shadow, chalk rim, number on a white dot. Sized by width. */
.ball { --c: var(--ink); aspect-ratio: 1; border-radius: 50%; background: var(--c); display: grid; place-items: center; container-type: inline-size; }
.ball { width: 44px; box-shadow: 0 0 0 1px #EEF2EA73; }
.ball > i { width: 46%; height: 46%; border-radius: 50%; background: #F6F4EC; color: var(--ink); font: 800 26cqw/1 var(--display); font-style: normal; display: grid; place-items: center; }
.b1 { --c: #F2C230; } .b7 { --c: #A8323F; } .b9 { background: linear-gradient(#F6F4EC 24%, #F2C230 0 76%, #F6F4EC 0); }
.b2 { --c: #4B98EE; } .b3 { --c: #E0483C; } .b4 { --c: #8448C8; } .b5 { --c: #EC7428; } .b6 { --c: #3FBF7F; }

/* A table: the cloth canvas under, the balls canvas over. */
.rig { aspect-ratio: 2.5152 / 1.3976; position: relative; }
.rig canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.rig canvas + canvas { z-index: 2; }

/* The form. A field in use gets a solid bar under it, like a chalk line: no ring. */
.card { --mark: var(--ink); background: var(--cream); color: var(--ink); border-radius: 5px; box-shadow: 0 6px 0 var(--cream-lip); padding: 14px; width: min(100%, 440px); z-index: 4; }
.join { display: grid; grid-template-columns: 2fr 3fr; gap: 10px; }
.join > button, .join > .note, .join > .done { grid-column: 1 / -1; }
label span { display: flex; justify-content: space-between; font: 700 13px/1 var(--ui); margin-bottom: 6px; }
label i { font-style: normal; font-weight: 500; opacity: .6; }
.join input:not([type=hidden]) { width: 100%; height: 48px; padding: 0 12px; font: 600 17px var(--ui); color: var(--ink); caret-color: var(--blue); background: #FFFDF6; border: 0; border-radius: 3px; outline: 0;
  box-shadow: inset 0 0 0 0 var(--mark); transition: box-shadow .14s ease-out, background-color .14s; }
.join input:not([type=hidden]):focus { background: #fff; box-shadow: inset 0 -5px 0 0 var(--mark); }
.join input::placeholder { color: #16191A66; }
.join input[aria-invalid=true] { box-shadow: inset 0 -5px 0 0 #C7382C; }
.join .go { --face: var(--blue); --lip: var(--blue-lip); color: var(--ink); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.note { font-size: 14px; font-weight: 700; color: #A52B22; } .note:empty { display: none; }
.done { display: flex; align-items: center; gap: 14px; padding: 8px 4px; } .done b { font-size: 26px; letter-spacing: -.02em; line-height: 1; }
.join.sent > :not(.done) { display: none; }
.join.sent .done { animation: rise .32s var(--out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; }
.hero .brand { position: relative; z-index: 4; }
.hero h1 { position: relative; z-index: 1; }

/* The first screen is the table itself. The headline is printed on the cloth and the balls roll over it. */
.hero { --tw: 100vw; height: max(100svh, 55.57vw); min-height: 600px; background: var(--maple); }
.hero .rig { position: static; aspect-ratio: auto; } /* the canvases place themselves in the hero, so the headline can sit between them */
.hero .rig canvas { inset: auto; width: var(--tw); height: auto; aspect-ratio: 2.5152 / 1.3976; left: calc(50% - var(--tw) / 2); top: calc(50% - var(--tw) * .27785); }
.hero .brand { position: absolute; left: 8vw; top: calc(50% - 21vw); color: var(--chalk); }
.hero h1 { position: absolute; left: 7.5vw; top: calc(50% - 16vw); font-size: 15.5vw; color: #EEF2EAE6; }
.hero .card { position: absolute; right: 8vw; top: calc(50% + 9.5vw); rotate: 2deg; box-shadow: 0 6px 0 var(--cream-lip), 10px 18px 0 #06120F66; }
@media (max-aspect-ratio: 1/1) { /* a tall screen shows a slice of the table, with the rack in it */
  .hero { --tw: calc(100svh * 1.8); height: 100svh; }
  .hero .rig canvas { left: calc(50% - var(--tw) * .685); }
  .hero .brand { left: 16px; top: 70px; }
  .hero h1 { left: 14px; top: auto; bottom: 236px; font-size: 22vw; }
  .hero .card { left: 16px; right: 16px; top: auto; bottom: 28px; width: auto; rotate: 0deg; }
}



/* ---------- The practice table: the controls sit on its lower edge ---------- */
.lab h2 { margin-bottom: .14em; }
.lab .rig { width: min(1320px, 100vw - 2 * var(--gut)); margin-inline: auto; z-index: 1; }
#table { cursor: crosshair; }
.keys { position: absolute; z-index: 3; right: max(var(--gut), (100vw - 1320px) / 2); translate: -18px -50%; display: flex; gap: 6px; }
.keys button { height: 44px; padding: 0 18px; border: 0; border-radius: 3px; background: var(--dark); color: var(--chalk); font: 700 16px var(--ui); box-shadow: 0 3px 0 var(--dark-lip); }
.keys button[aria-checked=true] { background: var(--cream); color: var(--ink); box-shadow: 0 3px 0 var(--cream-lip); }
.console { position: relative; z-index: 3; width: min(1080px, 100vw - 2 * var(--gut) - 48px); margin: -30px auto 0; padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1.7fr) auto minmax(0, 1fr) minmax(0, 1fr) 170px; gap: 22px; align-items: center; }
.console label span b { font: 700 13px var(--ui); color: var(--gold); letter-spacing: 0; }
.tilt { display: flex; gap: 14px; align-items: center; } .tilt label { flex: 1; min-width: 0; }
#side { width: 104px; height: 75px; flex: none; }
.spin { width: 76px; height: 76px; border-radius: 50%; background: #F6F4EC; box-shadow: 4px 5px 0 #06120F99; position: relative; touch-action: none; cursor: grab; }
.spin i { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; border-radius: 50%; background: var(--red); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: none; cursor: pointer; display: block; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 2px; background: #EEF2EA2E; }
input[type=range]::-moz-range-track { height: 8px; border-radius: 2px; background: #EEF2EA2E; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 26px; margin-top: -11px; border-radius: 3px; background: var(--cream); box-shadow: 0 3px 0 var(--cream-lip); }
input[type=range]::-moz-range-thumb { width: 22px; height: 26px; border: 0; border-radius: 3px; background: var(--cream); box-shadow: 0 3px 0 var(--cream-lip); }
@media (max-width: 900px) {
  .lab .rig { width: calc(100vw - 12px); }
  .keys { position: relative; right: 0; translate: 0 0; justify-content: flex-end; margin: 0 var(--gut) -22px; }
  .lab h2 { margin-bottom: .3em; }
  .console { width: calc(100vw - 2 * var(--gut)); margin-top: -14px; grid-template-columns: auto minmax(0, 1fr); gap: 12px 16px; }
  .console .tilt, .console .go { grid-column: 1 / -1; }
  .console .cell:has(.spin) { grid-row: span 2; }
}

/* ---------- The modes: six tiles of one size, each with its ball far too big for it ---------- */
.modes h2 { text-align: right; }
.modes ul { list-style: none; padding: 0 var(--gut); margin-top: clamp(20px, 3vw, 44px); display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 1.6vw, 22px); }
.modes li { aspect-ratio: 5 / 3; padding: clamp(14px, 2vw, 28px); position: relative; overflow: hidden; }
.modes li b { display: block; font-size: clamp(16px, 5.4vw, 21px); font-size: max(clamp(16px, 5.4vw, 21px), min(3.4vw, 50px)); white-space: nowrap; line-height: 1; }
.modes li span { display: block; white-space: nowrap; font-size: clamp(13px, 1.4vw, 19px); font-weight: 700; margin-top: .5em; opacity: .85; }
.modes .ball { position: absolute; width: 46%; right: -9%; bottom: -30%; box-shadow: 0 0 0 2px #EEF2EA73, clamp(6px, 1vw, 14px) clamp(7px, 1.2vw, 17px) 0 #06120F73; }
@media (max-width: 760px) { .modes ul { grid-template-columns: 1fr 1fr; } .modes li { aspect-ratio: 1; } .modes .ball { width: 66%; right: -16%; bottom: -22%; } }

/* ---------- The cues: all 26 on a shelf (two shelves on a phone). The picked one steps up and its place on the shelf turns gold. ---------- */
.pick { padding: clamp(20px, 3vw, 40px) var(--gut) 0; display: flex; flex-wrap: wrap; align-items: end; justify-content: start; gap: 14px 40px; }
.pick > div { flex-basis: 100%; } .bars { justify-content: start; }
#cue-name { display: block; font-size: clamp(38px, 8vw, 120px); color: var(--gold); white-space: nowrap; }
#cue-trick { display: inline-block; min-height: 26px; margin: 16px 0 0; background: var(--cream); color: var(--ink); box-shadow: 0 3px 0 var(--cream-lip); }
#cue-trick:empty { visibility: hidden; }
.bars { display: grid; grid-template-columns: auto clamp(150px, 20vw, 280px); gap: 8px 12px; align-items: center; font: 700 14px/1 var(--ui); }
.bars u { display: block; height: 12px; background: linear-gradient(90deg, var(--gold) calc(var(--n) * 10%), #8885 0); -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 3px), transparent 0 10%); mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 3px), transparent 0 10%); transition: background .18s; }
.rack { display: grid; grid-template-columns: repeat(26, 1fr); row-gap: 30px; margin: 34px var(--gut) 0; touch-action: pan-y; }
.rack button { min-width: 0; padding: 0; border: 0; border-bottom: clamp(8px, 1.2vw, 16px) solid var(--maple); background: none; color: var(--chalk); outline-offset: -2px; }
.rack canvas { width: 145.5%; margin-left: -22.75%; aspect-ratio: 64 / 420; display: block; pointer-events: none; opacity: .45; transition: transform .18s var(--out), opacity .18s; } /* wider than its place on the shelf: some cues have wide ends */
.rack button[aria-pressed=true] { border-bottom-color: var(--gold); box-shadow: 0 6px 0 var(--gold); }
.rack button[aria-pressed=true] canvas { opacity: 1; transform: translateY(-30px); }
@media (max-width: 760px) { .rack { grid-template-columns: repeat(13, 1fr); margin-top: -12px; } }

/* ---------- The roadmap: a nine-ball table, and under it the nine steps in one list, each with its ball ---------- */
.road { overflow-x: clip; } /* the cue may leave the table */
#road { pointer-events: none; }
.road h2 { text-align: center; margin-bottom: .3em; font-size: min(clamp(52px, 14vw, 200px), 18svh); }
/* the table and the nine rows fit one screen */
.stand { width: min(1320px, 100vw - 2 * var(--gut), max(520px, (100svh - 450px) * 1.8)); margin-inline: auto; position: relative; container-type: inline-size; }
.steps { list-style: none; padding: 0; margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr); }
.steps button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 2px 12px 2px 8px; border: 0; border-radius: 5px; background: none; color: var(--chalk); text-align: left; }
.steps button[aria-pressed=true] { background: var(--dark); box-shadow: 0 4px 0 var(--dark-lip); }
.steps .ball { width: 36px; flex: none; }
.steps .in .ball { animation: drop .34s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes drop { from { scale: 1.9; } }
.steps .now .ball { box-shadow: 0 0 0 3px var(--gold); }
.steps b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: clamp(15px, 4.9cqw, 26px); letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.steps span { font: 700 clamp(13px, 1.9cqw, 15px)/1 var(--ui); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; color: var(--chalk); margin-left: 4px; }
.steps .later b, .steps .later span { color: #EEF2EA99; }
.steps .now b, .steps .now span { color: var(--gold); }
.road .keys { position: static; translate: none; justify-content: flex-end; margin: 12px 0 0; min-height: 47px; }
@media (max-width: 900px) {
  .stand { width: min(100vw - 12px, max(50svh * 1.8, 520px)); margin-inline: auto; }
  .road h2 { margin-bottom: .55em; }
  .steps { margin: 12px 10px 0; }
  .road .keys { margin: 12px 10px 0 0; }
}
@media (max-width: 360px) { .steps button { gap: 8px; } .steps .ball { width: 30px; } }

/* ---------- The close: one blue block, the form hanging off its lower edge ---------- */
.road + .last { margin-top: clamp(28px, 5vw, 70px); }
.last { margin-top: clamp(72px, 12vw, 160px); padding: clamp(28px, 5vw, 80px) 0 0; background: var(--blue); box-shadow: 0 10px 0 var(--blue-lip); color: var(--ink); }
.last h2 { font-size: clamp(60px, 16.5vw, 250px); }
.last .card { margin: clamp(20px, 3vw, 48px) var(--gut) 0 auto; translate: 0 34%; rotate: -2deg; position: relative; box-shadow: 0 6px 0 var(--cream-lip), 10px 16px 0 #16191A40; }
@media (max-width: 520px) { .last .card { margin-inline: var(--gut); width: auto; rotate: -1deg; } }
footer { padding: clamp(110px, 16vw, 200px) var(--gut) max(40px, env(safe-area-inset-bottom)); font-size: 13px; font-weight: 500; opacity: .6; }


@media (prefers-reduced-motion: reduce) { .rack button, .rack canvas, .steps .ball, .join.sent .done, .join input { transition: none !important; animation: none; } .road .keys { min-height: 0; } }
