@font-face {
  font-family: 'Gotham';
  src: url('/brand/fonts/Gotham/Gotham Bold.otf') format('opentype');
  font-weight: 700;
}
@font-face {
  font-family: 'Work Sans';
  src: url('/brand/fonts/WorkSans/WorkSans-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Work Sans';
  src: url('/brand/fonts/WorkSans/WorkSans-SemiBold.ttf') format('truetype');
  font-weight: 600;
}
@font-face {
  font-family: 'Inter';
  src: url('/brand/fonts/Inter/Inter-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Inter';
  src: url('/brand/fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 600;
}

:root {
  --background: #000;
  --panel: #0a0a0a;
  --panel-2: #111;
  --border: #1f1f1f;
  --border-2: #333;
  --text: #e5e5e5;
  --muted: #888;
  --muted-2: #666;
  --red: #d71920;
  --amber: #ff9500;
  --signal: #2e0fe4;
  --success: #22c55e;
  --error: #ff6b6f;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: 'Work Sans', system-ui, sans-serif;
}

a { color: inherit; }
h1, h2, h3 {
  margin: 0;
  font-family: 'Gotham', 'Work Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
h1 { font-size: clamp(28px, 4vw, 52px); line-height: 0.95; }
h2 { font-size: 20px; }
h3 { font-size: 14px; }
p { color: var(--muted); line-height: 1.55; }

.shell { min-height: 100vh; }
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.9);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { height: 30px; width: auto; }
.main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }
.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 40px;
  align-items: center;
  padding: 44px 0;
}
.hero-copy { max-width: 760px; }
.hero-copy p { max-width: 620px; font-size: 17px; }
.eyebrow {
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.gradient-word {
  background: linear-gradient(135deg, var(--red) 40%, var(--amber) 100%);
  -webkit-background-clip: text;
  color: transparent;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.game-board-column, .solver-column { min-width: 0; }

.field { display: grid; gap: 6px; }
.label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.input, textarea, select {
  width: 100%;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  outline: none;
}
textarea { min-height: 220px; font-family: 'Inter', ui-monospace, monospace; resize: vertical; }
.input:focus, textarea:focus, select:focus { border-color: var(--red); }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--amber));
  font-family: 'Work Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text); }
.btn-danger { background: var(--error); }
.btn-small { padding: 8px 10px; font-size: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}
.tab.active { border-color: var(--red); color: var(--text); }

.agent-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}
.agent-card {
  min-height: 210px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.agent-card.locked {
  background: repeating-linear-gradient(135deg, #080808 0, #080808 12px, #111 12px, #111 24px);
  color: var(--muted);
}
.agent-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--avatar, var(--red));
  font-family: 'Gotham', sans-serif;
  font-size: 22px;
  color: #fff;
  flex: 0 0 auto;
}
.agent-card.locked .agent-icon { background: #1a1a1a; color: #444; }
.agent-name { font-weight: 700; letter-spacing: 0.02em; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.signal-tag { color: var(--text); border-color: rgba(255,255,255,0.22); }
.evidence-match { border-color: var(--red); color: var(--text); background: rgba(215,25,32,0.12); }
.agent-profile { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 0; }
.qty { position: absolute; top: 10px; right: 10px; color: var(--amber); font-size: 12px; font-weight: 700; }

.meter { display: grid; gap: 6px; }
.meter-line { height: 8px; border-radius: 999px; background: #1a1a1a; overflow: hidden; }
.meter-fill { height: 100%; width: var(--value, 0%); background: linear-gradient(90deg, var(--red), var(--amber)); }
.status { color: var(--muted); font-size: 13px; }
.success { color: var(--success); }
.error { color: var(--error); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border); padding: 9px; text-align: left; vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }

.evidence-board { display: grid; gap: 16px; margin-top: 14px; }
.evidence-groups { display: grid; gap: 10px; }
.evidence-group, .phrase-record, .registration-field-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}
.phrase-log { display: grid; gap: 10px; }
.phrase-text { font-weight: 700; line-height: 1.35; }
.deduction-reference {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.reference-row { margin: 8px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.settings-section { display: grid; gap: 12px; margin: 18px 0 22px; }
.registration-fields-form { display: grid; gap: 10px; }
.registration-field-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 110px 110px 120px;
  gap: 12px;
  align-items: end;
}
.phrase-admin-list { min-width: 240px; display: grid; gap: 8px; }
.phrase-admin-item { display: grid; gap: 3px; }

#tab-content .panel { padding: 16px; }
#tab-content .button-row { gap: 8px; }
#tab-content .btn { padding: 10px 12px; }
#tab-content p { margin: 10px 0 0; font-size: 13px; line-height: 1.4; }
#tab-content .field { gap: 4px; }
#tab-content .input,
#tab-content textarea,
#tab-content select {
  padding: 9px 10px;
}
#tab-content textarea { min-height: 120px; }
.content-renderer { display: grid; gap: 12px; margin-top: 12px; }
.content-card {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}
.content-card:first-child { border-top: 0; padding-top: 0; }
.content-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.content-card-head h3 {
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.content-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
}
.field-wide { grid-column: 1 / -1; }
.check-field {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}
.check-field input { width: 16px; height: 16px; accent-color: var(--red); }
.evidence-editor { gap: 10px; }
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.asset-preview {
  max-width: 180px;
  max-height: 110px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}

.qr-wrap { display: grid; gap: 12px; justify-items: start; }
canvas.qr { background: #fff; border-radius: 8px; padding: 8px; }

@media (max-width: 920px) {
  .hero, .game-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4, .content-fields, .evidence-grid, .deduction-reference, .registration-field-row { grid-template-columns: 1fr; }
  .content-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .solver-column { order: -1; }
  .topbar { padding: 10px 16px; gap: 12px; }
}

@media (max-width: 520px) {
  .main { width: min(100% - 20px, 1440px); padding-top: 18px; }
  .hero { min-height: auto; padding: 22px 0; gap: 20px; }
  h1 { font-size: 30px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .logo { height: 26px; }
  .button-row { width: 100%; }
  .btn { width: 100%; min-height: 44px; padding: 12px 14px; }
  .topbar .btn { width: auto; }
  .panel { padding: 16px; }
  .content-fields { grid-template-columns: 1fr; }
  #tab-content .btn { min-height: 44px; padding: 12px 14px; }
  #tab-content .content-card-head .btn {
    width: auto;
    min-height: 38px;
    padding: 9px 12px;
  }
  .agent-board { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .agent-card { min-height: 190px; padding: 12px; }
  .agent-name, .phrase-text { overflow-wrap: anywhere; }
}
