:root {
  --bg: #020617;
  --card: #0e1223;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #334155;
  --yellow: #f5c518;
  --ink: #0f172a;
  --green: #22c55e;
  --blue: #1d4ed8;
  --purple: #5b21b6;
  --danger: #fca5a5;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Fira Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-size: 1rem; font-weight: 650; }

button, input, select {
  min-height: 44px;
  font: inherit;
  color: var(--text);
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
}

button { cursor: pointer; }
button:hover { border-color: #cbd5e1; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.top, .bar, .actions, .pool-tools, .draft, .blackout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.top, .pools { padding: 0.75rem; }
.top { border-bottom: 1px solid var(--border); }

#power[aria-pressed="true"] {
  background: var(--green);
  color: var(--ink);
  border-color: var(--green);
}

#takeover[aria-pressed="true"],
#highlight[aria-pressed="true"] {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}

.blackout input { width: min(240px, 50vw); accent-color: var(--yellow); }

#status { margin: 0; color: var(--muted); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(420px, 1fr);
  gap: 0.75rem;
  padding: 0.75rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 0;
}

.bar-layout { background: var(--blue); margin: -0.75rem -0.75rem 0.75rem; padding: 0.75rem; border-radius: 8px 8px 0 0; }
.bar-effect { background: var(--purple); margin: -0.75rem -0.75rem 0.75rem; padding: 0.75rem; border-radius: 8px 8px 0 0; }

#qty { margin: 0; }

.beam-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.beam-view {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  background: #000;
}
#beam-canvas { display: block; touch-action: none; cursor: pointer; }
#beam-readout { min-height: 1.5rem; margin: 0.4rem 0 0; color: var(--muted); }

.cell {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  font-variant-numeric: tabular-nums;
}

.cell.selected { outline: 3px solid var(--yellow); outline-offset: -3px; }
.cell .order {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.75rem;
}

.table-wrap { overflow-x: auto; max-width: 100%; }

table { border-collapse: collapse; min-width: 1400px; }
th, td { border: 1px solid var(--border); padding: 0.2rem; text-align: left; }
th { color: var(--muted); font-weight: 600; }
td input, td select { width: 5.5rem; }
tr.current { outline: 2px solid var(--yellow); }

.forms { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.75rem; }
.forms button[aria-pressed="true"] {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}

.draft {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
#draft { margin: 0; padding-left: 1.2rem; min-width: 100%; }
#error { min-height: 1.5rem; color: var(--danger); margin: 0.5rem 0 0; }

.pools { display: grid; gap: 1rem; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.effect-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111827;
}
.effect-card input { min-width: 8rem; }
.pool button { min-width: 96px; position: relative; }
.pool button.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: 4px;
  background: var(--yellow);
}
.pool button small { display: block; color: var(--muted); }

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
