/* Zoo Emulator — a single dark theme, tuned for long stretches of watching. */

:root {
  color-scheme: dark;

  --bg:        #0d1411;
  --bg-raised: #141d19;
  --bg-sunken: #0a110e;
  --line:      #22302a;
  --line-soft: #1a251f;

  --ink:       #e8efe9;
  --ink-dim:   #9fb0a6;
  --ink-faint: #6f8278;

  --accent:      #7ee497;
  --accent-deep: #2f7d4b;
  --gold:        #ffd66b;
  --warn:        #e8c45c;
  --bad:         #ef7a72;
  --info:        #8fb8d9;

  --radius: 10px;
  --radius-sm: 7px;
  --pad: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --panel-w: 348px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible,
[role="tab"]:focus-visible,
input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------------ shell */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "topbar topbar" "stage panel";
  height: 100dvh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #17221d, #101a16);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.01em; }
.brand-mark { font-size: 20px; }
.brand-name { white-space: nowrap; }

.stats {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.stats::-webkit-scrollbar { display: none; }

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  min-width: 78px;
  white-space: nowrap;
}
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint); }
.stat-value { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-value.is-bad { color: var(--bad); }
.stat-value.is-good { color: var(--accent); }
#stat-rating .stat-value { color: var(--gold); letter-spacing: 0.06em; }

.speeds { display: flex; gap: 4px; }

.speed, .ghost, .primary {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.speed:hover, .ghost:hover { background: #1c2822; border-color: #31423a; }
.speed[aria-pressed="true"] {
  background: var(--accent-deep);
  border-color: var(--accent);
  color: #f2fff5;
}
.primary {
  background: var(--accent-deep);
  border-color: var(--accent);
  color: #f3fff6;
  padding: 8px 16px;
}
.primary:hover { background: #38945a; }

/* ------------------------------------------------------------------ stage */

.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #0a110e;
  overflow: hidden;
}

#zoo {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
#zoo.is-select { cursor: default; }

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: min(92%, 560px);
  padding: 7px 14px;
  background: rgba(10, 17, 14, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 12.5px;
  text-align: center;
  pointer-events: none;
}
.stage-hint strong { color: var(--ink); }

.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  max-width: min(92%, 520px);
  padding: 8px 15px;
  border-radius: var(--radius);
  background: rgba(10, 17, 14, 0.94);
  border: 1px solid var(--line);
  font-size: 13px;
  pointer-events: none;
}
.toast.is-bad { border-color: var(--bad); color: #ffd9d6; }
.toast.is-good { border-color: var(--accent); color: #d6ffe2; }

/* ------------------------------------------------------------------ panel */

.panel {
  grid-area: panel;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-width: 0;
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 7px 7px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  padding: 8px 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink-dim); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--bg-sunken); border-bottom-color: var(--accent); }

.tabpanels { min-height: 0; overflow: hidden; display: grid; }
.tabpanel { min-height: 0; overflow-y: auto; padding: var(--pad); display: flex; flex-direction: column; gap: 12px; }
.tabpanel[hidden] { display: none; }

.panel-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px var(--pad);
  border-top: 1px solid var(--line);
}
.save-note { margin-left: auto; font-size: 11px; color: var(--ink-faint); }

/* ------------------------------------------------------------- panel bits */

.group { display: flex; flex-direction: column; gap: 7px; }
.group > h3 {
  margin: 0;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  font-weight: 700;
}
.group-note { margin: 0; font-size: 12px; color: var(--ink-faint); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px 9px;
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.choice:hover:not(:disabled) { border-color: #3a4d43; background: #13201a; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: #16291d; }
.choice:disabled { opacity: 0.42; cursor: not-allowed; }
.choice-icon { font-size: 17px; line-height: 1; }
.choice-body { min-width: 0; }
.choice-name { display: block; font-weight: 620; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choice-meta { display: block; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.card {
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.is-selected { border-color: var(--gold); }
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-title { font-weight: 650; font-size: 13.5px; }
.card-sub { font-size: 11.5px; color: var(--ink-faint); margin-left: auto; font-variant-numeric: tabular-nums; }

.meter-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 34px; gap: 7px; align-items: center; font-size: 11.5px; }
.meter-row > span:first-child { color: var(--ink-faint); }
.meter-row > b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { height: 6px; border-radius: 999px; background: #0a120e; overflow: hidden; border: 1px solid var(--line-soft); }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.25s ease; }
.meter.is-warn > i { background: var(--warn); }
.meter.is-bad > i { background: var(--bad); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--line);
  background: #17231d;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
}
.mini:hover:not(:disabled) { border-color: #3a4d43; background: #1d2c24; }
.mini:disabled { opacity: 0.4; cursor: not-allowed; }
.mini.is-danger { color: var(--bad); border-color: #4a2b28; }
.mini.is-danger:hover:not(:disabled) { background: #2a1917; }

.empty { color: var(--ink-faint); font-size: 12.5px; margin: 0; }

.ticket { display: flex; flex-direction: column; gap: 6px; }
.ticket-head { display: flex; align-items: baseline; justify-content: space-between; }
.ticket-price { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ticket input[type="range"] { width: 100%; accent-color: var(--accent); }
.ticket-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-faint); }

.ledger { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--line-soft); }
.ledger th:first-child, .ledger td:first-child { text-align: left; color: var(--ink-dim); }
.ledger thead th { color: var(--ink-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.ledger .is-pos { color: var(--accent); }
.ledger .is-neg { color: var(--bad); }
.ledger tfoot td { font-weight: 700; border-bottom: 0; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.feed li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
  padding: 5px 7px;
  background: var(--bg-sunken);
  border-left: 2px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.feed li > time { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 11px; }
.feed li.is-good { border-left-color: var(--accent); }
.feed li.is-warn { border-left-color: var(--warn); }
.feed li.is-bad { border-left-color: var(--bad); }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 12.5px; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ----------------------------------------------------------------- dialog */

.sheet {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-raised);
  color: var(--ink);
  padding: 22px;
  max-width: 520px;
  width: calc(100% - 32px);
}
.sheet::backdrop { background: rgba(4, 8, 6, 0.7); }
.sheet h2 { margin: 0 0 10px; font-size: 18px; }
.help-list { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.help-list strong { color: var(--accent); }
.help-keys { color: var(--ink-faint); font-size: 12px; margin: 0 0 16px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-sunken);
  margin-right: 2px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  :root { --panel-w: auto; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "topbar" "stage" "panel";
  }
  /* Give the stage exactly the shape of the grid it draws, so a phone does not
     letterbox half the screen away. */
  .stage {
    aspect-ratio: 30 / 19;
    min-height: 150px;
    max-height: 44dvh;
  }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { gap: 8px; padding: 7px 10px; }
  .brand-name { display: none; }
  .choices { grid-template-columns: 1fr; }
  .stage-hint { bottom: 8px; font-size: 12px; }
}

@media (max-width: 560px) {
  .brand { display: none; }
  .stat { min-width: 62px; padding: 3px 8px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 13px; }
  .speed, .ghost { padding: 6px 9px; }
  .tab { font-size: 12.5px; padding: 8px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
