/* =========================================================================
   SLAY // COMMAND  —  cyberpunk glitch-terminal deck
   Mobile-first (375px base). No external resources.
   ========================================================================= */

:root {
  --bg:        #050508;
  --bg-2:      #0a0a12;
  --panel:     #0b0b14;
  --panel-2:   #10101c;
  --line:      #1e1e30;
  --magenta:   #ff2d95;
  --cyan:      #00e5ff;
  --amber:     #ffb020;
  --green:     #38ffb0;
  --red:       #ff4d5e;
  --text:      #dcdcec;
  --dim:       #7d7d9c;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;

  --strip-h: 42px;   /* the notice wraps to 2 lines at 375px */
  --hud-h:   44px;
  --nav-h:   60px;
}

*, *::before, *::after { box-sizing: border-box; }

/* author-level display rules below would otherwise beat the UA [hidden] rule */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: .01em;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ambient neon wash + scanlines ---------------------------------------- */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 60% at 12% 0%,  rgba(255, 45, 149, .13), transparent 60%),
    radial-gradient(120% 60% at 88% 100%, rgba(0, 229, 255, .11), transparent 60%);
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 900;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .028) 0px,
    rgba(255, 255, 255, .028) 1px,
    transparent 1px,
    transparent 3px
  );
  animation: scan-drift 9s linear infinite;
}
@keyframes scan-drift { from { background-position: 0 0; } to { background-position: 0 300px; } }

/* =========================================================================
   throttle strip (persistent, always visible)
   ========================================================================= */
.throttle-strip {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 60;
  min-height: var(--strip-h);
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  padding-top: calc(5px + env(safe-area-inset-top));
  font-size: 10.5px;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #ffe0a8;
  background: linear-gradient(90deg, rgba(255, 176, 32, .22), rgba(255, 176, 32, .08));
  border-bottom: 1px solid rgba(255, 176, 32, .45);
  backdrop-filter: blur(4px);
}
.throttle-tag {
  flex: none;
  font-weight: 700;
  color: #08080c;
  background: var(--amber);
  padding: 2px 6px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.throttle-msg { color: rgba(255, 224, 168, .9); text-transform: none; letter-spacing: .02em; }

/* =========================================================================
   HUD bar
   ========================================================================= */
.hud {
  position: fixed; left: 0; right: 0;
  top: calc(var(--strip-h) + env(safe-area-inset-top));
  z-index: 55;
  height: var(--hud-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  background: rgba(5, 5, 8, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand {
  font-size: 13px; font-weight: 700;
  letter-spacing: .12em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, .45);
}
.hud-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-user {
  font-size: 11px; color: var(--magenta);
  letter-spacing: .08em; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12ch;
}

/* =========================================================================
   layout
   ========================================================================= */
main {
  position: relative;
  z-index: 1;
  padding: calc(var(--strip-h) + var(--hud-h) + env(safe-area-inset-top) + 16px) 12px
           calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  max-width: 100%;
}
.view { animation: view-in .22s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.title {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #fff;
}

/* glitch text ---------------------------------------------------------- */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  pointer-events: none;
  clip-path: inset(0 0 100% 0);
}
.glitch::before { color: var(--magenta); animation: glitch-a 3.6s steps(1) infinite; }
.glitch::after  { color: var(--cyan);    animation: glitch-b 4.3s steps(1) infinite; }
@keyframes glitch-a {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  93% { clip-path: inset(8% 0 62% 0); transform: translate(-2px, 0); }
  95% { clip-path: inset(48% 0 30% 0); transform: translate(2px, 0); }
  97% { clip-path: inset(72% 0 12% 0); transform: translate(-1px, 0); }
}
@keyframes glitch-b {
  0%, 88%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  89% { clip-path: inset(28% 0 52% 0); transform: translate(2px, 0); }
  92% { clip-path: inset(62% 0 20% 0); transform: translate(-2px, 0); }
}
.glitch-burst { animation: burst .45s steps(2) 1; }
@keyframes burst {
  0%   { transform: translate(0, 0);   opacity: 1; }
  25%  { transform: translate(-3px, 1px); opacity: .7; }
  50%  { transform: translate(3px, -1px); opacity: 1; }
  75%  { transform: translate(-1px, 0);   opacity: .85; }
  100% { transform: none; opacity: 1; }
}

/* =========================================================================
   panels — terminal framing with corner ticks
   ========================================================================= */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .022), transparent 40%),
    var(--panel);
  border: 1px solid var(--line);
  padding: 14px 12px;
  margin: 0 0 14px;
}
.panel::before, .panel::after {
  content: ""; position: absolute;
  width: 11px; height: 11px;
}
.panel::before { top: -1px;    left: -1px;  border-top: 2px solid var(--cyan);      border-left: 2px solid var(--cyan); }
.panel::after  { bottom: -1px; right: -1px; border-bottom: 2px solid var(--magenta); border-right: 2px solid var(--magenta); }

.panel-tag, .step-tag {
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cyan);
}
.panel-tag.mt { margin-top: 20px; }
.step-tag { color: var(--magenta); }
.step-sub { color: var(--dim); letter-spacing: .04em; }
.tag-alt { color: var(--text); }

.hint { margin: -4px 0 12px; font-size: 12px; color: var(--dim); }
.fineprint { margin: 14px 0 0; font-size: 11px; color: var(--dim); text-align: center; }

.caret { color: var(--magenta); font-weight: 700; }
.cursor {
  display: inline-block; width: 8px; height: 1em;
  margin-left: 4px; vertical-align: -.14em;
  background: var(--cyan);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.prompt-line { margin: 0 0 16px; font-size: 12px; color: var(--dim); letter-spacing: .06em; }

/* =========================================================================
   forms + buttons
   ========================================================================= */
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label {
  font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim);
}
input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--magenta);
  padding: 11px 10px;
  border-radius: 0;
  min-height: 44px;
}
input::placeholder { color: #3a3a52; }
input:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  font: inherit;
  font-size: 12.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
  border: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  transition: background .14s, box-shadow .14s, color .14s;
}
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 11px; width: auto; }
.btn-cyan    { color: var(--cyan);    background: rgba(0, 229, 255, .09); }
.btn-magenta { color: var(--magenta); background: rgba(255, 45, 149, .1); }
/* muted, but must stay clearly brighter than :disabled */
.btn-ghost-line { color: #a6a6c6; background: rgba(255, 255, 255, .04); }
.btn:active:not(:disabled) { box-shadow: inset 0 0 0 99px rgba(255, 255, 255, .07); }
.btn:disabled {
  color: #4c4c66;
  background: rgba(255, 255, 255, .02);
  cursor: not-allowed;
  letter-spacing: .1em;
}
.btn-ghost {
  font: inherit; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em;
  color: #a6a6c6;
  background: transparent;
  border: 1px solid var(--line);
  padding: 5px 9px;
  cursor: pointer;
  min-height: 30px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }

select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--cyan);
  padding: 10px 8px;
  border-radius: 0;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
}

/* input + submit on one line; the button drops below on narrow screens */
.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}
.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.msg { margin: 12px 0 0; font-size: 12px; min-height: 1.2em; color: var(--dim); }
.msg.err { color: var(--red); }
.msg.ok  { color: var(--green); }

.login-wrap { max-width: 460px; margin: 6vh auto 0; }

/* =========================================================================
   status lines / meter
   ========================================================================= */
.status-line {
  margin-top: 12px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--dim);
  background: var(--bg-2);
  border-left: 2px solid var(--line);
  word-break: break-word;
}
.status-line.active { color: var(--cyan); border-left-color: var(--cyan); }
.status-line.ok     { color: var(--green); border-left-color: var(--green); }
.status-line.err    { color: var(--red);  border-left-color: var(--red); }
.status-line.warn   { color: #ffe0a8; border-left-color: var(--amber); }

.meter {
  margin-top: 8px; height: 3px; overflow: hidden;
  background: var(--line);
}
.meter-fill {
  display: block; width: 34%; height: 100%;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  animation: sweep 1.3s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

/* =========================================================================
   tables → card lists on narrow screens
   ========================================================================= */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: left;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cyan);
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  white-space: nowrap;
}
tbody td {
  padding: 8px;
  border-bottom: 1px solid rgba(30, 30, 48, .7);
  vertical-align: top;
}
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .018); }
td.num { text-align: right; }

@media (max-width: 620px) {
  table.responsive, table.responsive thead, table.responsive tbody,
  table.responsive tr, table.responsive th, table.responsive td { display: block; }
  table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.responsive tr {
    position: relative;
    border: 1px solid var(--line);
    border-left: 2px solid var(--magenta);
    background: var(--panel-2);
    margin-bottom: 8px;
    padding: 4px 2px;
  }
  table.responsive tbody tr:nth-child(even) { border-left-color: var(--cyan); background: var(--panel-2); }
  table.responsive td {
    display: grid;
    grid-template-columns: 11ch 1fr;
    gap: 8px;
    border-bottom: none;
    padding: 4px 10px;
    text-align: left;
  }
  table.responsive td::before {
    content: attr(data-label);
    font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--dim);
    align-self: center;
  }
  table.responsive td.num { text-align: left; }
}

/* =========================================================================
   player tables — sortable headers, row actions, expandable detail
   ========================================================================= */
th.sortable { padding: 0; }
.th-sort {
  font: inherit;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cyan);
  background: transparent;
  border: 0;
  padding: 7px 8px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.th-sort:hover { color: #fff; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .btn { min-width: 0; }
td.actions { white-space: nowrap; }

/* full-width detail slot injected as a sibling row of the player it belongs to */
tr.drow > td { padding: 0; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.detail {
  border-left: 2px solid var(--amber);
  padding: 10px 12px;
}
.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.detail-tag {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--amber);
}
.warnline { margin: 0 0 8px; font-size: 11.5px; color: #ffe0a8; }
.warnline::before { content: "! "; color: var(--amber); font-weight: 700; }

@media (max-width: 620px) {
  /* the actions cell has no label — it must not keep the 11ch label column */
  table.responsive td.actions { grid-template-columns: 1fr; padding: 8px 10px 10px; }
  table.responsive td.actions::before { content: none; }
  /* the detail row is a plain block here, not a card of its own */
  table.responsive tr.drow {
    border: 0; border-left: 0;
    background: transparent;
    margin: -8px 0 8px;
    padding: 0;
  }
  table.responsive tbody tr.drow:nth-child(even) { border-left: 0; background: transparent; }
  table.responsive tr.drow > td { display: block; padding: 0; border-bottom: 0; }
  table.responsive tr.drow td::before { content: none; }
}

/* =========================================================================
   card lists (missions / troops / generic data)
   ========================================================================= */
.cardlist { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.card {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--cyan);
  padding: 10px 12px;
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  color: #fff; word-break: break-word;
}
.badge {
  flex: none;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--magenta);
  border: 1px solid rgba(255, 45, 149, .5);
  padding: 2px 7px;
  white-space: nowrap;
}
.badge.cy { color: var(--cyan); border-color: rgba(0, 229, 255, .5); }
.badge.am { color: var(--amber); border-color: rgba(255, 176, 32, .5); }

.kv { display: grid; grid-template-columns: minmax(9ch, auto) 1fr; gap: 3px 10px; font-size: 12px; }
.kv dt { color: var(--dim); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; align-self: center; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.card-actions { margin-top: 10px; }

.empty { margin: 14px 0 0; font-size: 12px; color: var(--dim); }
.empty::before { content: "> "; color: var(--magenta); }

/* =========================================================================
   bottom navigation
   ========================================================================= */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 70;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(7, 7, 12, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--dim);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-top: 2px solid transparent;
  margin-top: -1px;
}
.bottom-nav svg {
  width: 21px; height: 21px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.bottom-nav a[aria-current="page"] {
  color: var(--cyan);
  border-top-color: var(--cyan);
  background: linear-gradient(180deg, rgba(0, 229, 255, .12), transparent 70%);
  text-shadow: 0 0 8px rgba(0, 229, 255, .5);
}

/* =========================================================================
   toasts
   ========================================================================= */
.toasts {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(10, 10, 18, .97);
  border: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 12px;
  color: var(--text);
  animation: toast-in .18s ease-out;
}
.toast::before { content: "> "; color: var(--cyan); }
.toast.err  { color: #ffc6cc; }
.toast.err::before  { color: var(--red); }
.toast.warn { color: #ffe0a8; }
.toast.warn::before { color: var(--amber); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   desktop widen
   ========================================================================= */
@media (min-width: 768px) {
  :root { --strip-h: 34px; }   /* notice fits on one line */
  body { font-size: 14.5px; }
  main {
    max-width: 940px;
    margin: 0 auto;
    padding-left: 20px; padding-right: 20px;
    padding-bottom: calc(var(--nav-h) + 40px);
  }
  .title { font-size: 26px; }
  .panel { padding: 18px 18px; }
  .btn { width: auto; min-width: 220px; }
  /* grid tracks win over the standalone min-width, otherwise a 220px button
     overflows its column (login BACK/LOG IN row). */
  .row-2 .btn, .row-3 .btn { width: 100%; min-width: 0; }
  .row-2, .row-3 { max-width: 560px; }
  .inline-form { grid-template-columns: 220px auto; max-width: 560px; }
  .inline-form .btn { width: 100%; min-width: 0; }
  .filters { grid-template-columns: repeat(3, 1fr); max-width: 700px; }
  .bottom-nav { max-width: 940px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .toasts { max-width: 420px; left: auto; right: 24px; }
}

/* =========================================================================
   reduced motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; background: none; }
  .glitch::before, .glitch::after { display: none; }
  .cursor { animation: none; }
  .meter-fill { animation: none; width: 100%; }
  .view, .toast, .glitch-burst { animation: none !important; }
  * { transition-duration: .01ms !important; }
}
