/* Pixel Kart page UI. Flat color blocks, chunky borders, pixel corners.
   Sizes: --fs is a whole multiple of 4 px (set by device.js), so every
   multiple of .25rem lands on a whole pixel. --b is the border width. */

@font-face {
  font-family: "Pixelify";
  src: url("../fonts/PixelifySans.ttf") format("truetype");
  font-weight: 400 700;
  font-display: block;
}

:root {
  --ink: #111216;
  --ink2: #22242e;
  --ink3: #3a3d4b;
  --paper: #f3efe6;
  --dim: #b4aea2;
  --hot: #ffd21a;
  --red: #e8402a;
  --mint: #12c9b5;
  --sky: #8fb4ff;
  --acc: var(--hot);
  --on-acc: var(--ink);
  --acc-text: var(--hot);
  --fs: 16px;
  --b: 3px;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --gut: 1rem;
  --n: var(--b);
  --notch: polygon(var(--n) 0, calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n), 100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%, var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n)), 0 var(--n), var(--n) var(--n));
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 7' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v7H0zM1 1h1v5H1zM2 2h1v3H2zM3 3h1v1H3z'/%3E%3C/svg%3E");
  font-size: var(--fs);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  height: 100dvh;
  font-family: "Pixelify", ui-monospace, monospace;
  font-weight: 500;
  line-height: 1.25;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-synthesis: none;
}

#stage { position: fixed; inset: 0; z-index: 0; }
#game { display: block; width: 100%; height: 100%; outline: none; image-rendering: pixelated; }

h1, h2, h3, p { margin: 0; font-weight: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
input { font: inherit; }
img { image-rendering: pixelated; }
[hidden] { display: none !important; }
:focus { outline: none; }

.scroll { touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ico { height: 1em; display: inline-block; vertical-align: -0.125em; flex: none; }

/* ------------------------------------------------------------- screens */

#ui { position: fixed; inset: 0; z-index: 2; }

.scr {
  position: absolute;
  inset: 0;
  padding: calc(var(--st) + var(--gut)) calc(var(--sr) + var(--gut)) calc(var(--sb) + var(--gut)) calc(var(--sl) + var(--gut));
  display: grid;
  gap: 1rem;
}

.scr.on > * { animation: rise 0.2s steps(4) backwards; }
.scr.on > *:nth-child(2) { animation-delay: 0.04s; }
.scr.on > *:nth-child(3) { animation-delay: 0.08s; }
.scr.on > *:nth-child(4) { animation-delay: 0.12s; }

@keyframes rise {
  from { transform: translateY(1rem); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes slide {
  from { transform: translateX(-2rem); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes bump { 50% { transform: translateY(calc(var(--b) * -1)); } }
@keyframes shake {
  25% { transform: translateX(-0.5rem); }
  75% { transform: translateX(0.5rem); }
}

.window { min-width: 0; min-height: 0; pointer-events: none; }

/* A plate is a flat block of ink with pixel corners. */
.plate, .cinfo, .tinfo, .rset, .chat, .obox, .hubr, .pband, .rhead {
  background: var(--ink);
  clip-path: var(--notch);
}

/* ------------------------------------------------------------- headers */

.bar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-right: 3.5rem; /* corner fullscreen button */
  min-width: 0;
}
.bar h2 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.5rem 0.75rem;
  background: var(--acc);
  color: var(--on-acc);
  clip-path: var(--notch);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0 0.75rem;
  background: var(--ink);
  font-size: 1.25rem;
  clip-path: var(--notch);
  flex: none;
}
.back:focus, .back:hover { background: var(--paper); color: var(--ink); }
.back:active { transform: translateY(var(--b)); }

/* ------------------------------------------------------------- buttons */

.menu { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

.mi {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  min-width: 15rem;
  padding: 0.5rem 1.25rem 0.5rem 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  background: var(--ink);
  color: var(--paper);
  clip-path: var(--notch);
  transition: transform 0.08s steps(2), background-color 0.05s steps(1);
}
.scr.on .mi { animation: slide 0.18s steps(3) backwards; animation-delay: calc(var(--i, 0) * 0.04s + 0.06s); }
.mi::before {
  content: "";
  width: 0.75rem;
  height: 1.25rem;
  margin-right: 0.5rem;
  background: currentColor;
  -webkit-mask: var(--arrow) no-repeat center / contain;
  mask: var(--arrow) no-repeat center / contain;
  opacity: 0;
}
.mi:focus, .mi:hover {
  background: var(--c, var(--hot));
  color: var(--ink);
  transform: translateX(1rem);
}
.mi:focus::before, .mi:hover::before { opacity: 1; }
.mi:active { transform: translate(1rem, var(--b)); }
html[data-input="touch"] .mi:not(:active) { transform: none; }
html[data-input="touch"] .mi:not(:active)::before { opacity: 0; }
html[data-input="touch"] .mi:not(:active) { background: var(--ink); color: var(--paper); }

.go {
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0.5rem 1.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  background: var(--paper);
  color: var(--ink);
  clip-path: var(--notch);
  transition: transform 0.08s steps(2);
}
.go.cta { background: var(--hot); }
.go:focus, .go:hover { background: var(--hot); color: var(--ink); transform: translateY(calc(var(--b) * -1)); }
.go.cta:focus, .go.cta:hover { background: var(--paper); }
.go:focus span::before, .go:hover span::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: calc(50% - 0.625rem);
  width: 0.75rem;
  height: 1.25rem;
  background: currentColor;
  -webkit-mask: var(--arrow) no-repeat center / contain;
  mask: var(--arrow) no-repeat center / contain;
}
.go:active { transform: translateY(var(--b)); }
.go:disabled { background: var(--ink3); color: var(--dim); transform: none; }
.go:disabled span::before { display: none; }

.mini {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  font-size: 1.25rem;
  background: var(--ink2);
  clip-path: var(--notch);
}
.mini:focus, .mini:hover { background: var(--paper); color: var(--ink); }
.mini:active { transform: translateY(var(--b)); }

/* ------------------------------------------------------------- rows */

.rows { display: flex; flex-direction: column; gap: 0.25rem; }
.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3rem;
  padding: 0 0.25rem 0 1rem;
  background: var(--ink);
  font-size: 1.25rem;
  clip-path: var(--notch);
  cursor: pointer;
  width: 100%;
}
.row .lbl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .ctl { display: flex; align-items: center; gap: 0.25rem; flex: none; }
.row .val { min-width: 6rem; text-align: center; display: inline-flex; justify-content: center; align-items: center; gap: 0.5rem; }
.row .arr {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  font-size: 1rem;
  color: var(--dim);
}
.row .arr:disabled { opacity: 0.2; }
.row:focus, .row:hover { background: var(--paper); color: var(--ink); }
.row:focus .arr, .row:hover .arr { color: var(--ink); }
.row.bump .val { animation: bump 0.12s steps(2); }
.row.ro { cursor: default; }
.row.ro .arr { visibility: hidden; }
.row.ro:focus, .row.ro:hover { background: var(--ink2); color: var(--paper); }
.row.link .ctl { gap: 0.5rem; padding-right: 0.75rem; color: var(--dim); }
.row.link:focus .ctl, .row.link:hover .ctl { color: var(--ink); }

.meter { display: inline-flex; gap: 0.25rem; }
.meter i { width: 0.5rem; height: 1rem; background: var(--ink3); }
.meter i.on { background: var(--hot); }
.row:focus .meter i, .row:hover .meter i { background: #cfc8ba; }
.row:focus .meter i.on, .row:hover .meter i.on { background: var(--ink); }

kbd {
  display: inline-block;
  min-width: 2rem;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  background: var(--paper);
  color: var(--ink);
  border-bottom: var(--b) solid var(--dim);
  clip-path: var(--notch);
}

/* ------------------------------------------------------------- portraits & stats */

.pt {
  position: relative;
  display: block;
  aspect-ratio: 1;
  background: var(--c);
  overflow: hidden;
  flex: none;
}
.pt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pt.sm { width: 2.5rem; clip-path: var(--notch); }

.stats { display: grid; gap: 0.25rem; font-size: 1rem; }
.stat { display: flex; align-items: center; gap: 0.75rem; }
.stat > span:first-child { width: 4rem; color: var(--dim); }
.sbar { display: inline-flex; gap: 0.25rem; }
.stat .sbar i { width: 1.5rem; height: 0.75rem; background: var(--ink3); }
.stat .sbar i.on { background: var(--c); }

/* ------------------------------------------------------------- title */

.title {
  grid-template: "top win" auto "low win" 1fr / minmax(0, auto) 1fr;
  align-content: stretch;
}
.title-top { grid-area: top; display: grid; gap: 0.5rem; justify-items: start; }
.wordmark { display: block; width: min(30rem, 56vw, (100dvh - 26rem) * 1.4); height: auto; }
.title .sub { font-size: 1.25rem; padding: 0.25rem 0.75rem; background: var(--ink); clip-path: var(--notch); }
.title .window { grid-area: win; }
.title-low { grid-area: low; align-self: end; display: grid; gap: 1rem; justify-items: start; }
.title .help {
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--dim);
  clip-path: var(--notch);
  max-width: 26rem;
  min-height: 2.25rem;
}
.press {
  font-size: 2rem;
  font-weight: 700;
  padding: 0.75rem 1.25rem;
  background: var(--hot);
  color: var(--ink);
  clip-path: var(--notch);
}
.press span { animation: blink 1s steps(1) infinite; }
.title:not(.started) .menu, .title:not(.started) .help { display: none; }
.title.started .press { display: none; }

/* ------------------------------------------------------------- racer select */

.chars, .tracks, .settings, .controls, .oname, .hub, .room, .results { grid-template-rows: auto 1fr; }

.cbody {
  display: grid;
  grid-template: "grid win" 1fr "grid info" auto / auto 1fr;
  gap: 1rem;
  min-height: 0;
}
.cleft { grid-area: grid; align-self: start; min-height: 0; }
.cbody .window { grid-area: win; }
.cgrid { display: grid; grid-template-columns: repeat(4, 5rem); gap: 0.5rem; }
.cg {
  position: relative;
  display: grid;
  background: var(--ink);
  padding: var(--b);
  clip-path: var(--notch);
  transition: transform 0.06s steps(2);
}
.cg .pt { width: 100%; }
.cg .cn {
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.25rem 0 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cg.sel { background: var(--paper); color: var(--ink); }
.cg:focus, .cg:hover { background: var(--hot); color: var(--ink); transform: translateY(calc(var(--b) * -1)); }
.cg:active { transform: translateY(var(--b)); }
html[data-input="touch"] .cg:not(.sel) { background: var(--ink); color: var(--paper); transform: none; }

.cinfo {
  grid-area: info;
  justify-self: end;
  width: min(100%, 26rem);
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}
.cname { font-size: 3rem; font-weight: 700; line-height: 1; color: var(--acc-text); }
.ctag { font-size: 1.25rem; min-height: 1.5em; }
.cinfo .go { margin-top: 0.25rem; }

/* ------------------------------------------------------------- track select */

.tbody {
  display: grid;
  grid-template: "list win info" auto "list win opts" 1fr / minmax(12rem, 16rem) 1fr minmax(16rem, 22rem);
  gap: 1rem;
  min-height: 0;
}
.tbody > .window { grid-area: win; }
html.portrait .tbody > .window { display: none; }
.tlist { grid-area: list; display: flex; flex-direction: column; gap: 0.25rem; align-self: start; }
.tr {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  font-size: 1.25rem;
  background: var(--ink);
  clip-path: var(--notch);
  transition: transform 0.06s steps(2);
}
.tr .outline { width: 2.75rem; height: 2.75rem; }
.tr.sel { background: var(--paper); color: var(--ink); }
.tr:focus, .tr:hover { background: var(--hot); color: var(--ink); transform: translateX(0.5rem); }
html[data-input="touch"] .tr:not(.sel) { background: var(--ink); color: var(--paper); transform: none; }
.tinfo { grid-area: info; display: grid; gap: 0.5rem; padding: 1rem; }
.tbig .outline { width: 100%; height: auto; max-height: 14rem; aspect-ratio: 1; display: block; margin: 0 auto; }
.tname { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--acc-text); }
.tblurb { font-size: 1.25rem; }
.tmeta { color: var(--dim); }
.topts { grid-area: opts; display: flex; flex-direction: column; gap: 0.25rem; align-self: end; }
.topts .go { margin-top: 0.5rem; }

.outline { display: inline-block; overflow: visible; }
.outline .o-under { fill: none; stroke: var(--ink); stroke-width: 14; stroke-linejoin: miter; }
.outline .o-road { fill: none; stroke: var(--paper); stroke-width: 6; stroke-linejoin: miter; }
.outline .o-start { fill: var(--hot); stroke: var(--ink); stroke-width: 3; }
.outline.o-mini .o-under { stroke-width: 22; }
.outline.o-mini .o-road { stroke-width: 10; }
.outline.o-mini .o-start { display: none; }
.tr:focus .o-road, .tr:hover .o-road, .tr.sel .o-road { stroke: var(--ink); }
.tr:focus .o-under, .tr:hover .o-under, .tr.sel .o-under { stroke: transparent; }
.outline.o-large .o-road { stroke: var(--acc); }
.outline.o-tiny { width: 1.5rem; height: 1.5rem; }
.outline.o-tiny .o-under { stroke-width: 26; }
.outline.o-tiny .o-road { stroke-width: 12; }
.outline.o-tiny .o-start { display: none; }
.row:focus .outline.o-tiny .o-road, .row:hover .outline.o-tiny .o-road { stroke: var(--ink); }
.row:focus .outline.o-tiny .o-under, .row:hover .outline.o-tiny .o-under { stroke: transparent; }
.tval { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ------------------------------------------------------------- settings & controls */

.sbody { width: min(100%, 34rem); display: grid; gap: 1rem; align-content: start; min-height: 0; overflow: auto; }
.fps { color: var(--dim); padding: 0 0.25rem; }
.fps:empty { display: none; }

.cbox { width: min(100%, 40rem); display: grid; grid-template-rows: auto 1fr; gap: 0.5rem; min-height: 0; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tab {
  min-height: 3rem;
  padding: 0 1rem;
  font-size: 1.25rem;
  background: var(--ink);
  clip-path: var(--notch);
}
.tab.sel { background: var(--acc); color: var(--on-acc); }
.tab:focus, .tab:hover { background: var(--paper); color: var(--ink); }
.cbox .scroll { min-height: 0; overflow: auto; }
.ctable { display: grid; gap: 0.25rem; }
.crow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  clip-path: var(--notch);
  font-size: 1.25rem;
}
.crow .what { flex: 1 1 10rem; }
.crow .keys { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.crow .or { color: var(--dim); padding: 0 0.25rem; font-size: 1rem; }

/* ------------------------------------------------------------- pause */

.pause { padding: 0; grid-template-columns: minmax(0, 28rem); }
.pband {
  clip-path: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: calc(var(--st) + 2rem) 2rem calc(var(--sb) + 2rem) calc(var(--sl) + 2rem);
  border-right: calc(var(--b) * 2) solid var(--hot);
}
.pband h2 { font-size: 4rem; font-weight: 700; line-height: 1; color: var(--hot); }
.psub { color: var(--dim); font-size: 1.25rem; max-width: 22rem; }
.pband .menu { margin-top: 0.5rem; }
.pband .mi:not(:focus):not(:hover) { background: var(--ink2); }

/* ------------------------------------------------------------- results */

.results { grid-template-rows: auto minmax(0, 1fr) auto; justify-items: start; }
.rhead { padding: 0.75rem 1rem; display: grid; gap: 0.25rem; border-left: calc(var(--b) * 2) solid var(--acc); }
.rhead h2 { font-size: 3rem; font-weight: 700; line-height: 1; color: var(--acc-text); }
.rsub { font-size: 1.25rem; }
.rtable {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-rows: min-content;
  gap: 0.25rem;
  width: min(100%, 36rem);
  overflow: auto;
  min-height: 0;
}
.rrow {
  display: grid;
  grid-template-columns: 2.5rem 2.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem 0 0;
  background: var(--ink);
  font-size: 1.25rem;
  clip-path: var(--notch);
  animation: slide 0.2s steps(3) backwards;
  animation-delay: calc(var(--i) * 0.05s);
}
.rrow .rp { text-align: center; font-weight: 700; font-size: 1.5rem; background: var(--ink2); align-self: stretch; display: grid; place-items: center; }
.rrow:nth-child(1) .rp { background: var(--hot); color: var(--ink); }
.rrow:nth-child(2) .rp { background: #d3d7e0; color: var(--ink); }
.rrow:nth-child(3) .rp { background: #d98c4a; color: var(--ink); }
.rrow .pt.sm { clip-path: none; }
.rrow .rn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 0.5rem; align-items: center; }
.rrow .botmark { color: var(--dim); font-size: 0.75rem; }
.rrow .rt { font-variant-numeric: tabular-nums; color: var(--dim); }
.rrow.me { background: var(--acc); color: var(--on-acc); }
.rrow.me .rt, .rrow.me .botmark { color: inherit; }
.rmenu { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rmenu .mi { min-width: 0; }

/* ------------------------------------------------------------- online */

.obox { width: min(100%, 30rem); display: grid; gap: 0.75rem; padding: 1rem; align-self: start; }
label.big { font-size: 1.5rem; font-weight: 700; color: var(--acc-text); }
.nick, .code, .say {
  width: 100%;
  min-height: 3.5rem;
  padding: 0 1rem;
  font-size: max(16px, 1.75rem);
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-bottom: calc(var(--b) * 2) solid var(--dim);
  border-radius: 0;
  clip-path: var(--notch);
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  caret-color: var(--red);
  -webkit-appearance: none;
  appearance: none;
}
.nick:focus, .code:focus, .say:focus { border-bottom-color: var(--hot); background: #fffaf0; }
.nick::placeholder, .code::placeholder, .say::placeholder { color: #9c968b; opacity: 1; }
.nick.shake { animation: shake 0.16s steps(2) 2; }
.obox .row .ptslot { display: contents; }
.obox .row { padding-left: 0.25rem; }
.obox .who, .namebtn .who { flex: 1; }
.netstatus { color: var(--dim); min-height: 1.25em; }
.netstatus:empty { display: none; }
html.busy .hub .menu, html.busy .rooms { opacity: 0.5; pointer-events: none; }

.hubbody { display: grid; grid-template-columns: minmax(0, 24rem) minmax(0, 28rem); gap: 1rem; align-content: start; justify-content: space-between; min-height: 0; }
.hubl { display: grid; gap: 1rem; align-content: start; }
.joinrow { display: grid; gap: 0.5rem; margin-top: 0.5rem; width: 100%; padding: 0.75rem; background: var(--ink); clip-path: var(--notch); }
.joinrow label { font-size: 1.25rem; color: var(--dim); }
.joinctl { display: flex; gap: 0.5rem; }
.code { letter-spacing: 0.5em; text-transform: uppercase; width: 10rem; flex: 1; text-indent: 0.25em; }
.joinctl .mini { min-height: 3.5rem; padding: 0 1.25rem; background: var(--hot); color: var(--ink); font-weight: 700; }
.joinctl .mini:focus, .joinctl .mini:hover { background: var(--paper); }
.namebtn { padding-left: 0.25rem; }
.hubr { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 0.5rem; padding: 1rem; min-height: 0; max-height: 100%; }
.hubr h3 { font-size: 1.5rem; font-weight: 700; color: var(--acc-text); }
.roomscroll { overflow: auto; min-height: 0; }
.rooms { display: grid; gap: 0.25rem; }
.rmrow {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  grid-template-areas: "c h p" "c t ph";
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink2);
  clip-path: var(--notch);
  text-align: left;
}
.rmrow .rc { grid-area: c; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.1em; color: var(--hot); }
.rmrow .rh { grid-area: h; font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmrow .rtr { grid-area: t; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmrow .rpl { grid-area: p; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.rmrow .rph { grid-area: ph; color: var(--red); }
.rmrow:focus, .rmrow:hover { background: var(--paper); color: var(--ink); }
.rmrow:focus .rc, .rmrow:hover .rc, .rmrow:focus .rtr, .rmrow:hover .rtr { color: var(--ink); }
.empty { color: var(--dim); padding: 0.5rem 0; max-width: 22rem; }

/* room */
.bar .copy { margin-left: auto; align-self: center; }
.roombody {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem);
  gap: 1rem;
  min-height: 0;
  overflow: auto;
}
.rleft { display: grid; gap: 0.5rem; align-content: start; }
.phase { padding: 0.5rem 0.75rem; background: var(--ink); clip-path: var(--notch); font-size: 1.25rem; justify-self: start; }
.phase[data-phase="racing"], .phase[data-phase="countdown"] { background: var(--hot); color: var(--ink); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 0.25rem; }
.slot {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) auto;
  grid-template-areas: "pt n p" "pt c r";
  column-gap: 0.75rem;
  align-items: center;
  min-height: 3.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  background: var(--ink);
  clip-path: var(--notch);
  border-left: calc(var(--b) * 2) solid var(--ink3);
  animation: rise 0.16s steps(3) backwards;
  animation-delay: calc(var(--i) * 0.02s);
}
.slot .pt { grid-area: pt; clip-path: none; }
.slot .sn { grid-area: n; display: flex; gap: 0.5rem; align-items: center; min-width: 0; font-size: 1.25rem; }
.slot .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .crown { color: var(--hot); font-size: 0.75rem; flex: none; }
.slot .sc { grid-area: c; color: var(--dim); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .sr { grid-area: r; font-size: 1rem; color: var(--dim); white-space: nowrap; text-align: right; }
.slot .sp { grid-area: p; display: flex; gap: 0.25rem; align-items: center; justify-content: flex-end; color: var(--dim); font-size: 0.75rem; }
.slot.rdy { border-left-color: var(--mint); }
.slot.rdy .sr { color: var(--mint); }
.slot.me { background: var(--ink2); border-left-color: var(--acc-text); }
.slot.me.rdy { border-left-color: var(--mint); }
.slot.empty { display: flex; gap: 0.5rem; min-height: 2.5rem; color: #5b5f70; font-size: 1rem; padding-left: 1rem; background: var(--ink); opacity: 0.8; clip-path: var(--notch); }
.slot .sum { display: none; }
html.portrait .slot .sum { display: inline; }
.kick {
  grid-row: 1 / 3;
  grid-column: 4;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  font-size: 1rem;
  color: var(--dim);
  background: var(--ink2);
  clip-path: var(--notch);
}
.slot:has(.kick) { grid-template-columns: 2.5rem minmax(0, 1fr) auto auto; }
.kick:focus, .kick:hover { background: var(--red); color: var(--paper); }
.kick.armed { background: var(--red); color: var(--paper); }
.kick span { display: none; }
.kick.armed span { display: inline; }

.rright { display: grid; gap: 1rem; align-content: start; min-height: 0; }
.ract { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.ract .ready { grid-column: 1; }
.ract .start { grid-column: 2; }
.ract .mini { grid-column: 1 / -1; justify-content: center; }
.room:not(.is-host) .ract .ready { grid-column: 1 / -1; }
.ready { background: var(--paper); font-size: 1.5rem; }
.ready.on { background: var(--mint); color: var(--ink); }
.ready.on span::after { content: ""; }
.start { font-size: 1.5rem; }
.rset { display: grid; gap: 0.25rem; padding: 0.5rem; }
.rset .row { background: var(--ink2); font-size: 1rem; min-height: 2.75rem; }
.rset .row .val { min-width: 7rem; }
.rset .row:focus, .rset .row:hover { background: var(--paper); }
.rset .row.ro:focus, .rset .row.ro:hover { background: var(--ink3); color: var(--paper); }
.sethead { font-size: 1.25rem; color: var(--dim); padding: 0.25rem 0.5rem; }
.chat { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.5rem; min-height: 10rem; max-height: 16rem; }
.log { overflow: auto; min-height: 4rem; display: flex; flex-direction: column; gap: 0.25rem; font-size: 1rem; }
.log > :first-child { margin-top: auto; }
.log .sys { color: var(--dim); }
.log b { font-weight: 700; }
.say { min-height: 2.75rem; font-size: max(16px, 1.25rem); font-weight: 500; }

/* ------------------------------------------------------------- overlay */

#overlay { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#overlay > * { pointer-events: auto; }
#fsbtn {
  position: absolute;
  top: calc(var(--st) + var(--gut));
  right: calc(var(--sr) + var(--gut));
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: var(--ink);
  clip-path: var(--notch);
}
#fsbtn:hover, #fsbtn:focus { background: var(--paper); color: var(--ink); }
#fsbtn.on { color: var(--hot); }
html[data-state="race"] #fsbtn, html[data-state="pause"] #fsbtn { display: none; }

#toast {
  position: absolute;
  top: calc(var(--st) + var(--gut));
  left: 50%;
  transform: translate(-50%, -150%);
  max-width: min(32rem, calc(100% - 2 * var(--gut) - 8rem));
  padding: 0.75rem 1rem;
  font-size: 1.25rem;
  background: var(--paper);
  color: var(--ink);
  clip-path: var(--notch);
  transition: transform 0.14s steps(3);
  pointer-events: none;
}
#toast.on { transform: translate(-50%, 0); }
#toast.err { background: var(--red); color: var(--paper); }
#toast.ok { background: var(--mint); color: var(--ink); }

#netbanner {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.5rem calc(var(--sr) + 1rem) calc(var(--sb) + 0.5rem) calc(var(--sl) + 1rem);
  font-size: 1.25rem;
  background: var(--hot);
  color: var(--ink);
  text-align: center;
  pointer-events: none;
}
#netbanner::before { content: ""; display: inline-block; width: 0.75rem; height: 0.75rem; margin-right: 0.75rem; background: var(--ink); animation: blink 0.6s steps(1) infinite; }

#itemhint {
  position: absolute;
  top: calc(var(--st) + 4.5rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(30rem, calc(100% - 2rem));
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  clip-path: var(--notch);
  pointer-events: none;
  font-size: 1rem;
}
#itemhint.on { animation: rise 0.16s steps(3) backwards; }
#itemhint img { width: 3rem; height: 3rem; flex: none; }
#itemhint b { display: block; font-size: 1.25rem; color: var(--hot); }
html:not([data-state="race"]) #itemhint { display: none; }

/* ------------------------------------------------------------- loader */

#loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--ink);
  transition: opacity 0.4s steps(5);
  --p: 0;
}
#loader.out { opacity: 0; pointer-events: none; }
.ld-box { width: min(32rem, 100%); display: grid; gap: 1.25rem; }
.ld-mark .wordmark { width: 100%; }
.ld-road { position: relative; height: 2rem; background: var(--ink2); clip-path: var(--notch); }
.ld-fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p) * 100%); background: var(--hot); }
.ld-kart {
  position: absolute;
  top: 50%;
  left: calc(var(--p) * (100% - 3rem));
  transform: translateY(-50%);
  width: 3rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: var(--red);
}
.ld-line { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.25rem; }
.ld-pct { font-variant-numeric: tabular-nums; color: var(--hot); }
.ld-tip { color: var(--dim); min-height: 2.5em; }
#loader.failed .ld-road { display: none; }
#loader.failed .ld-pct { display: none; }
#loader.failed .ld-text { color: var(--red); font-size: 1.5rem; }
.nojs { position: fixed; inset: auto 0 0 0; padding: 1rem; background: var(--red); z-index: 20; }

/* ------------------------------------------------------------- layout: short landscape (phones) */

html.short { --gut: 0.75rem; }
html.short .scr { gap: 0.5rem; }
html.short .bar h2 { font-size: 1.5rem; padding: 0.25rem 0.75rem; }
html.short .back { min-height: 2.75rem; font-size: 1rem; }
html.short .mi { min-height: 3rem; font-size: 1.5rem; }
html.short .go { min-height: 3rem; font-size: 1.5rem; }
html.short .title-low { gap: 0.5rem; }
html.short:not(.portrait) .title { grid-template: "top low" auto "win low" 1fr / 1fr auto; }
html.short:not(.portrait) .title-low { align-self: center; justify-items: stretch; margin-top: 3rem; }
html.short:not(.portrait) .title .menu { align-items: stretch; }
html.short:not(.portrait) .title .mi:focus, html.short:not(.portrait) .title .mi:hover { transform: translateX(-0.5rem); }
html.short .title .sub { display: none; }
html.short .title .help { display: none; }
html.short .wordmark { width: min(22rem, 46vw); }
html.short .cgrid { grid-template-columns: repeat(5, 3.5rem); gap: 0.25rem; }
html.short .cg .cn { display: none; }
html.short .cname { font-size: 2rem; }
html.short .cinfo { gap: 0.5rem; padding: 0.75rem; width: min(100%, 20rem); }
html.short .ctag { font-size: 1rem; }
html.short .stat .sbar i { width: 1rem; height: 0.5rem; }
html.short .tbody { grid-template: "list info" auto "list opts" 1fr / minmax(10rem, 14rem) 1fr; overflow: auto; }
html.short .tbody > .window { display: none; }
html.short .tr { min-height: 2.75rem; font-size: 1rem; }
html.short .tr .outline { width: 2rem; height: 2rem; }
html.short .tinfo { grid-template-columns: 4rem 1fr; grid-template-rows: auto auto 1fr; column-gap: 0.75rem; padding: 0.5rem 0.75rem; }
html.short .tmeta { display: none; }
html.short .tblurb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.short .tbig { grid-row: 1 / 4; }
html.short .tname { font-size: 1.5rem; }
html.short .tblurb { font-size: 1rem; }
html.short .row { min-height: 2.75rem; font-size: 1rem; }
html.short .pband h2 { font-size: 2.5rem; }
html.short .pband { padding-top: calc(var(--st) + 1rem); padding-bottom: calc(var(--sb) + 1rem); gap: 0.5rem; }
html.short .rhead h2 { font-size: 2rem; }
html.short .rhead { grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 1rem; padding: 0.5rem 0.75rem; }
html.short .rmenu .mi { min-height: 2.75rem; font-size: 1.25rem; }
html.short .rtable { grid-template-columns: 1fr 1fr; width: 100%; column-gap: 0.5rem; }
html.short .rrow { font-size: 1rem; grid-template-columns: 2rem 2rem 1fr auto; }
html.short .rrow .pt.sm { width: 2rem; }
html.short .rrow .rp { font-size: 1.25rem; }
html.short .results { justify-items: stretch; }
html.short .slots { gap: 0.25rem; }
html.short .slot { min-height: 2.75rem; grid-template-areas: "pt n r" "pt n p"; }
html.short .slot .sc { display: none; }
html.short .slot .pt.sm { width: 2rem; }
html.short .obox { padding: 0.75rem; gap: 0.5rem; }
html.short .nick { min-height: 3rem; }
html.short .hubr h3 { font-size: 1.25rem; }
html.short .joinrow { margin-top: 0; padding: 0.5rem; }

/* ------------------------------------------------------------- layout: portrait (phones) */

html.portrait .title { grid-template: "top" auto "win" 1fr "low" auto / 1fr; }
html.portrait .wordmark { width: calc(100% - 3.5rem); }
html.portrait .title-top { justify-items: stretch; }
html.portrait .title .sub { justify-self: start; font-size: 1rem; }
html.portrait .title-low { justify-items: stretch; }
html.portrait .title .menu { align-items: stretch; }
html.portrait .mi { min-height: 4rem; font-size: 1.75rem; min-width: 0; }
html.portrait .mi:focus, html.portrait .mi:hover { transform: translateX(0.5rem); }
html.portrait .press { justify-self: stretch; text-align: center; min-height: 4rem; }
html.portrait .title .help { max-width: none; }
html.portrait .bar h2 { font-size: 1.5rem; }

html.portrait .cbody { grid-template: "win" 1fr "info" auto "grid" auto / 1fr; gap: 0.5rem; }
html.portrait .cgrid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.25rem; }
html.portrait .cg .cn { display: none; }
html.portrait .cinfo { justify-self: stretch; width: auto; grid-template-columns: 1fr auto; align-items: end; gap: 0.5rem 1rem; padding: 0.75rem; }
html.portrait .cname { font-size: 2rem; grid-column: 1 / -1; }
html.portrait .ctag { grid-column: 1 / -1; font-size: 1rem; min-height: 0; }
html.portrait .cinfo .stats { font-size: 0.75rem; }
html.portrait .stat > span:first-child { width: 3rem; }
html.portrait .stat .sbar i { width: 1rem; height: 0.5rem; }
html.portrait .cinfo .go { font-size: 1.25rem; padding: 0.5rem 0.75rem; min-height: 3.5rem; }
html.portrait .cinfo .go span { max-width: 9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

html.portrait .tracks { grid-template-rows: auto minmax(0, 1fr); }
html.portrait .tbody { grid-template: "list" auto "info" auto "opts" auto / 1fr; overflow: auto; align-content: start; gap: 0.5rem; }
html.portrait .tlist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.25rem; }
html.portrait .tr { flex-direction: column; justify-content: center; gap: 0.25rem; padding: 0.5rem 0.25rem; font-size: 0.75rem; text-align: center; min-height: 4.5rem; }
html.portrait .tr:focus, html.portrait .tr:hover { transform: translateY(calc(var(--b) * -1)); }
html.portrait .tr .outline { width: 2rem; height: 2rem; }
html.portrait .tinfo { grid-template-columns: 5rem 1fr; grid-template-rows: auto auto 1fr; column-gap: 0.75rem; padding: 0.75rem; }
html.portrait .tbig { grid-row: 1 / 4; }
html.portrait .tname { font-size: 1.5rem; }
html.portrait .tblurb { font-size: 1rem; }
html.portrait .topts .go { min-height: 4rem; }

html.portrait .pause { grid-template-columns: 1fr; align-content: end; }
html.portrait .pband { border-right: 0; border-top: calc(var(--b) * 2) solid var(--hot); padding: 1.5rem calc(var(--sr) + 1rem) calc(var(--sb) + 1.5rem) calc(var(--sl) + 1rem); }
html.portrait .pband .menu { align-items: stretch; }
html.portrait .pband .mi { min-height: 4rem; }

html.portrait .results { justify-items: stretch; }
html.portrait .rtable { width: 100%; }
html.portrait .rrow { font-size: 1rem; }
html.portrait .rmenu { display: grid; grid-template-columns: 1fr 1fr; }
html.portrait .rmenu .mi:first-child { grid-column: 1 / -1; }
html.portrait .rmenu .mi { min-height: 3.5rem; font-size: 1.25rem; }
html.portrait .rmenu .mi:focus, html.portrait .rmenu .mi:hover { transform: none; }

html.portrait .hubbody { grid-template-columns: 1fr; overflow: auto; }
html.portrait .hub .menu { align-items: stretch; }
html.portrait .hubr { max-height: none; }
html.portrait .roombody { grid-template-columns: 1fr; }
html.portrait .bar .copy span { display: none; }
html.portrait .slot { min-height: 3rem; grid-template-areas: "pt n r" "pt c p"; }
html.portrait .slot .sn { font-size: 1rem; }
html.portrait .slot .sc { font-size: 0.75rem; }
html.portrait .slot .pt.sm { width: 2.25rem; }
html.portrait .slot.empty { min-height: 2.75rem; font-size: 1rem; }
html.portrait .slot.empty:not(.first) { display: none; }
html.portrait .slot.empty .one { display: none; }
html.portrait .roombody { align-content: start; gap: 0.5rem; }
html.portrait .rright, html.portrait .rleft { display: contents; }
html.portrait .ract { order: -2; position: sticky; top: 0; z-index: 1; padding-bottom: 0.25rem; }
html.portrait .phase { order: -1; justify-self: stretch; font-size: 1rem; }
html.portrait .rset { order: 1; }
html.portrait .chat { order: 2; }
html.portrait .bar .rword { display: none; }
html.portrait .room .bar h2 { flex: none; }


/* Wide screens: give the 3D scene more room. */
@media (min-aspect-ratio: 2/1) {
  .title { grid-template-columns: minmax(0, 40%) 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .press span { animation: none !important; }
}
