/* Spaceborn Awakening's colours, from its key art: deep crimson space, the logo's white with its
   red and blue fringes, the orange glow of the hero's helmet, the cyan of its Steam badge. */
:root {
  --bg: #0e080d;
  --panel: #170d15;
  --panel-2: #22131e;
  --button: #2a1724;
  --line: #3a2132;
  --text: #f6ecf2;
  --muted: #b292a6;
  --accent: #3fd0ff;
  --accent-soft: rgba(63, 208, 255, .13);
  --accent-ink: #02151c;
  --glow: #ff8a3d;
  --good: #5be08f;
  --bad: #ff4d6d;
  --quit: #8d7488;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}
/* A red nebula from the top right, an orange glow under it, and a few far stars. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 92% -12%, rgba(190, 30, 70, .30), transparent 62%),
    radial-gradient(700px 420px at 70% 0%, rgba(255, 138, 61, .10), transparent 70%),
    radial-gradient(900px 700px at -10% 110%, rgba(120, 40, 140, .22), transparent 65%),
    radial-gradient(1.2px 1.2px at 12% 18%, rgba(255, 255, 255, .55), transparent 60%),
    radial-gradient(1px 1px at 38% 72%, rgba(255, 255, 255, .45), transparent 60%),
    radial-gradient(1.4px 1.4px at 64% 34%, rgba(255, 255, 255, .5), transparent 60%),
    radial-gradient(1px 1px at 84% 82%, rgba(255, 255, 255, .4), transparent 60%),
    radial-gradient(1px 1px at 24% 52%, rgba(255, 255, 255, .35), transparent 60%);
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; font-weight: 800; margin: 0 0 .35rem; letter-spacing: .14em; text-transform: uppercase;
  text-shadow: -1.5px 0 rgba(255, 77, 109, .55), 1.5px 0 rgba(63, 150, 255, .55); }
h2 { font-size: .78rem; font-weight: 700; margin: 0; letter-spacing: .16em; text-transform: uppercase; color: var(--glow); }
p { margin: .4rem 0; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
[hidden] { display: none !important; }
::selection { background: rgba(63, 208, 255, .35); }

.top {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  padding: .65rem 1.25rem; border-bottom: 1px solid var(--line);
  background: rgba(14, 8, 13, .86); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
body.out .top { display: none; }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .7rem; }
.brand img { display: block; height: 28px; width: auto; }
.brand em { font-style: normal; font-size: .68rem; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line); padding-left: .7rem; }
nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); text-decoration: none; padding: .32rem .7rem; border-radius: 8px; border: 1px solid transparent; font-size: .92rem; }
nav a:hover { color: var(--text); background: var(--panel-2); }
nav a.on { color: var(--accent); background: var(--accent-soft); border-color: rgba(63, 208, 255, .35); }
#who { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .88rem; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.panel {
  background: linear-gradient(180deg, rgba(34, 19, 30, .92), rgba(23, 13, 21, .92));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1rem 0;
  box-shadow: inset 0 1px 0 rgba(255, 236, 246, .04), 0 10px 30px rgba(0, 0, 0, .25);
  min-width: 0;
}
.panelhead { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel > h2 { margin-bottom: .75rem; }
.panel.empty { border-style: dashed; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 0 1rem; align-items: start; }

/* Signed out: the game's title over the panel. */
.center { max-width: 560px; margin: 12vh auto 0; text-align: center; }
.center .panel { position: relative; z-index: 1; text-align: left; }
.center .panel input { width: 100%; box-sizing: border-box; }
.title { margin: 0 0 .6rem; text-shadow: none; }
.title img { width: 100%; height: auto; display: block; filter: drop-shadow(0 0 18px rgba(255, 138, 61, .35)); }
.kicker { margin: 0 0 1.6rem; font-size: .75rem; letter-spacing: .5em; text-transform: uppercase; color: var(--glow); }
.center h2 { margin-bottom: .5rem; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: .45rem .9rem;
  border: 1px solid var(--line); background: var(--button); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
button.small { padding: .25rem .65rem; font-size: .8rem; }
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid rgba(63, 208, 255, .6); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; border-color: var(--line); box-shadow: none; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.primary:hover:not(:disabled) { box-shadow: 0 0 0 3px rgba(63, 208, 255, .18), 0 0 22px rgba(63, 208, 255, .35); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.link { background: none; border: none; color: var(--accent); padding: 0 .25rem; }
.big { width: 100%; padding: .8rem; font-size: 1.05rem; margin-top: .75rem; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .4rem .55rem;
}
select { max-width: 15rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(63, 208, 255, .45); border-color: var(--accent); }
label { display: block; margin: .6rem 0 .2rem; color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 10rem; }
.row > .grow:empty { min-width: 0; }

/* The filter every numbers page shares. */
.filters {
  display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; margin: .75rem 0 .25rem;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(23, 13, 21, .75);
}
.filters select { font-size: .88rem; padding: .3rem .45rem; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin: .75rem 0 0; }
.tabs button { padding: .3rem .75rem; font-size: .85rem; text-transform: capitalize; }
.tabs button.on { color: var(--accent); border-color: rgba(63, 208, 255, .5); background: var(--accent-soft); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child > td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; letter-spacing: .03em; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; margin: 0 -.25rem; }
table.data th { cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); }
table.data th:hover { color: var(--text); }
table.data th.on { color: var(--accent); }
table.data th.on::after { content: attr(data-dir); font-size: .7em; margin-left: .3em; }
table.data td { font-size: .9rem; white-space: nowrap; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: rgba(63, 208, 255, .06); }
table.data tr.thin td { opacity: .55; }

.ratecell { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 64px; }
.bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .07); overflow: hidden; width: 100%; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 6px rgba(63, 208, 255, .5); }
.bar > i.good { background: var(--good); box-shadow: 0 0 6px rgba(91, 224, 143, .45); }
.bar > i.bad { background: var(--bad); box-shadow: 0 0 6px rgba(255, 77, 109, .45); }
.delta { font-variant-numeric: tabular-nums; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

.chip { display: inline-block; font-size: .72rem; padding: .05rem .5rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; margin-left: .35rem; text-transform: lowercase; }
td > .chip:first-child, .cards .chip:first-child, .pick > .chip, h1 + .chip, .row > .chip { margin-left: 0; }
.chip.good { color: var(--good); border-color: rgba(91, 224, 143, .45); }
.chip.bad { color: var(--bad); border-color: rgba(255, 77, 109, .5); }

.secret { background: var(--bg); border: 1px dashed rgba(63, 208, 255, .6); border-radius: 8px; padding: .75rem; word-break: break-all; }
pre.secret { white-space: pre-wrap; margin: 0; }
.panel.handoff { border-color: rgba(63, 208, 255, .45); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin: 1rem 0; }
.stats > div { background: linear-gradient(180deg, rgba(34, 19, 30, .9), rgba(23, 13, 21, .9)); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; min-width: 0; }
.stats b { display: block; font-size: 1.35rem; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.stats span { display: block; }
.stats.tight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .45rem; margin: 0; }
.stats.tight b { font-size: 1rem; }

/* Charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
svg.chart rect:hover { filter: brightness(1.35); }
.b-runs { fill: rgba(63, 208, 255, .35); }
.b-wins { fill: var(--good); }
.b-death { fill: var(--bad); }
.b-quit { fill: var(--quit); }
.b-win { fill: var(--good); }
.l-running { fill: none; stroke: var(--glow); stroke-width: 2.2; }
.l-level, .l-kills, .l-damage, .l-health { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.l-level { stroke: var(--accent); }
.l-kills { stroke: var(--glow); }
.l-damage { stroke: #c58bff; }
.l-health { stroke: var(--good); stroke-dasharray: 5 4; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin-top: .55rem; color: var(--muted); }
.key::before { content: ""; display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; margin-right: .4rem; vertical-align: -.1rem; }
.k-runs::before { background: rgba(63, 208, 255, .35); }
.k-wins::before, .k-win::before { background: var(--good); }
.k-death::before { background: var(--bad); }
.k-quit::before { background: var(--quit); }
.k-running::before { background: var(--glow); height: 3px; vertical-align: .2rem; }
.k-level::before { background: var(--accent); height: 3px; vertical-align: .2rem; }
.k-kills::before { background: var(--glow); height: 3px; vertical-align: .2rem; }
.k-damage::before { background: #c58bff; height: 3px; vertical-align: .2rem; }
.k-health::before { background: var(--good); height: 3px; vertical-align: .2rem; }
svg.mini { width: 160px; height: 34px; display: block; }
svg.mini .wr { fill: var(--good); }

/* A run's choices: the cards offered, the one taken lit. */
.picks { display: flex; flex-direction: column; gap: .35rem; max-height: 640px; overflow-y: auto; padding-right: .25rem; }
.pick { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.pick:last-child { border-bottom: none; }
.cards { display: flex; gap: .3rem; flex-wrap: wrap; }
.card { font-size: .8rem; padding: .1rem .5rem; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); background: rgba(0, 0, 0, .2); }
.card i { font-style: normal; opacity: .7; }
.card.took { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.metalist { display: grid; gap: .45rem; }
.metarow { display: grid; grid-template-columns: minmax(8rem, 1fr) 2fr auto; gap: .75rem; align-items: center; font-size: .9rem; }
.metarow .bar { height: 6px; }
.metarow .bar > i { background: var(--glow); box-shadow: 0 0 6px rgba(255, 138, 61, .5); }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid rgba(63, 208, 255, .4); border-radius: 10px;
  padding: .7rem 1.1rem; max-width: min(90vw, 640px); opacity: 0; pointer-events: none; transition: opacity .2s;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
#toast.show { opacity: 1; }
#toast.bad { border-color: var(--bad); }

@media (max-width: 640px) {
  .top { gap: .5rem .9rem; padding: .55rem 1rem; }
  .brand img { height: 20px; }
  main { padding: 1rem 1rem 3rem; }
  .center { margin-top: 7vh; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats b { font-size: 1.1rem; }
  .filters select { max-width: 100%; flex: 1 1 40%; }
  .metarow { grid-template-columns: 1fr 1fr auto; }
}

/* Phones (an iPhone Pro Max is 440 wide). Nothing under the notch or the home bar; a two-line
   header whose tabs scroll sideways; 16px controls, so iOS does not zoom into them, big enough for
   a thumb; tables of things to act on stacked as cards, each cell labelled with its column (app.js
   copies the headings onto the cells); tables of numbers scrolling sideways under their first
   column; chart labels big enough to read. */
body { -webkit-text-size-adjust: 100%; min-height: 100dvh; }
.top { padding-left: max(1.25rem, env(safe-area-inset-left)); padding-right: max(1.25rem, env(safe-area-inset-right)); }
main { padding-left: max(1.25rem, env(safe-area-inset-left)); padding-right: max(1.25rem, env(safe-area-inset-right)); padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
#toast { bottom: calc(1.5rem + env(safe-area-inset-bottom)); }

@media (max-width: 720px) {
  .top {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .45rem .75rem;
    padding: max(.55rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .45rem max(1rem, env(safe-area-inset-left));
  }
  .brand { grid-area: 1 / 1; min-width: 0; }
  .brand img { height: 20px; }
  .brand em { display: none; }
  #who { grid-area: 1 / 2; font-size: .8rem; gap: .5rem; min-width: 0; }
  #who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }
  #who button { padding: .3rem .75rem; min-height: 34px; font-size: .85rem; }
  nav {
    grid-area: 2 / 1 / 3 / 3; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin: 0 calc(-1 * max(1rem, env(safe-area-inset-right))) 0 calc(-1 * max(1rem, env(safe-area-inset-left)));
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex: none; padding: .4rem .8rem; }
  main { padding-top: 1.1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  .panel { padding: 1rem; }
  h1 { font-size: 1.1rem; letter-spacing: .14em; }

  input, select, textarea { font-size: 16px; }
  button, .button, select, input:not([type=checkbox]):not([type=radio]):not([type=range]) { min-height: 40px; }
  button.link { min-height: 0; }
  input[type=checkbox] { width: 1.15rem; height: 1.15rem; }
  .grow { min-width: 0; flex-basis: 12rem; }

  main table:not(.data), main table:not(.data) tbody { display: block; }
  main table:not(.data) thead { display: none; }
  main table:not(.data) tr { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .9rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
  main table:not(.data) tr:last-child { border-bottom: none; }
  main table:not(.data) td { display: block; padding: 0; border: none; min-width: 0; }
  main table:not(.data) td:first-child, main table:not(.data) td:has(> .row.end) { flex: 1 1 100%; }
  main table:not(.data) td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); }
  main table:not(.data) .bar { min-width: 90px; }

  table.data th:first-child, table.data td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
  table.data tr.thin td:first-child { opacity: 1; color: var(--muted); }
  svg.chart .axis { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .filters select { flex: 1 1 40%; min-width: 0; }
}

@media (max-width: 480px) {
  #who span { display: none; }
}
