Files
cs249r_book/site/assets/games/common.css
Vijay Janapa Reddi 1e97ae6da9 feat(lander): iter 8 — landing page — trim duplicate HUD, refresh copy, a11y
The landing page lagged the in-canvas state machine. DOM HUD duplicated VRAM
and Speed values now drawn in-canvas. 'How to play' didn't mention READY
screen, RETRY button, daily seed, trajectory marker, or altitude line.
'The Systems Concept' only framed the win path.

- DOM HUD trimmed to a key-cap controls row; VRAM/Speed values moved to
  .mlsp-sr-only aria-live span (kept for AT, hidden visually)
- 'How to play' rewritten to match current state (READY-to-launch, all six
  affordances called out)
- 'The Systems Concept' lists all five failure modes mapped to real training:
  diverged, local-min, missed-basin, off-course, OOM
- Tail line invites the other 13 games
- New shared CSS: .mlsp-controls-line (key-cap row), .mlsp-sr-only (standard
  visually-hidden pattern); reusable across the catalog

Lens-bounded change. Iter 9 (mobile/touch/a11y) is next.
2026-04-25 18:26:28 -04:00

669 lines
15 KiB
CSS

/* ============================================================
MLSysBook Playground — shared styles
One palette, one typography scale, reused by every game.
============================================================ */
:root {
--mlsp-blue: #cfe2f3;
--mlsp-blue-stroke: #4a90c4;
--mlsp-green: #d4edda;
--mlsp-green-stroke: #3d9e5a;
--mlsp-red: #f9d6d5;
--mlsp-red-stroke: #c44;
--mlsp-orange: #fdebd0;
--mlsp-orange-stroke: #c87b2a;
--mlsp-mit-red: #a31f34;
--mlsp-text: #333;
--mlsp-muted: #777;
--mlsp-faint: #bbb;
--mlsp-border: #e0e0e0;
--mlsp-bg-soft: #f7f7f7;
--mlsp-ink: #101827;
--mlsp-panel: #ffffff;
}
.mlsp-game-container {
position: relative;
margin: 1.75rem auto;
max-width: 720px;
border: 1px solid var(--mlsp-border);
border-radius: 12px;
background: #fff;
overflow: hidden;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
box-shadow: 0 8px 22px rgba(0,0,0,0.06);
}
.mlsp-game-container::before {
content: none;
}
.mlsp-game-canvas {
position: relative;
z-index: 1;
display: block;
width: 100%;
height: auto;
max-width: 100%;
background: #fafafa;
touch-action: manipulation;
cursor: default;
}
.mlsp-game-hud {
position: relative;
z-index: 2;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.62rem 0.9rem;
background: #fff;
border-top: 1px solid var(--mlsp-border);
font-size: 0.85rem;
color: var(--mlsp-muted);
flex-wrap: wrap;
gap: 0.5rem;
}
.mlsp-score {
font-weight: 600;
color: var(--mlsp-text);
font-variant-numeric: tabular-nums;
}
.mlsp-game-hud kbd {
background: var(--mlsp-bg-soft);
border: 1px solid var(--mlsp-faint);
border-bottom-width: 2px;
border-radius: 4px;
padding: 0 0.35rem;
font-size: 0.78rem;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
color: var(--mlsp-text);
}
main kbd {
display: inline-block;
min-width: 1.15em;
padding: 0.05rem 0.24rem;
border: 1px solid var(--mlsp-border);
border-bottom-width: 2px;
border-radius: 4px;
background: var(--mlsp-bg-soft);
color: var(--mlsp-text);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.78em;
line-height: 1.15;
text-align: center;
vertical-align: 0.08em;
}
.mlsp-controls-line {
display: inline-flex;
align-items: center;
gap: 0.45rem;
flex-wrap: wrap;
font-size: 0.84rem;
color: var(--mlsp-muted);
}
.mlsp-controls-line kbd {
margin: 0 0.05rem;
}
/* Screen-reader-only — keeps live VRAM/speed announcements available to AT */
/* without duplicating the in-canvas HUD visually. */
.mlsp-sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.mlsp-fullscreen-btn {
background: #fff;
border: 1px solid var(--mlsp-border);
border-radius: 6px;
cursor: pointer;
color: var(--mlsp-muted);
font-size: 1.1rem;
line-height: 1;
padding: 0.3rem 0.48rem;
margin-left: auto;
}
.mlsp-fullscreen-btn:hover {
border-color: var(--mlsp-mit-red);
color: var(--mlsp-mit-red);
}
/* Fullscreen handling */
.mlsp-game-container:fullscreen {
max-width: none;
width: 100vw;
height: 100vh;
margin: 0;
border: none;
border-radius: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
background: #111;
}
.mlsp-game-container:-webkit-full-screen {
max-width: none;
width: 100vw;
height: 100vh;
margin: 0;
border: none;
border-radius: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
background: #111;
}
.mlsp-game-container:fullscreen .mlsp-game-canvas,
.mlsp-game-container:-webkit-full-screen .mlsp-game-canvas {
flex: 1 1 auto;
width: 100vw;
height: calc(100vh - 58px);
min-height: 0;
object-fit: contain;
background: #fafafa;
margin: auto;
}
.mlsp-game-container:fullscreen .mlsp-game-hud,
.mlsp-game-container:-webkit-full-screen .mlsp-game-hud {
flex-shrink: 0;
min-height: 58px;
padding: 0.85rem clamp(1rem, 3vw, 2rem);
font-size: clamp(0.86rem, 1.2vw, 1rem);
}
/* Aha card — shown after game-over to turn the loop into a mini-lesson */
.mlsp-aha-card {
margin: 1rem auto;
max-width: 720px;
background: #fff;
border: 1px solid var(--mlsp-border);
border-left: 4px solid var(--mlsp-mit-red);
padding: 1rem 1.25rem;
border-radius: 12px;
font-size: 0.95rem;
color: var(--mlsp-text);
line-height: 1.55;
box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}
.mlsp-aha-label {
font-size: 0.72rem;
font-weight: 700;
color: var(--mlsp-mit-red);
text-transform: uppercase;
letter-spacing: 0.08em;
display: block;
margin-bottom: 0.4rem;
}
.mlsp-aha-card p {
margin: 0;
}
/* Share row — appended below the aha message. Holds the emoji-grid result */
/* and a copy-to-clipboard button. Reused across all games via attachShareRow. */
.mlsp-share-row {
margin-top: 0.85rem;
padding-top: 0.85rem;
border-top: 1px dashed var(--mlsp-border);
display: flex;
align-items: center;
gap: 0.85rem;
flex-wrap: wrap;
}
.mlsp-share-text {
margin: 0;
flex: 1 1 240px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.82rem;
line-height: 1.45;
color: var(--mlsp-text);
background: var(--mlsp-bg-soft);
border: 1px solid var(--mlsp-border);
border-radius: 6px;
padding: 0.55rem 0.7rem;
white-space: pre-wrap;
}
.mlsp-share-btn {
border: 1px solid var(--mlsp-mit-red);
background: #fff;
color: var(--mlsp-mit-red);
border-radius: 999px;
padding: 0.42rem 0.95rem;
font-size: 0.82rem;
font-weight: 700;
cursor: pointer;
transition: background 0.12s ease, color 0.12s ease;
white-space: nowrap;
}
.mlsp-share-btn:hover {
background: var(--mlsp-mit-red);
color: #fff;
}
/* Gallery card grid (on /games/ index and on the 404 "more" link) */
.mlsp-game-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 1.1rem;
margin: 1.5rem 0;
}
.mlsp-game-card {
border: 1px solid var(--mlsp-border);
border-radius: 12px;
padding: 1.25rem;
background: #fff;
display: flex;
flex-direction: column;
box-shadow: 0 2px 10px rgba(0,0,0,0.04);
transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.mlsp-game-card:hover {
border-color: rgba(163,31,52,0.35);
box-shadow: 0 8px 22px rgba(0,0,0,0.07);
transform: translateY(-2px);
}
.mlsp-game-card img {
width: 100%;
height: auto;
border-radius: 12px;
margin-bottom: 0.75rem;
display: block;
border: 1px solid rgba(74,144,196,0.18);
box-sizing: border-box;
}
.mlsp-game-card > a {
text-decoration: none;
}
.mlsp-cover {
min-height: 92px;
border-radius: 8px;
margin-bottom: 0.75rem;
border: 1px solid var(--mlsp-border);
display: flex;
align-items: center;
padding: 0.85rem 1rem;
box-sizing: border-box;
color: var(--mlsp-text);
font-weight: 700;
letter-spacing: 0.02em;
background:
linear-gradient(90deg, rgba(163,31,52,0.95) 0 4px, transparent 4px),
linear-gradient(180deg, #fff, #f7f7f7);
box-shadow: none;
}
.mlsp-cover::before {
content: none;
}
.mlsp-cover-lander,
.mlsp-cover-pipeline,
.mlsp-cover-allreduce { background: linear-gradient(90deg, rgba(74,144,196,0.95) 0 4px, transparent 4px), linear-gradient(180deg, #fff, #f7f7f7); }
.mlsp-cover-oom,
.mlsp-cover-kvcache,
.mlsp-cover-cluster { background: linear-gradient(90deg, rgba(106,74,122,0.95) 0 4px, transparent 4px), linear-gradient(180deg, #fff, #f7f7f7); }
.mlsp-cover-prune,
.mlsp-cover-loader,
.mlsp-cover-batch { background: linear-gradient(90deg, rgba(61,158,90,0.95) 0 4px, transparent 4px), linear-gradient(180deg, #fff, #f7f7f7); }
.mlsp-cover-quantization,
.mlsp-cover-checkpoint,
.mlsp-cover-roofline,
.mlsp-cover-topology,
.mlsp-cover-moe { background: linear-gradient(90deg, rgba(163,31,52,0.95) 0 4px, transparent 4px), linear-gradient(180deg, #fff, #f7f7f7); }
.mlsp-game-card.mlsp-hero-card {
grid-column: 1 / -1;
flex-direction: row;
gap: 1.5rem;
}
.mlsp-hero-img {
flex: 1;
min-width: 300px;
}
.mlsp-hero-img:empty {
display: none;
}
.mlsp-hero-img img {
margin-bottom: 0;
}
.mlsp-hero-body {
flex: 1.2;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.mlsp-hero-body p:last-child {
margin-bottom: 0;
}
.mlsp-game-card.mlsp-hero-card h3 {
font-size: 1.6rem;
margin-bottom: 0.5rem;
}
@media (max-width: 768px) {
.mlsp-game-card.mlsp-hero-card {
flex-direction: column;
}
.mlsp-hero-img {
width: 100%;
min-width: unset;
}
}
.mlsp-game-card h3 {
margin: 0 0 0.35rem 0;
font-size: 1.1rem;
color: var(--mlsp-text);
}
.mlsp-card-meta {
margin-top: 1rem;
padding-top: 0.85rem;
border-top: 1px dashed var(--mlsp-border);
font-size: 0.82rem;
color: var(--mlsp-muted);
line-height: 1.5;
}
.mlsp-meta-row {
margin-bottom: 0.3rem;
}
.mlsp-meta-row strong {
color: var(--mlsp-text);
font-weight: 600;
}
.mlsp-meta-row a {
color: var(--mlsp-mit-red);
text-decoration: none;
}
.mlsp-meta-row a:hover {
text-decoration: underline;
}
.mlsp-card-tagline {
display: block;
font-size: 0.85rem;
color: var(--mlsp-muted);
font-style: italic;
margin: 0;
}
.mlsp-game-card p {
font-size: 0.9rem;
margin: 0 0 1rem 0;
flex-grow: 0;
line-height: 1.5;
color: var(--mlsp-text);
}
.mlsp-game-card > p:has(.mlsp-card-tagline) {
margin-bottom: 0.75rem;
}
.mlsp-game-card > p:has(.mlsp-card-cta) {
margin-top: auto;
margin-bottom: 0;
}
.mlsp-game-card > p:not(:has(.mlsp-card-tagline)):not(:has(.mlsp-card-cta)) {
flex-grow: 1;
}
.mlsp-card-cta {
background: var(--mlsp-mit-red);
color: #fff !important;
padding: 0.48rem 0.8rem;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
font-size: 0.9rem;
text-align: center;
display: inline-block;
transition: background 0.15s ease;
box-shadow: none;
}
.mlsp-card-cta:hover {
background: #821827;
}
.mlsp-game-card.mlsp-coming-soon {
opacity: 0.65;
}
.mlsp-game-card.mlsp-coming-soon .mlsp-card-cta {
background: var(--mlsp-faint);
cursor: not-allowed;
pointer-events: none;
}
/* 404-specific chrome */
.mlsp-404-banner {
max-width: 680px;
margin: 1.5rem auto 0.5rem auto;
background: #fff;
border-left: 4px solid var(--mlsp-mit-red);
padding: 1rem 1.25rem;
border-radius: 4px;
color: var(--mlsp-text);
font-size: 1rem;
line-height: 1.5;
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.mlsp-404-banner strong {
color: var(--mlsp-mit-red);
font-weight: 700;
}
.mlsp-404-nav {
text-align: center;
font-size: 0.9rem;
color: var(--mlsp-muted);
margin: 0 auto 1rem auto;
max-width: 680px;
padding: 0 1rem;
}
.mlsp-404-nav a {
color: var(--mlsp-mit-red);
text-decoration: none;
font-weight: 500;
margin: 0 0.2rem;
}
.mlsp-404-nav a:hover { text-decoration: underline; }
.mlsp-404-intro {
text-align: center;
color: var(--mlsp-muted);
font-size: 0.95rem;
margin: 0.5rem auto 1rem auto;
max-width: 640px;
padding: 0 1rem;
}
.mlsp-404-more {
text-align: center;
font-size: 0.85rem;
color: var(--mlsp-muted);
margin: 0.5rem 0 2rem 0;
}
.mlsp-404-more a {
color: var(--mlsp-mit-red);
font-weight: 600;
text-decoration: none;
}
.mlsp-404-more a:hover { text-decoration: underline; }
.mlsp-404-hero {
max-width: 860px;
margin: 1.5rem auto 1rem auto;
padding: 0 1rem;
text-align: center;
}
.mlsp-404-eyebrow {
margin: 0 0 0.45rem 0;
font-size: 0.78rem;
letter-spacing: 0.16em;
font-weight: 800;
color: var(--mlsp-mit-red);
}
.mlsp-404-hero h1 {
margin: 0;
font-size: clamp(2rem, 4vw, 3.1rem);
line-height: 1.05;
color: var(--mlsp-text);
}
.mlsp-404-lede {
max-width: 720px;
margin: 0.9rem auto 0 auto;
font-size: 1.02rem;
line-height: 1.6;
color: var(--mlsp-muted);
}
.mlsp-404-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.75rem;
margin-top: 1.15rem;
}
.mlsp-404-primary,
.mlsp-404-secondary {
border-radius: 999px;
padding: 0.65rem 1rem;
text-decoration: none;
font-weight: 700;
font-size: 0.92rem;
}
.mlsp-404-primary {
background: var(--mlsp-mit-red);
color: #fff !important;
}
.mlsp-404-primary:hover { background: #821827; }
.mlsp-404-secondary {
background: #fff;
color: var(--mlsp-text) !important;
border: 1px solid var(--mlsp-border);
}
.mlsp-404-secondary:hover {
border-color: var(--mlsp-mit-red);
color: var(--mlsp-mit-red) !important;
}
.mlsp-404-lab {
max-width: 860px;
margin: 1.25rem auto 0 auto;
padding: 0 1rem;
}
.mlsp-404-lab-head {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 1rem;
margin-bottom: 0.85rem;
flex-wrap: wrap;
}
.mlsp-404-kicker {
margin: 0 0 0.25rem 0;
color: var(--mlsp-mit-red);
font-size: 0.74rem;
font-weight: 800;
letter-spacing: 0.14em;
}
.mlsp-404-lab-head h2 {
margin: 0;
color: var(--mlsp-text);
font-size: 1.45rem;
}
.mlsp-404-copy {
margin: 0.35rem 0 0 0;
max-width: 620px;
font-size: 0.95rem;
line-height: 1.5;
color: var(--mlsp-muted);
}
.mlsp-404-switcher-wrap {
display: flex;
flex-direction: column;
gap: 0.4rem;
align-items: flex-start;
}
.mlsp-404-switcher-label {
font-size: 0.78rem;
color: var(--mlsp-muted);
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.mlsp-404-switcher {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
}
.mlsp-404-chip {
border: 1px solid var(--mlsp-border);
background: #fff;
color: var(--mlsp-text);
border-radius: 999px;
padding: 0.45rem 0.8rem;
font-size: 0.84rem;
font-weight: 700;
cursor: pointer;
}
.mlsp-404-chip:hover,
.mlsp-404-chip.is-active {
border-color: var(--mlsp-mit-red);
background: #fff4f6;
color: var(--mlsp-mit-red);
}
.mlsp-404-footnote {
max-width: 760px;
margin: 0.85rem auto 0 auto;
font-size: 0.9rem;
color: var(--mlsp-muted);
line-height: 1.55;
}
.mlsp-404-footnote a {
color: var(--mlsp-mit-red);
font-weight: 600;
text-decoration: none;
}
.mlsp-404-footnote a:hover { text-decoration: underline; }
.mlsp-404-destinations {
max-width: 860px;
margin: 1.4rem auto 1.8rem auto;
padding: 0 1rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 0.75rem;
}
.mlsp-404-destination {
display: block;
text-decoration: none;
border: 1px solid var(--mlsp-border);
border-radius: 10px;
background: #fff;
padding: 0.95rem 1rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.mlsp-404-destination strong {
display: block;
color: var(--mlsp-text);
font-size: 0.98rem;
}
.mlsp-404-destination span {
display: block;
margin-top: 0.2rem;
font-size: 0.85rem;
line-height: 1.45;
color: var(--mlsp-muted);
}
.mlsp-404-destination:hover {
border-color: var(--mlsp-mit-red);
transform: translateY(-1px);
}
@media (max-width: 640px) {
.mlsp-404-actions {
flex-direction: column;
align-items: stretch;
}
.mlsp-404-primary,
.mlsp-404-secondary {
text-align: center;
}
}