/* Structure and design tokens only; the cyberpunk look is phase 8.
   Light scheme by default, dark from the system preference. */

:root {
  color-scheme: light dark;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #e9edf2;
  --fg: #16202b;
  --muted: #4d5b69;
  --border: #c9d2dc;
  --accent: #006b80;
  --accent-fg: #ffffff;
  --progress: #0088a3;
  --hp: #b3261e;
  --enemy: #8a4b00;
  --warning-bg: #fff4d6;
  --warning-fg: #5c4100;
  --focus: #7a2fd0;

  --radius: 8px;
  --gap: 12px;
  --pad: 16px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --fg: #e6edf3;
    --muted: #9aa7b4;
    --border: #30363d;
    --accent: #3cc8e0;
    --accent-fg: #06141a;
    --progress: #3cc8e0;
    --hp: #f2706a;
    --enemy: #f0a347;
    --warning-bg: #3a2e0c;
    --warning-fg: #f5dc9a;
    --focus: #c89bff;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 var(--font);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

button {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

button[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

:focus-visible,
button[aria-pressed="true"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.3 ui-monospace, monospace;
  word-break: break-all;
}

/* Layout: one column on phones; tabs down the side on wide screens. */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "hud" "tabs" "panel";
  max-width: 1280px;
  margin: 0 auto;
}

.hud {
  grid-area: hud;
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding: 10px var(--pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hud-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
}

.hud h1 {
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.cash {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.hud-activity {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.hud-bars {
  flex: 1;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.activity,
.hp-text {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp-text {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.notice:empty {
  display: none;
}

.notice {
  color: var(--hp);
  font-size: 0.9rem;
}

.tabs {
  grid-area: tabs;
  display: flex;
  gap: 4px;
  padding: 8px var(--pad);
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--bg);
}

.tab {
  flex: none;
  background: transparent;
  border-color: transparent;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--accent);
  font-weight: 600;
}

.panel {
  grid-area: panel;
  display: grid;
  gap: var(--gap);
  align-content: start;
  padding: 0 var(--pad) var(--pad);
  min-width: 0;
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas: "hud hud" "tabs panel";
  }

  .tabs {
    flex-direction: column;
    align-self: start;
    position: sticky;
    top: 140px;
    overflow: visible;
  }

  .tab {
    text-align: left;
  }

  .panel {
    padding-top: 8px;
  }
}

/* Bars: the fill is scaled with a transform, so a frame's update never
   triggers layout. */

.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--progress);
  transform-origin: left center;
  will-change: transform;
}

.bar.hp .bar-fill {
  background: var(--hp);
}

.bar.enemy .bar-fill {
  background: var(--enemy);
}

.bar.thin {
  height: 4px;
}

/* Cards and rows. */

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  align-items: start;
}

.card {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card h2 {
  font-size: 1.05rem;
}

.tag {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.rows {
  display: grid;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.card > .rows > .row:first-child,
.rows.card > .row:first-child {
  border-top: 0;
}

.row.active h3 {
  color: var(--accent);
}

.row-text {
  flex: 1 1 200px;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.row h3 {
  font-size: 0.975rem;
}

.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.feed li {
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.feed li:first-child {
  border-top: 0;
}

.feed:empty {
  display: none;
}

.warnings {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--warning-bg);
  color: var(--warning-fg);
}

.field {
  display: grid;
  gap: 4px;
}

/* Dialogs over the page. */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: rgb(0 0 0 / 0.55);
}

.dialog {
  display: grid;
  gap: var(--gap);
  width: min(100%, 440px);
  max-height: 100%;
  overflow: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dialog h2 {
  font-size: 1.1rem;
}

.summary {
  display: grid;
  gap: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill {
    will-change: auto;
  }
}
