/* Heimr — the signed-in pages: /login, /account, /admin.
 *
 * On top of style.css (its tokens, fonts and buttons). The same night sky,
 * with the planet's rim as a thin lit arc under the header, and quiet dusk
 * panels for everything else.
 */

.app {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(27, 49, 80, 0.85), transparent 70%),
    var(--night);
  font-size: 1rem;
  line-height: 1.55;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- header, and the rim ---------- */

.app-head {
  max-width: 50rem;
  margin: 0 auto;
  padding: 1.4rem var(--gutter) 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}
.app-head .wordmark.small { font-size: 1rem; }

.app-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; font-family: var(--display); font-size: 0.98rem; }
.app-nav a { color: var(--mist); text-decoration: none; padding: 0.2rem 0; border-bottom: 1px solid transparent; }
.app-nav a:hover { color: var(--snow); }
.app-nav a[aria-current="page"] { color: var(--snow); border-bottom-color: var(--haze); }

.link-button {
  background: none; border: 0; padding: 0.2rem 0; cursor: pointer;
  font: inherit; color: var(--mist);
}
.link-button:hover { color: var(--snow); }

/* The horizon, reduced to its lit edge. */
.app-rim {
  height: 3rem;
  margin-top: -0.5rem;
  overflow: hidden;
  position: relative;
  pointer-events: none;
  /* The arc's ends fade out, so the clipped glow never shows an edge. */
  -webkit-mask-image: radial-gradient(ellipse 48% 130% at 50% 0%, #000 45%, transparent 100%);
  mask-image: radial-gradient(ellipse 48% 130% at 50% 0%, #000 45%, transparent 100%);
}
.app-rim::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.6rem;
  width: 260vw;
  height: 260vw;
  transform: translateX(-50%);
  border-radius: 50%;
  box-shadow:
    0 -1px 0 rgba(143, 176, 216, 0.45),
    0 -8px 28px rgba(143, 176, 216, 0.18),
    0 -2px 60px rgba(110, 154, 90, 0.12);
}

.app-main {
  position: relative;
  z-index: 1;
  max-width: 50rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 5rem;
}
.app.wide .app-main, .app.wide .app-head { max-width: 72rem; }
.app.centered .app-main { max-width: 30rem; padding-top: clamp(1rem, 8vh, 5rem); }

.page-title {
  margin: 0.75rem 0 1.5rem;
  font-family: var(--display);
  font-weight: 300;
  font-size: var(--step-3);
  line-height: 1.1;
}

h2 {
  margin: 2.25rem 0 0.9rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.25;
}

.muted { color: var(--mist); }
.small { font-size: 0.88rem; }
.empty { margin: 0; padding: 1rem 0; }

/* ---------- panels ---------- */

.card {
  margin: 0 0 1.25rem;
  padding: 1.4rem 1.5rem 1.5rem;
  border: 1px solid rgba(143, 176, 216, 0.22);
  border-radius: 0.9rem;
  background: rgba(27, 49, 80, 0.55);
}
.card > h1 { margin: 0 0 0.75rem; font-family: var(--display); font-weight: 300; font-size: var(--step-2); line-height: 1.15; }
.card > h2, .card-head h2 { margin: 0 0 0.35rem; }
.card > p { margin: 0 0 1rem; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 1rem; }
.count { margin: 0; font-family: var(--display); color: var(--mist); }
.count strong { color: var(--snow); font-weight: 500; font-size: 1.2rem; }

/* ---------- forms ---------- */

label { display: block; margin-bottom: 0.3rem; font-family: var(--display); font-size: 0.88rem; letter-spacing: 0.03em; color: var(--mist); }
input[type="email"], input[type="text"], input[type="number"] {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(143, 176, 216, 0.4);
  border-radius: 0.5rem;
  background: var(--night);
  color: var(--snow);
  font-family: var(--display);
  font-size: 1rem;
}
input::placeholder { color: rgba(169, 184, 203, 0.5); }
input:focus { outline: 2px solid var(--haze); outline-offset: 1px; border-color: var(--haze); }

.stack { display: grid; gap: 0.6rem; }
.stack .button { margin-top: 0.5rem; justify-self: start; }

.invite-form { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto; gap: 0.75rem; align-items: end; }
.invite-form.wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 7rem) auto; }
.invite-form .button { min-height: 2.75rem; }
.field { min-width: 0; }

.button.small { padding: 0.35rem 0.8rem; font-size: 0.9rem; border-radius: 0.45rem; background: rgba(10, 20, 36, 0.5); }
button.button.small { font-size: 0.9rem; }
.button.danger { border-color: rgba(230, 140, 120, 0.6); color: #F2C4B8; }
.button.danger:hover { border-color: #F2C4B8; }
form.inline { display: inline; margin: 0; }

.form-error, .alert {
  grid-column: 1 / -1;
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.8rem;
  border-left: 3px solid #E0907C;
  background: rgba(224, 144, 124, 0.1);
  color: #F5D3CA;
  font-size: 0.95rem;
}

/* ---------- keys and codes ---------- */

.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
code.key {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 0.45rem;
  background: var(--night);
  border: 1px solid rgba(143, 176, 216, 0.3);
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  color: var(--snow);
  white-space: nowrap;
}
code.key.small { font-size: 0.85rem; padding: 0.1rem 0.45rem; letter-spacing: 0.06em; }
.key-row code.key { min-width: 12.5rem; text-align: center; }

.badge {
  display: inline-block;
  padding: 0.08rem 0.55rem 0.12rem;
  border-radius: 999px;
  border: 1px solid rgba(143, 176, 216, 0.45);
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--haze);
  white-space: nowrap;
  vertical-align: 0.1em;
}
td strong + .badge { margin-left: 0.4rem; }
.badge.good { border-color: rgba(110, 154, 90, 0.7); color: #B5D6A2; }
.badge.ok { border-color: rgba(143, 176, 216, 0.6); color: var(--haze); }
.badge.bad { border-color: rgba(224, 144, 124, 0.7); color: #F2B9A9; }
.badge.muted { border-color: rgba(169, 184, 203, 0.35); color: var(--mist); }

/* ---------- invites ---------- */

.invites { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid rgba(143, 176, 216, 0.18); }
.invites li { padding: 0.8rem 0; border-bottom: 1px solid rgba(143, 176, 216, 0.12); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 1rem; align-items: baseline; }
.invite-who { min-width: 0; overflow-wrap: anywhere; }
.invite-meta { display: flex; gap: 0.6rem; align-items: baseline; }
.invite-fallback { grid-column: 1 / -1; display: grid; gap: 0.5rem; justify-items: start; }
.invite-fallback p { margin: 0; }

/* ---------- stats ---------- */

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.tile {
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid rgba(143, 176, 216, 0.22);
  border-radius: 0.8rem;
  background: rgba(27, 49, 80, 0.55);
}
.tile p { margin: 0; }
.tile-value { font-family: var(--display); font-weight: 300; font-size: 2.3rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { font-family: var(--display); font-size: 0.92rem; color: var(--snow); }
.tile-note { font-size: 0.82rem; color: var(--mist); }
.totals { margin-top: 2rem; }

/* ---------- tables: rows on wide screens, cards on narrow ---------- */

table.rows { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.rows th {
  text-align: left;
  font-family: var(--display);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--mist);
  padding: 0 0.75rem 0.5rem 0;
  border-bottom: 1px solid rgba(143, 176, 216, 0.25);
}
table.rows td { padding: 0.65rem 0.75rem 0.65rem 0; border-bottom: 1px solid rgba(143, 176, 216, 0.12); vertical-align: top; overflow-wrap: anywhere; }
table.rows td .code { font-size: 0.9rem; }
table.rows tr:last-child td { border-bottom: 0; }

/* ---------- the per-player panel ---------- */

.manage summary {
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.9rem;
  color: var(--haze);
  list-style: none;
  white-space: nowrap;
}
.manage summary::-webkit-details-marker { display: none; }
.manage summary::after { content: " ▾"; font-size: 0.75em; }
.manage[open] summary::after { content: " ▴"; }
.manage-body {
  margin-top: 0.6rem;
  padding: 0.9rem 1rem;
  border-radius: 0.6rem;
  background: rgba(10, 20, 36, 0.7);
  border: 1px solid rgba(143, 176, 216, 0.2);
  display: grid;
  gap: 0.6rem;
  min-width: min(22rem, 80vw);
}
.row-form { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; margin: 0; }
.row-form label { margin: 0; }
.row-form input { min-height: 2.3rem; padding: 0.35rem 0.6rem; font-size: 0.92rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding-top: 0.3rem; }
.row-actions .key-row code.key { font-size: 0.95rem; min-width: 0; }
/* On wide screens the panel floats over the rows below, opening leftwards
   from its column, so opening it does not reflow the table. */
@media (min-width: 60.01rem) {
  table.players td:last-child { position: relative; }
  .manage[open] .manage-body {
    position: absolute;
    right: 0;
    top: 2.4rem;
    z-index: 5;
    width: 25rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    background: #0D1A2E;
  }
  table.rows td { overflow-wrap: normal; }
}

/* ---------- flash and toast ---------- */

.flash {
  position: relative;
  margin: 0 0 1.25rem;
  padding: 0.9rem 2.6rem 0.9rem 1rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(110, 154, 90, 0.6);
  background: rgba(110, 154, 90, 0.12);
  display: grid;
  gap: 0.5rem;
}
.flash p { margin: 0; }
.flash.warn { border-color: rgba(224, 144, 124, 0.7); background: rgba(224, 144, 124, 0.1); }
.flash-close {
  position: absolute; top: 0.4rem; right: 0.5rem;
  width: 2rem; height: 2rem;
  background: none; border: 0; cursor: pointer;
  font-size: 1.3rem; line-height: 1; color: var(--mist);
}
.flash-close:hover { color: var(--snow); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  background: var(--snow);
  color: var(--night);
  font-family: var(--display);
  font-size: 0.95rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.toast[hidden] { display: none; }

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

@media (max-width: 60rem) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invite-form, .invite-form.wide { grid-template-columns: minmax(0, 1fr); }
  .invite-form .button { justify-self: start; }

  table.rows, table.rows tbody, table.rows tr, table.rows td { display: block; }
  table.rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.rows tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(143, 176, 216, 0.18);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem 1rem;
  }
  table.rows td { padding: 0; border: 0; }
  table.rows td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--display);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--mist);
  }
  table.rows td[data-label=""]::before { display: none; }
  table.rows td:first-child { grid-column: 1 / -1; font-size: 1.05rem; }
  table.rows td:last-child:not(:first-child) { grid-column: 1 / -1; }
  .manage-body { min-width: 0; }
}

@media (max-width: 26rem) {
  .row-form { grid-template-columns: minmax(0, 1fr) auto; }
  .row-form label { grid-column: 1 / -1; }
  .key-row code.key { min-width: 0; }
}

/* ================= the operations pages (src/pages-ops.ts) ================= */

.lede { margin: -0.9rem 0 1.5rem; max-width: 46rem; }
.crumbs { margin: 0.5rem 0 -0.5rem; font-family: var(--display); font-size: 0.9rem; }
.crumbs a { color: var(--mist); text-decoration: none; }
.crumbs a::before { content: "← "; }
.crumbs a:hover { color: var(--snow); }
.section-note { margin: -0.6rem 0 0.8rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.section-head h2 { margin-bottom: 0.9rem; }
.attention { margin: 1rem 0 0; font-family: var(--display); }
.attention a { color: #F2B9A9; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; text-decoration-color: var(--haze); }
td a.strong + .badge { margin-left: 0.4rem; }
table.rows .button { white-space: nowrap; }
a.strong { font-weight: 600; color: var(--snow); text-decoration-color: rgba(143, 176, 216, 0.5); }
.num { font-family: var(--display); font-weight: 500; font-variant-numeric: tabular-nums; }
.page-title .badge { font-size: 0.9rem; vertical-align: 0.4em; margin-left: 0.4rem; }

/* ---------- more form controls ---------- */

textarea, select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(143, 176, 216, 0.4);
  border-radius: 0.5rem;
  background: var(--night);
  color: var(--snow);
  font-family: var(--display);
  font-size: 1rem;
}
textarea { resize: vertical; line-height: 1.45; min-height: 4.5rem; }
select { min-height: 2.75rem; }
textarea:focus, select:focus { outline: 2px solid var(--haze); outline-offset: 1px; border-color: var(--haze); }
fieldset.radios { border: 0; margin: 0.3rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.5rem; align-items: center; }
fieldset.radios legend { float: left; margin-right: 1rem; font-family: var(--display); font-size: 0.88rem; letter-spacing: 0.03em; color: var(--mist); }
fieldset.radios label { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; font-size: 0.95rem; color: var(--snow); cursor: pointer; }
input[type="radio"] { accent-color: var(--haze); width: 1.05rem; height: 1.05rem; }
.settings-form { max-width: 34rem; }

/* ---------- breakdowns: one bar per row, the number beside it ---------- */

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.5rem; }
ul.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
ul.bars li { display: grid; grid-template-columns: minmax(5.5rem, 9rem) minmax(0, 1fr) 5.5rem; gap: 0.75rem; align-items: center; }
.bar-label { font-family: var(--display); font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.bar { display: block; width: 100%; height: 0.7rem; overflow: visible; }
svg.bar rect { fill: var(--haze); }
ul.bars li:hover svg.bar rect { fill: #B7CDE8; }
.bar-value { font-family: var(--display); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bar-value .muted { margin-left: 0.4rem; }

/* ---------- bugs ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.25rem; font-family: var(--display); font-size: 0.95rem; }
.filters a {
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(143, 176, 216, 0.3);
  border-radius: 999px;
  color: var(--mist);
  text-decoration: none;
}
.filters a:hover { color: var(--snow); border-color: var(--haze); }
.filters a[aria-current="page"] { color: var(--night); background: var(--haze); border-color: var(--haze); }
.count-pill { font-variant-numeric: tabular-nums; opacity: 0.8; margin-left: 0.2rem; }
table.bugs td:first-child, table.bugs td[data-label="When"] { white-space: nowrap; }

.bug-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: start; }
.bug-grid .card { margin: 0; }
.bug-grid .card h2 { margin-bottom: 0.7rem; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.05rem; }
.shot { display: inline-block; max-width: 100%; border-radius: 0.6rem; overflow: hidden; border: 1px solid rgba(143, 176, 216, 0.3); background: #000; }
.shot img { display: block; max-width: 100%; max-height: 70vh; height: auto; }

dl.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.1rem 1.5rem; }
dl.facts > div { padding: 0.45rem 0; border-bottom: 1px solid rgba(143, 176, 216, 0.12); min-width: 0; }
dl.facts dt { font-family: var(--display); font-size: 0.78rem; letter-spacing: 0.04em; color: var(--mist); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; font-family: var(--display); font-size: 0.98rem; }
dl.facts.compact { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); margin-bottom: 1rem; }

pre.log {
  margin: 0;
  max-height: 32rem;
  overflow: auto;
  padding: 0.8rem 0;
  border-radius: 0.6rem;
  border: 1px solid rgba(143, 176, 216, 0.2);
  background: #060D18;
  font: 0.82rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #C9D5E3;
  tab-size: 4;
}
pre.log code { display: block; min-width: max-content; padding: 0 1rem; font: inherit; }
pre.log .ln { display: inline-block; width: 3.2em; margin-right: 1em; text-align: right; color: #4D5F77; user-select: none; }
pre.log .warn { color: #EBD49A; }
pre.log .err { color: #F2B9A9; }
pre.log:focus { outline: 2px solid var(--haze); outline-offset: 2px; }

/* ---------- crashes ---------- */

code.panic { font: 0.9rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--snow); overflow-wrap: anywhere; }
.crash-title code.panic { font-size: clamp(1.05rem, 0.9rem + 0.8vw, 1.4rem); line-height: 1.35; }
.sig { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.75rem; }

/* ---------- games ---------- */

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); gap: 1.25rem; align-items: start; }
.games .card { margin: 0; }
.game .card-head h2 { margin: 0 0 0.6rem; overflow-wrap: anywhere; }
.game-code { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.command-form { margin: 0 0 0.9rem; }
.command-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
.command-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.95rem; }
.command-row .button { min-height: 2.75rem; }
ol.command-log { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(143, 176, 216, 0.15); }
ol.command-log li { padding: 0.6rem 0; border-bottom: 1px solid rgba(143, 176, 216, 0.1); }
.cmd-head { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: baseline; justify-content: space-between; }
code.cmd { font: 0.88rem/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--snow); overflow-wrap: anywhere; }
pre.cmd-output {
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.7rem;
  border-left: 2px solid rgba(143, 176, 216, 0.4);
  background: rgba(6, 13, 24, 0.6);
  font: 0.8rem/1.45 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #C9D5E3;
}
details.help { margin: -0.5rem 0 1.5rem; }
details.help summary { cursor: pointer; font-family: var(--display); color: var(--haze); }
details.help ul { margin: 0.6rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.25rem; }
details.help code, .lede code, .note code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; color: var(--snow); }

/* ---------- releases ---------- */

.card.note p { margin: 0 0 0.6rem; }
.card.note p:last-child { margin: 0; }
table.release-list tr.current td { background: rgba(110, 154, 90, 0.08); }
table.release-list td:first-child { white-space: nowrap; }

/* ---------- the invite tree ---------- */

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { margin-left: 0.55rem; padding-left: 1.1rem; border-left: 1px solid rgba(143, 176, 216, 0.25); }
.tree li { position: relative; padding: 0.2rem 0; }
.tree ul ul > li::before {
  content: "";
  position: absolute;
  left: -1.1rem;
  top: 0.95rem;
  width: 0.8rem;
  border-top: 1px solid rgba(143, 176, 216, 0.25);
}
.tree-node { font-family: var(--display); }
.tree-node .muted { margin-left: 0.3rem; }

@media (max-width: 60rem) {
  .split, .bug-grid { grid-template-columns: minmax(0, 1fr); }
  ul.bars li { grid-template-columns: minmax(4.5rem, 7rem) minmax(0, 1fr) 4.5rem; }
  .lede { margin-top: -0.6rem; }
}
