html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1c2c;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --px is two game pixels in CSS pixels (1/320 of the width); main.js sets it whenever the game is resized. --u is one
   game pixel: the main menu's home screen and the pause menu are laid out in it. */
#stage {
  --px: 3px;
  --u: calc(var(--px) / 2);
  position: relative;
}

canvas {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  outline: none;
}

#game {
  width: 100%;
  height: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
  text-transform: inherit;
}

:focus-visible {
  outline: var(--px) solid #ffcd75;
  outline-offset: 0;
}

/* Pause button, top-right corner of the game */
#pause-btn {
  position: absolute;
  top: calc(var(--px) * 3);
  right: calc(var(--px) * 3);
  width: calc(var(--px) * 11);
  height: calc(var(--px) * 11);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--px) * 2);
  padding: 0;
  background: #1a1c2c;
  border: var(--px) solid #f4f4f4;
  cursor: pointer;
}

#pause-btn span {
  width: calc(var(--px) * 2);
  height: calc(var(--px) * 5);
  background: #f4f4f4;
}

#pause-btn[hidden] {
  display: none;
}

#pause-btn:hover,
#pause-btn[aria-expanded="true"] {
  background: #3b5dc9;
}

/* Pause menu (the Side Rail design): a full-height dock on the right, laid out in game pixels (its --px is one game
   pixel, --u), with the tabs down a rail on the left and the picked tab beside it. */
#menu {
  --px: var(--u);
  position: absolute;
  top: calc(var(--px) * 3);
  right: calc(var(--px) * 3);
  bottom: calc(var(--px) * 3);
  width: calc(var(--px) * 314);
  display: grid;
  grid-template-columns: calc(var(--px) * 74) 1fr;
  box-sizing: border-box;
  background: #1a1c2c;
  border: var(--px) solid #f4f4f4;
  box-shadow: calc(var(--px) * 3) calc(var(--px) * 3) 0 rgba(0, 0, 0, 0.5);
  color: #f4f4f4;
  font-family: 'Silkscreen', monospace;
  font-size: calc(var(--px) * 8);
  line-height: 1;
  text-transform: uppercase;
}

/* The rail: "Paused", the tabs (icon + name; Testing in orange), then Resume, Restart and Main menu at its foot */
.menu-rail {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 2);
  min-height: 0;
  padding: calc(var(--px) * 4) 0;
  background: #262b44;
  border-right: var(--px) solid #333c57;
}

.rail-head {
  margin: 0;
  padding: calc(var(--px) * 2) calc(var(--px) * 6) calc(var(--px) * 6);
  font-size: calc(var(--px) * 9);
  color: #ffcd75;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 2);
}

.tab {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 4);
  padding: calc(var(--px) * 5) calc(var(--px) * 6);
  background: none;
  border: var(--px) solid transparent;
  border-right: 0;
  font-size: calc(var(--px) * 7);
  color: #94b0c2;
  text-align: left;
  cursor: pointer;
}

.tab:hover {
  color: #f4f4f4;
}

/* The open tab joins the content beside it */
.tab[aria-selected="true"] {
  margin-right: calc(var(--px) * -1);
  background: #1a1c2c;
  border-color: #333c57;
  color: #ffcd75;
}

.tab.tab-dev {
  color: #ef7d57;
}

.rail-space {
  flex: 1;
}

.menu-rail .btn {
  margin: 0 calc(var(--px) * 4);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
  font-size: calc(var(--px) * 6.5);
  text-align: center;
}

.menu-rail .rail-resume {
  padding: calc(var(--px) * 6) calc(var(--px) * 4);
  font-size: calc(var(--px) * 8);
}

.menu-rail .rail-leave {
  background: transparent;
  border-color: #566c86;
}

/* The picked tab: the whole height, scrolling if it has to */
.menu-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: calc(var(--px) * 6);
}

#menu[hidden],
#menu [hidden] {
  display: none;
}

.menu-foot,
.tuning-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* The tab's reset button, stuck to the bottom of the content so it stays in reach on tabs that scroll */
.menu-foot {
  position: sticky;
  bottom: calc(var(--px) * -6);
  justify-content: flex-end;
  margin: auto calc(var(--px) * -6) calc(var(--px) * -6);
  padding: calc(var(--px) * 3) calc(var(--px) * 6) calc(var(--px) * 6);
  background: #1a1c2c;
  border-top: var(--px) solid #333c57;
}

.menu-foot .btn {
  font-size: 0.8em;
}

.stack-view {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 3);
  min-height: calc(var(--px) * 92);
}

/* Player tuning in the Dev tab, set off from the testing sliders above. */
/* UI tab: the trophy list, a cup in its metal's color (empty outline until earned) */
.trophy-list {
  display: flex;
  flex-direction: column;
  gap: var(--px);
}

.trophy-row {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 3);
}

.trophy-cup {
  flex: none;
  width: calc(var(--px) * 5);
  height: calc(var(--px) * 5);
  border: var(--px) solid #566c86;
}

.trophy-name {
  flex: none;
  width: calc(var(--px) * 56);
  font-size: 0.8em;
  white-space: nowrap;
  color: #94b0c2;
}

/* Testing tab: the playtesting tools, three to a row */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--px) * 2);
  margin-bottom: calc(var(--px) * 3);
}

.tool-grid .btn {
  font-size: 0.8em;
}

.tool-grid .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.test-section {
  min-height: 0;
  margin-top: calc(var(--px) * 3);
  padding-top: calc(var(--px) * 4);
  border-top: var(--px) solid #333c57;
}

/* Player tuning: a scrolling list of label + number + reset, with a tip under each */
.tuning-head .test-note {
  margin: 0;
}

.tuning-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 3);
  max-height: calc(var(--px) * 96);
  overflow-y: auto;
  padding-right: calc(var(--px) * 2);
}

.tuning-top {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 3);
}

.tuning-label {
  flex: 1;
  color: #94b0c2;
}

.tuning-item.changed .tuning-label {
  color: #ffcd75;
}

.num.tuning-num {
  width: calc(var(--px) * 40);
}

/* Only a changed value can be reset; the button keeps its space so the numbers stay lined up. */
.tuning-reset {
  visibility: hidden;
}

.tuning-item.changed .tuning-reset {
  visibility: visible;
}

.tuning-tip {
  display: block;
  margin-top: var(--px);
  font-size: 0.7em;
  color: #566c86;
}

/* Upgrade level pips: filled up to the current level */
.pips {
  display: flex;
  gap: var(--px);
}

.pip {
  width: calc(var(--px) * 5);
  height: calc(var(--px) * 8);
  background: #262b44;
  border: var(--px) solid #566c86;
}

.pip.on {
  background: #38b764;
  border-color: #a7f070;
}

.upgrade-effect {
  font-size: 0.75em;
  color: #94b0c2;
}

/* Player tab: preview, the team's faces and the randomize button in one column */
.preview-col {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 3);
}

/* Faces of the user's team: click one to customize / upgrade that player */
.faces {
  display: flex;
  gap: calc(var(--px) * 2);
}

.face {
  padding: 0;
  background: #262b44;
  border: var(--px) solid #566c86;
  cursor: pointer;
}

.face canvas {
  display: block;
  width: calc(var(--px) * 24);
  height: calc(var(--px) * 26);
}

.face:hover {
  border-color: #f4f4f4;
}

.face[aria-pressed="true"] {
  border-color: #ffcd75;
}

/* Upgrades: which player's levels are shown, with their name editable in place */
.player-pick {
  margin-bottom: calc(var(--px) * 2);
}

.name {
  box-sizing: border-box;
  width: calc(var(--px) * 80);
  height: calc(var(--px) * 10);
  padding: 0 calc(var(--px) * 2);
  background: #262b44;
  border: var(--px) solid #94b0c2;
}

.player-num {
  min-width: calc(var(--px) * 16);
  color: #94b0c2;
  text-align: center;
}

.key-btn {
  min-width: calc(var(--px) * 36);
  height: calc(var(--px) * 11);
  padding: 0 calc(var(--px) * 2);
  background: #262b44;
  border: var(--px) solid #94b0c2;
  cursor: pointer;
}

.key-btn:hover {
  border-color: #f4f4f4;
}

.key-btn[aria-pressed="true"] {
  border-color: #ffcd75;
  color: #ffcd75;
}

/* Game mode choices */
.mode-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--px) * 2);
  padding: calc(var(--px) * 4);
  background: #262b44;
  border: var(--px) solid #566c86;
  text-align: left;
  cursor: pointer;
}

.mode-option:hover {
  border-color: #f4f4f4;
}

.mode-option[aria-pressed="true"] {
  background: #29366f;
  border-color: #ffcd75;
}

.mode-name {
  color: #ffcd75;
}

.mode-desc {
  font-size: 0.75em;
  color: #94b0c2;
}

.test-note {
  margin: 0 0 calc(var(--px) * 2);
  color: #94b0c2;
}

.row + .test-note {
  margin-top: calc(var(--px) * 4);
}

.pct {
  min-width: calc(var(--px) * 24);
  text-align: right;
}

.slider-spacer {
  width: calc(var(--px) * 90);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: calc(var(--px) * 90);
  height: calc(var(--px) * 6);
  margin: 0;
  background: #262b44;
  border: var(--px) solid #94b0c2;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: calc(var(--px) * 5);
  height: calc(var(--px) * 10);
  background: #ffcd75;
  border: var(--px) solid #1a1c2c;
}

input[type="range"]::-moz-range-thumb {
  width: calc(var(--px) * 5);
  height: calc(var(--px) * 10);
  background: #ffcd75;
  border: var(--px) solid #1a1c2c;
  border-radius: 0;
}

.menu-body {
  display: grid;
  grid-template-columns: calc(var(--px) * 82) 1fr;
  gap: calc(var(--px) * 6);
  align-items: start;
}

#preview {
  width: calc(var(--px) * 80);
  height: calc(var(--px) * 92);
  border: var(--px) solid #333c57;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: var(--px);
}

.row {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 3);
  min-height: calc(var(--px) * 10);
}

.row label,
.row .label {
  width: calc(var(--px) * 56);
  flex: none;
  color: #94b0c2;
}

.presets {
  gap: calc(var(--px) * 2);
}

/* Sits in the label column, smaller and dimmer than a real label: the swatches are suggestions, not the only options. */
.row .preset-label {
  margin-right: var(--px);
  font-size: 0.7em;
  color: #566c86;
  text-align: right;
}

.btn {
  padding: calc(var(--px) * 2) calc(var(--px) * 4);
  background: #3b5dc9;
  border: var(--px) solid #f4f4f4;
  cursor: pointer;
}

.btn:hover {
  background: #41a6f6;
}

.btn-quiet {
  background: #333c57;
}

.step {
  width: calc(var(--px) * 10);
  height: calc(var(--px) * 10);
  padding: 0;
  background: #333c57;
  border: var(--px) solid #f4f4f4;
  cursor: pointer;
}

.step:hover {
  background: #3b5dc9;
}

.step:disabled {
  opacity: 0.35;
  cursor: default;
}

.step:disabled:hover {
  background: #333c57;
}

.value {
  min-width: calc(var(--px) * 38);
  text-align: center;
}

.swatch {
  width: calc(var(--px) * 9);
  height: calc(var(--px) * 9);
  padding: 0;
  border: var(--px) solid #333c57;
  cursor: pointer;
}

.swatch[aria-pressed="true"] {
  border-color: #f4f4f4;
}

input[type="color"] {
  width: calc(var(--px) * 14);
  height: calc(var(--px) * 10);
  padding: 0;
  background: none;
  border: var(--px) solid #f4f4f4;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
}

input[type="color"]::-moz-color-swatch {
  border: none;
}

.hex,
.num {
  box-sizing: border-box;
  height: calc(var(--px) * 10);
  padding: 0 calc(var(--px) * 2);
  background: #262b44;
  border: var(--px) solid #94b0c2;
}

.hex {
  width: calc(var(--px) * 50);
}

.num {
  width: calc(var(--px) * 22);
  text-align: center;
}

/* Career panel: season and tokens, team name, challenges, last game, standings */
.career-panel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 3);
}

.career-head {
  display: flex;
  justify-content: space-between;
  color: #ffcd75;
}

.career-tokens {
  color: #38b764;
}

.challenge {
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
}

/* Challenge tiers, easiest to hardest: the tier name in its own color */
.challenge.tier-0 .mode-name {
  color: #38b764;
}

.challenge.tier-1 .mode-name {
  color: #ffcd75;
}

.challenge.tier-2 .mode-name {
  color: #ef7d57;
}

.challenge.tier-3 .mode-name {
  color: #e43b44;
}

.standings {
  display: grid;
  grid-template-columns: calc(var(--px) * 14) 1fr calc(var(--px) * 30) calc(var(--px) * 26);
  gap: var(--px) calc(var(--px) * 3);
  font-size: 0.75em;
}

.standings-head {
  color: #566c86;
}

.standings-you {
  color: #ffcd75;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Career saving: whether progress is being saved */
.save-ok,
.save-warn {
  margin: 0;
  font-size: 0.75em;
}

.save-ok {
  color: #38b764;
}

.save-warn {
  color: #e43b44;
}

.career-panel > .btn {
  align-self: flex-start;
}

/* 2 Player formats: a little tighter than the mode buttons */
.duo-format {
  box-sizing: border-box;
  width: 100%;
  margin-bottom: calc(var(--px) * 2);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
}

/* Main menu: the logo over a panel in the pause menu's style, on the demo game behind it. Both hang from the top,
   so the logo stays put whichever view (and panel height) is showing. */
#title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  padding-top: calc(var(--px) * 8);
  gap: calc(var(--px) * 4);
  color: #f4f4f4;
  font-family: 'Silkscreen', monospace;
  font-size: calc(var(--px) * 8);
  line-height: 1;
  text-transform: uppercase;
}

#title[hidden],
#title [hidden] {
  display: none;
}

.title-logo {
  margin: 0;
  font-size: calc(var(--px) * 22);
  font-weight: normal;
  letter-spacing: var(--px);
  color: #ffcd75;
  text-shadow: calc(var(--px) * 2) calc(var(--px) * 2) 0 #1a1c2c;
}

.title-logo span {
  color: #ef7d57;
}

.title-panel {
  box-sizing: border-box;
  width: calc(var(--px) * 204);
  max-height: calc(var(--px) * 136);
  overflow-y: auto;
  padding: calc(var(--px) * 4);
  background: #1a1c2c;
  border: var(--px) solid #f4f4f4;
  box-shadow: calc(var(--px) * 3) calc(var(--px) * 3) 0 rgba(0, 0, 0, 0.5);
}

/* A mode's screen: Back and its name across the top */
.title-bar {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 4);
  margin-bottom: calc(var(--px) * 3);
}

.title-heading {
  color: #ffcd75;
}

.title-view.stack-view {
  min-height: 0;
}

/* The game options' labels on one line ("Free throws", "Half length") */
#title .row label,
#title .row .label {
  width: calc(var(--px) * 62);
  white-space: nowrap;
}

/* Quick game: the daily game's card above the options */
.daily-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--px) * 2);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
  background: #262b44;
  border: var(--px) solid #566c86;
}

/* Online: the lobby both players are in before the host starts */
.online-lobby {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--px) * 2);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
  background: #29366f;
  border: var(--px) solid #ffcd75;
}

.online-lobby p {
  margin: 0;
}

/* Online: the lobby finder's open games, one button each */
.lobby-list {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--px) * 2);
}

/* Quick game difficulty: three picks on the label's row */
.difficulty-row .key-btn {
  min-width: 0;
  padding: 0 calc(var(--px) * 3);
  white-space: nowrap;
  font-size: 0.85em;
}

/* 2 Player: the stack's gap already spaces the formats, so all three and the keys fit without scrolling */
#title .duo-format {
  margin-bottom: 0;
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
}


.btn.title-start {
  align-self: flex-start;
}

/* Career upgrades: which player, their face, then buy the next level of each stat */
.career-picks {
  gap: calc(var(--px) * 2);
}

/* The picked player: their face on the left, their name and upgrades beside it */
.career-player {
  display: flex;
  align-items: flex-start;
  gap: calc(var(--px) * 4);
}

.career-face {
  flex: none;
  display: block;
  width: calc(var(--px) * 24);
  height: calc(var(--px) * 26);
  border: var(--px) solid #ffcd75;
  image-rendering: pixelated;
}

.career-stats {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 2);
}

.career-buy {
  min-width: calc(var(--px) * 30);
  padding: var(--px) calc(var(--px) * 2);
}

/* Home, the Season Road design: laid out in --u (one game pixel of the 640x360 stage), over the demo game.
   The dock (modes) on the left, the road (this season's games) along the bottom, this week's challenges in a
   popover above its stop. The logo and panel the other views use are hidden here. */
#title.at-home > .title-logo,
#title.at-home > .title-panel {
  display: none;
}

.season-home {
  position: absolute;
  inset: 0;
  font-size: calc(var(--u) * 8);
}

/* Shade behind the dock and the road so the demo game doesn't fight the text */
.season-home::before,
.season-home::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.season-home::before {
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--u) * 210);
  background: linear-gradient(90deg, rgba(26, 28, 44, 0.8) 0 calc(var(--u) * 160), rgba(26, 28, 44, 0));
}

.season-home::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--u) * 130);
  background: linear-gradient(0deg, rgba(26, 28, 44, 0.9) 0 calc(var(--u) * 80), rgba(26, 28, 44, 0));
}

.home-dock,
.home-road,
.home-pop {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  padding: calc(var(--u) * 5);
  background: #1a1c2c;
  border: var(--u) solid #f4f4f4;
  box-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 rgba(0, 0, 0, 0.5);
}

.home-dock {
  left: calc(var(--u) * 6);
  top: calc(var(--u) * 6);
  bottom: calc(var(--u) * 82);
  width: calc(var(--u) * 150);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2);
}

.dock-logo {
  margin: 0 0 calc(var(--u) * 3);
  font-size: calc(var(--u) * 16);
  line-height: 0.9;
  color: #ffcd75;
  text-shadow: calc(var(--u) * 2) calc(var(--u) * 2) 0 #000;
}

.dock-logo span {
  display: block;
  padding-left: calc(var(--u) * 12);
  color: #ef7d57;
}

.dock-row {
  display: grid;
  grid-template-columns: calc(var(--u) * 11) 1fr;
  align-items: center;
  gap: var(--u) calc(var(--u) * 4);
  padding: calc(var(--u) * 2) calc(var(--u) * 4);
  background: none;
  border: var(--u) solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.dock-row .mode-desc {
  grid-column: 2;
  font-size: calc(var(--u) * 6);
}

.dock-row:hover,
.dock-row:focus-visible {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

.dock-sep {
  height: var(--u);
  margin: var(--u) 0;
  background: #333c57;
}

.dock-quick,
.road-link {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--u) * 3);
  padding: calc(var(--u) * 2) calc(var(--u) * 4);
  background: #333c57;
  border: var(--u) solid #f4f4f4;
  color: #f4f4f4;
  font: inherit;
  font-size: calc(var(--u) * 6);
  text-transform: inherit;
  cursor: pointer;
}

.dock-quick {
  align-self: flex-start;
  margin-top: auto;
}

.dock-quick:hover,
.dock-quick:focus-visible,
.road-link:hover,
.road-link:focus-visible {
  border-color: #ffcd75;
  color: #ffcd75;
  outline: none;
}

/* The pixel icons (title.js draws them) */
.ico {
  display: inline-block;
  image-rendering: pixelated;
}

/* The road: header, then a stop for every game of the season */
.home-road {
  left: calc(var(--u) * 6);
  right: calc(var(--u) * 6);
  bottom: calc(var(--u) * 6);
  height: calc(var(--u) * 70);
  padding: calc(var(--u) * 5) calc(var(--u) * 6);
}

.road-head {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 6);
  margin-bottom: calc(var(--u) * 5);
}

.road-head .mode-desc {
  font-size: calc(var(--u) * 6);
}

.road-tokens {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  margin-left: auto;
  color: #38b764;
  font-size: calc(var(--u) * 6);
}

.road-stops {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--stops, 9), 1fr);
  gap: calc(var(--u) * 4);
}

/* The line the stops sit on */
.road-stops::before {
  content: '';
  position: absolute;
  left: calc(var(--u) * 10);
  right: calc(var(--u) * 10);
  top: calc(var(--u) * 15);
  height: calc(var(--u) * 2);
  background: #333c57;
}

.stop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 3);
  font-size: calc(var(--u) * 6);
}

.stop-week {
  color: #566c86;
}

.stop-dot {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--u) * 14);
  height: calc(var(--u) * 14);
  background: #262b44;
  border: var(--u) solid #566c86;
  color: #1a1c2c;
}

.stop-result {
  color: #94b0c2;
  white-space: nowrap;
}

/* A win: a solid green stop with a check, its score in green. A loss: a hollow stop with a red X, its score in red. */
.stop.won .stop-dot {
  background: #38b764;
  border-color: #a7f070;
}

.stop.won .stop-result {
  color: #a7f070;
}

.stop.lost .stop-dot {
  background: #1a1c2c;
  border-color: #e43b44;
}

.stop.lost .stop-result {
  color: #e43b44;
}

.stop.played .stop-dot {
  background: #566c86;
}

.stop.now .stop-week,
.stop.now .stop-result {
  color: #ffcd75;
}

.stop.now .stop-dot {
  width: calc(var(--u) * 18);
  height: calc(var(--u) * 18);
  margin: calc(var(--u) * -2) 0;
  background: #ffcd75;
  border-color: #f4f4f4;
}

.stop.playoff:not(.won):not(.lost):not(.now) .stop-dot {
  background: #1a1c2c;
  border-style: dashed;
  border-color: #5d275d;
}

.stop.out .stop-week,
.stop.out .stop-result {
  color: #333c57;
}

/* This week's game: the matchup and its three challenges, pointing down at its stop */
.home-pop {
  bottom: calc(var(--u) * 82);
  width: calc(var(--u) * 190);
  padding: calc(var(--u) * 5);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 3);
  border-color: #ffcd75;
}

.home-pop::after {
  content: '';
  position: absolute;
  left: var(--arrow, calc(var(--u) * 30));
  bottom: calc(var(--u) * -6);
  border: calc(var(--u) * 5) solid transparent;
  border-top-color: #ffcd75;
  border-bottom: 0;
}

.home-pop.no-arrow::after {
  display: none;
}

.pop-vs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  background: #262b44;
  border: var(--u) solid #566c86;
}

.pop-team {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
}

.pop-record {
  color: #94b0c2;
  font-size: calc(var(--u) * 6);
}

.swatch {
  display: inline-block;
  width: calc(var(--u) * 10);
  height: calc(var(--u) * 8);
  border: var(--u) solid #f4f4f4;
}

/* A challenge: tier, goal, multiplier on one line (the tier colors come from .challenge.tier-N above) */
.home-pop .challenge {
  display: grid;
  grid-template-columns: calc(var(--u) * 44) 1fr auto;
  align-items: center;
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  background: #262b44;
  border: var(--u) solid #566c86;
  color: #f4f4f4;
  font: inherit;
  font-size: calc(var(--u) * 6.5);
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.home-pop .challenge:hover,
.home-pop .challenge:focus-visible {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

.home-pop .challenge .mode-name,
.home-pop .challenge .mult {
  font-size: inherit;
}

.challenge.tier-0 .mult {
  color: #38b764;
}

.challenge.tier-1 .mult {
  color: #ffcd75;
}

.challenge.tier-2 .mult {
  color: #ef7d57;
}

.challenge.tier-3 .mult {
  color: #e43b44;
}


.pop-note {
  margin: 0;
  color: #94b0c2;
  font-size: calc(var(--u) * 6);
  line-height: 1.2;
}

/* "Ready to play now?" after picking a challenge on the home screen */
.home-pop .challenge.picked {
  border-color: #ffcd75;
  cursor: default;
}

.pop-question {
  margin: var(--u) 0 0;
  color: #ffcd75;
}

.pop-ready {
  display: flex;
  gap: calc(var(--u) * 4);
}

.pop-ready .btn {
  font-size: calc(var(--u) * 7);
  padding: calc(var(--u) * 3) calc(var(--u) * 8);
  border-width: var(--u);
}

/* Controls tab: whose keys, the drawn keyboard and the legend. Each action has a color (--act) used by its keys on
   the keyboard and its swatch in the legend: move blue, shoot green, dunk orange, pass yellow, pause plum. */
.act-move {
  --act: #3b5dc9;
  --act-ink: #f4f4f4;
}

.act-shoot {
  --act: #38b764;
  --act-ink: #1a1c2c;
}

.act-dunk {
  --act: #ef7d57;
  --act-ink: #1a1c2c;
}

.act-pass {
  --act: #ffcd75;
  --act-ink: #1a1c2c;
}

.act-pause {
  --act: #5d275d;
  --act-ink: #f4f4f4;
}

.key-sets {
  gap: calc(var(--px) * 2);
}

.key-sets .key-btn {
  min-width: 0;
  padding: 0 calc(var(--px) * 4);
  font-size: calc(var(--px) * 7);
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 2);
}

/* 15 keys to a row, in quarter keys so the wide ones (Tab, Shift, Space) line up */
.keyboard-row {
  display: grid;
  grid-template-columns: repeat(60, 1fr);
}

.keycap {
  min-width: 0;
  height: calc(var(--px) * 14);
  margin: 0 var(--px);
  padding: 0;
  overflow: hidden;
  background: #262b44;
  border: var(--px) solid #333c57;
  color: #566c86;
  font-size: calc(var(--px) * 6);
  white-space: nowrap;
  cursor: pointer;
}

.keycap[class*="act-"] {
  background: var(--act);
  border-color: #f4f4f4;
  color: var(--act-ink);
}

/* Waiting for a key: any key on the keyboard can be clicked */
.keyboard.picking .keycap:hover {
  border-color: #ffcd75;
  color: #ffcd75;
}

.key-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--px) * 2) calc(var(--px) * 4);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 4);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
  background: none;
  border: var(--px) solid #333c57;
  font-size: calc(var(--px) * 7);
  text-align: left;
  cursor: pointer;
}

.legend-row[hidden] {
  display: none;
}

.legend-row:hover,
.legend-row:focus-visible,
.legend-row[aria-pressed="true"] {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

.legend-swatch {
  flex: none;
  width: calc(var(--px) * 8);
  height: calc(var(--px) * 8);
  background: var(--act);
  border: var(--px) solid #f4f4f4;
}

.key-name {
  margin-left: auto;
  color: #94b0c2;
  font-size: calc(var(--px) * 6);
}

.legend-row[aria-pressed="true"] .key-name {
  color: #ffcd75;
}

.key-hint {
  margin: 0;
  color: #566c86;
  font-size: calc(var(--px) * 6);
  line-height: 1.3;
}

/* Locker room: the talk panel along the bottom (who, what they say, the answers), or the trophy case, taller, with
   a button per trophy earned to put on the scoreboard's shelf or take off. In game pixels, like the menus. */
.locker-talk {
  position: absolute;
  left: calc(var(--u) * 24);
  right: calc(var(--u) * 24);
  bottom: calc(var(--u) * 26);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 5);
  max-height: calc(var(--u) * 300);
  overflow-y: auto;
  box-sizing: border-box;
  padding: calc(var(--u) * 8) calc(var(--u) * 10);
  background: #1a1c2c;
  border: var(--u) solid #f4f4f4;
  box-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 rgba(0, 0, 0, 0.5);
  color: #f4f4f4;
  font-family: 'Silkscreen', monospace;
  font-size: calc(var(--u) * 8);
  line-height: 1.3;
  text-transform: uppercase;
}

.locker-talk[hidden] {
  display: none;
}

.locker-talk p {
  margin: 0;
}

.locker-talk .btn {
  font-size: calc(var(--u) * 8);
  padding: calc(var(--u) * 3) calc(var(--u) * 8);
  border-width: var(--u);
}

.talk-actions {
  display: flex;
  gap: calc(var(--u) * 6);
}

.locker-talk.trophy-case {
  top: calc(var(--u) * 20);
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 3) calc(var(--u) * 6);
}

.case-item {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 5);
  padding: calc(var(--u) * 3) calc(var(--u) * 5);
  background: none;
  border: var(--u) solid #333c57;
  color: #94b0c2;
  font-size: calc(var(--u) * 7);
  text-align: left;
  cursor: pointer;
}

.case-item[aria-pressed="true"] {
  border-color: #ffcd75;
  background: #29366f;
  color: #f4f4f4;
}

.case-item:focus-visible {
  outline: var(--u) solid #ffcd75;
}

.case-item.locked {
  color: #566c86;
  cursor: default;
}

.case-cup {
  flex: none;
  width: calc(var(--u) * 8);
  height: calc(var(--u) * 8);
  border: var(--u) solid #f4f4f4;
}

/* Gear tab: name, < style >, and what unlocks the next style on its own line */
.gear-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--px) * 3);
}

.gear-row {
  display: grid;
  grid-template-columns: calc(var(--px) * 76) calc(var(--px) * 11) 1fr calc(var(--px) * 11);
  align-items: center;
  gap: var(--px) calc(var(--px) * 3);
}

.gear-row .value {
  text-align: center;
}

.gear-hint {
  grid-column: 1 / -1;
}

/* Quick game / Practice: the court picker, its name between the arrows */
.court-row .value {
  flex: 1;
  text-align: center;
}

/* Talk Time: the panel in three parts (portrait, what they say, the quest card); the trophy case and the tunnel use
   the whole width below. */
.locker-talk {
  display: grid;
  grid-template-columns: auto 1fr calc(var(--u) * 170);
  align-items: start;
  gap: calc(var(--u) * 8);
}

.talk-portrait {
  width: calc(var(--u) * 60);
  height: calc(var(--u) * 65);
  border: var(--u) solid #ffcd75;
  image-rendering: pixelated;
}

.talk-portrait[hidden] {
  display: none;
}

.talk-words {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 5);
  min-width: 0;
}

.talk-card {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 4);
  padding: calc(var(--u) * 5) calc(var(--u) * 6);
  background: #262b44;
  border: var(--u) solid #566c86;
}

.talk-card[hidden] {
  display: none;
}

.card-goal {
  color: #ffcd75;
}

.card-pips {
  display: flex;
  gap: var(--u);
}

.card-pips .pip {
  width: calc(var(--u) * 6);
  height: calc(var(--u) * 6);
  border-width: var(--u);
}

.card-count {
  font-size: calc(var(--u) * 6);
  color: #94b0c2;
}

.card-reward {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
  color: #38b764;
}

.talk-card .talk-actions {
  flex-wrap: wrap;
  gap: calc(var(--u) * 4);
}

/* The tunnel's three challenges, then Not yet, across the whole panel */
.locker-talk:has(.talk-court) {
  grid-template-columns: 1fr;
}

.talk-court {
  flex-direction: column;
  align-items: stretch;
}

.talk-court .challenge {
  display: grid;
  grid-template-columns: calc(var(--u) * 60) 1fr auto;
  padding: calc(var(--u) * 4) calc(var(--u) * 6);
  background: #262b44;
  border: var(--u) solid #566c86;
  color: #f4f4f4;
  font: inherit;
  font-size: calc(var(--u) * 8);
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.talk-court .challenge:hover,
.talk-court .challenge:focus-visible {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

.talk-court .btn {
  align-self: flex-start;
}

/* The trophy case as the case: glass shelves of cups, the ones on the scoreboard shelf ringed in gold, grey cups
   still to earn; and a row of the scoreboard shelf's 13 slots. */
.locker-talk.trophy-case {
  grid-template-columns: 1fr auto;
}

.talk-shelf {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 6);
}

.talk-shelf:empty {
  display: none;
}

.case-slots {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
}

.case-slots-label {
  margin-right: calc(var(--u) * 4);
  font-size: calc(var(--u) * 7);
  color: #94b0c2;
}

.case-slot {
  width: calc(var(--u) * 8);
  height: calc(var(--u) * 8);
  border: var(--u) solid #566c86;
}

.case-slot.on {
  background: #ffcd75;
  border-color: #ffcd75;
}

.locker-talk .case-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: calc(var(--u) * 4);
  background: #29366f;
  border: calc(var(--u) * 3) solid #8f563b;
}

.locker-talk .case-item {
  flex-direction: column;
  justify-content: flex-end;
  gap: calc(var(--u) * 3);
  min-height: calc(var(--u) * 44);
  padding: calc(var(--u) * 4) calc(var(--u) * 2);
  border: var(--u) solid transparent;
  border-bottom: calc(var(--u) * 3) solid #c98d5a; /* the glass shelf each cup stands on */
  background: none;
  text-align: center;
  font-size: calc(var(--u) * 6);
}

.locker-talk .case-item[aria-pressed="true"] {
  border-color: #ffcd75;
  border-bottom-color: #c98d5a;
  background: rgba(255, 205, 117, 0.12);
}

.locker-talk .case-cup {
  width: calc(var(--u) * 12);
  height: calc(var(--u) * 12);
  border-radius: 0 0 calc(var(--u) * 6) calc(var(--u) * 6);
}

.locker-talk .case-item.locked .case-cup {
  background: #566c86;
}

/* Drawers (the Dock Drawer design): Casual and 2 Player slide out beside the home screen's dock, with a gap between
   the two, and the menu stays on screen: the dock row stays lit, the challenge popover steps aside and the road dims.
   Laid out in game pixels (the panel's --px is --u). */
#title.at-home.drawer-open > .title-panel {
  --px: var(--u);
  display: block;
  position: absolute;
  z-index: 2;
  left: calc(var(--u) * 168);
  top: calc(var(--u) * 6);
  bottom: calc(var(--u) * 82);
  width: calc(var(--u) * 214);
  max-height: none;
  padding: calc(var(--u) * 6) calc(var(--u) * 7);
  border-color: #ffcd75;
  font-size: calc(var(--u) * 8);
}

#title.drawer-open .home-pop {
  display: none;
}

#title.drawer-open .home-road {
  opacity: 0.35;
}

.dock-row.open {
  background: #29366f;
  border-color: #ffcd75;
}

.drawer-view {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 3);
}

.drawer-view[hidden] {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: calc(var(--u) * 3);
  margin-bottom: var(--u);
  border-bottom: var(--u) solid #333c57;
  font-size: calc(var(--u) * 10);
}

.drawer-head .btn {
  font-size: calc(var(--u) * 6);
  padding: var(--u) calc(var(--u) * 4);
}

/* A game to pick: icon, name, the key that starts it, and a line under it */
.pick {
  display: grid;
  grid-template-columns: calc(var(--u) * 11) 1fr auto;
  align-items: center;
  gap: var(--u) calc(var(--u) * 4);
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  background: #262b44;
  border: var(--u) solid #566c86;
  color: #f4f4f4;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.pick .mode-desc {
  grid-column: 2 / 4;
  font-size: calc(var(--u) * 6);
}

.pick:hover,
.pick:focus-visible {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

.pick-key {
  padding: 0 calc(var(--u) * 2);
  border: var(--u) solid #566c86;
  color: #94b0c2;
  font-size: calc(var(--u) * 6);
}

.pick-key:empty {
  display: none;
}

/* The 3v3 game's options, indented under it */
.pick-sub {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 3);
  margin-left: calc(var(--u) * 15);
  padding: calc(var(--u) * 3) calc(var(--u) * 4) calc(var(--u) * 4);
  border-left: var(--u) solid #ffcd75;
  font-size: calc(var(--u) * 7);
}

#title .pick-sub .row label,
#title .pick-sub .row .label {
  width: calc(var(--u) * 56);
}

.pick-sub .key-btn {
  min-width: 0;
  height: calc(var(--u) * 10);
  padding: 0 calc(var(--u) * 3);
}

.drawer-note {
  margin: calc(var(--u) * 2) 0 0;
  font-size: calc(var(--u) * 6);
  color: #566c86;
}

/* 2 Player's Local / Online tabs */
.drawer-tabs {
  display: flex;
  margin-bottom: calc(var(--u) * 2);
}

.drawer-tab {
  flex: 1;
  padding: calc(var(--u) * 3) 0;
  background: #262b44;
  border: var(--u) solid #566c86;
  color: #94b0c2;
  font: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.drawer-tab[aria-selected="true"] {
  background: #29366f;
  border-color: #ffcd75;
  color: #ffcd75;
}

.versus-panel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 3);
}

.versus-panel[hidden] {
  display: none;
}

.versus-panel .row {
  gap: calc(var(--u) * 3);
}

.versus-panel .key-btn {
  min-width: 0;
  height: calc(var(--u) * 10);
  padding: 0 calc(var(--u) * 3);
}

/* Local: both players' keys, side by side */
.duo-keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 4);
  padding: calc(var(--u) * 4);
  background: #262b44;
  border: var(--u) solid #566c86;
  font-size: calc(var(--u) * 6);
}

.duo-keys > div {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2);
}

.duo-keys-p1 .mode-name {
  color: #ef7d57;
}

.duo-keys-p2 .mode-name {
  color: #41a6f6;
}

/* After a career game (aftergame.js): Main menu, Next game and Upgrades in a row along the bottom of the final
   screen; Next game swaps them for the next game's three challenges */
#after-game {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--px) * 8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--px) * 3);
  color: #f4f4f4;
  font-family: 'Silkscreen', monospace;
  font-size: calc(var(--px) * 8);
  text-transform: uppercase;
}

/* Picking a challenge: a dark band behind the cards so the box score doesn't show through */
#after-game.picking {
  bottom: 0;
  padding: calc(var(--px) * 6) 0 calc(var(--px) * 8);
  background: #1a1c2c;
  border-top: var(--px) solid #566c86;
}

#after-game[hidden] {
  display: none;
}

#after-game .btn {
  color: #f4f4f4;
  font: inherit;
  text-transform: inherit;
}

#after-game .btn:focus-visible {
  border-color: #ffcd75;
  outline: var(--px) solid #ffcd75;
}

.after-row {
  display: flex;
  gap: calc(var(--px) * 8);
}

.after-row .btn {
  min-width: calc(var(--px) * 60);
  padding: calc(var(--px) * 3) calc(var(--px) * 4);
}

/* Next game, the way on, stands out in the middle */
.after-row [data-focus="after-next"] {
  min-width: calc(var(--px) * 76);
  background: #38b764;
}

.after-row [data-focus="after-next"]:hover {
  background: #a7f070;
  color: #1a1c2c;
}

.after-note {
  margin: 0;
  color: #ffcd75;
}

.after-challenges {
  display: flex;
  gap: calc(var(--px) * 3);
}

.after-challenges .challenge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--px);
  width: calc(var(--px) * 96);
  background: #262b44;
  border: var(--px) solid #566c86;
  color: #f4f4f4;
  font: inherit;
  font-size: 0.75em;
  text-transform: inherit;
  cursor: pointer;
}

.after-challenges .challenge:hover,
.after-challenges .challenge:focus-visible {
  background: #29366f;
  border-color: #ffcd75;
  outline: none;
}

/* An error shown on the page (showError in config.js), to read off a screen with no console */
.error-box {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 100;
  margin: 0;
  padding: 8px;
  max-height: 40vh;
  overflow: auto;
  background: #b13e53;
  color: #f4f4f4;
  font: 12px/1.4 monospace;
  white-space: pre-wrap;
}
