:root {
  --bg: #000;
  --panel: #111214;
  --text: #d8d4c8;
  --muted: #8a877f;
  --accent: #9fd27a;
  --bad: #e07a6a;
  --line: #2a2c30;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* hidden means hidden, whatever display a rule below gives the element */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: flex; flex-direction: column; }

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

header .title { font-weight: 600; letter-spacing: 0.02em; }
header a.title { color: var(--text); }
header .status { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .status.bad { color: var(--bad); }
/* how many are watching the game live; the player's tooltip names them (play.js) */
header .spectators { color: var(--accent); white-space: nowrap; cursor: default; }
header a { color: var(--accent); text-decoration: none; }
header a:hover { text-decoration: underline; }
/* the header's link to the page it is on (see site_nav in server.py) */
header a[aria-current="page"] { color: var(--text); }

#stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

/* in fullscreen the stage alone fills the screen, header gone */
#stage:fullscreen { background: var(--bg); }

header .header-button {
  font: inherit;
  padding: 2px 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
header .header-button:hover { border-color: var(--muted); }

#screen {
  display: block;
  background: #000;
  outline: none;
  cursor: default;
}

/* the countdown to a pause, over the top of the game; clicks go through to it */
.notice {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px 16px;
  background: rgba(60, 20, 14, 0.9);
  color: var(--text);
  border-bottom: 1px solid var(--bad);
  text-align: center;
  pointer-events: none;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.75);
  text-align: center;
  padding: 16px;
}
#overlay[hidden] { display: none; }
#overlay p { margin: 0; font-size: 16px; max-width: 32em; }
#overlay button {
  font: inherit;
  padding: 6px 18px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
}
#overlay button[hidden] { display: none; }

/* leaderboard page */
.page { max-width: 960px; margin: 0 auto; padding: 16px; width: 100%; }
.page h1 { font-size: 20px; margin: 8px 0 12px; }
.page select { font: inherit; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 4px 8px; max-width: 100%; }
/* about as wide as the boards scores.js puts in it, so the find box beside it
   doesn't jump (or wrap to a new line) when they arrive */
#board { min-width: 16em; }
.page .note { color: var(--muted); }
.boards { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
.boards .field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; max-width: 100%; }
.boards input { font: inherit; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 4px 8px; width: 14em; max-width: 100%; }
.boards button { font: inherit; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 4px 12px; cursor: pointer; }
#find-note:empty { display: none; }
/* room for the header and one row (a row, or the "none" row) from the start,
   so what is below doesn't jump when the rows arrive: a row is a line and
   6px padding above and below, and its 1px border */
.table-wrap { overflow-x: auto; margin-top: 12px; min-height: calc(2 * (1.4em + 13px)); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.won td:first-child::after { content: " ★"; color: var(--accent); }

/* home page: the banner across the top, then the game on the left and the
   account and weekly seed cards on the right; one column on a narrow screen */
.home { max-width: 1120px; overflow-y: auto; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0 40px; align-items: start; }
.home h1 { font-size: 32px; margin: 20px 0 8px; }
.home h2 { font-size: 18px; margin: 24px 0 8px; }
.home .lead { font-size: 17px; margin: 0 0 12px; max-width: 40em; }
.home .play { margin: 0; }
.home .controls { margin: 4px 0 0; }
.home .note { margin: 4px 0 0; font-size: 13px; }
.home ul { padding-left: 20px; margin: 0; }
.home li { margin: 4px 0; }
/* the feature bullets side by side where the column is wide enough */
.home .features { columns: 2 18em; column-gap: 32px; }
.home .features li { break-inside: avoid; margin: 0; padding-bottom: 6px; }
.home-side { display: grid; gap: 16px; margin-top: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
.home .card h2 { font-size: 16px; margin: 0 0 8px; }
.card p { margin: 8px 0; }
.card .hint { color: var(--muted); font-size: 13px; }
.weekly-card table { margin-top: 4px; table-layout: fixed; }
.weekly-card th, .weekly-card td { padding: 4px 6px; }
.weekly-card th:first-child { width: 2.5em; }
.weekly-card th.num:not(:first-child) { width: 4.2em; }
.weekly-card td.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekly-card .more { margin-bottom: 0; }
.weekly-card a { color: var(--accent); }
/* the Playing now card: games to watch live, one a line (home.js) */
.home .playing-list { list-style: none; margin: 4px 0 0; padding: 0; }
.home .playing-list li { margin: 0; padding: 5px 0; border-top: 1px solid var(--line); }
.playing-list li:first-child { border-top: none; }
.playing-list a { color: var(--accent); font-weight: 600; }
.playing-list .what { color: var(--muted); margin-left: 8px; }
.playing-list .tag { margin-left: 8px; }
@media (max-width: 899px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
.play-button {
  display: inline-block;
  margin: 8px 0;
  padding: 10px 24px;
  font-size: 17px;
  font-weight: 600;
  color: #0b0d08;
  background: var(--accent);
  border-radius: 6px;
  text-decoration: none;
}
.play-button:hover { filter: brightness(1.1); }
/* no link: this visitor can't start a game right now (see #play-full) */
.play-button[aria-disabled="true"] { background: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.home .slots { margin-left: 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.home .play-full { margin: 0 0 4px; color: var(--bad); font-size: 14px; max-width: 40em; }
.account form { display: grid; gap: 10px; margin-top: 12px; }
.account label { display: grid; gap: 4px; }
.account label.check { display: flex; align-items: center; gap: 8px; }
.account input[type="text"], .account input:not([type]), .account input[type="password"] {
  font: inherit;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.account button {
  font: inherit;
  padding: 6px 16px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  justify-self: start;
}
.account button[type="submit"] { border-color: var(--accent); }
.account button:disabled { opacity: 0.6; cursor: default; }
.account .tabs { display: flex; gap: 4px; }
.account .tabs button[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.account form .hint { margin: 0; }
.account .message { margin: 8px 0 0; color: var(--accent); }
.account .message:empty { display: none; }
.account .message.bad { color: var(--bad); }
/* fields and buttons stand out from the card behind them */
.card .account input:not([type="checkbox"]), .card.account input:not([type="checkbox"]), .card.account button { background: var(--bg); }
header .who { color: var(--muted); }
tr.guest td:nth-child(2) { color: var(--muted); }
kbd {
  font: 13px ui-monospace, Consolas, monospace;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

/* staff: the admin page, and the leaderboard as staff see it */
:root { --chart: #78b04f; --chart-on: #9fd27a; }
.muted, tr.unseen td { color: var(--muted); }
.tag {
  display: inline-block;
  padding: 0 6px;
  margin-right: 4px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}
.tag.good { color: var(--accent); border-color: var(--accent); }
.tag.bad { color: var(--bad); border-color: var(--bad); }
.staff button, td.actions button {
  font: inherit;
  padding: 4px 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.staff button:hover, td.actions button:hover { border-color: var(--muted); }
/* as specific as the rules above, or they would win */
.staff button.danger, td.actions button.danger { color: var(--bad); }
.staff button.danger:hover, td.actions button.danger:hover { border-color: var(--bad); }
td.actions { white-space: nowrap; }
td.actions button { padding: 1px 8px; margin-right: 4px; font-size: 13px; }
.staff { max-width: 1200px; overflow-y: auto; }
.staff h2 { font-size: 16px; margin: 24px 0 8px; }
.staff .toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.staff .tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.staff .tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.staff .message { min-height: 1.4em; color: var(--accent); margin: 8px 0; }
.staff .message.bad { color: var(--bad); }
/* the server mode buttons on the overview; the current mode lit like a tab */
.staff .modes { display: flex; flex-wrap: wrap; gap: 4px; }
.staff .modes button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.staff .modes button.paused[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); }
.staff .modes button:disabled { opacity: 0.45; cursor: default; }
.staff .modes button:disabled:hover { border-color: var(--line); }
.staff .modes button[aria-pressed="true"]:disabled { opacity: 1; }
.staff .pause-state { color: var(--bad); }
.staff .filter { display: inline-flex; align-items: center; gap: 8px; }
.staff .filter input {
  font: inherit;
  padding: 4px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.staff details { margin-top: 12px; }
.staff summary { cursor: pointer; color: var(--muted); }
.totals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 0;
}
.totals div { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; }
.totals dt { color: var(--muted); font-size: 12px; }
.totals dd { margin: 2px 0 0; font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: none; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--chart); }
.chart .bar.on { fill: var(--chart-on); }
.chart .hit { fill: transparent; }
.chart .axis { display: flex; justify-content: space-between; font-size: 12px; margin-top: 2px; }
.staff .readout { min-height: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
/* weekly attempts in the accounts list: one symbol each, its state in its shape */
td.weekly-cell { white-space: nowrap; }
.weekly {
  display: inline-block;
  min-width: 24px;
  margin-right: 4px;
  padding: 0 4px;
  font: 14px/20px ui-monospace, Consolas, monospace;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
}
.weekly.finished { color: var(--accent); }
.weekly.playing { color: var(--text); }
.staff button.weekly { padding: 0 4px; }
.staff button.weekly:hover { border-color: var(--accent); }

/* links to files: the leaderboard's Run column, the My files page */
td.links { white-space: nowrap; }
td.links a, td.links button.link { margin-right: 12px; }
td.links a:last-child, td.links button.link:last-child { margin-right: 0; }
.files a, .morgue a, td.links a { color: var(--accent); text-decoration: none; }
.files a:hover, .morgue a:hover, td.links a:hover { text-decoration: underline; }
button.link {
  font: inherit;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
}
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--bad); }
header a.fresh { color: #0b0d08; background: var(--accent); padding: 0 8px; border-radius: 4px; }

/* the admin page's crash reports */
.staff .crash-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.staff .crash-toolbar p { margin: 8px 0; }
.staff tr.crash-new td { color: var(--text); font-weight: 600; }
.staff td.crash-error { overflow-wrap: anywhere; min-width: 16em; }
.staff .crash-place { display: block; color: var(--muted); font-weight: normal; font-size: 13px; }
.staff tr.crash-detail > td { background: var(--panel); }
.staff .crash-links a { color: var(--accent); text-decoration: none; margin-right: 16px; }
.staff .crash-links a:hover { text-decoration: underline; }
.staff .crash-trace { white-space: pre; max-height: 480px; overflow: auto; }

/* my files page */
.files, .morgue { overflow-y: auto; }
.files h2 { font-size: 16px; margin: 24px 0 4px; }
.files .message { min-height: 1.4em; color: var(--accent); }
.files .message.bad, .morgue .message { color: var(--bad); }
td.file-name { overflow-wrap: anywhere; }
/* whose files these are, filled in by files.js: its line is kept meanwhile */
.files #who { min-height: 1.4em; }

/* downloads page (styled as the my files page), the home page's link to it,
   and the admin page's upload form */
.downloads .message:empty { display: none; }
.home .download { margin: 4px 0 0; }
.home .download a { color: var(--accent); }
.upload-form { display: grid; gap: 10px; max-width: 32em; margin: 8px 0 0; }
.upload-form label { display: grid; gap: 4px; }
.upload-form label.check { display: flex; align-items: center; gap: 8px; }
.upload-form input[type="text"] {
  font: inherit;
  padding: 4px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.upload-form input[type="file"] { font: inherit; color: var(--text); max-width: 100%; }
.upload-form .buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.upload-form progress { flex: 1; min-width: 8em; accent-color: var(--accent); }
.staff button.move { padding: 1px 6px; font-size: 11px; }
.staff button.move:disabled { opacity: 0.35; cursor: default; }
.staff button.move:disabled:hover { border-color: var(--line); }
.staff td.file-name a { color: var(--accent); text-decoration: none; }
.staff td.file-name a:hover { text-decoration: underline; }

/* morgue page: the game's morgue file in the site's style */
.morgue { max-width: 760px; }
/* min-height: the links' line is kept until morgue.js fills them in */
.morgue .toolbar { display: flex; flex-wrap: wrap; gap: 16px; margin: 4px 0 8px; min-height: 1.4em; }
.morgue .message:empty { display: none; }
.morgue h1 { font-size: 24px; margin: 8px 0 4px; }
.morgue h2 {
  font-size: 15px;
  margin: 24px 0 8px;
  padding-bottom: 4px;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.morgue section > p { margin: 2px 0; }
.morgue .morgue-line { overflow-wrap: anywhere; }
.morgue-fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 6px 0; }
.morgue-fields div { display: contents; }
.morgue-fields dt { color: var(--muted); }
.morgue-fields dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.morgue-pre {
  font: 13px/1.2 ui-monospace, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  overflow-x: auto;
  margin: 6px 0;
}

/* banners: real scenes from the game (banner.js, site-banners.js). Hidden
   until drawn, and for good when the site has none. */
.banner { margin: 0; }
.banner canvas { display: block; margin: 0 auto; image-rendering: pixelated; max-width: 100%; }
.banner figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; font-style: italic; text-align: center; }
.banner-wide { margin-top: 16px; }
/* The home page's wide banner keeps its place from the first paint instead of
   pushing the page down when it is drawn: its canvas starts out the size
   banner.js will draw it, and its caption line is there, empty, meanwhile.
   banner.js draws the 40 x 10 cells of a wide banner (SHAPES in
   web/banners/make_banners.py) at a whole multiple of 8 screen pixels a
   cell, as many as the page's width allows, at most data-max (24) CSS pixels
   a cell; the width below is that sum, with --dpr the screen's pixels per CSS
   pixel (set below for the usual screens and zoom levels; on another,
   the banner may still move a little when drawn). Change both together. */
.banner-wide canvas {
  aspect-ratio: 4 / 1;
  /* browsers without round() */
  width: min(100%, 960px);
  width: calc(max(320px, round(down, min(100% * var(--dpr), 960px * var(--dpr)), 320px)) / var(--dpr));
}
.banner-wide figcaption { min-height: 1.4em; }
:root { --dpr: 1; }
@media (min-resolution: 0.495dppx) and (max-resolution: 0.505dppx) { :root { --dpr: 0.5; } }
@media (min-resolution: 0.66dppx) and (max-resolution: 0.67dppx) { :root { --dpr: 0.6667; } }
@media (min-resolution: 0.745dppx) and (max-resolution: 0.755dppx) { :root { --dpr: 0.75; } }
@media (min-resolution: 0.795dppx) and (max-resolution: 0.805dppx) { :root { --dpr: 0.8; } }
@media (min-resolution: 0.895dppx) and (max-resolution: 0.905dppx) { :root { --dpr: 0.9; } }
@media (min-resolution: 1.095dppx) and (max-resolution: 1.105dppx) { :root { --dpr: 1.1; } }
@media (min-resolution: 1.245dppx) and (max-resolution: 1.255dppx) { :root { --dpr: 1.25; } }
@media (min-resolution: 1.37dppx) and (max-resolution: 1.38dppx) { :root { --dpr: 1.375; } }
@media (min-resolution: 1.495dppx) and (max-resolution: 1.505dppx) { :root { --dpr: 1.5; } }
@media (min-resolution: 1.745dppx) and (max-resolution: 1.755dppx) { :root { --dpr: 1.75; } }
@media (min-resolution: 1.995dppx) and (max-resolution: 2.005dppx) { :root { --dpr: 2; } }
@media (min-resolution: 2.245dppx) and (max-resolution: 2.255dppx) { :root { --dpr: 2.25; } }
@media (min-resolution: 2.495dppx) and (max-resolution: 2.505dppx) { :root { --dpr: 2.5; } }
@media (min-resolution: 2.995dppx) and (max-resolution: 3.005dppx) { :root { --dpr: 3; } }
@media (min-resolution: 3.495dppx) and (max-resolution: 3.505dppx) { :root { --dpr: 3.5; } }
@media (min-resolution: 3.995dppx) and (max-resolution: 4.005dppx) { :root { --dpr: 4; } }
/* tall banners in the margins beside a page, where the screen has room for
   them: 160px wide plus a gap on each side of the 960px (or 760px) page */
.side-banners .banner { position: fixed; top: 64px; display: none; }
.side-banners .left { right: calc(50% + 480px + 24px); }
.side-banners .right { left: calc(50% + 480px + 24px); }
.side-banners.narrow .left { right: calc(50% + 380px + 24px); }
.side-banners.narrow .right { left: calc(50% + 380px + 24px); }
@media (min-width: 1380px) and (min-height: 520px) {
  .side-banners .banner { display: block; }
}
@media (min-width: 1180px) and (min-height: 520px) {
  .side-banners.narrow .banner { display: block; }
}
