/* Night over Johto: indigo ground, gold and silver trim, one bright color per player. */
:root {
  color-scheme: dark;
  --bg: #15172e;
  --panel: #1f2244;
  --panel-2: #2a2e59;
  --line: #41467c;
  --text: #f1f2fb;
  --muted: #a5abd6;
  --gold: #f2c34e;
  --silver: #cdd5e6;
  --p0: #ff7a66;
  --p1: #62aef5;
  --p2: #f2c34e;
  --p3: #66d08f;
  --bad: #ff6b6b;
  --display: "Pixelify Sans", "Courier New", monospace;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--body);
}
#app {
  max-width: 1120px;
  margin: 0 auto;
  padding-block: 20px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); line-height: 1.05; color: var(--gold); overflow-wrap: anywhere; }
h2 { font-size: 1.3rem; color: var(--silver); margin-block: 22px 10px; }
h3 { font-size: 1.35rem; color: var(--gold); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

button.primary, .link-sheet > button:not(.ghost), .danger-solid {
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 700;
  width: 100%;
}
button.primary { background: var(--gold); border-color: var(--gold); color: #1c1a10; }
button.primary:disabled { opacity: 0.45; }
.danger-solid { background: var(--bad); border-color: var(--bad); color: #2a0b0b; }
.ghost {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.ghost:hover { border-color: var(--silver); }
.ghost.danger { color: var(--bad); border-color: transparent; }

input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}
input::placeholder { color: var(--muted); }

/* header */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.brand { min-width: 0; }
.eyebrow { color: var(--silver); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.top-actions { display: flex; gap: 8px; }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
  border-block: 2px solid var(--line);
}
.stat { padding: 10px 4px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font: 700 1.6rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.78rem; }
.offline { margin-top: 10px; color: var(--bad); font-size: 0.9rem; }

/* tabs */
nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex;
  gap: 4px;
  padding-block: 10px;
  background: var(--bg);
  overflow-x: auto;
}
nav button {
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 1.05rem;
  white-space: nowrap;
}
nav button.on { background: var(--gold); color: #1c1a10; }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
.chips button.on { background: var(--panel-2); color: var(--text); border-color: var(--silver); }

/* link cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.cards.team { grid-template-columns: minmax(0, 1fr); }
.link, .team-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  min-width: 0;
}
.link.is-linked, .link.is-team { border-color: var(--silver); }
.link.is-team { box-shadow: inset 0 0 0 1px var(--gold); border-color: var(--gold); }
.link.is-dead, .link.is-missed { background: transparent; border-style: dashed; }
.link-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 2px 4px 8px;
  text-align: left;
}
.area { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.more { margin-left: auto; color: var(--muted); letter-spacing: 1px; }
.pill {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.pill.linked { background: var(--silver); color: #1a1d33; }
.pill.team { background: var(--gold); color: #1c1a10; }
.pill.dead, .pill.missed { background: transparent; color: var(--bad); outline: 1px solid var(--bad); }
.cause { color: var(--muted); font-size: 0.88rem; padding: 0 4px 8px; }

.quad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.heads { padding: 0 9px; }
.who { font-size: 0.85rem; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.p0 { --c: var(--p0); } .p1 { --c: var(--p1); } .p2 { --c: var(--p2); } .p3 { --c: var(--p3); }
.who { color: var(--c); }
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-height: 92px;
  min-width: 0;
  padding: 4px 2px 6px;
  border: 1px dashed var(--c);
  border-radius: 6px;
  background: var(--bg);
}
.slot.full { border-style: solid; }
.slot:not(:disabled):hover { background: var(--panel-2); }
.slot:disabled { opacity: 0.85; }
.plus { flex: 1; display: grid; place-items: center; font: 700 1.7rem var(--display); color: var(--c, var(--muted)); }
.nick {
  width: 100%;
  font-size: 0.76rem;
  text-align: center;
  color: var(--c);
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.ability { width: 100%; font-size: 0.68rem; line-height: 1.15; text-align: center; color: var(--muted); overflow-wrap: anywhere; }
.sprite { display: block; width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; }
.sprite.dimmed { filter: grayscale(1) brightness(0.7); }
@media (min-width: 560px) { .sprite { width: 64px; height: 64px; } }
.team-row .sprite { width: 72px; height: 72px; }

.types { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.type {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--t);
  color: #14141c;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: capitalize;
  text-shadow: none;
}

.empty { color: var(--muted); padding: 28px 8px; text-align: center; }

.log { list-style: none; margin: 8px 0 0; padding: 0; }
.log li { display: flex; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--panel-2); }
.log time { flex: none; width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log span { min-width: 0; overflow-wrap: anywhere; }

/* sheets */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: min(86dvh, 760px);
  padding: 0;
  border: 2px solid var(--gold);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  overscroll-behavior: contain;
}
dialog::backdrop { background: rgb(8 9 24 / 0.72); }
.link-sheet, .picker { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head p { color: var(--muted); font-size: 0.9rem; }
.roster { margin: 0; padding: 0; list-style: none; font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.stack, .end form { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.player-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.player-inputs input { border-color: var(--c); color: var(--c); }
.end { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.end summary { cursor: pointer; font-weight: 700; }
.end[open] summary { margin-bottom: 10px; color: var(--bad); }

.pick-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.pick-form .primary { width: auto; }
.pick-preview { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 56px; }
.pick-preview .types { justify-content: flex-start; }
.pick-preview strong { display: block; overflow-wrap: anywhere; }
.pick-preview .plus { flex: none; width: 56px; }
.evos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.evos button { padding: 4px 10px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 4px;
  height: min(44dvh, 380px);
  overflow-y: auto;
  align-content: start;
}
.pick { display: flex; flex-direction: column; align-items: center; padding: 4px 2px; border: 1px solid transparent; border-radius: 6px; font-size: 0.74rem; line-height: 1.15; }
.pick:hover { background: var(--panel-2); }
.pick.on { border-color: var(--gold); background: var(--panel-2); }

@media (max-width: 440px) {
  .pick-form { grid-template-columns: minmax(0, 1fr) auto; }
  #pick-nick { grid-column: 1 / -1; }
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--silver);
  color: #1a1d33;
  font-weight: 700;
  overflow-wrap: anywhere;
  z-index: 20;
}

.locked { max-width: 420px; margin: 18vh auto 0; text-align: center; display: grid; gap: 12px; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .slot, .ghost { transition: background-color 0.12s, border-color 0.12s; }
}
