/* Kalastra GM Console - mobile first (360 px and up), dark, the website's own tokens
   (Kalastra-Web resources/css/tokens.css). System fonts only: nothing is loaded from outside. */
:root {
  --canvas: #0b0918;
  --canvas-deep: #06040f;
  --panel: rgba(255, 255, 255, .035);
  --panel-border: rgba(255, 255, 255, .09);
  --input: rgba(0, 0, 0, .32);
  --input-border: rgba(255, 255, 255, .14);
  --gold-400: #f0c765;
  --gold-500: #e8b64c;
  --gold-600: #d09a2e;
  --gold-dim: #b09a68;
  --on-gold: #1a1305;
  --green-400: #7ceab4;
  --coral-400: #ff8f6b;
  --violet-400: #b3a8ff;
  --ink: #ece9f5;
  --ink-2: #cfcae4;
  --ink-3: #a6a0c2;
  --ink-5: #8b84ab;
  --ink-7: #6f6892;
  --r-card: 16px;
  --r-btn: 10px;
  --tabs-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas) linear-gradient(180deg, #151032 0, var(--canvas) 320px) no-repeat;
  color: var(--ink);
  font: 16px/1.45 var(--font);
  overflow-x: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 20px; color: var(--ink); }
.card-title { font-size: 15px; font-weight: 650; color: var(--gold-500); margin-bottom: 6px; }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.center { text-align: center; }
a { color: var(--gold-500); }

/* ---- header ---------------------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(11, 9, 24, .92);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; color: var(--gold-500); letter-spacing: .02em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--ink-5); white-space: nowrap; }
.who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.who-name { font-size: 14px; color: var(--ink-2); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: rgba(232, 182, 76, .14); color: var(--gold-400); white-space: nowrap;
}
.chip-ok { background: rgba(124, 234, 180, .13); color: var(--green-400); }
.chip-bad { background: rgba(255, 143, 107, .15); color: var(--coral-400); }
.chip-dim { background: rgba(255, 255, 255, .06); color: var(--ink-3); }
.chip-info { background: rgba(179, 168, 255, .14); color: var(--violet-400); }

/* ---- banners ----------------------------------------------------------------------------- */
.banner { margin: 0; padding: 10px 16px; font-size: 14px; }
.banner-offline { background: rgba(255, 143, 107, .14); color: var(--coral-400); border-bottom: 1px solid rgba(255, 143, 107, .3); }
.banner-dev { background: rgba(179, 168, 255, .14); color: var(--violet-400); border-bottom: 1px solid rgba(179, 168, 255, .3); }

/* ---- layout ------------------------------------------------------------------------------ */
.wrap {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom));
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--r-card);
  padding: 14px; margin: 12px 0; min-width: 0;
}
.stamp { margin: 2px 0 8px; font-size: 13px; color: var(--ink-5); }
.msg { margin: 8px 0; font-size: 14.5px; min-height: 0; overflow-wrap: anywhere; }
.msg:empty { display: none; }
.msg-error { color: var(--coral-400); }
.msg-ok { color: var(--green-400); }
.msg-info { color: var(--ink-2); }

/* ---- forms ------------------------------------------------------------------------------- */
.login { max-width: 420px; margin: 24px auto; padding: 20px 16px; }
.login-title { font-size: 22px; color: var(--gold-500); margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; min-width: 0; }
.field-label { font-size: 13.5px; color: var(--ink-3); }
.field input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: 16px var(--font); color: var(--ink);
  background: var(--input); border: 1px solid var(--input-border); border-radius: var(--r-btn);
}
.field input:focus { outline: 2px solid var(--gold-500); outline-offset: 1px; border-color: transparent; }
.search { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.search .field { margin: 8px 0; }
.grow { flex: 1 1 200px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-btn);
  font: 600 16px var(--font); cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.btn-gold { background: var(--gold-500); color: var(--on-gold); margin: 8px 0; }
.btn-gold:active { background: var(--gold-600); }
.btn-gold[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--panel-border); }
.btn-ghost:active { background: rgba(255, 255, 255, .06); }
.btn-small { min-height: 44px; padding: 0 12px; font-size: 14.5px; }
.btn-block { width: 100%; margin-top: 10px; }

/* ---- world ------------------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 8px 0 4px; }
.tile {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: 12px; min-width: 0;
}
.tile-label { font-size: 12.5px; color: var(--ink-3); }
.tile-value { font-size: 26px; font-weight: 700; color: var(--gold-500); line-height: 1.15; overflow-wrap: anywhere; }
.tile-sub { font-size: 12.5px; color: var(--ink-5); overflow-wrap: anywhere; }
.tile-value.ok { color: var(--green-400); }
.tile-value.bad { color: var(--coral-400); }

.zones, .services, .log { list-style: none; margin: 0; padding: 0; }
.zone {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, .05);
}
.zone:first-child { border-top: 0; }
.zone-id { font: 600 13px var(--mono); color: var(--ink-5); }
.zone-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.zone-right { display: flex; align-items: center; gap: 6px; }
.zone-players { font-weight: 700; color: var(--gold-500); min-width: 20px; text-align: right; }
.zone-players.zero { color: var(--ink-7); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-up { background: var(--green-400); }
.dot-down { background: var(--coral-400); }
.dot-unknown { background: var(--ink-7); }
.dot-closed { background: transparent; border: 1px solid var(--ink-7); }
.closed-zones summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--ink-2); font-weight: 600; }
.services { display: flex; flex-wrap: wrap; gap: 8px; }
.services li { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .04); }

/* ---- chart (SVG drawn by app.js) --------------------------------------------------------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--gold-500); }
.chart .bar-zero { fill: rgba(232, 182, 76, .35); }
.chart .gap { fill: rgba(255, 255, 255, .06); }
.chart .axis { stroke: rgba(255, 255, 255, .14); stroke-width: 1; }
.chart .grid { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.chart text { fill: var(--ink-5); font: 10px var(--font); }
.chart-legend { font-size: 12.5px; color: var(--ink-5); margin-top: 6px; overflow-wrap: anywhere; }

/* ---- players ----------------------------------------------------------------------------- */
.result-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.result-id { font-size: 19px; font-weight: 700; color: var(--gold-500); margin-right: 4px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 4px 10px; margin: 6px 0 2px; font-size: 14.5px; }
.kv dt { color: var(--ink-3); overflow-wrap: anywhere; }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.sub { font-size: 13px; font-weight: 650; color: var(--gold-dim); margin: 12px 0 2px; text-transform: uppercase; letter-spacing: .06em; }
.slots { list-style: none; margin: 4px 0; padding: 0; }
.slots li { display: flex; justify-content: space-between; gap: 10px; min-height: 36px; align-items: center; border-top: 1px solid rgba(255, 255, 255, .05); }
.slots li:first-child { border-top: 0; }
.slot-name { overflow-wrap: anywhere; }
.slot-level { color: var(--gold-500); font-weight: 650; white-space: nowrap; }

/* ---- logs -------------------------------------------------------------------------------- */
.log li { padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .06); min-width: 0; }
.log li:first-child { border-top: 0; }
.log-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--ink-5); }
.log-meta .who-gm { color: var(--gold-400); font-weight: 600; }
.log-text { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-bad { color: var(--coral-400); }
.log-ok { color: var(--green-400); }

/* ---- bottom tab bar (thumb reach) -------------------------------------------------------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 0 8px env(safe-area-inset-bottom);
  background: rgba(8, 6, 18, .96); border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
}
.tab {
  flex: 1 1 0; max-width: 180px; min-height: var(--tabs-h);
  background: none; border: 0; border-top: 2px solid transparent;
  color: var(--ink-3); font: 600 15px var(--font); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab[aria-current="page"] { color: var(--gold-500); border-top-color: var(--gold-500); }
.tab:focus-visible { outline: 2px solid var(--gold-400); outline-offset: -4px; }

@media (max-width: 419px) {
  .who-name { display: none; }          /* a phone header keeps the role chip and the Sign out button */
}
@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .who-name { max-width: 200px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
